1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.10
4: Copyright (C) 1989-2012 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 (envoi_signal_processus(
612: (*(*((struct_processus_fils *)
613: (*s_objet).objet)).thread).pid, rpl_sigcont)
614: != 0)
615: {
616: // Le processus est peut-être dans l'état zombie.
617: }
618:
619: break;
620: }
621: }
622: else
623: {
624: if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
625: (*s_objet).objet)).thread).mutex)) != 0)
626: {
627: (*s_etat_processus).erreur_systeme = d_es_processus;
628: return;
629: }
630:
631: if ((*(*((struct_processus_fils *)
632: (*s_objet).objet)).thread).thread_actif == d_vrai)
633: {
634: if (((pthread_equal((*(*((struct_processus_fils *)
635: (*s_objet).objet)).thread).tid,
636: (*(*((struct_processus_fils *)
637: (*(*l_element_courant).donnee).objet)).thread)
638: .tid) != 0)) && ((*(*((struct_processus_fils *)
639: (*s_objet).objet)).thread).pid ==
640: (*(*((struct_processus_fils *)
641: (*(*l_element_courant).donnee).objet)).thread)
642: .pid))
643: {
644: if (envoi_signal_thread(
645: (*(*((struct_processus_fils *)
646: (*s_objet).objet)).thread).tid, rpl_sigcont)
647: != 0)
648: {
649: // Le thread est peut-être dans l'état zombie.
650: }
651:
652: if (pthread_mutex_unlock(
653: &((*(*((struct_processus_fils *)
654: (*s_objet).objet)).thread).mutex)) != 0)
655: {
656: (*s_etat_processus).erreur_systeme =
657: d_es_processus;
658: return;
659: }
660:
661: break;
662: }
663: }
664:
665: if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
666: (*s_objet).objet)).thread).mutex)) != 0)
667: {
668: (*s_etat_processus).erreur_systeme = d_es_processus;
669: return;
670: }
671: }
672:
673: l_element_courant = (*l_element_courant).suivant;
674: }
675:
676: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
677: {
678: (*s_etat_processus).erreur_systeme = d_es_processus;
679: }
680: }
681: }
682: else
683: {
684: liberation(s_etat_processus, s_objet);
685:
686: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
687: return;
688: }
689:
690: liberation(s_etat_processus, s_objet);
691:
692: return;
693: }
694:
695:
696: /*
697: ================================================================================
698: Fonction 'cstop'
699: ================================================================================
700: Entrées :
701: --------------------------------------------------------------------------------
702: Sorties :
703: --------------------------------------------------------------------------------
704: Effets de bord : néant
705: ================================================================================
706: */
707:
708: void
709: instruction_cstop(struct_processus *s_etat_processus)
710: {
711: (*s_etat_processus).erreur_execution = d_ex;
712:
713: if ((*s_etat_processus).affichage_arguments == 'Y')
714: {
715: printf("\n CSTOP ");
716:
717: if ((*s_etat_processus).langue == 'F')
718: {
719: printf("(capture du signal stop)\n\n");
720: printf(" Aucun argument\n");
721: }
722: else
723: {
724: printf("(catch stop signal)\n\n");
725: printf(" No argument\n");
726: }
727:
728: return;
729: }
730: else if ((*s_etat_processus).test_instruction == 'Y')
731: {
732: (*s_etat_processus).nombre_arguments = -1;
733: return;
734: }
735:
736: if (test_cfsf(s_etat_processus, 31) == d_vrai)
737: {
738: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
739: {
740: return;
741: }
742: }
743:
744: if ((*s_etat_processus).var_volatile_traitement_retarde_stop == 0)
745: {
746: (*s_etat_processus).var_volatile_traitement_retarde_stop = 1;
747: }
748: else
749: {
750: (*s_etat_processus).erreur_execution = d_ex_stop;
751: }
752:
753: return;
754: }
755:
756:
757: /*
758: ================================================================================
759: Fonction 'clrfuse'
760: ================================================================================
761: Entrées :
762: --------------------------------------------------------------------------------
763: Sorties :
764: --------------------------------------------------------------------------------
765: Effets de bord : néant
766: ================================================================================
767: */
768:
769: void
770: instruction_clrfuse(struct_processus *s_etat_processus)
771: {
772: (*s_etat_processus).erreur_execution = d_ex;
773:
774: if ((*s_etat_processus).affichage_arguments == 'Y')
775: {
776: printf("\n CLRFUSE ");
777:
778: if ((*s_etat_processus).langue == 'F')
779: {
780: printf("(libère un fusible)\n\n");
781: printf(" Aucun argument\n");
782: }
783: else
784: {
785: printf("(release fuse signal)\n\n");
786: printf(" No argument\n");
787: }
788:
789: return;
790: }
791: else if ((*s_etat_processus).test_instruction == 'Y')
792: {
793: (*s_etat_processus).nombre_arguments = -1;
794: return;
795: }
796:
797: if (test_cfsf(s_etat_processus, 31) == d_vrai)
798: {
799: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
800: {
801: return;
802: }
803: }
804:
805: if ((*s_etat_processus).presence_fusible == d_faux)
806: {
807: (*s_etat_processus).erreur_execution = d_ex_fusible;
808: return;
809: }
810:
811: if (pthread_cancel((*s_etat_processus).thread_fusible) != 0)
812: {
813: if ((*s_etat_processus).var_volatile_requete_arret == 0)
814: {
815: (*s_etat_processus).erreur_systeme = d_es_processus;
816: return;
817: }
818: }
819:
820: (*s_etat_processus).thread_fusible = 0;
821: (*s_etat_processus).presence_fusible = d_faux;
822:
823: return;
824: }
825:
826:
827: /*
828: ================================================================================
829: Fonction 'crtab'
830: ================================================================================
831: Entrées :
832: --------------------------------------------------------------------------------
833: Sorties :
834: --------------------------------------------------------------------------------
835: Effets de bord : néant
836: ================================================================================
837: */
838:
839: static struct_objet *
840: creation_table(struct_processus *s_etat_processus,
841: struct_liste_chainee *dimensions)
842: {
843: struct_objet *s_table;
844:
845: unsigned long i;
846:
847: if ((s_table = allocation(s_etat_processus, TBL)) == NULL)
848: {
849: return(NULL);
850: }
851:
852: (*((struct_tableau *) (*s_table).objet)).nombre_elements =
853: (unsigned long) (*((integer8 *) (*(*dimensions).donnee).objet));
854:
855: dimensions = (*dimensions).suivant;
856:
857: if (((*((struct_tableau *) (*s_table).objet)).elements =
858: malloc((*((struct_tableau *) (*s_table).objet))
859: .nombre_elements * sizeof(struct_objet *))) == NULL)
860: {
861: return(NULL);
862: }
863:
864: if (dimensions == NULL)
865: {
866: for(i = 0; i < (*((struct_tableau *) (*s_table).objet))
867: .nombre_elements; i++)
868: {
869: if (((*((struct_tableau *) (*s_table).objet)).elements[i] =
870: allocation(s_etat_processus, LST)) == NULL)
871: {
872: return(NULL);
873: }
874: }
875: }
876: else
877: {
878: for(i = 0; i < (*((struct_tableau *) (*s_table).objet))
879: .nombre_elements; i++)
880: {
881: if (((*((struct_tableau *) (*s_table).objet)).elements[i] =
882: creation_table(s_etat_processus, dimensions)) == NULL)
883: {
884: return(NULL);
885: }
886: }
887: }
888:
889: return(s_table);
890: }
891:
892: void
893: instruction_crtab(struct_processus *s_etat_processus)
894: {
895: struct_liste_chainee *l_element_courant;
896:
897: struct_objet *s_objet_argument;
898: struct_objet *s_objet_resultat;
899:
900: (*s_etat_processus).erreur_execution = d_ex;
901:
902: if ((*s_etat_processus).affichage_arguments == 'Y')
903: {
904: printf("\n CRTAB ");
905:
906: if ((*s_etat_processus).langue == 'F')
907: {
908: printf("(création d'une table régulière)\n\n");
909: }
910: else
911: {
912: printf("(create a regular table)\n\n");
913: }
914:
915: printf(" 1: %s\n", d_LST);
916: printf("-> 1: %s\n", d_TAB);
917:
918: return;
919: }
920: else if ((*s_etat_processus).test_instruction == 'Y')
921: {
922: (*s_etat_processus).nombre_arguments = -1;
923: return;
924: }
925:
926: if (test_cfsf(s_etat_processus, 31) == d_vrai)
927: {
928: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
929: {
930: return;
931: }
932: }
933:
934: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
935: &s_objet_argument) == d_erreur)
936: {
937: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
938: return;
939: }
940:
941: if ((*s_objet_argument).type == LST)
942: {
943: l_element_courant = (*s_objet_argument).objet;
944:
945: if (l_element_courant == NULL)
946: {
947: liberation(s_etat_processus, s_objet_argument);
948:
949: (*s_etat_processus).erreur_execution =
950: d_ex_argument_invalide;
951: return;
952: }
953:
954: while(l_element_courant != NULL)
955: {
956: if ((*(*l_element_courant).donnee).type != INT)
957: {
958: liberation(s_etat_processus, s_objet_argument);
959:
960: (*s_etat_processus).erreur_execution =
961: d_ex_erreur_type_argument;
962: return;
963: }
964:
965: l_element_courant = (*l_element_courant).suivant;
966: }
967:
968: if ((s_objet_resultat = creation_table(s_etat_processus,
969: (*s_objet_argument).objet)) == NULL)
970: {
971: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
972: return;
973: }
974: }
975: else
976: {
977: liberation(s_etat_processus, s_objet_argument);
978:
979: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
980: return;
981: }
982:
983: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
984: s_objet_resultat) == d_erreur)
985: {
986: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
987: return;
988: }
989:
990: liberation(s_etat_processus, s_objet_argument);
991:
992: return;
993: }
994:
995: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>