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