File: satupdat.c

package info (click to toggle)
fbb 7.07-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,244 kB
  • ctags: 8,123
  • sloc: ansic: 87,810; sh: 2,324; makefile: 297
file content (1393 lines) | stat: -rw-r--r-- 33,297 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
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
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
/*********************************************************************
SATUPDAT.C copyright 1989-2009 Bernard PIDOUX, F6BVP [ f6bvp@amsat.org ]

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA  02111-1307  USA
 ************************************************************************
 *
 * NOM / NAME : AJOURSAT  SATUPDAT 
 *
 * Lecture des parametres Kepleriens des satellites
 * pour serveur F6FBB a partir des bulletins de l'AMSAT
 *
 ************************************************************************
 * HISTORIQUE :
 * DATE			AUTEUR / AUTHOR : Bernard Pidoux, f6bvp@amsat.org
 * ajoursat 16/10/89	Bernard Pidoux F6BVP
 * 11/11/89		le répertoire n'est pas imposé * 20/05/00
 *			portage sous linux (J-P ROUBELAT - F6FBB)
 *
 * Version 1.72 12/12/90  avec vérifications renforcés du synchronisme
 * du format de lecture, sans bouclage infini.
 * 1.74	 3/03/91  Traite jusqu'à 768 Satellites
 * 26/04/91	 Test si place disponible en mémoire
 * 1.75 27/04/91  Option lecture format Nasa
 * nouveau renforcement controle intégrité des donnés
 * Exclusion des doublons
 * libéation mémoire alloué en sortie
 * extension fichier source .txt uniquement par défaut
 * 1.76 19/05/91  CRC en lecture format Nasa	
 * changement du format de lecture lignes NASA
 * 24/05/91	 déplacement message "Aucune mise  jour aprés else
 * 1.77 28/05/91  CRC en lecture format AMSAT
 * 1.78 31/10/93 fscanf remplacé par fgets dans AMSAT pour supprimer
 * plantage programme sur longue ligne sans RC
 * 1.80 20/11/93  prise en compte de la date_limite des donnés
 * 1.83 20/11/94  champ ELEMENT SET pour compatibilité
 * format AMSAT du service REQKEP
 * 1.84 :  15/02/98 suite plantage par ligne pseudo Satellite
 * agrandissement tableaux buf1 et buf2 
 * 1.85 : 12/01/2000 pour le bogue !
 *        dernières mises au point 9 juin 2000 sous Linux
 * 1.86 : septembre 2007
 * 1.87 : 26/09/2009
 * 1.88 Jan-26-2015 changed fgets() lines avoiding compiler warnings 
 *************************************************************************/

#include <math.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <syslog.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>

/* #define DEBUG */
/* #define FRANCAIS*/
#define VERSION "1.88"
/* Tabulation a 4 espaces !! */

#ifdef DEBUG
#define d_printf printf
#else
void d_printf(const char * format, ...);

void d_printf(const char * format, ...) 
{
}
#endif

#define TRUE 1
#define FALSE 0
/*
 * Record du fichier SATEL 
 */

#define __a2__ __attribute__ ((packed, aligned(2)))

typedef struct typ_satel {
	char dd[18];		/* Nom du satellite	*/
	short y3;		/* Annee de reference	*/
	double d3 __a2__;	/* Jour de reference	*/
	short n3;		/* Mois de reference	*/
	short h3;		/* Heure de reference	*/
	short m3;		/* Minute de reference	*/
	short s3;		/* Seconde de reference */
	double i0 __a2__;	/* Inclinaison	*/
	double o0 __a2__;	/* R.A.A.N.		*/
	double e0 __a2__;	/* Excentricite */
	double w0 __a2__;	/* Argument de perigee	*/
	double m0 __a2__;	/* Anomalie moyenne	*/
	double a0 __a2__;	/* Contient 0.0 */
	double n0 __a2__;	/* Mouvement moyen	*/
	double q3 __a2__;	/* Derivee du mouv. moy.*/
	long k0 __a2__;		/* Orbite de reference	*/
	double f1 __a2__;	/* Frequence pour le calcul doppler */
	double v1 __a2__;	/* Contient	 0.0	*/
	short pas;		/* Pas des calculs*/
	long maj __a2__;	/* Date de derniere mise à jour*/
	long cat __a2__;	/* Catalog Number - anciennement vide	*/
	short set;		/* Element set NASA */
	short libre[3];
} satel;

#define MAXSAT 769
#define LINE 81

/********** Prototypes **************/

int Misajour(satel ** vieux, int vv, satel ** nouv, int nn, char option);
int Ecrit_Sat(char *filename, satel ** stru, int nombre);
void Amsat(char *filename);
void nasa(char *filename);
int Lire_Ancien(char *filename);
void Print_Sat(satel ** stru, int m);	/* Imprime fichier */
void Tri_Cat(satel ** stru, int nombre);
void Tri(satel ** stru, int nombre);	/* tri a bulle des noms de satellites */
void CopyStru(satel ** stru, int indice, satel * psat);
int doublons(int nombre);
void avorte(void);
int fraicheur(void);
/************************************/


char *filename, *str;		/* Nom fichier Source et copie */
struct tm *cejour;		/* date et time declares dans TIME.H */
char *aujour;			/* Date de derniere mise à jour */
int date_limite;		/* nombre de jours ancienneté limite pour les données */
satel *vieux[MAXSAT];
satel *nouveaux[MAXSAT];
satel *tampon[MAXSAT];		/* tampon pour mise à jour */
satel sat;			/* declaration structure sat de type satel */
int nsat;			/* nombre de satellites modifié */
int maxsat;			/* nombre de satellites gérable */
char *opt;
char *options[5];
char *option;
char *dmo;
char *dmold;
int good_crc;
int bad_crc;

void sortie(int n)
{
	int i;

	for (i = 0; i < maxsat; i++) 
	{
		free(vieux[i]);
		free(nouveaux[i]);
		/*
		 * farfree(tampon[i]); 
		 */
		free(tampon[i]);
	}
	free(filename);
	free(str);
	free(dmo);
	free(dmold);
	exit(n);
}

void avorte(void)
/*
 * Nom:			  avorte() Description :  Sortie du programme en cas
 * d'erreur. Commentaire :	Efface le fichier provisoire et ferme les
 * fichiers de travail. 
 */
{
	remove(dmo);		/* efface le fichier provisoire .$$$ */
#ifdef FRANCAIS
	printf("\nDépassement du nombre de satellites autorisé!\n");
	printf(" ou pas assez de mémoire.\n");
#else
	printf("\nToo much satellites on file !\n");
	printf(" or not enough memory for the program.\n");
#endif
	sortie(1);
}

int main(int argc, char *argv[])
{
	int i, j, k, l, m, n = 0;
	/* long jour;		 secondes depuis 1er Janv 1970 0 heures GMT */
	/* char option1;	 option format fichier /A AMSAT, /N NASA */
	/* char option2='X';	 option de mise a jour fusion par défaut*/
	/* char option3='X';	 option de délai*/
	char optionA;
	char optionB;
	char optionC;
	time_t temps;

	for (i = 0; i < MAXSAT; i++) 
	{
		vieux[i] = (satel *) (malloc(sizeof(satel)));
		tampon[i] = (satel *) (malloc(sizeof(satel)));
		nouveaux[i] = (satel *) (malloc(sizeof(satel)));

		if (nouveaux[i] == NULL)
			avorte();
	}
	maxsat = i - 1;
	for (i = 0; i < 5; i++)
		options[i] = (char *) (calloc(40, sizeof(char)));
	option = (char *) (malloc(40 * sizeof(char)));
	dmo = (char *) (malloc(80 * sizeof(char)));
	dmold = (char *) (malloc(80 * sizeof(char)));
	opt =  (char *) (malloc(40 * sizeof(char)));
	str = (char *) (malloc(80 * sizeof(char)));
	filename = (char *) (malloc(80 * sizeof(char)));

	strcpy(dmold, "satel.dat");
	strcpy(dmo, "satel.$$$");

	*options[0] = 'A';		/* défaut format AMSAT */
	optionA = 'A';
	*options[1] = 'F';		/* fusion des donnés */
	optionB = 'F';
	date_limite = 100;		/* effacer donnés si supéieures é00 jours */
	optionC = 'D';

	/*
	 * printf("%d arguments\n",argc); for(i=0;i<argc;i++) printf("%s
	 * ",argv[i]); printf("\n"); 
	 */
	if (argc >= 2 && argc <= 5) 
	{
		strcpy(filename, argv[1]);

		for (i = 0; i < argc-2; i++) 
		{
			strcpy(option, argv[i + 2]);
			opt = strstr(option, "/");
			if (opt == NULL)
				break;
			opt++;
			*options[i] = toupper(*opt);
			if (*options[i] == 'D')
				date_limite = atoi(++opt);
		}
	}
#ifdef FRANCAIS
	printf("\nMise à jour des paramètres orbitaux de la banque de données des satellites pour BBS F6FBB\n");
	printf("Version %s - janvier 2015 - Bernard Pidoux, f6bvp@amsat.org\n",VERSION);
	if ((argc < 2) || (argc > 5)) 
	{
		printf("Emploi: ajoursat nom_fichier<.txt> </option> </option> </option>\n");
		printf("\nOption lecture :");
		printf("\n		/a format AMSAT (par défaut)");
		printf("\n		/n format NASA");
		printf("\nOption mise à jour :");
		printf("\n		/f fusion avec les anciennes données (par défaut)");
		printf("\n		/u uniquement des anciennes données");
		printf("\n		/s seulement les données réactualisées");
		printf("\nOption effacement	 :");
		printf("\n		/dxxx supprime les données de plus de xxx jours");
		printf("\n			  (par défaut 100 jours)\n");
		printf("\n<<maximum %d satellites>>\n", maxsat);
		sortie(0);
	}
#else
	printf("\nUpdate of F6FBB's BBS satellite data base orbital parameters\n");
	printf("Version %s - January 2015 - Bernard Pidoux, f6bvp@amsat.org\n",VERSION);
	if ((argc < 2) || (argc > 5)) 
	{
		printf("Usage: satupdat file_name<.txt> </option> </option> </option>\n");
		printf("\nReading option:");
		printf("\n		/a AMSAT format (default)");
		printf("\n		/n NASA format");
		printf("\nUpdate option:");
		printf("\n		/f merging new and old data (default)");
		printf("\n		/u update only satellites being in the data base");
		printf("\n		/s keep only satellites being in the input file");
		printf("\nDelete option:");
		printf("\n		/dxxx delete data older than xxx days");
		printf("\n			  (default 100 days)\n");
		printf("\n<<%d satellites maximum>>\n", maxsat);
		sortie(0);
	}
#endif	

	time(&temps);
	cejour = gmtime(&temps);

	for (i = 0; i < argc - 2; i++) 
	{
		if (*options[i] == 'A')
			optionA = 'A';
		else if (*options[i] == 'N')
			optionA = 'N';
		else if (*options[i] == 'S')
			optionB = 'S';
		else if (*options[i] == 'U')
			optionB = 'U';
		else if (*options[i] == 'F')
			optionB = 'F';
		else if (*options[i] == 'D')
			optionC = 'D';
	}

#ifdef FRANCAIS
	if (optionA == 'A')
		printf("Lecture format AMSAT\n");
	else if (optionA == 'N')
		printf("Lecture format NASA avec CRC-10\n");
	printf("Mise  jour ");
	if (optionB == 'S')
		printf("en gardant seulement les satellites de la nouvelle liste\n");
	else if (optionB == 'U')
		printf("uniquement des données des anciens satellites\n");
	else if (optionB == 'F')
		printf("en fusionnant la nouvelle avec l'ancienne liste\n");
	if (optionC == 'D')
		printf("avec suppression des données de plus de %d jours.\n", date_limite);
#else
	if (optionA == 'A')
		printf("Reading AMSAT format\n");
	else if (optionA == 'N')
		printf("Reading NASA format with CRC-10\n");
	printf("Update ");
	if (optionB == 'S')
		printf("keeping only satellites being in the input file\n");
	else if (optionB == 'U')
		printf("only satellites being already in the data base\n");
	else if (optionB == 'F')
		printf("merging new list with old list\n");
	if (optionC == 'D')
		printf("deleting data older than %d days.\n", date_limite);
#endif

	n = Lire_Ancien(dmold);
	if (n > 1) 
	{
		Tri_Cat(vieux, n);
	}

	if (n != -1)
	{
#ifdef FRANCAIS
		printf("\n%d données de moins de %d jours", n, date_limite);
#else
		printf("\n%d data less than %d days", n, date_limite);
#endif
	}
	
	if (strchr(filename, '.') == NULL) 
	{
		strtok(filename, ".");
		strcat(filename, ".txt");
	}

#ifdef FRANCAIS
	printf("\nLecture du fichier: %s\n\n", filename);
#else
	printf("\nReading file: %s\n\n", filename);
#endif
				 
	if (optionA == 'A') 
		Amsat(filename);
	else if (optionA == 'N') 
		nasa(filename);

	m = good_crc;	
	
	if (good_crc > 0) 
	{		
		/* Il existe au moins une donné nouvelle... */
		Tri_Cat(nouveaux, m);
	printf ("(%d)",m); 
		j = doublons(m);
	printf ("(%d)",j); 
		k = Misajour(vieux, n, nouveaux, j, optionB);
		Tri(nouveaux, k);	/* tri alphabetique pour liste */
	printf ("(%d)",k); 
		/* Print_Sat(nouveaux,j); */
		remove("satel.bak");
		rename(dmold, "satel.bak");
		l = Ecrit_Sat(dmo, nouveaux, k);
		rename(dmo, dmold);
	}

#ifdef FRANCAIS
	if (good_crc > 0) 
		printf("\nLes données de %d satellites sur %d ont été réactualisées", nsat, k);
	else if (good_crc == 0)
		printf("\nAucune nouvelle donnée");
	else if (good_crc == -1)
		printf("\nFichier %s non trouvé !", filename);
#else
	if (good_crc > 0) 
		printf("\nData of %d satellites over %d have been updated", nsat, k);
	else if (good_crc == 0)
		printf("\nNothing to update");
	else if (good_crc == -1)
		printf("\nFile %s not found !", filename);
#endif

#ifdef FRANCAIS
	printf(" le %02d/%02d/%02d ", cejour->tm_mday, cejour->tm_mon+1, cejour->tm_year%100);
	printf("a %02u:%02u:%02u\n", cejour->tm_hour, cejour->tm_min, cejour->tm_sec);
#else
	printf(" on %02d/%02d/%02d ", cejour->tm_mday, cejour->tm_mon+1, cejour->tm_year%100);
	printf("at %02u:%02u:%02u\n", cejour->tm_hour, cejour->tm_min, cejour->tm_sec);
#endif

	sortie(0);
	return 0;
}

/*
 * fonction validation du checksum NASA revue le 24/01/92 pour nouveau format 
 * NASA avec signe (+) valeur 0 
 */

int crcdix(char *ligne)
{
	char caract;
	char *pointeur;
	int i, crc10, crc, valide;

	crc10 = 0;
	pointeur = ligne;
	/*
	 * printf("\n%s\n",ligne);
	 */
	for (i = 0; i < 68; i++) 
	{
		caract = pointeur[i];
		if (caract == '-')
			crc = 1;
		else if (caract == '+')
			crc = 0;
		else
			crc = atoi(&caract);
		crc10 += crc;
		crc10 = crc10 % 10;
	}
	caract = pointeur[68];
	crc = atoi(&caract);
	if (crc == crc10)
		valide = 1;
	else
		valide = -1;
	return (valide);
}

/*************************** FORMAT AMSAT *************************/

int crc, crc10;
int checksum(char *ligne)
{
	int i;
	char caract;

	for (i = 0; i < strlen(ligne); i++) 
	{
		caract = ligne[i];
		if (caract == '-')
			crc += 1;
		else if (caract == '+')
			crc += 2;
		else
			crc += atoi(&caract);
	}
	/* printf("*%d*\n",crc); */
	return (crc);
}

void Amsat(char *filename)
{
	FILE *fd;
	char tampon[82];
	char ligne[81];
	char buf1[41] = "\0";
	char buf2[41] = "\0";
	char nom[18];
	long jour;			/* secondes depuis 1er Janv 1970 0 heures GMT */
	int k, n, m = 0;
	int valide;			/* validation enregistrement */

	fd = fopen(filename, "rt");
	if (fd != NULL) 
	{

		while (!feof(fd)) 
		{
			crc = valide = 0;
			do {
				if (fgets(tampon, LINE, fd) != NULL) {
				sscanf(tampon, "%s", ligne);
				d_printf("%s\n",ligne);
				}
			} while (strcmp("Satellite:", ligne) && !(feof(fd)));

			crc = checksum(tampon);

			k = sscanf(tampon, "%*s %s %s %s", nom, buf1, buf2);
			if (k > 1)
				strcat(nom, " "), strncat(nom, buf1, 9);
			else if (k > 2)
				strcat(nom, " "), strncat(nom, buf2, 9);

			strncpy(sat.dd, nom, 17);
			sat.dd[17] = '\0';

			if (!feof(fd)) 
			{

				k = fscanf(fd, "%80s", ligne);
				if (strncmp("Catalog", ligne, 7) == 0 && !feof(fd))
					valide = 1;
				for (n = 0; n < 2; n++)
					k = fscanf(fd, "%80s", ligne);
				sat.cat = atol(ligne);	/* Catalog number */
				crc = checksum(ligne);

				for (n = 0; n < 2; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
					d_printf("%s\n",ligne);
					d_printf("\n*%s*",ligne);
				}
				
				k = fscanf(fd, "%2d", (int *)&sat.y3);
				d_printf("%s\n", ligne);
				/* itoa(sat.y3,ligne,10); */
				sprintf(ligne, "%2d", sat.y3);
				crc = checksum(ligne);
				d_printf("%d ", sat.y3);

				k = fscanf(fd, "%lf", &sat.d3);
				d_printf("%s\n",ligne);
				sprintf(ligne, "%3.8lf", sat.d3);
				crc = checksum(ligne);
				d_printf("%lf\n",sat.d3);

				/* Nouvelle ligne élire */
				for (n = 0; n < 2; n++) 
				{
					k = fscanf(fd, "%80s", ligne);	/* Element Set */
					d_printf("%s\n",ligne);
					d_printf("\n*%s*",ligne);
				}
				k = fscanf(fd, "%4d", (int *)&sat.set);	/* element number */
				sprintf(ligne, "%4d", sat.set);
				crc = checksum(ligne);
				d_printf("%4d\n",sat.set);

				k = fscanf(fd, "%80s", ligne);
				d_printf("*%s*",ligne);
				k = fscanf(fd, "%lf", &sat.i0); /* inclinaison */
				sprintf(ligne, "%3.8lf", sat.i0);
				d_printf("%lf\n",sat.i0);
				crc = checksum(ligne);

				for (n = 0; n < 4; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
					crc = checksum(ligne);
				}
				k = fscanf(fd, "%lf", &sat.o0); /* R.A.A.N. */
				sprintf(ligne, "%3.8lf", sat.o0);
				crc = checksum(ligne);

				for (n = 0; n < 2; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
					crc = checksum(ligne);
				}
				k = fscanf(fd, "%lf", &sat.e0); /* excentricite */
				sprintf(ligne, "%3.8lf", sat.e0);
				crc = checksum(ligne);

				for (n = 0; n < 3; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
				}
				k = fscanf(fd, "%lf", &sat.w0); /* arg. perigee */
				sprintf(ligne, "%3.8lf", sat.w0);
				crc = checksum(ligne);

				for (n = 0; n < 3; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
				}
				k = fscanf(fd, "%lf", &sat.m0); /* anomal. moyenne */
				sprintf(ligne, "%3.8lf", sat.m0);
				crc = checksum(ligne);

				sat.a0 = 0.0;	/* * contient 0.0 */

				for (n = 0; n < 3; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
					crc = checksum(ligne);
				}
				k = fscanf(fd, "%lf", &sat.n0); /* mouvement moyen */
				sprintf(ligne, "%3.8lf", sat.n0);
				crc = checksum(ligne);

				for (n = 0; n < 3; n++) 
				{
					k = fscanf(fd, "%80s", ligne);
					crc = checksum(ligne);
				}
				k = fscanf(fd, "%lf", &sat.q3); /* deriv. mouvem. moy. */
				sprintf(ligne, "%2.7e", sat.q3);
				crc = checksum(ligne);
				
				k = fscanf(fd, "%80s", ligne);	/* day ^2 */
				crc = checksum(ligne);
				
				k = fscanf(fd, "%80s", ligne);	/* Epoch */
				crc = checksum(ligne);

				if (strcmp("Epoch", ligne) != 0)
					valide = 0;
				k = fscanf(fd, "%80s", ligne);	/* rev: */
				crc = checksum(ligne);
				
				k = fscanf(fd, "%ld", &sat.k0); /* num. orbite referen. */
				sprintf(ligne, "%ld", sat.k0);
				crc = checksum(ligne);

				k = fscanf(fd, "%80s", ligne);
				/*
				 * while(strcmp("Checksum:",ligne) && !(feof(fd))) ;
				 */
				 
				k = fscanf(fd, "%d", &crc10);
				d_printf("CRC calcule:%d et lu:%d\n",crc,crc10);
				sat.f1 = 0.0;
				sat.v1 = 0.0;
				sat.pas = 5;

				time(&jour);
				sat.maj = jour;

				if ((sat.cat != 0) && (valide != 0)) 
				{
					if ((crc == crc10) && (fraicheur())) 
						printf("%3d : %-18s",  m + 1, sat.dd);
					else
						printf("      %-18s", sat.dd);
					
					if (fraicheur()) 
					{
						if (crc == crc10) 
						{
							CopyStru(nouveaux, m, &sat);
							m++;	/* incrémente le compteur de satellites mis à jour */
							printf(" ok\n");
							if (m > maxsat)
								break;;
						} 
						else
						{
#ifdef FRANCAIS
							printf(" erreur de CRC !\n");
#else
							printf(" bad CRC !\n");
#endif
						}
					} 
					else
					{
#ifdef FRANCAIS
						printf(" données trop anciennes !\n");
#else
						printf(" data too old !\n");
#endif		
					}
				}
			}		/* tant que pas fin de fichier */
		}			/* tant que pas fin de fichier */
	fclose(fd);
	}				/* si pas NULL	*/
	else
		m = -1;
/*return (m);*/
	good_crc = m;
}

void CopyStru(satel ** stru, int indice, satel * psat)
{
	*stru[indice] = *psat;
}

/*
 * élimination des doublons de satellites
 * en conservant les donnés les plus récentes
 * retourne le nombre de satellites
 */

int doublons(int nombre)
{
	int i, j, k;

#ifdef FRANCAIS
	printf("\nrecherche de doublons");
#else
	printf("\nlooking for duplicate");
#endif				/*
				 * FRANCAIS 
				 */

	for (i = 0; i < nombre - 1; i++) 
	{
		printf(".");
		for (j = i + 1; j < nombre; j++) 
		{
			if (nouveaux[i]->cat == nouveaux[j]->cat) 
			{
				if (((nouveaux[i]->y3 == nouveaux[j]->y3)
					 && (nouveaux[i]->d3 > nouveaux[j]->d3))
					|| (nouveaux[i]->y3 > nouveaux[j]->y3)) 
				{
					nouveaux[j]->libre[0] = -1;
				} 
				else 
				{
					nouveaux[i]->libre[0] = -1;
				}
			}
		}
	}

	k = 0;
	for (i = 0; i < nombre; i++) 
	{
		if (nouveaux[i]->libre[0] != -1) 
		{
			CopyStru(tampon, k, nouveaux[i]);
			k++;
		}
	}
	for (i = 0; i < k; i++) 
	{
		CopyStru(nouveaux, i, tampon[i]);
	}
	return (i);
}

/*
 * Ecrit_Sat.c 
 */

int Ecrit_Sat(char *filename, satel **stru, int nombre)
{
	int fd2;
	int indice, n;
	char *str;

	str = (char *) (malloc(30 * sizeof(char)));
	strtok(filename, ".");
	strcat(filename, ".dat");
	sprintf(str, "%s", filename);
	strcpy(filename, str);
	n = nombre;

	/*
	 * fd2 = open(filename,O_CREAT|O_RDWR|O_BINARY,S_IREAD|S_IWRITE); 
	 */
	fd2 = open(filename, O_CREAT | O_RDWR, S_IREAD | S_IWRITE | S_IEXEC);
	if (fd2 != -1) 
	{
		for (indice = 0; indice < nombre; indice++) 
		{
			if (stru[indice]->libre[0] != -1) 
			{
	/*			printf("sat:{%s}\n ", stru[indice]->dd);  */
				write(fd2, stru[indice], sizeof(satel));
			} 
			else
				n--;
		}
	close(fd2);
	}

	free(str);
	return (n);
}

/* LIRVIEUX.C
 * Relecture de la base de donné des parametres képlériens
 * avec suppression des donnés qui dépassent la date_limite
 */

int fd2;
int openfile(char *filename)
/*
 * Nom:			  openfile() Description :	Ouvre le fichier source.
 * Commentaire :  Les fichiers doivent être dans le réertoire FICHIERS 
 */
{
	char *str;

	str = (char *) (malloc(30 * sizeof(char)));
	strtok(filename, ".");
	strcat(filename, ".dat");
	sprintf(str, "%s", filename);
	strcpy(filename, str);
	/*
	 * fd2 = open(filename,O_BINARY); 
	 */
	fd2 = open(filename, O_RDWR, S_IREAD | S_IWRITE | S_IEXEC);

#ifdef FRANCAIS
	if (fd2 == -1)
		printf("fichier %s non trouvé - nouvelle banque créée !\n", filename);
	else
		printf("lecture fichier %s\n", filename);
#else
	if (fd2 == -1)
		printf("file %s not found - new data base created !\n", filename);
	else
		printf("reading file %s\n", filename);
#endif

	return (fd2);
}

int Lire_Ancien(char *filename)
{
	int n, m, lg;
	if ((n = openfile(filename)) != -1) 
	{
		m = 0;
		while (m < maxsat) 
		{
			lg = read(fd2, &sat, sizeof(sat));
			if (lg <= 0)
				break;

			if (fraicheur()) 
			{
				CopyStru(vieux, m, &sat);
				m++;
			}
		}
		if (m > maxsat)
			avorte();
		close(fd2);
		return (m);
	} 
	else
		return (n);
}

/*
 * MISAJOUR.C	version 28 Avril 1991
 * retourne le nombre de satellites dans la nouvelle liste
 * le compteur nsat est égal au nombre de satellites réactualisé
 * libère la mémoire tampon en sortie	
 */

int Misajour(satel ** vieux, int vv, satel ** nouv, int nn, char option)
{
	int i, j, nnn, vvv;
	long jour;	/* secondes depuis 1er Janv 1970 0 heures GMT */

	i = 0;
	nsat = 0;
	nnn = 0;
	vvv = 0;
	--nn;
	--vv;
	time(&jour);

	switch (option) 
	{
	/* Option de fusion anciennes & nouvelles données */
	case 'F':
		/* on compare anciennes et nouvelles données 
		 * en fonction du numéro de catalogue */
		while ((nnn <= nn) && (vvv <= vv)) 
		{
			if (nouv[nnn]->cat < vieux[vvv]->cat) 
			{
				CopyStru(tampon, i, nouv[nnn]);
				nnn++;
				nsat++;
			} 
			else if (nouv[nnn]->cat == vieux[vvv]->cat) 
			{
				/* Objet courant déja au catalogue */
				if (((nouv[nnn]->y3 == vieux[vvv]->y3)
						 && (nouv[nnn]->d3 > vieux[vvv]->d3))
						|| (nouv[nnn]->y3 > vieux[vvv]->y3)) 
				{
					CopyStru(tampon, i, nouv[nnn]);
					nouv[nnn]->maj = jour;
					memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
					memcpy(&tampon[i]->f1, &vieux[vvv]->f1, sizeof(sat.f1));
					memcpy(&tampon[i]->pas, &vieux[vvv]->pas, sizeof(sat.pas));
					nsat++;
				} 
				else 
				{
					CopyStru(tampon, i, vieux[vvv]);
				}
				nnn++;
				vvv++;
			} 
			else if (nouv[nnn]->cat > vieux[vvv]->cat) 
			{
				CopyStru(tampon, i, vieux[vvv]);
				vvv++;
			}
			i++;
		}

		if (nnn >= nn) 
		{
			while (vvv <= vv) 
			{
				CopyStru(tampon, i, vieux[vvv]);
				vvv++;
				i++;
			}
		}
		if (vvv >= vv) 
		{
			while (nnn <= nn) 
			{
				CopyStru(tampon, i, nouv[nnn]);
				nouv[nnn]->maj = jour;
				memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
				nnn++;
				i++;
				nsat++;
			}
		}

		break;

	case 'S':
		while ((nnn <= nn) && (vvv <= vv)) 
		{
			if (nouv[nnn]->cat < vieux[vvv]->cat) 
			{
				CopyStru(tampon, i, nouv[nnn]);
				nouv[nnn]->maj = jour;
				memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
				nnn++;
				i++;
				nsat++;
			} 
			else if (nouv[nnn]->cat == vieux[vvv]->cat) 
			{
				if (((nouv[nnn]->y3 == vieux[vvv]->y3)
						&& (nouv[nnn]->d3 > vieux[vvv]->d3))
						|| (nouv[nnn]->y3 > vieux[vvv]->y3)) 
				{
					CopyStru(tampon, i, nouv[nnn]);
					nouv[nnn]->maj = jour;
					memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
					/* On conserve la fréuence balise et le pas du calcul */
					memcpy(&tampon[i]->f1, &vieux[vvv]->f1, sizeof(sat.f1));
					memcpy(&tampon[i]->pas, &vieux[vvv]->pas, sizeof(sat.pas));
					nsat++;
				} 
				else 
				{
					CopyStru(tampon, i, vieux[vvv]);
				}
				nnn++;
				vvv++;
				i++;
			} 
			else if (nouv[nnn]->cat > vieux[vvv]->cat)
			{
				vvv++;
			}
		}

		if (vvv >= vv) 
		{
			while (nnn <= nn) 
			{
				CopyStru(tampon, i, nouv[nnn]);
				nouv[nnn]->maj = jour;
				memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
				nnn++;
				i++;
				nsat++;
			}
		}

		break;
		
	case 'U':
		/* mettre à jour seulement les données des satellites déja connus */
		while ((nnn <= nn) && (vvv <= vv)) 
		{
			if (nouv[nnn]->cat < vieux[vvv]->cat) 
			{
				nnn++;
			} 
			else if (nouv[nnn]->cat == vieux[vvv]->cat) 
			{
				if (((nouv[nnn]->y3 == vieux[vvv]->y3)
						 && (nouv[nnn]->d3 > vieux[vvv]->d3))
						|| (nouv[nnn]->y3 > vieux[vvv]->y3)) 
				{
					CopyStru(tampon, i, nouv[nnn]);
					nouv[nnn]->maj = jour;
					memcpy(&tampon[i]->maj, &nouv[nnn]->maj, sizeof(sat.maj));
					memcpy(&tampon[i]->f1, &vieux[vvv]->f1, sizeof(sat.f1));
					memcpy(&tampon[i]->pas, &vieux[vvv]->pas, sizeof(sat.pas));
					nsat++;
				} 
				else 
				{
					CopyStru(tampon, i, vieux[vvv]);
				}
				nnn++;
				vvv++;
				i++;
			} 
			else if (nouv[nnn]->cat > vieux[vvv]->cat) 
			{
				CopyStru(tampon, i, vieux[vvv]);
				vvv++;
				i++;
			}
		}

		if (nnn >= nn) 
		{
			while (vvv <= vv) 
			{
				CopyStru(tampon, i, vieux[vvv]);
				vvv++;
				i++;
			}
		}

		break;
	}

	for (j = 0; j < i; j++)
		CopyStru(nouv, j, tampon[j]);

	return i;

}

/********************************
 *	NASA.C			*
 *				*
 * Version 1.6 du 23/10/94
 * retourne -1 si fichier non trouvé
 *				*
 *	avec CRC10		*
 ********************************/

int crcdix(char *ligne);

int fraicheur()
{
	double anciennete;	/* ancienneté des prévisions en nombre de jours */
	double jours;		/* différence de jours */
	int annees;			/* nombre d'annés */

	jours = (double) cejour->tm_yday - sat.d3;
	annees = (cejour->tm_year - sat.y3) % 100;	/* nombre d'années */
		
	
	if (annees == 0) 
	{
		anciennete = jours;
		d_printf(" %d jours d'ancienneté ",(int)(jours + 0.5));
	} 
	else 
	{
/* jours éoulé */
		anciennete = (365.0 - sat.d3) + (double) (annees - 1) * 365.0 + (double) cejour->tm_yday;
		d_printf(" = %02d années écoulées; %d jours d'ancienneté",annees,(int)(anciennete+0.5));
	}
	if (anciennete < date_limite)
		return 1;
	else
		return 0;
}

char *epure(char *ligne)
{
	int len = strlen(ligne);
	char *ptr;
	
	while (len > 0)
	{
		ptr = ligne + len - 1;
		if (isgraph(*ptr))
			break;
		*ptr = '\0';
		--len;
	}
	
	return ligne;
}

void nasa(char *filename)
{
	int i, m, r;			/* m = number of sat entries - r number of rejected entries */
	int twolinemodel;		/* 2Line model */
	int ligne1valide, ligne2valide; /* enregistrement valide 1 sinon 0 */
	char *ligne;			/* tampon pour lire ligne du fichier */
	long jour;			/* secondes depuis 1er Janv 1970 0 heures GMT  */
	double i0;			/* Inclinaison */
	double o0;			/* R.A.A.N. */
	double e0;			/* Excentricite */
	double w0;			/* Argument de perigee */
	double m0;			/* Anomalie moyenne */
	double n0;			/* Mouvement moyen */
	long k0;			/* Orbite de reference */
	int set;			/* Element Number */
	long catalog, cat;		/* Catalog Number - anciennement vide */
	int y3;				/* Annee de reference */
	double d3;			/* Jour de reference */
	double q3;			/* Derivee du mouv. moy. */
	char caract[13];
	char *pointe, *pointeur;
	satel *satp;
	FILE *fd;

	satp = &sat;

	ligne = (char *) (malloc(82 * sizeof(char)));
	if (ligne == NULL)
		avorte();

	m = r = 0;

	fd = fopen(filename, "rt");

	if (fd != NULL) 
	{

		while (!feof(fd)) 
		{

			twolinemodel = FALSE;
			ligne1valide = TRUE;
			ligne2valide = TRUE;
			catalog = -1;
			strcpy(ligne, " ");
			pointe = strchr(ligne, '1');
			pointeur = strchr(ligne, 'U');

			while ((pointe - ligne != 0) || (pointeur - ligne != 7)) 
			{
				strncpy(sat.dd, ligne, 17);
				sat.dd[17] = '\0';
				if (strncmp (sat.dd, "DECODE 2-LINE", 13) == 0)
					twolinemodel = TRUE;
				if (fgets(ligne, LINE, fd) == NULL) 
					break;
				epure(ligne);
				pointe = strchr(ligne, '1');
				pointeur = strchr(ligne, 'U');
			}

			if (feof(fd))
				break;
				
				ligne1valide = crcdix(ligne);

			if (!feof(fd)) 
			{
				caract[5] = '\0';
				for (i = 2; i < 7; i++)
					caract[i - 2] = ligne[i];
				cat = atol(caract); /* numéro catalogue */

				caract[2] = '\0';
				caract[0] = ligne[18];
				caract[1] = ligne[19];
				y3 = atoi(caract);	/* année */

				caract[12] = '\0';
				for (i = 20; i < 32; i++)
					caract[i - 20] = ligne[i];
				d3 = atof(caract);	/* jour julien */

				caract[10] = '\0';
				for (i = 33; i < 43; i++)
					caract[i - 33] = ligne[i];
				q3 = atof(caract);	/* 1ère dérivée mouvement moyen */

				caract[4] = '\0';
				for (i = 64; i < 68; i++)
					caract[i - 64] = ligne[i];
				set = atoi(caract); /* Element Set */

				sat.set = set;	/* Element Number */
				sat.cat = cat;	/* numéro catalogue */
				sat.y3 = y3;	/* année  */
				sat.d3 = d3;	/* jour julien */
				sat.q3 = q3;	/* 1ère dérivée mouvement moyen */


				if (fgets(ligne, LINE, fd) != NULL)
				
				ligne2valide = crcdix(ligne);

				epure(ligne);

				if (ligne[0] != '2')
					ligne2valide = 0;	/* deuxième ligne */
				caract[5] = '\0';
				for (i = 2; i < 7; i++)
					caract[i - 2] = ligne[i];
				catalog = atol(caract); /* numéro catalogue */
				if (catalog != cat)
					ligne1valide = 0;
				caract[8] = '\0';
				for (i = 8; i < 16; i++)
					caract[i - 8] = ligne[i];
				i0 = atof(caract);	/* inclinaison */
				caract[8] = '\0';
				for (i = 17; i < 25; i++)
					caract[i - 17] = ligne[i];
				o0 = atof(caract);	/* R.A.A.N. */
				caract[7] = '\0';
				for (i = 26; i < 33; i++)
					caract[i - 26] = ligne[i];
				e0 = atof(caract);	/* excentricité*/
				e0 /= 10e+06;
				caract[8] = '\0';
				for (i = 34; i < 42; i++)
					caract[i - 34] = ligne[i];
				w0 = atof(caract);	/* arg. périgé */
				caract[8] = '\0';
				for (i = 43; i < 51; i++)
					caract[i - 43] = ligne[i];
				m0 = atof(caract);	/* anomal. moyenne */
				caract[11] = '\0';
				for (i = 52; i < 63; i++)
					caract[i - 52] = ligne[i];
				n0 = atof(caract);	/* mouvement moyen */
				caract[5] = '\0';
				for (i = 63; i < 68; i++)
					caract[i - 63] = ligne[i];
				k0 = atol(caract);	/* numéro orbite */

				sat.i0 = i0;	/* inclinaison */
				sat.o0 = o0;	/* R.A.A.N. */
				sat.e0 = e0;	/* excentricité*/
				sat.w0 = w0;	/* arg. périgé */
				sat.m0 = m0;	/* anomal. moyenne */
				sat.n0 = n0;	/* mouvement moyen */
				sat.k0 = k0;	/* numéro orbite */

				sat.a0 = 0.0;	/* contient 0.0 */
				sat.f1 = 0.0;
				sat.v1 = 0.0;

				sat.pas = 5;
				time(&jour);
				sat.maj = jour;

				if (twolinemodel == FALSE) 
				{
					if ((ligne1valide == -1) || (ligne2valide == -1) || !fraicheur()) 
						printf("      %-18s", sat.dd);
					else
						printf("%3d : %-18s", m + 1, sat.dd);
					if (ligne1valide == TRUE && ligne2valide == TRUE) 
					{
						if (fraicheur()) 
						{
							CopyStru(nouveaux, m, satp);
							m++;	/* incrémente le compteur de satellites mis à jour */
							printf(" ok\n");
							if (m > maxsat)
								break;
						}
						else
						{
#ifdef FRANCAIS
							printf(" données trop anciennes !\n");
#else
							printf(" data too old !\n");
#endif			
						}
					}
					else
					{
						r++;
#ifdef FRANCAIS
						printf(" erreur de CRC !\n");
#else
						printf(" CRC error !\n");
#endif

					}
				}
			ligne1valide = TRUE;
			ligne2valide = TRUE;
			}		/* tant que pas fin de fichier */
		}			/* tant que pas fin de fichier */
    fclose(fd);
	} 
	else
		m = -1;			/* si nul=fichier non trouvé*/
	free(ligne);
	good_crc = m;
	bad_crc = r;
}

/* tri a bulle des noms de satellites  */
void Tri(satel ** stru, int nombre)
{				
	int i, j;
	satel *tampon;		/* tampon pour comparaison */

#ifdef FRANCAIS
	printf("\ntri alphabétique");
#else
	printf("\nsorting by name");
#endif

	/* on trie les pointeurs */
	for (i = 0; i < nombre - 1; i++) 
	{
		printf(".");
		for (j = i + 1; j < nombre; j++) 
		{
			if (strcmp(stru[i]->dd, stru[j]->dd) > 0) 
			{
				tampon = stru[i];
				stru[i] = stru[j];
				stru[j] = tampon;
			}
		}
	}
}


/* tri à bulle des numéros de catalogue de satellites */
void Tri_Cat(satel ** stru, int nombre)
{
	int i, j;
	satel *tampon;		/* tampon pour comparaison	*/

#ifdef FRANCAIS
	printf("\ntri par numéro de catalogue");
#else
	printf("\nsorting by catalog number");
#endif 

	/* on trie les pointeurs */
	for (i = 0; i < nombre - 1; i++) 
	{
		printf(".");
		for (j = i + 1; j < nombre; j++) 
		{
			if (stru[i]->cat > stru[j]->cat) 
			{
				tampon = stru[i];
				stru[i] = stru[j];
				stru[j] = tampon;
			}
		}
	}
}