1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.12
4: Copyright (C) 1989-2013 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 'get'
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_get(struct_processus *s_etat_processus)
40: {
41: logical1 variable_partagee;
42:
43: struct_liste_chainee *l_element_courant;
44:
45: struct_objet *s_objet_1;
46: struct_objet *s_objet_2;
47: struct_objet *s_objet_3;
48: struct_objet *s_objet_element;
49: struct_objet *s_objet_resultat;
50:
51: unsigned long indice_i;
52: unsigned long indice_j;
53: unsigned long nombre_dimensions;
54:
55: (*s_etat_processus).erreur_execution = d_ex;
56:
57: if ((*s_etat_processus).affichage_arguments == 'Y')
58: {
59: printf("\n GET ");
60:
61: if ((*s_etat_processus).langue == 'F')
62: {
63: printf("(prend un élément)\n\n");
64: }
65: else
66: {
67: printf("(get element)\n\n");
68: }
69:
70: printf(" 2: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
71: printf(" 1: %s\n", d_LST);
72: printf("-> 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
73:
74: printf(" 2: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
75: printf(" 1: %s\n", d_LST);
76: printf("-> 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
77:
78: printf(" 2: %s, %s\n", d_TAB, d_NOM);
79: printf(" 1: %s\n", d_LST);
80: printf("-> 1: %s, %s, %s, %s, %s, %s,\n"
81: " %s, %s, %s, %s, %s,\n"
82: " %s, %s, %s, %s, %s,\n"
83: " %s, %s, %s, %s,\n"
84: " %s, %s\n\n",
85: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
86: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
87: d_SQL, d_SLB, d_PRC, d_MTX);
88:
89: printf(" 2: %s, %s\n", d_LST, d_NOM);
90: printf(" 1: %s\n", d_INT);
91: printf("-> 1: %s, %s, %s, %s, %s, %s,\n"
92: " %s, %s, %s, %s, %s,\n"
93: " %s, %s, %s, %s, %s,\n"
94: " %s, %s, %s, %s,\n"
95: " %s, %s\n",
96: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
97: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
98: d_SQL, d_SLB, d_PRC, d_MTX);
99:
100: return;
101: }
102: else if ((*s_etat_processus).test_instruction == 'Y')
103: {
104: (*s_etat_processus).nombre_arguments = -1;
105: return;
106: }
107:
108: if (test_cfsf(s_etat_processus, 31) == d_vrai)
109: {
110: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
111: {
112: return;
113: }
114: }
115:
116: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
117: &s_objet_1) == d_erreur)
118: {
119: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
120: return;
121: }
122:
123: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
124: &s_objet_2) == d_erreur)
125: {
126: liberation(s_etat_processus, s_objet_1);
127:
128: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
129: return;
130: }
131:
132: /*
133: --------------------------------------------------------------------------------
134: Traitement des éléments des vecteurs
135: --------------------------------------------------------------------------------
136: */
137:
138: if (((*s_objet_2).type == VIN) ||
139: ((*s_objet_2).type == VRL) ||
140: ((*s_objet_2).type == VCX))
141: {
142: if ((*s_objet_1).type != LST)
143: {
144: liberation(s_etat_processus, s_objet_1);
145: liberation(s_etat_processus, s_objet_2);
146:
147: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
148: return;
149: }
150:
151: l_element_courant = (*s_objet_1).objet;
152: nombre_dimensions = 0;
153:
154: while(l_element_courant != NULL)
155: {
156: nombre_dimensions++;
157: l_element_courant = (*l_element_courant).suivant;
158: }
159:
160: if (nombre_dimensions != 1)
161: {
162: liberation(s_etat_processus, s_objet_1);
163: liberation(s_etat_processus, s_objet_2);
164:
165: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
166: return;
167: }
168:
169: l_element_courant = (*s_objet_1).objet;
170:
171: if ((*(*l_element_courant).donnee).type != INT)
172: {
173: liberation(s_etat_processus, s_objet_1);
174: liberation(s_etat_processus, s_objet_2);
175:
176: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
177: return;
178: }
179:
180: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
181: {
182: liberation(s_etat_processus, s_objet_1);
183: liberation(s_etat_processus, s_objet_2);
184:
185: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
186: return;
187: }
188: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
189: (integer8) (*((struct_vecteur *) (*s_objet_2).objet)).taille)
190: {
191: liberation(s_etat_processus, s_objet_1);
192: liberation(s_etat_processus, s_objet_2);
193:
194: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
195: return;
196: }
197:
198: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
199:
200: if ((*s_objet_2).type == VIN)
201: {
202: /*
203: * Vecteur d'entiers
204: */
205:
206: if ((s_objet_resultat = allocation(s_etat_processus, INT))
207: == NULL)
208: {
209: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
210: return;
211: }
212:
213: (*((integer8 *) (*s_objet_resultat).objet)) =
214: ((integer8 *) (*((struct_vecteur *) (*s_objet_2).objet))
215: .tableau)[indice_i - 1];
216: }
217: else if ((*s_objet_2).type == VRL)
218: {
219: /*
220: * Vecteur de réels
221: */
222:
223: if ((s_objet_resultat = allocation(s_etat_processus, REL))
224: == NULL)
225: {
226: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
227: return;
228: }
229:
230: (*((real8 *) (*s_objet_resultat).objet)) =
231: ((real8 *) (*((struct_vecteur *) (*s_objet_2).objet))
232: .tableau)[indice_i - 1];
233: }
234: else
235: {
236: /*
237: * Vecteur de complexes
238: */
239:
240: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
241: == NULL)
242: {
243: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
244: return;
245: }
246:
247: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
248: ((struct_complexe16 *) (*((struct_vecteur *)
249: (*s_objet_2).objet)).tableau)[indice_i - 1].partie_reelle;
250: (*((struct_complexe16 *) (*s_objet_resultat).objet))
251: .partie_imaginaire = ((struct_complexe16 *)
252: (*((struct_vecteur *) (*s_objet_2).objet)).tableau)
253: [indice_i - 1].partie_imaginaire;
254: }
255: }
256:
257: /*
258: --------------------------------------------------------------------------------
259: Traitement des éléments des matrices
260: --------------------------------------------------------------------------------
261: */
262:
263: else if (((*s_objet_2).type == MIN) ||
264: ((*s_objet_2).type == MRL) ||
265: ((*s_objet_2).type == MCX))
266: {
267: if ((*s_objet_1).type != LST)
268: {
269: liberation(s_etat_processus, s_objet_1);
270: liberation(s_etat_processus, s_objet_2);
271:
272: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
273: return;
274: }
275:
276: l_element_courant = (*s_objet_1).objet;
277: nombre_dimensions = 0;
278:
279: while(l_element_courant != NULL)
280: {
281: nombre_dimensions++;
282: l_element_courant = (*l_element_courant).suivant;
283: }
284:
285: if (nombre_dimensions != 2)
286: {
287: liberation(s_etat_processus, s_objet_1);
288: liberation(s_etat_processus, s_objet_2);
289:
290: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
291: return;
292: }
293:
294: l_element_courant = (*s_objet_1).objet;
295:
296: indice_i = 0;
297: indice_j = 0;
298:
299: while(l_element_courant != NULL)
300: {
301: if ((*(*l_element_courant).donnee).type != INT)
302: {
303: liberation(s_etat_processus, s_objet_1);
304: liberation(s_etat_processus, s_objet_2);
305:
306: (*s_etat_processus).erreur_execution =
307: d_ex_erreur_type_argument;
308: return;
309: }
310:
311: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
312: {
313: liberation(s_etat_processus, s_objet_1);
314: liberation(s_etat_processus, s_objet_2);
315:
316: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
317: return;
318: }
319:
320: if (indice_i == 0)
321: {
322: indice_i = (*((integer8 *)
323: (*(*l_element_courant).donnee).objet));
324: }
325: else
326: {
327: indice_j = (*((integer8 *)
328: (*(*l_element_courant).donnee).objet));
329: }
330:
331: l_element_courant = (*l_element_courant).suivant;
332: }
333:
334: if ((indice_i > (*((struct_matrice *) (*s_objet_2).objet))
335: .nombre_lignes) || (indice_j > (*((struct_matrice *)
336: (*s_objet_2).objet)).nombre_colonnes))
337: {
338: liberation(s_etat_processus, s_objet_1);
339: liberation(s_etat_processus, s_objet_2);
340:
341: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
342: return;
343: }
344:
345: if ((*s_objet_2).type == MIN)
346: {
347: /*
348: * Matrice d'entiers
349: */
350:
351: if ((s_objet_resultat = allocation(s_etat_processus, INT))
352: == NULL)
353: {
354: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
355: return;
356: }
357:
358: (*((integer8 *) (*s_objet_resultat).objet)) =
359: ((integer8 **) (*((struct_matrice *) (*s_objet_2).objet))
360: .tableau)[indice_i - 1][indice_j - 1];
361: }
362: else if ((*s_objet_2).type == MRL)
363: {
364: /*
365: * Matrice de réels
366: */
367:
368: if ((s_objet_resultat = allocation(s_etat_processus, REL))
369: == NULL)
370: {
371: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
372: return;
373: }
374:
375: (*((real8 *) (*s_objet_resultat).objet)) =
376: ((real8 **) (*((struct_matrice *) (*s_objet_2).objet))
377: .tableau)[indice_i - 1][indice_j - 1];
378: }
379: else
380: {
381: /*
382: * Matrices de complexes
383: */
384:
385: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
386: == NULL)
387: {
388: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
389: return;
390: }
391:
392: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
393: ((struct_complexe16 **) (*((struct_matrice *)
394: (*s_objet_2).objet)).tableau)[indice_i - 1]
395: [indice_j - 1].partie_reelle;
396: (*((struct_complexe16 *) (*s_objet_resultat).objet))
397: .partie_imaginaire = ((struct_complexe16 **)
398: (*((struct_matrice *) (*s_objet_2).objet)).tableau)
399: [indice_i - 1][indice_j - 1].partie_imaginaire;
400: }
401: }
402:
403: /*
404: --------------------------------------------------------------------------------
405: Traitement des listes
406: --------------------------------------------------------------------------------
407: */
408:
409: else if ((*s_objet_2).type == LST)
410: {
411: if ((*s_objet_1).type != INT)
412: {
413: liberation(s_etat_processus, s_objet_1);
414: liberation(s_etat_processus, s_objet_2);
415:
416: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
417: return;
418: }
419:
420: indice_i = (*((integer8 *) (*s_objet_1).objet));
421: indice_j = 1;
422:
423: l_element_courant = (*s_objet_2).objet;
424:
425: while((l_element_courant != NULL) && (indice_j != indice_i))
426: {
427: l_element_courant = (*l_element_courant).suivant;
428: indice_j++;
429: }
430:
431: if (l_element_courant != NULL)
432: {
433: if ((s_objet_resultat = copie_objet(s_etat_processus,
434: (*l_element_courant).donnee, 'P')) == NULL)
435: {
436: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
437: return;
438: }
439: }
440: else
441: {
442: liberation(s_etat_processus, s_objet_1);
443: liberation(s_etat_processus, s_objet_2);
444:
445: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
446: return;
447: }
448: }
449:
450: /*
451: --------------------------------------------------------------------------------
452: Traitement des tables
453: --------------------------------------------------------------------------------
454: */
455:
456: else if ((*s_objet_2).type == TBL)
457: {
458: if ((*s_objet_1).type != LST)
459: {
460: liberation(s_etat_processus, s_objet_1);
461: liberation(s_etat_processus, s_objet_2);
462:
463: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
464: return;
465: }
466:
467: l_element_courant = (*s_objet_1).objet;
468: s_objet_element = s_objet_2;
469:
470: while(l_element_courant != NULL)
471: {
472: if ((*(*l_element_courant).donnee).type != INT)
473: {
474: liberation(s_etat_processus, s_objet_1);
475: liberation(s_etat_processus, s_objet_2);
476:
477: (*s_etat_processus).erreur_execution =
478: d_ex_erreur_type_argument;
479: return;
480: }
481:
482: if ((*s_objet_element).type != TBL)
483: {
484: liberation(s_etat_processus, s_objet_1);
485: liberation(s_etat_processus, s_objet_2);
486:
487: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
488: return;
489: }
490:
491: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
492:
493: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
494: (*s_objet_element).objet)).nombre_elements))
495: {
496: liberation(s_etat_processus, s_objet_1);
497: liberation(s_etat_processus, s_objet_2);
498:
499: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
500: return;
501: }
502:
503: s_objet_element = (*((struct_tableau *) (*s_objet_element)
504: .objet)).elements[indice_i - 1];
505: l_element_courant = (*l_element_courant).suivant;
506: }
507:
508: if ((s_objet_resultat = copie_objet(s_etat_processus,
509: s_objet_element, 'P')) == NULL)
510: {
511: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
512: return;
513: }
514: }
515:
516: /*
517: --------------------------------------------------------------------------------
518: Traitement des variables
519: --------------------------------------------------------------------------------
520: */
521:
522: else if ((*s_objet_2).type == NOM)
523: {
524: variable_partagee = d_faux;
525:
526: if (recherche_variable(s_etat_processus, (*((struct_nom *)
527: (*s_objet_2).objet)).nom) == d_faux)
528: {
529: (*s_etat_processus).erreur_systeme = d_es;
530: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
531:
532: liberation(s_etat_processus, s_objet_1);
533: liberation(s_etat_processus, s_objet_2);
534:
535: return;
536: }
537:
538: s_objet_3 = (*(*s_etat_processus).pointeur_variable_courante).objet;
539:
540: if (s_objet_3 == NULL)
541: {
542: if (recherche_variable_partagee(s_etat_processus,
543: (*(*s_etat_processus).pointeur_variable_courante).nom,
544: (*(*s_etat_processus).pointeur_variable_courante)
545: .variable_partagee, (*(*s_etat_processus)
546: .pointeur_variable_courante).origine) == NULL)
547: {
548: (*s_etat_processus).erreur_systeme = d_es;
549: (*s_etat_processus).erreur_execution =
550: d_ex_variable_non_definie;
551:
552: liberation(s_etat_processus, s_objet_1);
553: liberation(s_etat_processus, s_objet_2);
554:
555: return;
556: }
557:
558: s_objet_3 = (*(*s_etat_processus)
559: .pointeur_variable_partagee_courante).objet;
560: variable_partagee = d_vrai;
561: }
562:
563: if (((*s_objet_3).type == VIN) ||
564: ((*s_objet_3).type == VRL) ||
565: ((*s_objet_3).type == VCX))
566: {
567: if ((*s_objet_1).type != LST)
568: {
569: if (variable_partagee == d_vrai)
570: {
571: if (pthread_mutex_unlock(&((*(*s_etat_processus)
572: .pointeur_variable_partagee_courante).mutex)) != 0)
573: {
574: (*s_etat_processus).erreur_systeme = d_es_processus;
575: return;
576: }
577: }
578:
579: liberation(s_etat_processus, s_objet_1);
580: liberation(s_etat_processus, s_objet_2);
581:
582: (*s_etat_processus).erreur_execution =
583: d_ex_erreur_type_argument;
584: return;
585: }
586:
587: l_element_courant = (*s_objet_1).objet;
588: nombre_dimensions = 0;
589:
590: while(l_element_courant != NULL)
591: {
592: nombre_dimensions++;
593: l_element_courant = (*l_element_courant).suivant;
594: }
595:
596: if (nombre_dimensions != 1)
597: {
598: if (variable_partagee == d_vrai)
599: {
600: if (pthread_mutex_unlock(&((*(*s_etat_processus)
601: .pointeur_variable_partagee_courante).mutex)) != 0)
602: {
603: (*s_etat_processus).erreur_systeme = d_es_processus;
604: return;
605: }
606: }
607:
608: liberation(s_etat_processus, s_objet_1);
609: liberation(s_etat_processus, s_objet_2);
610:
611: (*s_etat_processus).erreur_execution =
612: d_ex_dimensions_invalides;
613: return;
614: }
615:
616: l_element_courant = (*s_objet_1).objet;
617:
618: if ((*(*l_element_courant).donnee).type != INT)
619: {
620: if (variable_partagee == d_vrai)
621: {
622: if (pthread_mutex_unlock(&((*(*s_etat_processus)
623: .pointeur_variable_partagee_courante).mutex)) != 0)
624: {
625: (*s_etat_processus).erreur_systeme = d_es_processus;
626: return;
627: }
628: }
629:
630: liberation(s_etat_processus, s_objet_1);
631: liberation(s_etat_processus, s_objet_2);
632:
633: (*s_etat_processus).erreur_execution =
634: d_ex_erreur_type_argument;
635: return;
636: }
637:
638: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
639: {
640: if (variable_partagee == d_vrai)
641: {
642: if (pthread_mutex_unlock(&((*(*s_etat_processus)
643: .pointeur_variable_partagee_courante).mutex)) != 0)
644: {
645: (*s_etat_processus).erreur_systeme = d_es_processus;
646: return;
647: }
648: }
649:
650: liberation(s_etat_processus, s_objet_1);
651: liberation(s_etat_processus, s_objet_2);
652:
653: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
654: return;
655: }
656: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
657: (integer8) (*((struct_vecteur *) (*s_objet_3).objet))
658: .taille)
659: {
660: if (variable_partagee == d_vrai)
661: {
662: if (pthread_mutex_unlock(&((*(*s_etat_processus)
663: .pointeur_variable_partagee_courante).mutex)) != 0)
664: {
665: (*s_etat_processus).erreur_systeme = d_es_processus;
666: return;
667: }
668: }
669:
670: liberation(s_etat_processus, s_objet_1);
671: liberation(s_etat_processus, s_objet_2);
672:
673: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
674: return;
675: }
676:
677: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
678:
679: if ((*s_objet_3).type == VIN)
680: {
681: /*
682: * Vecteur d'entiers
683: */
684:
685: if ((s_objet_resultat = allocation(s_etat_processus, INT))
686: == NULL)
687: {
688: if (variable_partagee == d_vrai)
689: {
690: if (pthread_mutex_unlock(&((*(*s_etat_processus)
691: .pointeur_variable_partagee_courante).mutex))
692: != 0)
693: {
694: (*s_etat_processus).erreur_systeme = d_es_processus;
695: return;
696: }
697: }
698:
699: (*s_etat_processus).erreur_systeme
700: = d_es_allocation_memoire;
701: return;
702: }
703:
704: (*((integer8 *) (*s_objet_resultat).objet)) =
705: ((integer8 *) (*((struct_vecteur *)
706: (*s_objet_3).objet)).tableau)[indice_i - 1];
707: }
708: else if ((*s_objet_3).type == VRL)
709: {
710: /*
711: * Vecteur de réels
712: */
713:
714: if ((s_objet_resultat = allocation(s_etat_processus, REL))
715: == NULL)
716: {
717: if (variable_partagee == d_vrai)
718: {
719: if (pthread_mutex_unlock(&((*(*s_etat_processus)
720: .pointeur_variable_partagee_courante).mutex))
721: != 0)
722: {
723: (*s_etat_processus).erreur_systeme = d_es_processus;
724: return;
725: }
726: }
727:
728: (*s_etat_processus).erreur_systeme
729: = d_es_allocation_memoire;
730: return;
731: }
732:
733: (*((real8 *) (*s_objet_resultat).objet)) =
734: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
735: .tableau)[indice_i - 1];
736: }
737: else
738: {
739: /*
740: * Vecteur de complexes
741: */
742:
743: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
744: == NULL)
745: {
746: if (variable_partagee == d_vrai)
747: {
748: if (pthread_mutex_unlock(&((*(*s_etat_processus)
749: .pointeur_variable_partagee_courante).mutex))
750: != 0)
751: {
752: (*s_etat_processus).erreur_systeme = d_es_processus;
753: return;
754: }
755: }
756:
757: (*s_etat_processus).erreur_systeme
758: = d_es_allocation_memoire;
759: return;
760: }
761:
762: (*((struct_complexe16 *) (*s_objet_resultat).objet))
763: .partie_reelle = ((struct_complexe16 *)
764: (*((struct_vecteur *) (*s_objet_3).objet))
765: .tableau)[indice_i - 1].partie_reelle;
766: (*((struct_complexe16 *) (*s_objet_resultat).objet))
767: .partie_imaginaire = ((struct_complexe16 *)
768: (*((struct_vecteur *) (*s_objet_3).objet)).tableau)
769: [indice_i - 1].partie_imaginaire;
770: }
771: }
772: else if (((*s_objet_3).type == MIN) ||
773: ((*s_objet_3).type == MRL) ||
774: ((*s_objet_3).type == MCX))
775: {
776: if ((*s_objet_1).type != LST)
777: {
778: if (variable_partagee == d_vrai)
779: {
780: if (pthread_mutex_unlock(&((*(*s_etat_processus)
781: .pointeur_variable_partagee_courante).mutex)) != 0)
782: {
783: (*s_etat_processus).erreur_systeme = d_es_processus;
784: return;
785: }
786: }
787:
788: liberation(s_etat_processus, s_objet_1);
789: liberation(s_etat_processus, s_objet_2);
790:
791: (*s_etat_processus).erreur_execution =
792: d_ex_erreur_type_argument;
793: return;
794: }
795:
796: l_element_courant = (*s_objet_1).objet;
797: nombre_dimensions = 0;
798:
799: while(l_element_courant != NULL)
800: {
801: nombre_dimensions++;
802: l_element_courant = (*l_element_courant).suivant;
803: }
804:
805: if (nombre_dimensions != 2)
806: {
807: if (variable_partagee == d_vrai)
808: {
809: if (pthread_mutex_unlock(&((*(*s_etat_processus)
810: .pointeur_variable_partagee_courante).mutex)) != 0)
811: {
812: (*s_etat_processus).erreur_systeme = d_es_processus;
813: return;
814: }
815: }
816:
817: liberation(s_etat_processus, s_objet_1);
818: liberation(s_etat_processus, s_objet_2);
819:
820: (*s_etat_processus).erreur_execution =
821: d_ex_dimensions_invalides;
822: return;
823: }
824:
825: l_element_courant = (*s_objet_1).objet;
826:
827: indice_i = 0;
828: indice_j = 0;
829:
830: while(l_element_courant != NULL)
831: {
832: if ((*(*l_element_courant).donnee).type != INT)
833: {
834: if (variable_partagee == d_vrai)
835: {
836: if (pthread_mutex_unlock(&((*(*s_etat_processus)
837: .pointeur_variable_partagee_courante).mutex))
838: != 0)
839: {
840: (*s_etat_processus).erreur_systeme = d_es_processus;
841: return;
842: }
843: }
844:
845: liberation(s_etat_processus, s_objet_1);
846: liberation(s_etat_processus, s_objet_2);
847:
848: (*s_etat_processus).erreur_execution =
849: d_ex_erreur_type_argument;
850: return;
851: }
852:
853: if ((*((integer8 *) (*(*l_element_courant)
854: .donnee).objet)) <= 0)
855: {
856: if (variable_partagee == d_vrai)
857: {
858: if (pthread_mutex_unlock(&((*(*s_etat_processus)
859: .pointeur_variable_partagee_courante).mutex))
860: != 0)
861: {
862: (*s_etat_processus).erreur_systeme = d_es_processus;
863: return;
864: }
865: }
866:
867: liberation(s_etat_processus, s_objet_1);
868: liberation(s_etat_processus, s_objet_2);
869:
870: (*s_etat_processus).erreur_execution =
871: d_ex_argument_invalide;
872: return;
873: }
874:
875: if (indice_i == 0)
876: {
877: indice_i = (*((integer8 *)
878: (*(*l_element_courant).donnee).objet));
879: }
880: else
881: {
882: indice_j = (*((integer8 *)
883: (*(*l_element_courant).donnee).objet));
884: }
885:
886: l_element_courant = (*l_element_courant).suivant;
887: }
888:
889: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
890: .nombre_lignes) || (indice_j > (*((struct_matrice *)
891: (*s_objet_3).objet)).nombre_colonnes))
892: {
893: if (variable_partagee == d_vrai)
894: {
895: if (pthread_mutex_unlock(&((*(*s_etat_processus)
896: .pointeur_variable_partagee_courante).mutex)) != 0)
897: {
898: (*s_etat_processus).erreur_systeme = d_es_processus;
899: return;
900: }
901: }
902:
903: liberation(s_etat_processus, s_objet_1);
904: liberation(s_etat_processus, s_objet_2);
905:
906: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
907: return;
908: }
909:
910: if ((*s_objet_3).type == MIN)
911: {
912: /*
913: * Matrice d'entiers
914: */
915:
916: if ((s_objet_resultat = allocation(s_etat_processus, INT))
917: == NULL)
918: {
919: if (variable_partagee == d_vrai)
920: {
921: if (pthread_mutex_unlock(&((*(*s_etat_processus)
922: .pointeur_variable_partagee_courante).mutex))
923: != 0)
924: {
925: (*s_etat_processus).erreur_systeme = d_es_processus;
926: return;
927: }
928: }
929:
930: (*s_etat_processus).erreur_systeme =
931: d_es_allocation_memoire;
932: return;
933: }
934:
935: (*((integer8 *) (*s_objet_resultat).objet)) =
936: ((integer8 **) (*((struct_matrice *)
937: (*s_objet_3).objet))
938: .tableau)[indice_i - 1][indice_j - 1];
939: }
940: else if ((*s_objet_3).type == MRL)
941: {
942: /*
943: * Matrice de réels
944: */
945:
946: if ((s_objet_resultat = allocation(s_etat_processus, REL))
947: == NULL)
948: {
949: if (variable_partagee == d_vrai)
950: {
951: if (pthread_mutex_unlock(&((*(*s_etat_processus)
952: .pointeur_variable_partagee_courante).mutex))
953: != 0)
954: {
955: (*s_etat_processus).erreur_systeme = d_es_processus;
956: return;
957: }
958: }
959:
960: (*s_etat_processus).erreur_systeme =
961: d_es_allocation_memoire;
962: return;
963: }
964:
965: (*((real8 *) (*s_objet_resultat).objet)) =
966: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
967: .tableau)[indice_i - 1][indice_j - 1];
968: }
969: else
970: {
971: /*
972: * Matrices de complexes
973: */
974:
975: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
976: == NULL)
977: {
978: if (variable_partagee == d_vrai)
979: {
980: if (pthread_mutex_unlock(&((*(*s_etat_processus)
981: .pointeur_variable_partagee_courante).mutex))
982: != 0)
983: {
984: (*s_etat_processus).erreur_systeme = d_es_processus;
985: return;
986: }
987: }
988:
989: (*s_etat_processus).erreur_systeme =
990: d_es_allocation_memoire;
991: return;
992: }
993:
994: (*((struct_complexe16 *) (*s_objet_resultat).objet))
995: .partie_reelle = ((struct_complexe16 **)
996: (*((struct_matrice *)
997: (*s_objet_3).objet)).tableau)[indice_i - 1]
998: [indice_j - 1].partie_reelle;
999: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1000: .partie_imaginaire = ((struct_complexe16 **)
1001: (*((struct_matrice *) (*s_objet_3).objet)).tableau)
1002: [indice_i - 1][indice_j - 1].partie_imaginaire;
1003: }
1004: }
1005: else if ((*s_objet_3).type == LST)
1006: {
1007: if ((*s_objet_1).type != INT)
1008: {
1009: if (variable_partagee == d_vrai)
1010: {
1011: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1012: .pointeur_variable_partagee_courante).mutex)) != 0)
1013: {
1014: (*s_etat_processus).erreur_systeme = d_es_processus;
1015: return;
1016: }
1017: }
1018:
1019: liberation(s_etat_processus, s_objet_1);
1020: liberation(s_etat_processus, s_objet_2);
1021:
1022: (*s_etat_processus).erreur_execution =
1023: d_ex_erreur_type_argument;
1024: return;
1025: }
1026:
1027: indice_i = (*((integer8 *) (*s_objet_1).objet));
1028: indice_j = 1;
1029:
1030: l_element_courant = (*s_objet_3).objet;
1031:
1032: while((l_element_courant != NULL) && (indice_j != indice_i))
1033: {
1034: l_element_courant = (*l_element_courant).suivant;
1035: indice_j++;
1036: }
1037:
1038: if (l_element_courant != NULL)
1039: {
1040: if ((s_objet_resultat = copie_objet(s_etat_processus,
1041: (*l_element_courant).donnee, 'P')) == NULL)
1042: {
1043: if (variable_partagee == d_vrai)
1044: {
1045: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1046: .pointeur_variable_partagee_courante).mutex))
1047: != 0)
1048: {
1049: (*s_etat_processus).erreur_systeme = d_es_processus;
1050: return;
1051: }
1052: }
1053:
1054: (*s_etat_processus).erreur_systeme =
1055: d_es_allocation_memoire;
1056: return;
1057: }
1058: }
1059: else
1060: {
1061: if (variable_partagee == d_vrai)
1062: {
1063: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1064: .pointeur_variable_partagee_courante).mutex)) != 0)
1065: {
1066: (*s_etat_processus).erreur_systeme = d_es_processus;
1067: return;
1068: }
1069: }
1070:
1071: liberation(s_etat_processus, s_objet_1);
1072: liberation(s_etat_processus, s_objet_2);
1073:
1074: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1075: return;
1076: }
1077: }
1078: else if ((*s_objet_3).type == TBL)
1079: {
1080: if ((*s_objet_1).type != LST)
1081: {
1082: if (variable_partagee == d_vrai)
1083: {
1084: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1085: .pointeur_variable_partagee_courante).mutex)) != 0)
1086: {
1087: (*s_etat_processus).erreur_systeme = d_es_processus;
1088: return;
1089: }
1090: }
1091:
1092: liberation(s_etat_processus, s_objet_1);
1093: liberation(s_etat_processus, s_objet_2);
1094:
1095: (*s_etat_processus).erreur_execution =
1096: d_ex_erreur_type_argument;
1097: return;
1098: }
1099:
1100: l_element_courant = (*s_objet_1).objet;
1101: s_objet_element = s_objet_3;
1102:
1103: while(l_element_courant != NULL)
1104: {
1105: if ((*(*l_element_courant).donnee).type != INT)
1106: {
1107: if (variable_partagee == d_vrai)
1108: {
1109: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1110: .pointeur_variable_partagee_courante).mutex))
1111: != 0)
1112: {
1113: (*s_etat_processus).erreur_systeme = d_es_processus;
1114: return;
1115: }
1116: }
1117:
1118: liberation(s_etat_processus, s_objet_1);
1119: liberation(s_etat_processus, s_objet_2);
1120:
1121: (*s_etat_processus).erreur_execution =
1122: d_ex_erreur_type_argument;
1123: return;
1124: }
1125:
1126: if ((*s_objet_element).type != TBL)
1127: {
1128: if (variable_partagee == d_vrai)
1129: {
1130: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1131: .pointeur_variable_partagee_courante).mutex))
1132: != 0)
1133: {
1134: (*s_etat_processus).erreur_systeme = d_es_processus;
1135: return;
1136: }
1137: }
1138:
1139: liberation(s_etat_processus, s_objet_1);
1140: liberation(s_etat_processus, s_objet_2);
1141:
1142: (*s_etat_processus).erreur_execution =
1143: d_ex_element_inexistant;
1144: return;
1145: }
1146:
1147: indice_i = (*((integer8 *) (*(*l_element_courant)
1148: .donnee).objet));
1149:
1150: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
1151: (*s_objet_element).objet)).nombre_elements))
1152: {
1153: if (variable_partagee == d_vrai)
1154: {
1155: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1156: .pointeur_variable_partagee_courante).mutex))
1157: != 0)
1158: {
1159: (*s_etat_processus).erreur_systeme = d_es_processus;
1160: return;
1161: }
1162: }
1163:
1164: liberation(s_etat_processus, s_objet_1);
1165: liberation(s_etat_processus, s_objet_2);
1166:
1167: (*s_etat_processus).erreur_execution =
1168: d_ex_element_inexistant;
1169: return;
1170: }
1171:
1172: s_objet_element = (*((struct_tableau *) (*s_objet_element)
1173: .objet)).elements[indice_i - 1];
1174: l_element_courant = (*l_element_courant).suivant;
1175: }
1176:
1177: if ((s_objet_resultat = copie_objet(s_etat_processus,
1178: s_objet_element, 'P')) == NULL)
1179: {
1180: if (variable_partagee == d_vrai)
1181: {
1182: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1183: .pointeur_variable_partagee_courante).mutex)) != 0)
1184: {
1185: (*s_etat_processus).erreur_systeme = d_es_processus;
1186: return;
1187: }
1188: }
1189:
1190: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1191: return;
1192: }
1193: }
1194: else
1195: {
1196: if (variable_partagee == d_vrai)
1197: {
1198: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1199: .pointeur_variable_partagee_courante).mutex)) != 0)
1200: {
1201: (*s_etat_processus).erreur_systeme = d_es_processus;
1202: return;
1203: }
1204: }
1205:
1206: liberation(s_etat_processus, s_objet_1);
1207: liberation(s_etat_processus, s_objet_2);
1208:
1209: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1210: return;
1211: }
1212:
1213: if (variable_partagee == d_vrai)
1214: {
1215: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1216: .pointeur_variable_partagee_courante).mutex)) != 0)
1217: {
1218: (*s_etat_processus).erreur_systeme = d_es_processus;
1219: return;
1220: }
1221: }
1222: }
1223:
1224: /*
1225: --------------------------------------------------------------------------------
1226: Type incompatible avec la fonction GET
1227: --------------------------------------------------------------------------------
1228: */
1229:
1230: else
1231: {
1232: liberation(s_etat_processus, s_objet_1);
1233: liberation(s_etat_processus, s_objet_2);
1234:
1235: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1236: return;
1237: }
1238:
1239: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1240: s_objet_resultat) == d_erreur)
1241: {
1242: return;
1243: }
1244:
1245: liberation(s_etat_processus, s_objet_1);
1246: liberation(s_etat_processus, s_objet_2);
1247:
1248: return;
1249: }
1250:
1251:
1252: /*
1253: ================================================================================
1254: Fonction 'geti'
1255: ================================================================================
1256: Entrées :
1257: --------------------------------------------------------------------------------
1258: Sorties :
1259: --------------------------------------------------------------------------------
1260: Effets de bord : néant
1261: ================================================================================
1262: */
1263:
1264: void
1265: instruction_geti(struct_processus *s_etat_processus)
1266: {
1267: logical1 variable_partagee;
1268:
1269: struct_liste_chainee *l_element_courant;
1270:
1271: struct_objet *s_copie_1;
1272: struct_objet *s_objet_1;
1273: struct_objet *s_objet_2;
1274: struct_objet *s_objet_3;
1275: struct_objet *s_objet_resultat;
1276:
1277: unsigned long indice_i;
1278: unsigned long indice_j;
1279: unsigned long nombre_dimensions;
1280: unsigned long nombre_elements;
1281:
1282: (*s_etat_processus).erreur_execution = d_ex;
1283:
1284: if ((*s_etat_processus).affichage_arguments == 'Y')
1285: {
1286: printf("\n GETI ");
1287:
1288: if ((*s_etat_processus).langue == 'F')
1289: {
1290: printf("(prend un élément)\n\n");
1291: }
1292: else
1293: {
1294: printf("(get element)\n\n");
1295: }
1296:
1297: printf(" 2: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
1298: printf(" 1: %s\n", d_LST);
1299: printf("-> 3: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
1300: printf(" 2: %s\n", d_LST);
1301: printf(" 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
1302:
1303: printf(" 2: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
1304: printf(" 1: %s\n", d_LST);
1305: printf("-> 3: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
1306: printf(" 2: %s\n", d_LST);
1307: printf(" 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
1308:
1309: printf(" 2: %s, %s\n", d_LST, d_NOM);
1310: printf(" 1: %s\n", d_INT);
1311: printf("-> 3: %s, %s\n", d_LST, d_NOM);
1312: printf(" 2: %s\n", d_INT);
1313: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
1314: " %s, %s, %s, %s, %s,\n"
1315: " %s, %s, %s, %s, %s,\n"
1316: " %s, %s, %s, %s,\n"
1317: " %s, %s\n",
1318: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
1319: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
1320: d_SQL, d_SLB, d_PRC, d_MTX);
1321:
1322: return;
1323: }
1324: else if ((*s_etat_processus).test_instruction == 'Y')
1325: {
1326: (*s_etat_processus).nombre_arguments = -1;
1327: return;
1328: }
1329:
1330: if (test_cfsf(s_etat_processus, 31) == d_vrai)
1331: {
1332: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
1333: {
1334: return;
1335: }
1336: }
1337:
1338: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1339: &s_objet_1) == d_erreur)
1340: {
1341: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1342: return;
1343: }
1344:
1345: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1346: &s_objet_2) == d_erreur)
1347: {
1348: liberation(s_etat_processus, s_objet_1);
1349:
1350: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1351: return;
1352: }
1353:
1354: if ((s_copie_1 = copie_objet(s_etat_processus, s_objet_1, 'O')) == NULL)
1355: {
1356: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1357: return;
1358: }
1359:
1360: liberation(s_etat_processus, s_objet_1);
1361: s_objet_1 = s_copie_1;
1362:
1363: /*
1364: --------------------------------------------------------------------------------
1365: Traitement des éléments des vecteurs
1366: --------------------------------------------------------------------------------
1367: */
1368:
1369: if (((*s_objet_2).type == VIN) ||
1370: ((*s_objet_2).type == VRL) ||
1371: ((*s_objet_2).type == VCX))
1372: {
1373: if ((*s_objet_1).type != LST)
1374: {
1375: liberation(s_etat_processus, s_objet_1);
1376: liberation(s_etat_processus, s_objet_2);
1377:
1378: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1379: return;
1380: }
1381:
1382: l_element_courant = (*s_objet_1).objet;
1383: nombre_dimensions = 0;
1384:
1385: while(l_element_courant != NULL)
1386: {
1387: nombre_dimensions++;
1388: l_element_courant = (*l_element_courant).suivant;
1389: }
1390:
1391: if (nombre_dimensions != 1)
1392: {
1393: liberation(s_etat_processus, s_objet_1);
1394: liberation(s_etat_processus, s_objet_2);
1395:
1396: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
1397: return;
1398: }
1399:
1400: l_element_courant = (*s_objet_1).objet;
1401:
1402: if ((*(*l_element_courant).donnee).type != INT)
1403: {
1404: liberation(s_etat_processus, s_objet_1);
1405: liberation(s_etat_processus, s_objet_2);
1406:
1407: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1408: return;
1409: }
1410:
1411: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1412: {
1413: liberation(s_etat_processus, s_objet_1);
1414: liberation(s_etat_processus, s_objet_2);
1415:
1416: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1417: return;
1418: }
1419: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
1420: (integer8) (*((struct_vecteur *) (*s_objet_2).objet)).taille)
1421: {
1422: liberation(s_etat_processus, s_objet_1);
1423: liberation(s_etat_processus, s_objet_2);
1424:
1425: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1426: return;
1427: }
1428:
1429: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1430:
1431: if ((*s_objet_2).type == VIN)
1432: {
1433: /*
1434: * Vecteur d'entiers
1435: */
1436:
1437: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1438: == NULL)
1439: {
1440: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1441: return;
1442: }
1443:
1444: (*((integer8 *) (*s_objet_resultat).objet)) =
1445: ((integer8 *) (*((struct_vecteur *) (*s_objet_2).objet))
1446: .tableau)[indice_i - 1];
1447: }
1448: else if ((*s_objet_2).type == VRL)
1449: {
1450: /*
1451: * Vecteur de réels
1452: */
1453:
1454: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1455: == NULL)
1456: {
1457: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1458: return;
1459: }
1460:
1461: (*((real8 *) (*s_objet_resultat).objet)) =
1462: ((real8 *) (*((struct_vecteur *) (*s_objet_2).objet))
1463: .tableau)[indice_i - 1];
1464: }
1465: else
1466: {
1467: /*
1468: * Vecteur de complexes
1469: */
1470:
1471: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
1472: == NULL)
1473: {
1474: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1475: return;
1476: }
1477:
1478: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
1479: ((struct_complexe16 *) (*((struct_vecteur *)
1480: (*s_objet_2).objet)).tableau)[indice_i - 1].partie_reelle;
1481: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1482: .partie_imaginaire = ((struct_complexe16 *)
1483: (*((struct_vecteur *) (*s_objet_2).objet)).tableau)
1484: [indice_i - 1].partie_imaginaire;
1485: }
1486:
1487: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
1488: (indice_i % (*((struct_vecteur *) (*s_objet_2).objet)).taille)
1489: + 1;
1490: }
1491:
1492: /*
1493: --------------------------------------------------------------------------------
1494: Traitement des éléments des matrices
1495: --------------------------------------------------------------------------------
1496: */
1497:
1498: else if (((*s_objet_2).type == MIN) ||
1499: ((*s_objet_2).type == MRL) ||
1500: ((*s_objet_2).type == MCX))
1501: {
1502: if ((*s_objet_1).type != LST)
1503: {
1504: liberation(s_etat_processus, s_objet_1);
1505: liberation(s_etat_processus, s_objet_2);
1506:
1507: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1508: return;
1509: }
1510:
1511: l_element_courant = (*s_objet_1).objet;
1512: nombre_dimensions = 0;
1513:
1514: while(l_element_courant != NULL)
1515: {
1516: nombre_dimensions++;
1517: l_element_courant = (*l_element_courant).suivant;
1518: }
1519:
1520: if (nombre_dimensions != 2)
1521: {
1522: liberation(s_etat_processus, s_objet_1);
1523: liberation(s_etat_processus, s_objet_2);
1524:
1525: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
1526: return;
1527: }
1528:
1529: l_element_courant = (*s_objet_1).objet;
1530:
1531: indice_i = 0;
1532: indice_j = 0;
1533:
1534: while(l_element_courant != NULL)
1535: {
1536: if ((*(*l_element_courant).donnee).type != INT)
1537: {
1538: liberation(s_etat_processus, s_objet_1);
1539: liberation(s_etat_processus, s_objet_2);
1540:
1541: (*s_etat_processus).erreur_execution =
1542: d_ex_erreur_type_argument;
1543: return;
1544: }
1545:
1546: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1547: {
1548: liberation(s_etat_processus, s_objet_1);
1549: liberation(s_etat_processus, s_objet_2);
1550:
1551: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1552: return;
1553: }
1554:
1555: if (indice_i == 0)
1556: {
1557: indice_i = (*((integer8 *)
1558: (*(*l_element_courant).donnee).objet));
1559: }
1560: else
1561: {
1562: indice_j = (*((integer8 *)
1563: (*(*l_element_courant).donnee).objet));
1564: }
1565:
1566: l_element_courant = (*l_element_courant).suivant;
1567: }
1568:
1569: if ((indice_i > (*((struct_matrice *) (*s_objet_2).objet))
1570: .nombre_lignes) || (indice_j > (*((struct_matrice *)
1571: (*s_objet_2).objet)).nombre_colonnes))
1572: {
1573: liberation(s_etat_processus, s_objet_1);
1574: liberation(s_etat_processus, s_objet_2);
1575:
1576: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1577: return;
1578: }
1579:
1580: if ((*s_objet_2).type == MIN)
1581: {
1582: /*
1583: * Matrice d'entiers
1584: */
1585:
1586: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1587: == NULL)
1588: {
1589: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1590: return;
1591: }
1592:
1593: (*((integer8 *) (*s_objet_resultat).objet)) =
1594: ((integer8 **) (*((struct_matrice *) (*s_objet_2).objet))
1595: .tableau)[indice_i - 1][indice_j - 1];
1596: }
1597: else if ((*s_objet_2).type == MRL)
1598: {
1599: /*
1600: * Matrice de réels
1601: */
1602:
1603: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1604: == NULL)
1605: {
1606: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1607: return;
1608: }
1609:
1610: (*((real8 *) (*s_objet_resultat).objet)) =
1611: ((real8 **) (*((struct_matrice *) (*s_objet_2).objet))
1612: .tableau)[indice_i - 1][indice_j - 1];
1613: }
1614: else
1615: {
1616: /*
1617: * Matrices de complexes
1618: */
1619:
1620: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
1621: == NULL)
1622: {
1623: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1624: return;
1625: }
1626:
1627: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
1628: ((struct_complexe16 **) (*((struct_matrice *)
1629: (*s_objet_2).objet)).tableau)[indice_i - 1]
1630: [indice_j - 1].partie_reelle;
1631: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1632: .partie_imaginaire = ((struct_complexe16 **)
1633: (*((struct_matrice *) (*s_objet_2).objet)).tableau)
1634: [indice_i - 1][indice_j - 1].partie_imaginaire;
1635: }
1636:
1637:
1638: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
1639: (*s_objet_1).objet)).suivant).donnee).objet))) >
1640: (integer8) (*((struct_matrice *) (*s_objet_2).objet))
1641: .nombre_colonnes)
1642: {
1643: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_1)
1644: .objet)).suivant).donnee).objet)) = 1;
1645:
1646: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
1647: (*s_objet_1).objet)).donnee).objet))) >
1648: (integer8) (*((struct_matrice *) (*s_objet_2).objet))
1649: .nombre_lignes)
1650: {
1651: (*((integer8 *) (*(*((struct_liste_chainee *)
1652: (*s_objet_1).objet)).donnee).objet)) = 1;
1653: }
1654: }
1655: }
1656:
1657: /*
1658: --------------------------------------------------------------------------------
1659: Traitement des listes
1660: --------------------------------------------------------------------------------
1661: */
1662:
1663: else if ((*s_objet_2).type == LST)
1664: {
1665: if ((*s_objet_1).type != INT)
1666: {
1667: liberation(s_etat_processus, s_objet_1);
1668: liberation(s_etat_processus, s_objet_2);
1669:
1670: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1671: return;
1672: }
1673:
1674: nombre_elements = 0;
1675: l_element_courant = (*s_objet_2).objet;
1676:
1677: while(l_element_courant != NULL)
1678: {
1679: l_element_courant = (*l_element_courant).suivant;
1680: nombre_elements++;
1681: }
1682:
1683: indice_i = (*((integer8 *) (*s_objet_1).objet));
1684: indice_j = 1;
1685: l_element_courant = (*s_objet_2).objet;
1686:
1687: while((l_element_courant != NULL) && (indice_j != indice_i))
1688: {
1689: l_element_courant = (*l_element_courant).suivant;
1690: indice_j++;
1691: }
1692:
1693: if (l_element_courant != NULL)
1694: {
1695: if ((s_objet_resultat = copie_objet(s_etat_processus,
1696: (*l_element_courant).donnee, 'O')) == NULL)
1697: {
1698: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1699: return;
1700: }
1701: }
1702: else
1703: {
1704: liberation(s_etat_processus, s_objet_1);
1705: liberation(s_etat_processus, s_objet_2);
1706:
1707: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1708: return;
1709: }
1710:
1711: (*((integer8 *) (*s_objet_1).objet)) =
1712: (indice_i % nombre_elements) + 1;
1713: }
1714:
1715: /*
1716: --------------------------------------------------------------------------------
1717: Traitement des variables
1718: --------------------------------------------------------------------------------
1719: */
1720:
1721: else if ((*s_objet_2).type == NOM)
1722: {
1723: variable_partagee = d_faux;
1724:
1725: if (recherche_variable(s_etat_processus, (*((struct_nom *)
1726: (*s_objet_2).objet)).nom) == d_faux)
1727: {
1728: (*s_etat_processus).erreur_systeme = d_es;
1729: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
1730:
1731: liberation(s_etat_processus, s_objet_1);
1732: liberation(s_etat_processus, s_objet_2);
1733:
1734: return;
1735: }
1736:
1737: s_objet_3 = (*(*s_etat_processus).pointeur_variable_courante).objet;
1738:
1739: if (s_objet_3 == NULL)
1740: {
1741: if (recherche_variable_partagee(s_etat_processus,
1742: (*(*s_etat_processus).pointeur_variable_courante).nom,
1743: (*(*s_etat_processus).pointeur_variable_courante)
1744: .variable_partagee, (*(*s_etat_processus)
1745: .pointeur_variable_courante).origine) == NULL)
1746: {
1747: (*s_etat_processus).erreur_systeme = d_es;
1748: (*s_etat_processus).erreur_execution =
1749: d_ex_variable_non_definie;
1750:
1751: liberation(s_etat_processus, s_objet_1);
1752: liberation(s_etat_processus, s_objet_2);
1753:
1754: return;
1755: }
1756:
1757: s_objet_3 = (*(*s_etat_processus)
1758: .pointeur_variable_partagee_courante).objet;
1759: variable_partagee = d_vrai;
1760: }
1761:
1762: if (((*s_objet_3).type == VIN) ||
1763: ((*s_objet_3).type == VRL) ||
1764: ((*s_objet_3).type == VCX))
1765: {
1766: if ((*s_objet_1).type != LST)
1767: {
1768: if (variable_partagee == d_vrai)
1769: {
1770: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1771: .pointeur_variable_partagee_courante).mutex)) != 0)
1772: {
1773: (*s_etat_processus).erreur_systeme = d_es_processus;
1774: return;
1775: }
1776: }
1777:
1778: liberation(s_etat_processus, s_objet_1);
1779: liberation(s_etat_processus, s_objet_2);
1780:
1781: (*s_etat_processus).erreur_execution =
1782: d_ex_erreur_type_argument;
1783: return;
1784: }
1785:
1786: l_element_courant = (*s_objet_1).objet;
1787: nombre_dimensions = 0;
1788:
1789: while(l_element_courant != NULL)
1790: {
1791: nombre_dimensions++;
1792: l_element_courant = (*l_element_courant).suivant;
1793: }
1794:
1795: if (nombre_dimensions != 1)
1796: {
1797: if (variable_partagee == d_vrai)
1798: {
1799: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1800: .pointeur_variable_partagee_courante).mutex)) != 0)
1801: {
1802: (*s_etat_processus).erreur_systeme = d_es_processus;
1803: return;
1804: }
1805: }
1806:
1807: liberation(s_etat_processus, s_objet_1);
1808: liberation(s_etat_processus, s_objet_2);
1809:
1810: (*s_etat_processus).erreur_execution =
1811: d_ex_dimensions_invalides;
1812: return;
1813: }
1814:
1815: l_element_courant = (*s_objet_1).objet;
1816:
1817: if ((*(*l_element_courant).donnee).type != INT)
1818: {
1819: if (variable_partagee == d_vrai)
1820: {
1821: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1822: .pointeur_variable_partagee_courante).mutex)) != 0)
1823: {
1824: (*s_etat_processus).erreur_systeme = d_es_processus;
1825: return;
1826: }
1827: }
1828:
1829: liberation(s_etat_processus, s_objet_1);
1830: liberation(s_etat_processus, s_objet_2);
1831:
1832: (*s_etat_processus).erreur_execution =
1833: d_ex_erreur_type_argument;
1834: return;
1835: }
1836:
1837: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1838: {
1839: if (variable_partagee == d_vrai)
1840: {
1841: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1842: .pointeur_variable_partagee_courante).mutex)) != 0)
1843: {
1844: (*s_etat_processus).erreur_systeme = d_es_processus;
1845: return;
1846: }
1847: }
1848:
1849: liberation(s_etat_processus, s_objet_1);
1850: liberation(s_etat_processus, s_objet_2);
1851:
1852: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1853: return;
1854: }
1855: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
1856: (integer8) (*((struct_vecteur *) (*s_objet_3).objet))
1857: .taille)
1858: {
1859: if (variable_partagee == d_vrai)
1860: {
1861: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1862: .pointeur_variable_partagee_courante).mutex)) != 0)
1863: {
1864: (*s_etat_processus).erreur_systeme = d_es_processus;
1865: return;
1866: }
1867: }
1868:
1869: liberation(s_etat_processus, s_objet_1);
1870: liberation(s_etat_processus, s_objet_2);
1871:
1872: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1873: return;
1874: }
1875:
1876: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1877:
1878: if ((*s_objet_3).type == VIN)
1879: {
1880: /*
1881: * Vecteur d'entiers
1882: */
1883:
1884: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1885: == NULL)
1886: {
1887: if (variable_partagee == d_vrai)
1888: {
1889: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1890: .pointeur_variable_partagee_courante).mutex))
1891: != 0)
1892: {
1893: (*s_etat_processus).erreur_systeme = d_es_processus;
1894: return;
1895: }
1896: }
1897:
1898: (*s_etat_processus).erreur_systeme
1899: = d_es_allocation_memoire;
1900: return;
1901: }
1902:
1903: (*((integer8 *) (*s_objet_resultat).objet)) =
1904: ((integer8 *) (*((struct_vecteur *)
1905: (*s_objet_3).objet)).tableau)[indice_i - 1];
1906: }
1907: else if ((*s_objet_3).type == VRL)
1908: {
1909: /*
1910: * Vecteur de réels
1911: */
1912:
1913: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1914: == NULL)
1915: {
1916: if (variable_partagee == d_vrai)
1917: {
1918: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1919: .pointeur_variable_partagee_courante).mutex))
1920: != 0)
1921: {
1922: (*s_etat_processus).erreur_systeme = d_es_processus;
1923: return;
1924: }
1925: }
1926:
1927: (*s_etat_processus).erreur_systeme
1928: = d_es_allocation_memoire;
1929: return;
1930: }
1931:
1932: (*((real8 *) (*s_objet_resultat).objet)) =
1933: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
1934: .tableau)[indice_i - 1];
1935: }
1936: else
1937: {
1938: /*
1939: * Vecteur de complexes
1940: */
1941:
1942: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
1943: == NULL)
1944: {
1945: if (variable_partagee == d_vrai)
1946: {
1947: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1948: .pointeur_variable_partagee_courante).mutex))
1949: != 0)
1950: {
1951: (*s_etat_processus).erreur_systeme = d_es_processus;
1952: return;
1953: }
1954: }
1955:
1956: (*s_etat_processus).erreur_systeme
1957: = d_es_allocation_memoire;
1958: return;
1959: }
1960:
1961: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1962: .partie_reelle = ((struct_complexe16 *)
1963: (*((struct_vecteur *) (*s_objet_3).objet))
1964: .tableau)[indice_i - 1].partie_reelle;
1965: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1966: .partie_imaginaire = ((struct_complexe16 *)
1967: (*((struct_vecteur *) (*s_objet_3).objet)).tableau)
1968: [indice_i - 1].partie_imaginaire;
1969: }
1970:
1971: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
1972: (indice_i % (*((struct_vecteur *) (*s_objet_3).objet))
1973: .taille) + 1;
1974: }
1975: else if (((*s_objet_3).type == MIN) ||
1976: ((*s_objet_3).type == MRL) ||
1977: ((*s_objet_3).type == MCX))
1978: {
1979: if ((*s_objet_1).type != LST)
1980: {
1981: if (variable_partagee == d_vrai)
1982: {
1983: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1984: .pointeur_variable_partagee_courante).mutex)) != 0)
1985: {
1986: (*s_etat_processus).erreur_systeme = d_es_processus;
1987: return;
1988: }
1989: }
1990:
1991: liberation(s_etat_processus, s_objet_1);
1992: liberation(s_etat_processus, s_objet_2);
1993:
1994: (*s_etat_processus).erreur_execution =
1995: d_ex_erreur_type_argument;
1996: return;
1997: }
1998:
1999: l_element_courant = (*s_objet_1).objet;
2000: nombre_dimensions = 0;
2001:
2002: while(l_element_courant != NULL)
2003: {
2004: nombre_dimensions++;
2005: l_element_courant = (*l_element_courant).suivant;
2006: }
2007:
2008: if (nombre_dimensions != 2)
2009: {
2010: if (variable_partagee == d_vrai)
2011: {
2012: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2013: .pointeur_variable_partagee_courante).mutex)) != 0)
2014: {
2015: (*s_etat_processus).erreur_systeme = d_es_processus;
2016: return;
2017: }
2018: }
2019:
2020: liberation(s_etat_processus, s_objet_1);
2021: liberation(s_etat_processus, s_objet_2);
2022:
2023: (*s_etat_processus).erreur_execution =
2024: d_ex_dimensions_invalides;
2025: return;
2026: }
2027:
2028: l_element_courant = (*s_objet_1).objet;
2029:
2030: indice_i = 0;
2031: indice_j = 0;
2032:
2033: while(l_element_courant != NULL)
2034: {
2035: if ((*(*l_element_courant).donnee).type != INT)
2036: {
2037: if (variable_partagee == d_vrai)
2038: {
2039: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2040: .pointeur_variable_partagee_courante).mutex))
2041: != 0)
2042: {
2043: (*s_etat_processus).erreur_systeme = d_es_processus;
2044: return;
2045: }
2046: }
2047:
2048: liberation(s_etat_processus, s_objet_1);
2049: liberation(s_etat_processus, s_objet_2);
2050:
2051: (*s_etat_processus).erreur_execution =
2052: d_ex_erreur_type_argument;
2053: return;
2054: }
2055:
2056: if ((*((integer8 *) (*(*l_element_courant)
2057: .donnee).objet)) <= 0)
2058: {
2059: if (variable_partagee == d_vrai)
2060: {
2061: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2062: .pointeur_variable_partagee_courante).mutex))
2063: != 0)
2064: {
2065: (*s_etat_processus).erreur_systeme = d_es_processus;
2066: return;
2067: }
2068: }
2069:
2070: liberation(s_etat_processus, s_objet_1);
2071: liberation(s_etat_processus, s_objet_2);
2072:
2073: (*s_etat_processus).erreur_execution =
2074: d_ex_argument_invalide;
2075: return;
2076: }
2077:
2078: if (indice_i == 0)
2079: {
2080: indice_i = (*((integer8 *)
2081: (*(*l_element_courant).donnee).objet));
2082: }
2083: else
2084: {
2085: indice_j = (*((integer8 *)
2086: (*(*l_element_courant).donnee).objet));
2087: }
2088:
2089: l_element_courant = (*l_element_courant).suivant;
2090: }
2091:
2092: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
2093: .nombre_lignes) || (indice_j > (*((struct_matrice *)
2094: (*s_objet_3).objet)).nombre_colonnes))
2095: {
2096: if (variable_partagee == d_vrai)
2097: {
2098: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2099: .pointeur_variable_partagee_courante).mutex)) != 0)
2100: {
2101: (*s_etat_processus).erreur_systeme = d_es_processus;
2102: return;
2103: }
2104: }
2105:
2106: liberation(s_etat_processus, s_objet_1);
2107: liberation(s_etat_processus, s_objet_2);
2108:
2109: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2110: return;
2111: }
2112:
2113: if ((*s_objet_3).type == MIN)
2114: {
2115: /*
2116: * Matrice d'entiers
2117: */
2118:
2119: if ((s_objet_resultat = allocation(s_etat_processus, INT))
2120: == NULL)
2121: {
2122: if (variable_partagee == d_vrai)
2123: {
2124: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2125: .pointeur_variable_partagee_courante).mutex))
2126: != 0)
2127: {
2128: (*s_etat_processus).erreur_systeme = d_es_processus;
2129: return;
2130: }
2131: }
2132:
2133: (*s_etat_processus).erreur_systeme =
2134: d_es_allocation_memoire;
2135: return;
2136: }
2137:
2138: (*((integer8 *) (*s_objet_resultat).objet)) =
2139: ((integer8 **) (*((struct_matrice *)
2140: (*s_objet_3).objet))
2141: .tableau)[indice_i - 1][indice_j - 1];
2142: }
2143: else if ((*s_objet_3).type == MRL)
2144: {
2145: /*
2146: * Matrice de réels
2147: */
2148:
2149: if ((s_objet_resultat = allocation(s_etat_processus, REL))
2150: == NULL)
2151: {
2152: if (variable_partagee == d_vrai)
2153: {
2154: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2155: .pointeur_variable_partagee_courante).mutex))
2156: != 0)
2157: {
2158: (*s_etat_processus).erreur_systeme = d_es_processus;
2159: return;
2160: }
2161: }
2162:
2163: (*s_etat_processus).erreur_systeme =
2164: d_es_allocation_memoire;
2165: return;
2166: }
2167:
2168: (*((real8 *) (*s_objet_resultat).objet)) =
2169: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
2170: .tableau)[indice_i - 1][indice_j - 1];
2171: }
2172: else
2173: {
2174: /*
2175: * Matrices de complexes
2176: */
2177:
2178: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
2179: == NULL)
2180: {
2181: if (variable_partagee == d_vrai)
2182: {
2183: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2184: .pointeur_variable_partagee_courante).mutex))
2185: != 0)
2186: {
2187: (*s_etat_processus).erreur_systeme = d_es_processus;
2188: return;
2189: }
2190: }
2191:
2192: (*s_etat_processus).erreur_systeme =
2193: d_es_allocation_memoire;
2194: return;
2195: }
2196:
2197: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2198: .partie_reelle = ((struct_complexe16 **)
2199: (*((struct_matrice *)
2200: (*s_objet_3).objet)).tableau)[indice_i - 1]
2201: [indice_j - 1].partie_reelle;
2202: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2203: .partie_imaginaire = ((struct_complexe16 **)
2204: (*((struct_matrice *) (*s_objet_3).objet)).tableau)
2205: [indice_i - 1][indice_j - 1].partie_imaginaire;
2206: }
2207:
2208: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
2209: (*s_objet_1).objet)).suivant).donnee).objet))) >
2210: (integer8) (*((struct_matrice *) (*s_objet_3).objet))
2211: .nombre_colonnes)
2212: {
2213: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_1)
2214: .objet)).suivant).donnee).objet)) = 1;
2215:
2216: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
2217: (*s_objet_1).objet)).donnee).objet))) >
2218: (integer8) (*((struct_matrice *) (*s_objet_3).objet))
2219: .nombre_lignes)
2220: {
2221: (*((integer8 *) (*(*((struct_liste_chainee *)
2222: (*s_objet_1).objet)).donnee).objet)) = 1;
2223: }
2224: }
2225: }
2226: else if ((*s_objet_3).type == LST)
2227: {
2228: if ((*s_objet_1).type != INT)
2229: {
2230: if (variable_partagee == d_vrai)
2231: {
2232: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2233: .pointeur_variable_partagee_courante).mutex)) != 0)
2234: {
2235: (*s_etat_processus).erreur_systeme = d_es_processus;
2236: return;
2237: }
2238: }
2239:
2240: liberation(s_etat_processus, s_objet_1);
2241: liberation(s_etat_processus, s_objet_2);
2242:
2243: (*s_etat_processus).erreur_execution =
2244: d_ex_erreur_type_argument;
2245: return;
2246: }
2247:
2248: nombre_elements = 0;
2249: l_element_courant = (*s_objet_3).objet;
2250:
2251: while(l_element_courant != NULL)
2252: {
2253: l_element_courant = (*l_element_courant).suivant;
2254: nombre_elements++;
2255: }
2256:
2257: indice_i = (*((integer8 *) (*s_objet_1).objet));
2258: indice_j = 1;
2259: l_element_courant = (*s_objet_3).objet;
2260:
2261: while((l_element_courant != NULL) && (indice_j != indice_i))
2262: {
2263: l_element_courant = (*l_element_courant).suivant;
2264: indice_j++;
2265: }
2266:
2267: if (l_element_courant != NULL)
2268: {
2269: if ((s_objet_resultat = copie_objet(s_etat_processus,
2270: (*l_element_courant).donnee, 'O')) == NULL)
2271: {
2272: if (variable_partagee == d_vrai)
2273: {
2274: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2275: .pointeur_variable_partagee_courante).mutex))
2276: != 0)
2277: {
2278: (*s_etat_processus).erreur_systeme = d_es_processus;
2279: return;
2280: }
2281: }
2282:
2283: (*s_etat_processus).erreur_systeme =
2284: d_es_allocation_memoire;
2285: return;
2286: }
2287: }
2288: else
2289: {
2290: if (variable_partagee == d_vrai)
2291: {
2292: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2293: .pointeur_variable_partagee_courante).mutex)) != 0)
2294: {
2295: (*s_etat_processus).erreur_systeme = d_es_processus;
2296: return;
2297: }
2298: }
2299:
2300: liberation(s_etat_processus, s_objet_1);
2301: liberation(s_etat_processus, s_objet_2);
2302:
2303: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2304: return;
2305: }
2306:
2307: (*((integer8 *) (*s_objet_1).objet)) =
2308: (indice_i % nombre_elements) + 1;
2309: }
2310: else
2311: {
2312: if (variable_partagee == d_vrai)
2313: {
2314: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2315: .pointeur_variable_partagee_courante).mutex)) != 0)
2316: {
2317: (*s_etat_processus).erreur_systeme = d_es_processus;
2318: return;
2319: }
2320: }
2321:
2322: liberation(s_etat_processus, s_objet_1);
2323: liberation(s_etat_processus, s_objet_2);
2324:
2325: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2326: return;
2327: }
2328:
2329: if (variable_partagee == d_vrai)
2330: {
2331: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2332: .pointeur_variable_partagee_courante).mutex)) != 0)
2333: {
2334: (*s_etat_processus).erreur_systeme = d_es_processus;
2335: return;
2336: }
2337: }
2338: }
2339:
2340: /*
2341: --------------------------------------------------------------------------------
2342: Type incompatible avec la fonction GETI
2343: --------------------------------------------------------------------------------
2344: */
2345:
2346: else
2347: {
2348: liberation(s_etat_processus, s_objet_1);
2349: liberation(s_etat_processus, s_objet_2);
2350:
2351: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2352: return;
2353: }
2354:
2355: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2356: s_objet_2) == d_erreur)
2357: {
2358: return;
2359: }
2360:
2361: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2362: s_objet_1) == d_erreur)
2363: {
2364: return;
2365: }
2366:
2367: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2368: s_objet_resultat) == d_erreur)
2369: {
2370: return;
2371: }
2372:
2373: return;
2374: }
2375:
2376: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>