1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.30
4: Copyright (C) 1989-2019 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #include "rpl-conv.h"
24:
25:
26: /*
27: ================================================================================
28: Fonction 'restart'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_restart(struct_processus *s_etat_processus)
40: {
41: struct timespec attente;
42:
43: (*s_etat_processus).erreur_execution = d_ex;
44:
45: if ((*s_etat_processus).affichage_arguments == 'Y')
46: {
47: printf("\n RESTART ");
48:
49: if ((*s_etat_processus).langue == 'F')
50: {
51: printf("(réinitialisation du programme)\n\n");
52: printf(" Aucun argument\n");
53: }
54: else
55: {
56: printf("(program reinitialization)\n\n");
57: printf(" No argument\n");
58: }
59:
60: return;
61: }
62: else if ((*s_etat_processus).test_instruction == 'Y')
63: {
64: (*s_etat_processus).nombre_arguments = -1;
65: return;
66: }
67:
68: if (test_cfsf(s_etat_processus, 31) == d_vrai)
69: {
70: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
71: {
72: return;
73: }
74: }
75:
76: envoi_signal_processus((*s_etat_processus).pid_processus_pere,
77: rpl_sigabort, d_faux);
78: (*s_etat_processus).requete_arret = 'Y';
79:
80: attente.tv_sec = 0;
81: attente.tv_nsec = GRANULARITE_us * 1000;
82:
83: while((*s_etat_processus).var_volatile_requete_arret == 0)
84: {
85: scrutation_interruptions(s_etat_processus);
86: nanosleep(&attente, NULL);
87: INCR_GRANULARITE(attente.tv_nsec);
88: }
89:
90: if ((*s_etat_processus).traitement_instruction_halt == d_vrai)
91: {
92: (*s_etat_processus).execution_pas_suivant = d_vrai;
93: }
94:
95: (*s_etat_processus).requete_redemarrage = d_vrai;
96: return;
97: }
98:
99:
100: /*
101: ================================================================================
102: Fonction 'regex'
103: ================================================================================
104: Entrées : pointeur sur une structure struct_processus
105: --------------------------------------------------------------------------------
106: Sorties :
107: --------------------------------------------------------------------------------
108: Effets de bord : néant
109: ================================================================================
110: */
111:
112: void
113: instruction_regex(struct_processus *s_etat_processus)
114: {
115: integer8 longueur;
116:
117: regex_t expression;
118:
119: struct_liste_chainee *l_element_courant_ecriture;
120: struct_liste_chainee *l_element_courant_lecture;
121:
122: struct_objet *s_objet_argument_1;
123: struct_objet *s_objet_argument_2;
124: struct_objet *s_objet_resultat;
125:
126: unsigned char *exp;
127:
128: (*s_etat_processus).erreur_execution = d_ex;
129:
130: if ((*s_etat_processus).affichage_arguments == 'Y')
131: {
132: printf("\n REGEX ");
133:
134: if ((*s_etat_processus).langue == 'F')
135: {
136: printf("(expression régulière)\n\n");
137: }
138: else
139: {
140: printf("(regular expression)\n\n");
141: }
142:
143: printf(" 2: %s\n", d_LST);
144: printf(" 1: %s\n", d_CHN);
145: printf("-> 1: %s\n\n", d_LST);
146:
147: printf(" 2: %s\n", d_CHN);
148: printf(" 1: %s\n", d_CHN);
149: printf("-> 1: %s (0 or -1)\n", d_INT);
150:
151: return;
152: }
153: else if ((*s_etat_processus).test_instruction == 'Y')
154: {
155: (*s_etat_processus).nombre_arguments = -1;
156: return;
157: }
158:
159: if (test_cfsf(s_etat_processus, 31) == d_vrai)
160: {
161: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
162: {
163: return;
164: }
165: }
166:
167: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
168: &s_objet_argument_1) == d_erreur)
169: {
170: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
171: return;
172: }
173:
174: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
175: &s_objet_argument_2) == d_erreur)
176: {
177: liberation(s_etat_processus, s_objet_argument_1);
178:
179: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
180: return;
181: }
182:
183: if (((*s_objet_argument_1).type == CHN) &&
184: ((*s_objet_argument_2).type == CHN))
185: {
186: // Renvoie 0 ou -1
187:
188: if ((exp = formateur_flux(s_etat_processus, (*s_objet_argument_1).objet,
189: &longueur)) == NULL)
190: {
191: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
192: return;
193: }
194:
195: if (regcomp(&expression, (const char *) exp,
196: REG_EXTENDED | REG_NOSUB) != 0)
197: {
198: liberation(s_etat_processus, s_objet_argument_1);
199: liberation(s_etat_processus, s_objet_argument_2);
200:
201: (*s_etat_processus).erreur_execution = d_ex_expression_reguliere;
202: return;
203: }
204:
205: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
206: {
207: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
208: return;
209: }
210:
211: if (regexec(&expression, (const char *) (*s_objet_argument_2).objet,
212: 0, NULL, 0) == 0)
213: {
214: (*((integer8 *) (*s_objet_resultat).objet)) = -1;
215: }
216: else // REG_NOMATCH
217: {
218: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
219: }
220:
221: regfree(&expression);
222: free(exp);
223: }
224: else if (((*s_objet_argument_1).type == CHN) &&
225: ((*s_objet_argument_2).type == LST))
226: {
227: // Renvoie une liste de chaînes qui correspondent
228:
229: if ((exp = formateur_flux(s_etat_processus, (*s_objet_argument_1).objet,
230: &longueur)) == NULL)
231: {
232: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
233: return;
234: }
235:
236: if (regcomp(&expression, (const char *) exp,
237: REG_EXTENDED | REG_NOSUB) != 0)
238: {
239: liberation(s_etat_processus, s_objet_argument_1);
240: liberation(s_etat_processus, s_objet_argument_2);
241:
242: (*s_etat_processus).erreur_execution = d_ex_expression_reguliere;
243: return;
244: }
245:
246: if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL)
247: {
248: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
249: return;
250: }
251:
252: l_element_courant_lecture = (*s_objet_argument_2).objet;
253: l_element_courant_ecriture = NULL;
254:
255: while(l_element_courant_lecture != NULL)
256: {
257: if ((*(*l_element_courant_lecture).donnee).type != CHN)
258: {
259: regfree(&expression);
260: liberation(s_etat_processus, s_objet_argument_1);
261: liberation(s_etat_processus, s_objet_argument_2);
262: liberation(s_etat_processus, s_objet_resultat);
263:
264: (*s_etat_processus).erreur_execution =
265: d_ex_erreur_type_argument;
266: return;
267: }
268:
269: if (regexec(&expression, (const char *)
270: (*(*l_element_courant_lecture).donnee).objet,
271: 0, NULL, 0) == 0)
272: {
273: if (l_element_courant_ecriture == NULL)
274: {
275: if (((*s_objet_resultat).objet =
276: allocation_maillon(s_etat_processus)) == NULL)
277: {
278: (*s_etat_processus).erreur_systeme =
279: d_es_allocation_memoire;
280: return;
281: }
282:
283: l_element_courant_ecriture = (*s_objet_resultat).objet;
284:
285: if (((*l_element_courant_ecriture).donnee =
286: copie_objet(s_etat_processus,
287: (*l_element_courant_lecture).donnee, 'P'))
288: == NULL)
289: {
290: (*s_etat_processus).erreur_systeme =
291: d_es_allocation_memoire;
292: return;
293: }
294:
295: (*l_element_courant_ecriture).suivant = NULL;
296: }
297: else
298: {
299: if (((*l_element_courant_ecriture).suivant =
300: allocation_maillon(s_etat_processus)) == NULL)
301: {
302: (*s_etat_processus).erreur_systeme =
303: d_es_allocation_memoire;
304: return;
305: }
306:
307: l_element_courant_ecriture =
308: (*l_element_courant_ecriture).suivant;
309:
310: if (((*l_element_courant_ecriture).donnee =
311: copie_objet(s_etat_processus,
312: (*l_element_courant_lecture).donnee, 'P'))
313: == NULL)
314: {
315: (*s_etat_processus).erreur_systeme =
316: d_es_allocation_memoire;
317: return;
318: }
319:
320: (*l_element_courant_ecriture).suivant = NULL;
321: }
322: }
323:
324: l_element_courant_lecture = (*l_element_courant_lecture).suivant;
325: }
326:
327: regfree(&expression);
328: free(exp);
329: }
330: else
331: {
332: liberation(s_etat_processus, s_objet_argument_1);
333: liberation(s_etat_processus, s_objet_argument_2);
334:
335: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
336: return;
337: }
338:
339: liberation(s_etat_processus, s_objet_argument_1);
340: liberation(s_etat_processus, s_objet_argument_2);
341:
342: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
343: s_objet_resultat) == d_erreur)
344: {
345: return;
346: }
347:
348: return;
349: }
350:
351:
352: /*
353: ================================================================================
354: Fonction 'rgdl'
355: ================================================================================
356: Entrées : pointeur sur une structure struct_processus
357: --------------------------------------------------------------------------------
358: Sorties :
359: --------------------------------------------------------------------------------
360: Effets de bord : néant
361: ================================================================================
362: */
363:
364: void
365: instruction_rgdl(struct_processus *s_etat_processus)
366: {
367: integer8 i;
368: integer8 l;
369:
370: struct_objet *s_objet_argument_1;
371: struct_objet *s_objet_argument_2;
372: struct_objet *s_objet_argument_3;
373: struct_objet *s_objet_resultat;
374:
375: unsigned char *ptr_e;
376: unsigned char *ptr_l;
377:
378: (*s_etat_processus).erreur_execution = d_ex;
379:
380: if ((*s_etat_processus).affichage_arguments == 'Y')
381: {
382: printf("\n RGDL ");
383:
384: if ((*s_etat_processus).langue == 'F')
385: {
386: printf("(fer à droite)\n\n");
387: }
388: else
389: {
390: printf("(ragged left)\n\n");
391: }
392:
393: printf(" 3: %s\n", d_CHN);
394: printf(" 2: %s\n", d_INT);
395: printf(" 1: %s\n", d_CHN);
396: printf("-> 1: %s\n", d_CHN);
397:
398: return;
399: }
400: else if ((*s_etat_processus).test_instruction == 'Y')
401: {
402: (*s_etat_processus).nombre_arguments = -1;
403: return;
404: }
405:
406: if (test_cfsf(s_etat_processus, 31) == d_vrai)
407: {
408: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
409: {
410: return;
411: }
412: }
413:
414: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
415: &s_objet_argument_1) == d_erreur)
416: {
417: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
418: return;
419: }
420:
421: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
422: &s_objet_argument_2) == d_erreur)
423: {
424: liberation(s_etat_processus, s_objet_argument_1);
425:
426: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
427: return;
428: }
429:
430: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
431: &s_objet_argument_3) == d_erreur)
432: {
433: liberation(s_etat_processus, s_objet_argument_1);
434: liberation(s_etat_processus, s_objet_argument_2);
435:
436: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
437: return;
438: }
439:
440: if (((*s_objet_argument_1).type == CHN) &&
441: ((*s_objet_argument_2).type == INT) &&
442: ((*s_objet_argument_3).type == CHN))
443: {
444: if ((strlen((unsigned char *) (*s_objet_argument_1).objet) != 1) ||
445: ((*((integer8 *) (*s_objet_argument_2).objet)) < 0))
446: {
447: liberation(s_etat_processus, s_objet_argument_1);
448: liberation(s_etat_processus, s_objet_argument_2);
449: liberation(s_etat_processus, s_objet_argument_3);
450:
451: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
452: return;
453: }
454:
455: if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL)
456: {
457: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
458: return;
459: }
460:
461: if (((*s_objet_resultat).objet = malloc(((size_t) ((*((integer8 *)
462: (*s_objet_argument_2).objet)) + 1)) * sizeof(unsigned char)))
463: == NULL)
464: {
465: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
466: return;
467: }
468:
469: if (((l = (integer8) strlen((unsigned char *) (*s_objet_argument_3)
470: .objet))) >= (*((integer8 *) (*s_objet_argument_2).objet)))
471: {
472: // Recadrage simple
473:
474: ptr_e = (unsigned char *) (*s_objet_resultat).objet;
475: ptr_l = ((unsigned char *) (*s_objet_argument_3).objet)
476: + (l - (*((integer8 *) (*s_objet_argument_2).objet)));
477:
478: while((*ptr_l) != d_code_fin_chaine)
479: {
480: *ptr_e++ = *ptr_l++;
481: }
482:
483: (*ptr_e) = d_code_fin_chaine;
484: }
485: else
486: {
487: // Ajout des caractères
488:
489: ptr_e = (unsigned char *) (*s_objet_resultat).objet;
490: ptr_l = (unsigned char *) (*s_objet_argument_3).objet;
491:
492: for(i = 0; i < (*((integer8 *) (*s_objet_argument_2).objet)) - l;
493: i++)
494: {
495: *ptr_e++ = ((unsigned char *) (*s_objet_argument_1).objet)[0];
496: }
497:
498: while((*ptr_l) != d_code_fin_chaine)
499: {
500: *ptr_e++ = *ptr_l++;
501: }
502:
503: (*ptr_e) = d_code_fin_chaine;
504: }
505: }
506: else
507: {
508: liberation(s_etat_processus, s_objet_argument_1);
509: liberation(s_etat_processus, s_objet_argument_2);
510: liberation(s_etat_processus, s_objet_argument_3);
511:
512: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
513: return;
514: }
515:
516: liberation(s_etat_processus, s_objet_argument_1);
517: liberation(s_etat_processus, s_objet_argument_2);
518: liberation(s_etat_processus, s_objet_argument_3);
519:
520: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
521: s_objet_resultat) == d_erreur)
522: {
523: return;
524: }
525:
526: return;
527: }
528:
529:
530: /*
531: ================================================================================
532: Fonction 'rgdr'
533: ================================================================================
534: Entrées : pointeur sur une structure struct_processus
535: --------------------------------------------------------------------------------
536: Sorties :
537: --------------------------------------------------------------------------------
538: Effets de bord : néant
539: ================================================================================
540: */
541:
542: void
543: instruction_rgdr(struct_processus *s_etat_processus)
544: {
545: integer8 i;
546: integer8 l;
547:
548: struct_objet *s_objet_argument_1;
549: struct_objet *s_objet_argument_2;
550: struct_objet *s_objet_argument_3;
551: struct_objet *s_objet_resultat;
552:
553: unsigned char *ptr_e;
554: unsigned char *ptr_l;
555:
556: (*s_etat_processus).erreur_execution = d_ex;
557:
558: if ((*s_etat_processus).affichage_arguments == 'Y')
559: {
560: printf("\n RGDR ");
561:
562: if ((*s_etat_processus).langue == 'F')
563: {
564: printf("(fer à gauche)\n\n");
565: }
566: else
567: {
568: printf("(ragged right)\n\n");
569: }
570:
571: printf(" 3: %s\n", d_CHN);
572: printf(" 2: %s\n", d_INT);
573: printf(" 1: %s\n", d_CHN);
574: printf("-> 1: %s\n", d_CHN);
575:
576: return;
577: }
578: else if ((*s_etat_processus).test_instruction == 'Y')
579: {
580: (*s_etat_processus).nombre_arguments = -1;
581: return;
582: }
583:
584: if (test_cfsf(s_etat_processus, 31) == d_vrai)
585: {
586: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
587: {
588: return;
589: }
590: }
591:
592: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
593: &s_objet_argument_1) == d_erreur)
594: {
595: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
596: return;
597: }
598:
599: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
600: &s_objet_argument_2) == d_erreur)
601: {
602: liberation(s_etat_processus, s_objet_argument_1);
603:
604: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
605: return;
606: }
607:
608: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
609: &s_objet_argument_3) == d_erreur)
610: {
611: liberation(s_etat_processus, s_objet_argument_1);
612: liberation(s_etat_processus, s_objet_argument_2);
613:
614: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
615: return;
616: }
617:
618: if (((*s_objet_argument_1).type == CHN) &&
619: ((*s_objet_argument_2).type == INT) &&
620: ((*s_objet_argument_3).type == CHN))
621: {
622: if ((strlen((unsigned char *) (*s_objet_argument_1).objet) != 1) ||
623: ((*((integer8 *) (*s_objet_argument_2).objet)) < 0))
624: {
625: liberation(s_etat_processus, s_objet_argument_1);
626: liberation(s_etat_processus, s_objet_argument_2);
627: liberation(s_etat_processus, s_objet_argument_3);
628:
629: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
630: return;
631: }
632:
633: if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL)
634: {
635: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
636: return;
637: }
638:
639: if (((*s_objet_resultat).objet = malloc(((size_t) ((*((integer8 *)
640: (*s_objet_argument_2).objet)) + 1)) * sizeof(unsigned char)))
641: == NULL)
642: {
643: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
644: return;
645: }
646:
647: if (((l = (integer8) strlen((unsigned char *) (*s_objet_argument_3)
648: .objet))) >= (*((integer8 *) (*s_objet_argument_2).objet)))
649: {
650: // Recadrage simple
651:
652: ptr_e = (unsigned char *) (*s_objet_resultat).objet;
653: ptr_l = ((unsigned char *) (*s_objet_argument_3).objet);
654:
655: for(i = 0; i < (*((integer8 *) (*s_objet_argument_2).objet)); i++)
656: {
657: *ptr_e++ = *ptr_l++;
658: }
659:
660: (*ptr_e) = d_code_fin_chaine;
661: }
662: else
663: {
664: // Ajout des caractères
665:
666: ptr_e = (unsigned char *) (*s_objet_resultat).objet;
667: ptr_l = (unsigned char *) (*s_objet_argument_3).objet;
668:
669: while((*ptr_l) != d_code_fin_chaine)
670: {
671: *ptr_e++ = *ptr_l++;
672: }
673:
674: for(i = 0; i < (*((integer8 *) (*s_objet_argument_2).objet)) - l;
675: i++)
676: {
677: *ptr_e++ = ((unsigned char *) (*s_objet_argument_1).objet)[0];
678: }
679:
680: (*ptr_e) = d_code_fin_chaine;
681: }
682: }
683: else
684: {
685: liberation(s_etat_processus, s_objet_argument_1);
686: liberation(s_etat_processus, s_objet_argument_2);
687: liberation(s_etat_processus, s_objet_argument_3);
688:
689: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
690: return;
691: }
692:
693: liberation(s_etat_processus, s_objet_argument_1);
694: liberation(s_etat_processus, s_objet_argument_2);
695: liberation(s_etat_processus, s_objet_argument_3);
696:
697: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
698: s_objet_resultat) == d_erreur)
699: {
700: return;
701: }
702:
703: return;
704: }
705:
706:
707: /*
708: ================================================================================
709: Fonction 'record'
710: ================================================================================
711: Entrées : pointeur sur une structure struct_processus
712: --------------------------------------------------------------------------------
713: Sorties :
714: --------------------------------------------------------------------------------
715: Effets de bord : néant
716: ================================================================================
717: */
718:
719: static int
720: fonction_comparaison(const void *argument_1, const void *argument_2)
721: {
722: return(strcmp((unsigned char *) (**((struct_objet **) argument_1)).objet,
723: (unsigned char *) (**((struct_objet **) argument_2)).objet));
724: }
725:
726:
727: void
728: instruction_record(struct_processus *s_etat_processus)
729: {
730: integer8 i;
731:
732: struct_objet *s_objet_argument_1;
733: struct_objet *s_objet_argument_2;
734: struct_objet *s_objet_resultat;
735:
736: (*s_etat_processus).erreur_execution = d_ex;
737:
738: if ((*s_etat_processus).affichage_arguments == 'Y')
739: {
740: printf("\n RECORD ");
741:
742: if ((*s_etat_processus).langue == 'F')
743: {
744: printf("(création d'un enregistrement)\n\n");
745: }
746: else
747: {
748: printf("(create record)\n\n");
749: }
750:
751: printf(" 1: %s\n", d_TAB);
752: printf("-> 1: %s\n", d_REC);
753:
754: return;
755: }
756: else if ((*s_etat_processus).test_instruction == 'Y')
757: {
758: (*s_etat_processus).nombre_arguments = -1;
759: return;
760: }
761:
762: if (test_cfsf(s_etat_processus, 31) == d_vrai)
763: {
764: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
765: {
766: return;
767: }
768: }
769:
770: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
771: &s_objet_argument_1) == d_erreur)
772: {
773: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
774: return;
775: }
776:
777: if ((*s_objet_argument_1).type == TBL)
778: {
779: // Vérification des noms
780:
781: if ((*((struct_tableau *) (*s_objet_argument_1).objet)).nombre_elements
782: == 0)
783: {
784: (*s_etat_processus).erreur_execution = d_ex_nombre_arguments;
785: liberation(s_etat_processus, s_objet_argument_1);
786: return;
787: }
788:
789: for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_1).objet))
790: .nombre_elements; i++)
791: {
792: if ((*(*((struct_tableau *) (*s_objet_argument_1).objet))
793: .elements[i]).type != CHN)
794: {
795: (*s_etat_processus).erreur_execution =
796: d_ex_erreur_type_argument;
797:
798: liberation(s_etat_processus, s_objet_argument_1);
799: return;
800: }
801: }
802:
803: // Tri de la table des noms
804:
805: qsort((*((struct_tableau *) (*s_objet_argument_1).objet)).elements,
806: (size_t) (*((struct_tableau *) (*s_objet_argument_1).objet))
807: .nombre_elements, sizeof(struct_objet *),
808: fonction_comparaison);
809:
810: // Vérification de l'unicité des noms
811:
812: for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_1).objet))
813: .nombre_elements - 1; i++)
814: {
815: if (strcmp((unsigned char *) (*(*((struct_tableau *)
816: (*s_objet_argument_1).objet)).elements[i]).objet,
817: (unsigned char *) (*(*((struct_tableau *)
818: (*s_objet_argument_1).objet)).elements[i + 1]).objet)
819: == 0)
820: {
821: (*s_etat_processus).erreur_execution =
822: d_ex_argument_invalide;
823:
824: liberation(s_etat_processus, s_objet_argument_1);
825: return;
826: }
827: }
828:
829: // Allocation de la table des données
830:
831: if ((s_objet_argument_2 = allocation(s_etat_processus, TBL)) == NULL)
832: {
833: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
834: return;
835: }
836:
837: (*((struct_tableau *) (*s_objet_argument_2).objet)).nombre_elements =
838: (*((struct_tableau *) (*s_objet_argument_1).objet))
839: .nombre_elements;
840:
841: if (((*((struct_tableau *) (*s_objet_argument_2).objet)).elements =
842: malloc(((size_t) (*((struct_tableau *)
843: (*s_objet_argument_2).objet)).nombre_elements) *
844: sizeof(struct_objet *))) == NULL)
845: {
846: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
847: return;
848: }
849:
850: for(i = 0; i < (*((struct_tableau *) (*s_objet_argument_2).objet))
851: .nombre_elements; i++)
852:
853: {
854: if (((*((struct_tableau *) (*s_objet_argument_2).objet)).elements[i]
855: = allocation(s_etat_processus, LST)) == NULL)
856: {
857: return;
858: }
859: }
860:
861: if ((s_objet_resultat = allocation(s_etat_processus, REC)) == NULL)
862: {
863: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
864: return;
865: }
866:
867: (*((struct_record *) (*s_objet_resultat).objet)).noms =
868: s_objet_argument_1;
869: (*((struct_record *) (*s_objet_resultat).objet)).donnees =
870: s_objet_argument_2;
871: }
872: else
873: {
874: liberation(s_etat_processus, s_objet_argument_1);
875:
876: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
877: return;
878: }
879:
880: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
881: s_objet_resultat) == d_erreur)
882: {
883: return;
884: }
885:
886: return;
887: }
888:
889: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>