1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.3
4: Copyright (C) 1989-2011 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 'clusr'
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_clusr(struct_processus *s_etat_processus)
40: {
41: struct_liste_variables *l_element_courant;
42:
43: (*s_etat_processus).erreur_execution = d_ex;
44:
45: if ((*s_etat_processus).affichage_arguments == 'Y')
46: {
47: printf("\n CLUSR ");
48:
49: if ((*s_etat_processus).langue == 'F')
50: {
51: printf("(effacement des variables)\n\n");
52: printf(" Aucun argument\n");
53: }
54: else
55: {
56: printf("(clear variables)\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: l_element_courant = (*s_etat_processus).l_liste_variables_par_niveau;
77:
78: if (l_element_courant == NULL)
79: {
80: return;
81: }
82:
83: do
84: {
85: if ((*l_element_courant).liste != NULL)
86: {
87: if ((*(*l_element_courant).liste).donnee != NULL)
88: {
89: if ((*((struct_variable *) (*(*l_element_courant).liste)
90: .donnee)).niveau == 1)
91: {
92: while((*l_element_courant).liste != NULL)
93: {
94: if (retrait_variable(s_etat_processus,
95: (*((struct_variable *) (*(*l_element_courant)
96: .liste).donnee)).nom, 'G') == d_erreur)
97: {
98: return;
99: }
100:
101: if ((*s_etat_processus).niveau_supprime == d_vrai)
102: {
103: // La dernière variable de niveau 1 a été
104: // supprimée. On sort donc de la boucle car
105: // (*l_element_courant).liste pointe sur
106: // un pointeur libérée par retrait_variable().
107:
108: break;
109: }
110: }
111:
112: break;
113: }
114: }
115: }
116:
117: l_element_courant = (*l_element_courant).precedent;
118: } while(l_element_courant != (*s_etat_processus)
119: .l_liste_variables_par_niveau);
120:
121: return;
122: }
123:
124:
125: /*
126: ================================================================================
127: Fonction 'col->'
128: ================================================================================
129: Entrées :
130: --------------------------------------------------------------------------------
131: Sorties :
132: --------------------------------------------------------------------------------
133: Effets de bord : néant
134: ================================================================================
135: */
136:
137: void
138: instruction_col_fleche(struct_processus *s_etat_processus)
139: {
140: struct_objet *s_objet;
141: struct_objet *s_objet_elementaire;
142:
143: unsigned long i;
144: unsigned long j;
145:
146: (*s_etat_processus).erreur_execution = d_ex;
147:
148: if ((*s_etat_processus).affichage_arguments == 'Y')
149: {
150: printf("\n COL-> ");
151:
152: if ((*s_etat_processus).langue == 'F')
153: {
154: printf("(extraction des colonnes d'une matrice)\n\n");
155: }
156: else
157: {
158: printf("(extract matrix columns)\n\n");
159: }
160:
161: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
162: printf("-> n: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
163: printf(" ...\n");
164: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
165: printf(" 1: %s\n", d_INT);
166:
167: return;
168: }
169: else if ((*s_etat_processus).test_instruction == 'Y')
170: {
171: (*s_etat_processus).nombre_arguments = -1;
172: return;
173: }
174:
175: if (test_cfsf(s_etat_processus, 31) == d_vrai)
176: {
177: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
178: {
179: return;
180: }
181: }
182:
183: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
184: &s_objet) == d_erreur)
185: {
186: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
187: return;
188: }
189:
190: if ((*s_objet).type == MIN)
191: {
192: for(i = 0; i < (*((struct_matrice *)
193: (*s_objet).objet)).nombre_colonnes; i++)
194: {
195: if ((s_objet_elementaire = allocation(s_etat_processus, MIN))
196: == NULL)
197: {
198: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
199: return;
200: }
201:
202: (*((struct_matrice *) (*s_objet_elementaire).objet))
203: .nombre_colonnes = 1;
204: (*((struct_matrice *) (*s_objet_elementaire).objet))
205: .nombre_lignes = (*((struct_matrice *) (*s_objet).objet))
206: .nombre_lignes;
207:
208: if (((*((struct_matrice *) (*s_objet_elementaire).objet)).tableau =
209: malloc((*((struct_matrice *) (*s_objet).objet))
210: .nombre_lignes * sizeof(integer8 *))) == NULL)
211: {
212: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
213: return;
214: }
215:
216: for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
217: .nombre_lignes; j++)
218: {
219: if ((((integer8 **) (*((struct_matrice *) (*s_objet_elementaire)
220: .objet)).tableau)[j] = malloc(sizeof(integer8)))
221: == NULL)
222: {
223: (*s_etat_processus).erreur_systeme =
224: d_es_allocation_memoire;
225: return;
226: }
227:
228: ((integer8 **) (*((struct_matrice *) (*s_objet_elementaire)
229: .objet)).tableau)[j][0] = ((integer8 **)
230: (*((struct_matrice *) (*s_objet).objet)).tableau)[j][i];
231: }
232:
233: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
234: s_objet_elementaire) == d_erreur)
235: {
236: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
237: return;
238: }
239: }
240: }
241: else if ((*s_objet).type == MRL)
242: {
243: for(i = 0; i < (*((struct_matrice *)
244: (*s_objet).objet)).nombre_colonnes; i++)
245: {
246: if ((s_objet_elementaire = allocation(s_etat_processus, MRL))
247: == NULL)
248: {
249: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
250: return;
251: }
252:
253: (*((struct_matrice *) (*s_objet_elementaire).objet))
254: .nombre_colonnes = 1;
255: (*((struct_matrice *) (*s_objet_elementaire).objet))
256: .nombre_lignes = (*((struct_matrice *) (*s_objet).objet))
257: .nombre_lignes;
258:
259: if (((*((struct_matrice *) (*s_objet_elementaire).objet)).tableau =
260: malloc((*((struct_matrice *) (*s_objet).objet))
261: .nombre_lignes * sizeof(real8 *))) == NULL)
262: {
263: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
264: return;
265: }
266:
267: for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
268: .nombre_lignes; j++)
269: {
270: if ((((real8 **) (*((struct_matrice *) (*s_objet_elementaire)
271: .objet)).tableau)[j] = malloc(sizeof(real8)))
272: == NULL)
273: {
274: (*s_etat_processus).erreur_systeme =
275: d_es_allocation_memoire;
276: return;
277: }
278:
279: ((real8 **) (*((struct_matrice *) (*s_objet_elementaire)
280: .objet)).tableau)[j][0] = ((real8 **)
281: (*((struct_matrice *) (*s_objet).objet)).tableau)[j][i];
282: }
283:
284: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
285: s_objet_elementaire) == d_erreur)
286: {
287: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
288: return;
289: }
290: }
291: }
292: else if ((*s_objet).type == MCX)
293: {
294: for(i = 0; i < (*((struct_matrice *)
295: (*s_objet).objet)).nombre_colonnes; i++)
296: {
297: if ((s_objet_elementaire = allocation(s_etat_processus, MCX))
298: == NULL)
299: {
300: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
301: return;
302: }
303:
304: (*((struct_matrice *) (*s_objet_elementaire).objet))
305: .nombre_colonnes = 1;
306: (*((struct_matrice *) (*s_objet_elementaire).objet))
307: .nombre_lignes = (*((struct_matrice *) (*s_objet).objet))
308: .nombre_lignes;
309:
310: if (((*((struct_matrice *) (*s_objet_elementaire).objet)).tableau =
311: malloc((*((struct_matrice *) (*s_objet).objet))
312: .nombre_lignes * sizeof(complex16 *))) == NULL)
313: {
314: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
315: return;
316: }
317:
318: for(j = 0; j < (*((struct_matrice *) (*s_objet).objet))
319: .nombre_lignes; j++)
320: {
321: if ((((complex16 **) (*((struct_matrice *)
322: (*s_objet_elementaire).objet)).tableau)[j] =
323: malloc(sizeof(complex16))) == NULL)
324: {
325: (*s_etat_processus).erreur_systeme =
326: d_es_allocation_memoire;
327: return;
328: }
329:
330: (((complex16 **) (*((struct_matrice *) (*s_objet_elementaire)
331: .objet)).tableau)[j][0]).partie_reelle =
332: (((complex16 **) (*((struct_matrice *) (*s_objet)
333: .objet)).tableau)[j][i]).partie_reelle;
334: (((complex16 **) (*((struct_matrice *) (*s_objet_elementaire)
335: .objet)).tableau)[j][0]).partie_imaginaire =
336: (((complex16 **) (*((struct_matrice *) (*s_objet)
337: .objet)).tableau)[j][i]).partie_imaginaire;
338: }
339:
340: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
341: s_objet_elementaire) == d_erreur)
342: {
343: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
344: return;
345: }
346: }
347: }
348: else
349: {
350: liberation(s_etat_processus, s_objet);
351:
352: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
353: return;
354: }
355:
356: if ((s_objet_elementaire = allocation(s_etat_processus, INT)) == NULL)
357: {
358: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
359: return;
360: }
361:
362: (*((integer8 *) (*s_objet_elementaire).objet)) =
363: (*((struct_matrice *) (*s_objet).objet)).nombre_colonnes;
364:
365: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
366: s_objet_elementaire) == d_erreur)
367: {
368: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
369: return;
370: }
371:
372: liberation(s_etat_processus, s_objet);
373:
374: return;
375: }
376:
377:
378: /*
379: ================================================================================
380: Fonction 'clrswi'
381: ================================================================================
382: Entrées : pointeur sur une structure struct_processus
383: --------------------------------------------------------------------------------
384: Sorties :
385: --------------------------------------------------------------------------------
386: Effets de bord : néant
387: ================================================================================
388: */
389:
390: void
391: instruction_clrswi(struct_processus *s_etat_processus)
392: {
393: integer8 interruption;
394:
395: struct_objet *s_objet_argument;
396:
397: (*s_etat_processus).erreur_execution = d_ex;
398:
399: if ((*s_etat_processus).affichage_arguments == 'Y')
400: {
401: printf("\n CLRSWI ");
402:
403: if ((*s_etat_processus).langue == 'F')
404: {
405: printf("(suppression d'une interruption logicielle)\n\n");
406: }
407: else
408: {
409: printf("(software interrupt deletion)\n\n");
410: }
411:
412: printf(" 1: %s\n", d_INT);
413:
414: return;
415: }
416: else if ((*s_etat_processus).test_instruction == 'Y')
417: {
418: (*s_etat_processus).nombre_arguments = -1;
419: return;
420: }
421:
422: if (test_cfsf(s_etat_processus, 31) == d_vrai)
423: {
424: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
425: {
426: return;
427: }
428: }
429:
430: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
431: &s_objet_argument) == d_erreur)
432: {
433: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
434: return;
435: }
436:
437: if ((*s_objet_argument).type == INT)
438: {
439: interruption = (*((integer8 *) (*s_objet_argument).objet));
440:
441: if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
442: {
443: liberation(s_etat_processus, s_objet_argument);
444:
445: (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
446: return;
447: }
448:
449: liberation(s_etat_processus, (*s_etat_processus)
450: .corps_interruptions[interruption - 1]);
451: (*s_etat_processus).corps_interruptions[interruption - 1] = NULL;
452: }
453: else
454: {
455: liberation(s_etat_processus, s_objet_argument);
456:
457: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
458: return;
459: }
460:
461: return;
462: }
463:
464:
465: /*
466: ================================================================================
467: Fonction 'clrcntxt'
468: ================================================================================
469: Entrées :
470: --------------------------------------------------------------------------------
471: Sorties :
472: --------------------------------------------------------------------------------
473: Effets de bord : néant
474: ================================================================================
475: */
476:
477: void
478: instruction_clrcntxt(struct_processus *s_etat_processus)
479: {
480: struct_liste_chainee *l_element_courant;
481: struct_liste_chainee *l_element_suivant;
482:
483: (*s_etat_processus).erreur_execution = d_ex;
484:
485: if ((*s_etat_processus).affichage_arguments == 'Y')
486: {
487: printf("\n CLCNTXT ");
488:
489: if ((*s_etat_processus).langue == 'F')
490: {
491: printf("(effacement des contextes)\n\n");
492: printf(" Aucun argument\n");
493: }
494: else
495: {
496: printf("(clear contexts)\n\n");
497: printf(" No argument\n");
498: }
499:
500: return;
501: }
502: else if ((*s_etat_processus).test_instruction == 'Y')
503: {
504: (*s_etat_processus).nombre_arguments = -1;
505: return;
506: }
507:
508: if (test_cfsf(s_etat_processus, 31) == d_vrai)
509: {
510: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
511: {
512: return;
513: }
514: }
515:
516: l_element_courant = (*s_etat_processus).l_base_pile_contextes;
517:
518: while(l_element_courant != NULL)
519: {
520: l_element_suivant = (*l_element_courant).suivant;
521: liberation(s_etat_processus, (*l_element_courant).donnee);
522: free(l_element_courant);
523: l_element_courant = l_element_suivant;
524: }
525:
526: (*s_etat_processus).l_base_pile_contextes = NULL;
527:
528: return;
529: }
530:
531:
532: /*
533: ================================================================================
534: Fonction 'continue'
535: ================================================================================
536: Entrées :
537: --------------------------------------------------------------------------------
538: Sorties :
539: --------------------------------------------------------------------------------
540: Effets de bord : néant
541: ================================================================================
542: */
543:
544: void
545: instruction_continue(struct_processus *s_etat_processus)
546: {
547: struct_liste_chainee *l_element_courant;
548:
549: struct_objet *s_objet;
550:
551: (*s_etat_processus).erreur_execution = d_ex;
552:
553: if ((*s_etat_processus).affichage_arguments == 'Y')
554: {
555: printf("\n CONTINUE ");
556:
557: if ((*s_etat_processus).langue == 'F')
558: {
559: printf("(relance d'un processus suspendu)\n\n");
560: }
561: else
562: {
563: printf("(continue a pending process)\n\n");
564: }
565:
566: printf(" 1: %s\n", d_PRC);
567:
568: return;
569: }
570: else if ((*s_etat_processus).test_instruction == 'Y')
571: {
572: (*s_etat_processus).nombre_arguments = -1;
573: return;
574: }
575:
576: if (test_cfsf(s_etat_processus, 31) == d_vrai)
577: {
578: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
579: {
580: return;
581: }
582: }
583:
584: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
585: &s_objet) == d_erreur)
586: {
587: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
588: return;
589: }
590:
591: if ((*s_objet).type == PRC)
592: {
593: if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
594: {
595: (*s_etat_processus).erreur_systeme = d_es_processus;
596: }
597: else
598: {
599: l_element_courant = (struct_liste_chainee *)
600: (*s_etat_processus).l_base_pile_processus;
601:
602: while(l_element_courant != NULL)
603: {
604: if ((*(*((struct_processus_fils *) (*s_objet).objet)).thread)
605: .processus_detache == d_vrai)
606: {
607: if ((*(*((struct_processus_fils *) (*s_objet).objet))
608: .thread).pid == (*(*((struct_processus_fils *)
609: (*(*l_element_courant).donnee).objet)).thread).pid)
610: {
611: if (kill((*(*((struct_processus_fils *)
612: (*s_objet).objet)).thread).pid, SIGCONT) != 0)
613: {
614: // Le processus est peut-être dans l'état zombie.
615: }
616:
617: break;
618: }
619: }
620: else
621: {
622: if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
623: (*s_objet).objet)).thread).mutex)) != 0)
624: {
625: (*s_etat_processus).erreur_systeme = d_es_processus;
626: return;
627: }
628:
629: if ((*(*((struct_processus_fils *)
630: (*s_objet).objet)).thread).thread_actif == d_vrai)
631: {
632: if (((pthread_equal((*(*((struct_processus_fils *)
633: (*s_objet).objet)).thread).tid,
634: (*(*((struct_processus_fils *)
635: (*(*l_element_courant).donnee).objet)).thread)
636: .tid) != 0)) && ((*(*((struct_processus_fils *)
637: (*s_objet).objet)).thread).pid ==
638: (*(*((struct_processus_fils *)
639: (*(*l_element_courant).donnee).objet)).thread)
640: .pid))
641: {
642: if (pthread_kill((*(*((struct_processus_fils *)
643: (*s_objet).objet)).thread).tid, SIGCONT)
644: != 0)
645: {
646: // Le thread est peut-être dans l'état zombie.
647: }
648:
649: if (pthread_mutex_unlock(
650: &((*(*((struct_processus_fils *)
651: (*s_objet).objet)).thread).mutex)) != 0)
652: {
653: (*s_etat_processus).erreur_systeme =
654: d_es_processus;
655: return;
656: }
657:
658: break;
659: }
660: }
661:
662: if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
663: (*s_objet).objet)).thread).mutex)) != 0)
664: {
665: (*s_etat_processus).erreur_systeme = d_es_processus;
666: return;
667: }
668: }
669:
670: l_element_courant = (*l_element_courant).suivant;
671: }
672:
673: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
674: {
675: (*s_etat_processus).erreur_systeme = d_es_processus;
676: }
677: }
678: }
679: else
680: {
681: liberation(s_etat_processus, s_objet);
682:
683: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
684: return;
685: }
686:
687: liberation(s_etat_processus, s_objet);
688:
689: return;
690: }
691:
692:
693: /*
694: ================================================================================
695: Fonction 'cstop'
696: ================================================================================
697: Entrées :
698: --------------------------------------------------------------------------------
699: Sorties :
700: --------------------------------------------------------------------------------
701: Effets de bord : néant
702: ================================================================================
703: */
704:
705: void
706: instruction_cstop(struct_processus *s_etat_processus)
707: {
708: (*s_etat_processus).erreur_execution = d_ex;
709:
710: if ((*s_etat_processus).affichage_arguments == 'Y')
711: {
712: printf("\n CSTOP ");
713:
714: if ((*s_etat_processus).langue == 'F')
715: {
716: printf("(capture du signal stop)\n\n");
717: printf(" Aucun argument\n");
718: }
719: else
720: {
721: printf("(catch stop signal)\n\n");
722: printf(" No argument\n");
723: }
724:
725: return;
726: }
727: else if ((*s_etat_processus).test_instruction == 'Y')
728: {
729: (*s_etat_processus).nombre_arguments = -1;
730: return;
731: }
732:
733: if (test_cfsf(s_etat_processus, 31) == d_vrai)
734: {
735: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
736: {
737: return;
738: }
739: }
740:
741: if ((*s_etat_processus).var_volatile_traitement_retarde_stop == 0)
742: {
743: (*s_etat_processus).var_volatile_traitement_retarde_stop = 1;
744: }
745: else
746: {
747: (*s_etat_processus).erreur_execution = d_ex_stop;
748: }
749:
750: return;
751: }
752:
753:
754: /*
755: ================================================================================
756: Fonction 'clrfuse'
757: ================================================================================
758: Entrées :
759: --------------------------------------------------------------------------------
760: Sorties :
761: --------------------------------------------------------------------------------
762: Effets de bord : néant
763: ================================================================================
764: */
765:
766: void
767: instruction_clrfuse(struct_processus *s_etat_processus)
768: {
769: (*s_etat_processus).erreur_execution = d_ex;
770:
771: if ((*s_etat_processus).affichage_arguments == 'Y')
772: {
773: printf("\n CLRFUSE ");
774:
775: if ((*s_etat_processus).langue == 'F')
776: {
777: printf("(libère un fusible)\n\n");
778: printf(" Aucun argument\n");
779: }
780: else
781: {
782: printf("(release fuse signal)\n\n");
783: printf(" No argument\n");
784: }
785:
786: return;
787: }
788: else if ((*s_etat_processus).test_instruction == 'Y')
789: {
790: (*s_etat_processus).nombre_arguments = -1;
791: return;
792: }
793:
794: if (test_cfsf(s_etat_processus, 31) == d_vrai)
795: {
796: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
797: {
798: return;
799: }
800: }
801:
802: if ((*s_etat_processus).presence_fusible == d_faux)
803: {
804: (*s_etat_processus).erreur_execution = d_ex_fusible;
805: return;
806: }
807:
808: if (pthread_cancel((*s_etat_processus).thread_fusible) != 0)
809: {
810: if ((*s_etat_processus).var_volatile_requete_arret == 0)
811: {
812: (*s_etat_processus).erreur_systeme = d_es_processus;
813: return;
814: }
815: }
816:
817: (*s_etat_processus).thread_fusible = 0;
818: (*s_etat_processus).presence_fusible = d_faux;
819:
820: return;
821: }
822:
823:
824: /*
825: ================================================================================
826: Fonction 'crtab'
827: ================================================================================
828: Entrées :
829: --------------------------------------------------------------------------------
830: Sorties :
831: --------------------------------------------------------------------------------
832: Effets de bord : néant
833: ================================================================================
834: */
835:
836: void
837: instruction_crtab(struct_processus *s_etat_processus)
838: {
839: struct_liste_chainee *l_element_courant;
840:
841: struct_objet *s_objet_argument;
842: struct_objet *s_objet_resultat;
843:
844: struct_objet *
845: creation_table(struct_liste_chainee *dimensions)
846: {
847: struct_objet *s_table;
848:
849: unsigned long i;
850:
851: if ((s_table = allocation(s_etat_processus, TBL)) == NULL)
852: {
853: return(NULL);
854: }
855:
856: (*((struct_tableau *) (*s_table).objet)).nombre_elements =
857: (unsigned long) (*((integer8 *) (*(*dimensions).donnee).objet));
858:
859: dimensions = (*dimensions).suivant;
860:
861: if (((*((struct_tableau *) (*s_table).objet)).elements =
862: malloc((*((struct_tableau *) (*s_table).objet))
863: .nombre_elements * sizeof(struct_objet *))) == NULL)
864: {
865: return(NULL);
866: }
867:
868: if (dimensions == NULL)
869: {
870: for(i = 0; i < (*((struct_tableau *) (*s_table).objet))
871: .nombre_elements; i++)
872: {
873: if (((*((struct_tableau *) (*s_table).objet)).elements[i] =
874: allocation(s_etat_processus, LST)) == NULL)
875: {
876: return(NULL);
877: }
878: }
879: }
880: else
881: {
882: for(i = 0; i < (*((struct_tableau *) (*s_table).objet))
883: .nombre_elements; i++)
884: {
885: if (((*((struct_tableau *) (*s_table).objet)).elements[i] =
886: creation_table(dimensions)) == NULL)
887: {
888: return(NULL);
889: }
890: }
891: }
892:
893: return(s_table);
894: }
895:
896: (*s_etat_processus).erreur_execution = d_ex;
897:
898: if ((*s_etat_processus).affichage_arguments == 'Y')
899: {
900: printf("\n CRTAB ");
901:
902: if ((*s_etat_processus).langue == 'F')
903: {
904: printf("(création d'une table régulière)\n\n");
905: }
906: else
907: {
908: printf("(create a regular table)\n\n");
909: }
910:
911: printf(" 1: %s\n", d_LST);
912: printf("-> 1: %s\n", d_TAB);
913:
914: return;
915: }
916: else if ((*s_etat_processus).test_instruction == 'Y')
917: {
918: (*s_etat_processus).nombre_arguments = -1;
919: return;
920: }
921:
922: if (test_cfsf(s_etat_processus, 31) == d_vrai)
923: {
924: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
925: {
926: return;
927: }
928: }
929:
930: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
931: &s_objet_argument) == d_erreur)
932: {
933: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
934: return;
935: }
936:
937: if ((*s_objet_argument).type == LST)
938: {
939: l_element_courant = (*s_objet_argument).objet;
940:
941: if (l_element_courant == NULL)
942: {
943: liberation(s_etat_processus, s_objet_argument);
944:
945: (*s_etat_processus).erreur_execution =
946: d_ex_argument_invalide;
947: return;
948: }
949:
950: while(l_element_courant != NULL)
951: {
952: if ((*(*l_element_courant).donnee).type != INT)
953: {
954: liberation(s_etat_processus, s_objet_argument);
955:
956: (*s_etat_processus).erreur_execution =
957: d_ex_erreur_type_argument;
958: return;
959: }
960:
961: l_element_courant = (*l_element_courant).suivant;
962: }
963:
964: if ((s_objet_resultat =
965: creation_table((*s_objet_argument).objet)) == NULL)
966: {
967: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
968: return;
969: }
970: }
971: else
972: {
973: liberation(s_etat_processus, s_objet_argument);
974:
975: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
976: return;
977: }
978:
979: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
980: s_objet_resultat) == d_erreur)
981: {
982: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
983: return;
984: }
985:
986: liberation(s_etat_processus, s_objet_argument);
987:
988: return;
989: }
990:
991: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>