0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <stdio.h>
0037 #include <stdlib.h>
0038 #include <string.h>
0039 #include "tsdef.h"
0040 #include "tsconf.h"
0041 #if (client == MAC)
0042
0043 #endif
0044 #include "tsmes.h"
0045 #include "tstype.h"
0046 #include "tsext.h"
0047 #include "functs.h"
0048
0049
0050 void * MemAlloc( Longint );
0051 void FreeMemory( void * );
0052
0053
0054 #define MIN_SIZE 1024
0055 void lzrw1_decompress();
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 Longint FAR_PASCAL
0086 Emission_Entrees (
0087 #if (client == MAC)
0088 ConnHandle nsock,
0089 #else
0090 int nsock,
0091 #endif
0092 pS_Entree ptent,
0093 Longint code_param )
0094 {
0095 pS_Entree pcent;
0096 short int envoi;
0097 Longint Resultat;
0098 int Rang;
0099
0100 Resultat = ok;
0101 Rang = 0;
0102
0103 pcent = ptent;
0104 envoi = SUITE;
0105
0106 while (pcent != NULL)
0107 {
0108 if ((Resultat = Emission (nsock, (char *) &envoi, taille_short, code_param))
0109 != ok)
0110 return Resultat;
0111
0112 if ((Resultat = Emission (nsock, pcent->union_var.cval,
0113 (Longint) sizeof (pcent->union_var), code_param))
0114 != ok)
0115 return Resultat;
0116
0117 pcent = pcent->ps_suivant;
0118 }
0119
0120 envoi = FIN;
0121
0122 if ((Resultat = Emission (nsock, (char *) &envoi, taille_short, code_param))
0123 != ok)
0124 return Resultat;
0125
0126 return Resultat;
0127 }
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 Longint FAR_PASCAL
0149 Reception_Donnee (
0150 #if (client == MAC)
0151 ConnHandle nsock,
0152 #else
0153 int nsock,
0154 #endif
0155 pS_Donnee *ptdon,
0156 Longint code_param )
0157 {
0158 pS_Donnee pcdon;
0159 short int envoi;
0160 Longint Resultat;
0161 Resultat = ok;
0162
0163 pcdon = NULL;
0164 *ptdon = NULL;
0165
0166 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0167 != ok)
0168 return Resultat;
0169 if (envoi == FIN)
0170 return Resultat;
0171
0172 while (envoi == SUITE)
0173 {
0174
0175 if (pcdon == NULL)
0176 {
0177 pcdon = (pS_Donnee) MemAlloc ( sizeof (struct S_Donnee) );
0178 *ptdon = pcdon;
0179 }
0180 else
0181 {
0182 pcdon->ps_suivant = (pS_Donnee) MemAlloc (sizeof (struct S_Donnee));
0183 pcdon = pcdon->ps_suivant;
0184 }
0185 if ((Resultat = Reception (nsock, pcdon->nom, TAILLE_NOM_DONNEE, code_param))
0186 != ok)
0187 return Resultat;
0188
0189 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0190 != ok)
0191 return Resultat;
0192
0193 }
0194 if(pcdon != NULL)
0195 pcdon->ps_suivant = NULL;
0196
0197 return Resultat;
0198 }
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 Longint FAR_PASCAL
0217 Reception_DescEntree (
0218 #if (client == MAC)
0219 ConnHandle nsock,
0220 #else
0221 int nsock,
0222 #endif
0223 pS_DescEntree *ptent,
0224 Longint code_param )
0225 {
0226 pS_DescEntree pcent;
0227 short int envoi;
0228 Longint Resultat;
0229
0230 Resultat = ok;
0231
0232 pcent = NULL;
0233 *ptent = NULL;
0234
0235 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0236 != ok)
0237 return Resultat;
0238
0239 if (envoi == FIN)
0240 return Resultat;
0241
0242 while (envoi == SUITE)
0243 {
0244
0245 if (pcent == NULL)
0246 {
0247 pcent = (pS_DescEntree) MemAlloc (sizeof (struct S_DescEntree));
0248 *ptent = pcent;
0249 }
0250 else
0251 {
0252 pcent->ps_suivant = (pS_DescEntree) MemAlloc (sizeof (struct S_DescEntree));
0253 pcent = pcent->ps_suivant;
0254 }
0255
0256 if ((Resultat = Reception (nsock, pcent->nom, TAILLE_NOM_ENTREE, code_param))
0257 != ok)
0258 return Resultat;
0259
0260 if ((Resultat = Reception (nsock, pcent->format, TAILLE_FORMAT, code_param))
0261 != ok)
0262 return Resultat;
0263
0264 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0265 != ok)
0266 return Resultat;
0267
0268 }
0269 pcent->ps_suivant = NULL;
0270
0271 return Resultat;
0272 }
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291 Longint FAR_PASCAL
0292 Reception_DescCoord (
0293 #if (client == MAC)
0294 ConnHandle nsock,
0295 #else
0296 int nsock,
0297 #endif
0298 pS_DescCoord *ptcoord,
0299 Longint code_param )
0300 {
0301 pS_DescCoord pccoord;
0302 short int envoi;
0303 Longint Resultat;
0304
0305
0306 Resultat = ok;
0307
0308 pccoord = NULL;
0309 *ptcoord = NULL;
0310
0311 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0312 != ok)
0313 return Resultat;
0314
0315 if (envoi == FIN)
0316 return Resultat;
0317
0318 while (envoi == SUITE)
0319 {
0320 if (pccoord == NULL)
0321 {
0322 pccoord = (pS_DescCoord) MemAlloc (sizeof (struct S_DescCoord));
0323 *ptcoord = pccoord;
0324 }
0325 else
0326 {
0327 pccoord->ps_suivant = (pS_DescCoord) MemAlloc (
0328 sizeof (struct S_DescCoord));
0329 pccoord = pccoord->ps_suivant;
0330 }
0331
0332 if ((Resultat = Reception (nsock, pccoord->nom, TAILLE_NOM_COORDONNEE, code_param))
0333 != ok)
0334 return Resultat;
0335
0336 if ((Resultat = Reception (nsock, pccoord->format, TAILLE_FORMAT, code_param))
0337 != ok)
0338 return Resultat;
0339
0340 if ((Resultat = Reception (nsock, pccoord->unite, TAILLE_NOM_UNITE, code_param))
0341 != ok)
0342 return Resultat;
0343
0344 if ((Resultat = Reception (nsock, pccoord->pretraitement,
0345 TAILLE_PRETRAITEMENT, code_param))
0346 != ok)
0347 return Resultat;
0348
0349 if ((Resultat = Reception (nsock, (char *) &pccoord->indice_max, taille_short,
0350 code_param))
0351 != ok)
0352 return Resultat;
0353
0354 if ((Resultat = Reception (nsock, (char *) &pccoord->struct_fich, taille_long,
0355 code_param))
0356 != ok)
0357 return Resultat;
0358
0359 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0360 != ok)
0361 return Resultat;
0362
0363 }
0364 pccoord->ps_suivant = NULL;
0365
0366 return Resultat;
0367 }
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388 Longint FAR_PASCAL
0389 Reception_Chaine (
0390 #if (client == MAC)
0391 ConnHandle nsock,
0392 #else
0393 int nsock,
0394 #endif
0395 char **chaine,
0396 Longint code_param )
0397 {
0398 short int envoi;
0399 Longint longchaine;
0400 Longint Resultat;
0401
0402 Resultat = ok;
0403
0404
0405
0406 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0407 != ok)
0408 return Resultat;
0409
0410
0411 if (envoi == FIN)
0412 {
0413 *chaine = NULL;
0414 return Resultat;
0415 }
0416
0417
0418
0419 if ((Resultat = Reception (nsock, (char *) &longchaine, taille_long, code_param))
0420 != ok)
0421 return Resultat;
0422 *chaine = (char *) MemAlloc (longchaine);
0423 if ((Resultat = Reception (nsock, *chaine, (Longint) longchaine, code_param))
0424 != ok)
0425 return Resultat;
0426
0427 return Resultat;
0428 }
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447 Longint FAR_PASCAL
0448 Reception_DescTrait (
0449 #if (client == MAC)
0450 ConnHandle nsock,
0451 #else
0452 int nsock,
0453 #endif
0454 pS_DescTrait *pttrait,
0455 Longint code_param )
0456 {
0457 short int envoi;
0458 Longint Resultat;
0459 Resultat = ok;
0460
0461 *pttrait = NULL;
0462
0463 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0464 != ok)
0465 return Resultat;
0466
0467 if (envoi == FIN)
0468 return Resultat;
0469 *pttrait = (pS_DescTrait) MemAlloc (sizeof (struct S_DescTrait));
0470
0471
0472 if ((Resultat = Reception (nsock, (*pttrait)->nom, TAILLE_NOM_TRAITEMENT, code_param))
0473 != ok)
0474 return Resultat;
0475
0476 if ((Resultat = Reception (nsock, (*pttrait)->date, TAILLE_DATE, code_param))
0477 != ok)
0478 return Resultat;
0479
0480
0481
0482 if ((Resultat = Reception_Chaine (nsock, &((*pttrait)->commentaire), code_param))
0483 != ok)
0484 return Resultat;
0485
0486 if ((Resultat = Reception_Chaine (nsock, &((*pttrait)->machine), code_param))
0487 != ok)
0488 return Resultat;
0489
0490 if ((Resultat = Reception_Chaine (nsock, &((*pttrait)->localisation), code_param))
0491 != ok)
0492 return Resultat;
0493
0494 if ((Resultat = Reception_Chaine (nsock, &((*pttrait)->auteurs), code_param))
0495 != ok)
0496 return Resultat;
0497
0498
0499
0500 if ((Resultat = Reception (nsock, (char *) &((*pttrait)->type), taille_long, code_param))
0501 != ok)
0502 return Resultat;
0503
0504 if ((Resultat = Reception (nsock, (char *) &(*pttrait)->num_version,
0505 taille_short, code_param))
0506 != ok)
0507 return Resultat;
0508
0509 if ((Resultat = Reception (nsock, (char *) &(*pttrait)->nb_donnees,
0510 taille_short, code_param))
0511 != ok)
0512 return Resultat;
0513
0514 if ((Resultat = Reception (nsock, (char *) &(*pttrait)->nb_entrees,
0515 taille_short, code_param))
0516 != ok)
0517 return Resultat;
0518
0519
0520
0521 if ((Resultat = Reception_Donnee (nsock, &(*pttrait)->ps_donnee, code_param))
0522 != ok)
0523 return Resultat;
0524
0525 if ((Resultat = Reception_DescEntree (nsock, &(*pttrait)->ps_entree, code_param))
0526 != ok)
0527 return Resultat;
0528
0529 return Resultat;
0530 }
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549 Longint FAR_PASCAL
0550 Reception_DescDiag (
0551 #if (client == MAC)
0552 ConnHandle nsock,
0553 #else
0554 int nsock,
0555 #endif
0556 pS_DescDiag *ptdiag,
0557 Longint code_param )
0558 {
0559 short int envoi;
0560 Longint Resultat;
0561 Resultat = ok;
0562
0563 *ptdiag = NULL;
0564
0565 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0566 != ok)
0567 return Resultat;
0568
0569 if (envoi == FIN)
0570 return Resultat;
0571 *ptdiag = (pS_DescDiag) MemAlloc (sizeof (struct S_DescDiag));
0572
0573
0574
0575
0576 if ((Resultat = Reception (nsock, (*ptdiag)->nom, TAILLE_NOM_DIAGNOSTIC, code_param))
0577 != ok)
0578 return Resultat;
0579
0580 if ((Resultat = Reception (nsock, (*ptdiag)->date, TAILLE_DATE, code_param))
0581 != ok)
0582 return Resultat;
0583
0584
0585
0586 if ((Resultat = Reception_Chaine (nsock, &((*ptdiag)->commentaire), code_param))
0587 != ok)
0588 return Resultat;
0589
0590 if ((Resultat = Reception_Chaine (nsock, &((*ptdiag)->auteurs), code_param))
0591 != ok)
0592 return Resultat;
0593
0594
0595
0596
0597 if ((Resultat = Reception (nsock, (char *) &((*ptdiag)->type), taille_long, code_param))
0598 != ok)
0599 return Resultat;
0600
0601 if ((Resultat = Reception (nsock, (char *) &(*ptdiag)->num_version,
0602 taille_short, code_param))
0603 != ok)
0604 return Resultat;
0605
0606 if ((Resultat = Reception (nsock, (char *) &(*ptdiag)->nb_donnees, taille_short,
0607 code_param))
0608 != ok)
0609 return Resultat;
0610
0611
0612
0613 if ((Resultat = Reception_Donnee (nsock, &(*ptdiag)->ps_donnee, code_param))
0614 != ok)
0615 return Resultat;
0616
0617 return Resultat;
0618 }
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637 Longint FAR_PASCAL
0638 Reception_DescDon (
0639 #if (client == MAC)
0640 ConnHandle nsock,
0641 #else
0642 int nsock,
0643 #endif
0644 pS_DescDon *ptdon,
0645 Longint code_param )
0646 {
0647 short int envoi;
0648 Longint Resultat;
0649
0650 Resultat = ok;
0651
0652 *ptdon = NULL;
0653
0654 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0655 != ok)
0656 return Resultat;
0657
0658 if (envoi == FIN)
0659 return Resultat;
0660 *ptdon = (pS_DescDon) MemAlloc (sizeof (struct S_DescDon));
0661
0662
0663 if ((Resultat = Reception (nsock, (*ptdon)->nom, TAILLE_NOM_DONNEE, code_param))
0664 != ok)
0665 return Resultat;
0666
0667 if ((Resultat = Reception (nsock, (*ptdon)->nom_producteur,
0668 TAILLE_NOM_PRODUCTEUR, code_param))
0669 != ok)
0670 return Resultat;
0671
0672
0673
0674 if ((Resultat = Reception_Chaine (nsock, &((*ptdon)->commentaire), code_param))
0675 != ok)
0676 return Resultat;
0677
0678
0679
0680 if ((Resultat = Reception (nsock, (char *) &((*ptdon)->type), taille_long, code_param))
0681 != ok)
0682 return Resultat;
0683
0684 if ((Resultat = Reception (nsock, (char *) &(*ptdon)->nb_comp, taille_short, code_param))
0685 != ok)
0686 return Resultat;
0687
0688 if ((Resultat = Reception (nsock, (char *) &(*ptdon)->nb_coord, taille_short,
0689 code_param))
0690 != ok)
0691 return Resultat;
0692
0693 if ((Resultat = Reception (nsock, (char *) &(*ptdon)->nb_donnees_groupe,
0694 taille_short, code_param))
0695 != ok)
0696 return Resultat;
0697
0698
0699
0700 if ((Resultat = Reception_Donnee (nsock, &(*ptdon)->ps_donnee_groupe, code_param))
0701 != ok)
0702 return Resultat;
0703
0704 if ((Resultat = Reception_DescCoord (nsock, &(*ptdon)->ps_coord, code_param))
0705 != ok)
0706 return Resultat;
0707
0708 return Resultat;
0709 }
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736 Longint FAR_PASCAL
0737 Reception_Unite (
0738 #if (client == MAC)
0739 ConnHandle nsock,
0740 #else
0741 int nsock,
0742 #endif
0743 pS_Unite *ptunite,
0744 Longint code_param )
0745 {
0746 pS_Unite pcunite;
0747 short int envoi;
0748 Longint Resultat;
0749
0750 Resultat = ok;
0751
0752 pcunite = NULL;
0753 *ptunite = NULL;
0754
0755 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0756 != ok)
0757 return Resultat;
0758
0759 if (envoi == FIN)
0760 return Resultat;
0761
0762 while (envoi == SUITE)
0763 {
0764
0765 if (pcunite == NULL)
0766 {
0767 pcunite = (pS_Unite) MemAlloc (sizeof (struct S_Unite));
0768 *ptunite = pcunite;
0769 }
0770 else
0771 {
0772 pcunite->ps_suivant = (pS_Unite) MemAlloc (sizeof (struct S_Unite));
0773 pcunite = pcunite->ps_suivant;
0774 }
0775
0776 if ((Resultat = Reception (nsock, pcunite->nom, TAILLE_NOM_UNITE, code_param))
0777 != ok)
0778 return Resultat;
0779
0780 if ((Resultat = Reception (nsock, (char *) &envoi, taille_short, code_param))
0781 != ok)
0782 return Resultat;
0783
0784 }
0785 pcunite->ps_suivant = NULL;
0786
0787 return Resultat;
0788 }
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813 Longint FAR_PASCAL
0814 Reception_Tableau (
0815 #if (client == MAC)
0816 ConnHandle nsock,
0817 #else
0818 int nsock,
0819 #endif
0820 char HUGE *Tab,
0821 Longint Tablg,
0822 char *Tabtyp,
0823 Longint code_param )
0824 {
0825 short int HUGE *S;
0826 unsigned short int HUGE *US;
0827 Longint HUGE *L;
0828
0829 #ifdef __alpha
0830 unsigned int HUGE *UL;
0831 #else
0832 unsigned long HUGE *UL;
0833 #endif
0834
0835 float HUGE *F;
0836 Double HUGE *D;
0837 char HUGE *C;
0838
0839 Longint i;
0840 Longint Tablg2;
0841 Longint Resultat;
0842
0843
0844 Longint lcomp;
0845 char HUGE *Cc;
0846
0847
0848 Resultat = ok;
0849
0850 if (Tablg > 0)
0851 {
0852
0853 C = (char HUGE *) MemAlloc (Tablg);
0854
0855 if(compress_on) {
0856
0857 if ((Resultat = Reception (nsock,(char *)&lcomp, sizeof(Longint),
0858 code_param)) != ok)
0859 return Resultat;
0860
0861
0862 Cc = (char HUGE *) MemAlloc (lcomp);
0863 #if (client == PC)
0864 if ((Resultat = ReceptionHuge (nsock,Cc, lcomp, code_param))
0865 != ok)
0866 #else
0867 if ((Resultat = Reception (nsock,Cc, lcomp, code_param))
0868 != ok)
0869 #endif
0870 return Resultat;
0871
0872
0873 if(Tablg > MIN_SIZE)
0874 lzrw1_decompress (Cc, lcomp, C);
0875 else
0876 memcpy(C,Cc,Tablg);
0877
0878 FreeMemory( Cc);
0879
0880 }
0881 else
0882 {
0883 #if (client == PC)
0884 if ((Resultat = ReceptionHuge (nsock,C, Tablg, code_param))
0885 != ok)
0886 #else
0887 if ((Resultat = Reception (nsock,C, Tablg, code_param))
0888 != ok)
0889 #endif
0890 return Resultat;
0891
0892 }
0893
0894
0895
0896 switch (Tabtyp[0])
0897 {
0898
0899 case entier_court:
0900 S = (short int HUGE *) C;
0901 switch (tslib_reel)
0902 {
0903 case reel_simple:
0904 Tablg2 = Tablg * (taille_float / taille_short);
0905 F = (float HUGE *) MemAlloc (Tablg2);
0906 for (i = 0; i < Tablg / taille_short; i++)
0907 F[i] = (float) S[i];
0908 C = (char HUGE *) F;
0909 for (i = 0; i < Tablg2; i++)
0910 Tab[i] = C[i];
0911 FreeMemory( (void HUGE *)F);
0912 break;
0913 case reel_double:
0914 Tablg2 = Tablg *
0915 (taille_double / taille_short);
0916 D = (Double HUGE *) MemAlloc (Tablg2);
0917 for (i = 0; i < Tablg / taille_short; i++)
0918 D[i] = (Double) S[i];
0919 C = (char HUGE *) D;
0920 for (i = 0; i < Tablg2; i++)
0921 Tab[i] = C[i];
0922 FreeMemory( (void HUGE *)D);
0923 }
0924 FreeMemory( (void HUGE *)S);
0925 break;
0926
0927 case entier_long:
0928 L = (Longint HUGE *) C;
0929 switch (tslib_reel)
0930 {
0931 case reel_simple:
0932 Tablg2 = Tablg * (taille_float / taille_long);
0933 F = (float HUGE *) MemAlloc (Tablg2);
0934 for (i = 0; i < Tablg / taille_long; i++)
0935 F[i] = (float) L[i];
0936 C = (char HUGE *) F;
0937 for (i = 0; i < Tablg2; i++)
0938 Tab[i] = C[i];
0939 FreeMemory( (void HUGE *)F);
0940 break;
0941 case reel_double:
0942 Tablg2 = Tablg * (taille_double / taille_long);
0943 D = (Double HUGE *) MemAlloc (Tablg2);
0944 for (i = 0; i < Tablg / taille_long; i++)
0945 D[i] = (Double) L[i];
0946 C = (char HUGE *) D;
0947 for (i = 0; i < Tablg2; i++)
0948 Tab[i] = C[i];
0949 FreeMemory( (void HUGE *)D);
0950 }
0951 FreeMemory( (void HUGE *)L);
0952
0953 break;
0954
0955 case non_signe:
0956
0957 switch (Tabtyp[1])
0958 {
0959 case entier_court:
0960 US = (unsigned short int HUGE *) C;
0961 switch (tslib_reel)
0962 {
0963 case reel_simple:
0964 Tablg2 = Tablg * (taille_float / taille_short);
0965 F = (float HUGE *) MemAlloc (Tablg2);
0966 for (i = 0; i < Tablg / taille_short; i++)
0967 F[i] = (float) US[i];
0968 C = (char HUGE *) F;
0969 for (i = 0; i < Tablg2; i++)
0970 Tab[i] = C[i];
0971 FreeMemory( (void HUGE *)F);
0972 break;
0973
0974 case reel_double:
0975 Tablg2 = Tablg *
0976 (taille_double / taille_short);
0977 D = (Double HUGE *) MemAlloc (Tablg2);
0978 for (i = 0; i < Tablg / taille_short; i++)
0979 D[i] = (Double) US[i];
0980 C = (char HUGE *) D;
0981 for (i = 0; i < Tablg2; i++)
0982 Tab[i] = C[i];
0983 FreeMemory( (void HUGE *)D);
0984 }
0985 FreeMemory( (void HUGE *)US);
0986
0987 break;
0988
0989
0990 case entier_long:
0991 #ifdef __alpha
0992 UL = (unsigned int HUGE *) C;
0993 #else
0994 UL = (unsigned long HUGE *) C;
0995 #endif
0996 switch (tslib_reel)
0997 {
0998 case reel_simple:
0999 Tablg2 = Tablg * (taille_float / taille_long);
1000 F = (float HUGE *) MemAlloc (Tablg2);
1001 for (i = 0; i < Tablg / taille_long; i++)
1002 F[i] = (float) UL[i];
1003 C = (char HUGE *) F;
1004 for (i = 0; i < Tablg2; i++)
1005 Tab[i] = C[i];
1006 FreeMemory( (void HUGE *)F);
1007 break;
1008
1009 case reel_double:
1010 Tablg2 = Tablg * (taille_double / taille_long);
1011 D = (Double HUGE *) MemAlloc (Tablg2);
1012 for (i = 0; i < Tablg / taille_long; i++)
1013 D[i] = (Double) UL[i];
1014 C = (char HUGE *) D;
1015 for (i = 0; i < Tablg2; i++)
1016 Tab[i] = C[i];
1017 FreeMemory( (void HUGE *)D);
1018 }
1019 FreeMemory( (void HUGE *)UL);
1020 }
1021 break;
1022
1023
1024 case reel_simple:
1025 switch (tslib_reel)
1026 {
1027 case reel_double:
1028 F = (float HUGE *) C;
1029 Tablg2 = Tablg * (taille_double / taille_float);
1030 D = (Double HUGE *) MemAlloc (Tablg2);
1031 for (i = 0; i < Tablg / taille_float; i++)
1032 D[i] = (Double) F[i];
1033 C = (char HUGE *) D;
1034 for (i = 0; i < Tablg2; i++)
1035 Tab[i] = C[i];
1036 FreeMemory( (void HUGE *)F);
1037 FreeMemory( (void HUGE *)D);
1038 break;
1039
1040 case reel_simple:
1041 for (i = 0; i < Tablg; i++)
1042 Tab[i] = C[i];
1043 FreeMemory( (void HUGE *)C);
1044 }
1045 break;
1046
1047 case reel_double:
1048 switch (tslib_reel)
1049 {
1050 case reel_simple:
1051 D = (Double HUGE *) C;
1052 Tablg2 = Tablg / (taille_double / taille_float);
1053 F = (float HUGE *) MemAlloc (Tablg2);
1054 for (i = 0; i < Tablg / taille_double; i++)
1055 {
1056 F[i] = (float) D[i];
1057 }
1058 C = (char HUGE *) F;
1059 for (i = 0; i < Tablg2; i++)
1060 Tab[i] = C[i];
1061 FreeMemory( (void HUGE *)F);
1062 FreeMemory( (void HUGE *)D);
1063 break;
1064 case reel_double:
1065 for (i = 0; i < Tablg; i++)
1066 Tab[i] = C[i];
1067 FreeMemory( (void HUGE *)C);
1068 }
1069 break;
1070 default:
1071 for (i = 0; i < Tablg; i++)
1072 Tab[i] = C[i];
1073 FreeMemory( (void HUGE *)C);
1074 }
1075
1076 }
1077 return Resultat;
1078 }
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102 Longint FAR_PASCAL
1103 Reception_Tab_Coord (
1104 #if (client == MAC)
1105 ConnHandle nsock,
1106 #else
1107 int nsock,
1108 #endif
1109 char *Tab,
1110 Longint *Tablg,
1111 char *Tabtyp,
1112 Longint Typtab,
1113 Longint code_param )
1114 {
1115 short int *S;
1116 unsigned short int *US;
1117 Longint *L;
1118 #ifdef __alpha
1119 unsigned int *UL;
1120 #else
1121 unsigned long *UL;
1122 #endif
1123 float *F;
1124 Double *D;
1125 char *C;
1126 pS_LisCoord tab_temp;
1127 pS_LisCoord tab_prec;
1128 pS_LisCoord tab_deb;
1129 char *ind_tab;
1130 char *ctab;
1131 int i, j;
1132 Longint Tablg2;
1133 Longint Tablong[MAX_INDICE];
1134 Longint Resultat;
1135
1136 Resultat = ok;
1137
1138 if (Tablg[0] > 0)
1139 {
1140
1141
1142
1143 switch (Typtab)
1144 {
1145 case UNIQ:
1146 Tablg2 = *Tablg;
1147 break;
1148 case MULT:
1149 Tablg2 = 0;
1150 for (i = 0; i < MAX_INDICE; i++)
1151 Tablg2 = Tablg2 + Tablg[i];
1152 }
1153
1154 ctab = (char *) MemAlloc (Tablg2);
1155 if ((Resultat = Reception (nsock, ctab, Tablg2, code_param))
1156 != ok)
1157 return Resultat;
1158
1159
1160
1161 switch (Typtab)
1162 {
1163 case UNIQ:
1164 for (i = 0; i < MAX_INDICE; i++)
1165 switch (Tabtyp[i * 2])
1166 {
1167 case entier_court:
1168 Tablong[i] = taille_short;
1169 break;
1170 case entier_long:
1171 Tablong[i] = taille_long;
1172 break;
1173 case reel_simple:
1174 Tablong[i] = taille_float;
1175 break;
1176 case reel_double:
1177 Tablong[i] = taille_double;
1178 break;
1179 case non_signe:
1180 switch (Tabtyp[(i * 2) + 1])
1181 {
1182 case entier_court:
1183 Tablong[i] = taille_short;
1184 break;
1185 case entier_long:
1186 Tablong[i] = taille_long;
1187 }
1188 break;
1189 default:
1190 Tablong[i] = 0;
1191 }
1192 break;
1193 case MULT:
1194 for (i = 0; i < MAX_INDICE; i++)
1195 Tablong[i] = Tablg[i];
1196 break;
1197 }
1198
1199
1200
1201 ind_tab = ctab;
1202 tab_temp = tab_deb = tab_prec = NULL;
1203 for (j = 0; j < (MAX_INDICE || (Tablg[j] == 0)) ; j++)
1204 {
1205 tab_temp = (pS_LisCoord) MemAlloc (
1206 sizeof (struct S_LisCoord));
1207 if (tab_deb == NULL)
1208 tab_deb = tab_temp;
1209 if (tab_prec != NULL)
1210 tab_prec->ps_suivant = tab_temp;
1211 tab_temp->nb_octets = 0;
1212 tab_temp->ps_suivant = NULL;
1213 switch (Tabtyp[0])
1214 {
1215
1216 case entier_court:
1217 S = (short int *) ind_tab;
1218 switch (tslib_reel)
1219 {
1220 case reel_simple:
1221 Tablg2 = Tablong[j] *
1222 (taille_float / taille_short);
1223 F = (float *) MemAlloc (Tablg2);
1224 for (i = 0; i < Tablong[j] / taille_short; i++)
1225 F[i] = (float) S[i];
1226 C = (char *) F;
1227 break;
1228 case reel_double:
1229 Tablg2 = Tablong[j] *
1230 (taille_double / taille_short);
1231 D = (Double *) MemAlloc (Tablg2);
1232 for (i = 0; i < Tablong[j] / taille_short; i++)
1233 D[i] = (Double) S[i];
1234 C = (char *) D;
1235 }
1236 tab_temp->nb_octets = Tablg2;
1237 tab_temp->table = (char *) MemAlloc (Tablg2);
1238 for (i = 0; i < Tablg2; i++)
1239 tab_temp->table[i] = C[i];
1240 FreeMemory( (void *)C);
1241 FreeMemory( (void *)S);
1242 switch (tslib_reel)
1243 {
1244 case reel_simple:
1245 FreeMemory( (void *)F);
1246 break;
1247 case reel_double:
1248 FreeMemory( (void *)D);
1249 break;
1250 }
1251 break;
1252
1253 case entier_long:
1254 L = (Longint *) ind_tab;
1255 switch (tslib_reel)
1256 {
1257 case reel_simple:
1258 Tablg2 = Tablong[j] *
1259 (taille_float / taille_long);
1260 F = (float *) MemAlloc (Tablg2);
1261 for (i = 0; i < Tablong[j] / taille_long; i++)
1262 F[i] = (float) L[i];
1263 C = (char *) F;
1264 break;
1265 case reel_double:
1266 Tablg2 = Tablong[j] *
1267 (taille_double / taille_long);
1268 D = (Double *) MemAlloc (Tablg2);
1269 for (i = 0; i < Tablong[j] / taille_long; i++)
1270 D[i] = (Double) L[i];
1271 C = (char *) D;
1272 }
1273 tab_temp->nb_octets = Tablg2;
1274 tab_temp->table = (char *) MemAlloc (Tablg2);
1275 for (i = 0; i < Tablg2; i++)
1276 tab_temp->table[i] = C[i];
1277 FreeMemory( (void *)C);
1278 FreeMemory( (void *)L);
1279 switch (tslib_reel)
1280 {
1281 case reel_simple:
1282 FreeMemory( (void *)F);
1283 break;
1284 case reel_double:
1285
1286 break;
1287 }
1288
1289 break;
1290
1291 case non_signe:
1292
1293 switch (Tabtyp[1])
1294 {
1295 case entier_court:
1296 US = (unsigned short int *) ind_tab;
1297 switch (tslib_reel)
1298 {
1299 case reel_simple:
1300 Tablg2 = Tablong[j] *
1301 (taille_float / taille_short);
1302 F = (float *) MemAlloc (Tablg2);
1303 for (i = 0; i < Tablong[j] / taille_short; i++)
1304 F[i] = (float) US[i];
1305 C = (char *) F;
1306 break;
1307
1308 case reel_double:
1309 Tablg2 = Tablong[j] *
1310 (taille_double / taille_short);
1311 D = (Double *) MemAlloc (Tablg2);
1312 for (i = 0; i < Tablong[j] / taille_short; i++)
1313 D[i] = (Double) US[i];
1314 C = (char *) D;
1315 }
1316 tab_temp->nb_octets = Tablg2;
1317 tab_temp->table = (char *) MemAlloc (Tablg2);
1318 for (i = 0; i < Tablg2; i++)
1319 tab_temp->table[i] = C[i];
1320 FreeMemory( (void *)C);
1321 FreeMemory( (void *)US);
1322 switch (tslib_reel)
1323 {
1324 case reel_simple:
1325 FreeMemory( (void *)F);
1326 break;
1327 case reel_double:
1328 FreeMemory( (void *)D);
1329 break;
1330 }
1331
1332 break;
1333
1334
1335 case entier_long:
1336 #ifdef __alpha
1337 UL = (unsigned int *) ind_tab;
1338 #else
1339 UL = (unsigned long *) ind_tab;
1340 #endif
1341 switch (tslib_reel)
1342 {
1343 case reel_simple:
1344 Tablg2 = Tablong[j] *
1345 (taille_float / taille_long);
1346 F = (float *) MemAlloc (Tablg2);
1347 for (i = 0; i < Tablong[j] / taille_long; i++)
1348 F[i] = (float) UL[i];
1349 C = (char *) F;
1350 break;
1351
1352 case reel_double:
1353 Tablg2 = Tablong[j] *
1354 (taille_double / taille_long);
1355 D = (Double *) MemAlloc (Tablg2);
1356 for (i = 0; i < Tablong[j] / taille_long; i++)
1357 D[i] = (Double) UL[i];
1358 C = (char *) D;
1359 }
1360 tab_temp->nb_octets = Tablg2;
1361 tab_temp->table = (char *) MemAlloc (Tablg2);
1362 for (i = 0; i < Tablg2; i++)
1363 tab_temp->table[i] = C[i];
1364 FreeMemory( (void *)C);
1365 FreeMemory( (void *)UL);
1366 switch (tslib_reel)
1367 {
1368 case reel_simple:
1369 FreeMemory( (void *)F);
1370 break;
1371 case reel_double:
1372 FreeMemory( (void *)D);
1373 break;
1374 }
1375 }
1376 break;
1377
1378
1379 case reel_simple:
1380 switch (tslib_reel)
1381 {
1382 case reel_double:
1383 F = (float *) ind_tab;
1384 Tablg2 = Tablong[j] * (taille_double / taille_float);
1385 D = (Double *) MemAlloc (Tablg2);
1386 for (i = 0; i < Tablong[j] / taille_float; i++)
1387 D[i] = (Double) F[i];
1388 C = (char *) D;
1389 tab_temp->nb_octets = Tablg2;
1390 tab_temp->table = (char *) MemAlloc (Tablg2);
1391 for (i = 0; i < Tablg2; i++)
1392 tab_temp->table[i] = C[i];
1393
1394
1395 FreeMemory(D);
1396 break;
1397 case reel_simple:
1398 tab_temp->nb_octets = Tablong[j];
1399 Tablg2 = Tablong[j];
1400 tab_temp->table = (char *) MemAlloc (Tablong[j]);
1401 for (i = 0; i < Tablong[j]; i++)
1402 tab_temp->table[i] = ind_tab[i];
1403 }
1404
1405 break;
1406
1407 case reel_double:
1408 switch (tslib_reel)
1409 {
1410 case reel_simple:
1411 D = (Double *) ind_tab;
1412 Tablg2 = Tablong[j] / (taille_double / taille_float);
1413 F = (float *) MemAlloc (Tablg2);
1414 for (i = 0; i < Tablong[j] / taille_double; i++)
1415 F[i] = (float) D[i];
1416 C = (char *) F;
1417 tab_temp->nb_octets = Tablg2;
1418 tab_temp->table = (char *) MemAlloc (Tablg2);
1419 for (i = 0; i < Tablg2; i++)
1420 tab_temp->table[i] = C[i];
1421 FreeMemory( (void *)C);
1422 FreeMemory( (void *)F);
1423 FreeMemory( (void *)D);
1424 break;
1425 case reel_double:
1426 tab_temp->nb_octets = Tablong[j];
1427 Tablg2 = Tablong[j];
1428 tab_temp->table = (char *) MemAlloc (Tablong[j]);
1429 for (i = 0; i < Tablong[j]; i++)
1430 tab_temp->table[i] = ind_tab[i];
1431 }
1432 break;
1433 default:
1434 tab_temp->nb_octets = Tablong[j];
1435 Tablg2 = Tablong[j];
1436 tab_temp->table = (char *) MemAlloc (Tablong[j]);
1437 for (i = 0; i < Tablong[j]; i++)
1438 tab_temp->table[i] = ind_tab[i];
1439 }
1440
1441 tab_prec = tab_temp;
1442 ind_tab = ind_tab + Tablong[j];
1443 }
1444
1445
1446
1447 tab_temp = tab_deb;
1448 j = 0;
1449 while (tab_temp != NULL)
1450 {
1451 if (tab_temp->nb_octets > 0)
1452 for (i = 0; i < tab_temp->nb_octets; i++, j++)
1453 Tab[j] = tab_temp->table[i];
1454 tab_deb = tab_temp;
1455 tab_temp = tab_deb->ps_suivant;
1456 FreeMemory( (void *)tab_deb);
1457 }
1458
1459
1460 }
1461 return (Resultat);
1462 }
1463
1464
1465 void * MemAlloc( Longint byte )
1466 {
1467 void * result;
1468
1469 #if ( client == PC )
1470 result = GlobalLock( GlobalAlloc (
1471 GMEM_MOVEABLE, byte ) );
1472 #else
1473 result = malloc ( byte );
1474 #endif
1475
1476 return( result );
1477 }
1478
1479
1480 void FreeMemory( void * F )
1481 {
1482 #if (client == PC )
1483 {
1484 GLOBALHANDLE hMemory;
1485 if( F == NULL)
1486 return;
1487 hMemory= (GLOBALHANDLE) GlobalHandle( (UINT) SELECTOROF( F ) );
1488 GlobalUnlock(hMemory);
1489 GlobalFree(hMemory);
1490 }
1491 #else
1492 free (F);
1493 #endif
1494 }
1495
1496
1497 #define TRUE 1
1498 #define UBYTE unsigned char
1499 #define UWORD unsigned short
1500
1501 #ifdef __alpha
1502 #define ULONG unsigned int
1503 #else
1504 #define ULONG unsigned long
1505 #endif
1506
1507 #define FLAG_BYTES 4
1508 #define FLAG_COMPRESS 0
1509 #define FLAG_COPY 1
1510
1511 void fast_copy(p_src,p_dst,len)
1512 UBYTE *p_src,*p_dst;
1513 {
1514 while (len--) *p_dst++=*p_src++;
1515 }
1516
1517
1518 void lzrw1_decompress(p_src_first,src_len,p_dst_first)
1519
1520
1521
1522
1523
1524
1525
1526
1527 UBYTE *p_src_first, *p_dst_first; ULONG src_len;
1528 {
1529 UWORD controlbits=0, control;
1530 UBYTE *p_src=p_src_first+FLAG_BYTES, *p_dst=p_dst_first,
1531 *p_src_post=p_src_first+src_len;
1532 if (*p_src_first==FLAG_COPY)
1533 {fast_copy(p_src_first+FLAG_BYTES,p_dst_first,src_len-FLAG_BYTES);
1534 return;}
1535 while (p_src!=p_src_post)
1536 {if (controlbits==0)
1537 {control=*p_src++; control|=(*p_src++)<<8; controlbits=16;}
1538 if (control&1)
1539 {UWORD offset,len; UBYTE *p;
1540 offset=(*p_src&0xF0)<<4; len=1+(*p_src++&0xF);
1541 offset+=*p_src++&0xFF; p=p_dst-offset;
1542 while (len--) *p_dst++=*p++;}
1543 else
1544 *p_dst++=*p_src++;
1545 control>>=1; controlbits--;
1546 }
1547 }
1548