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 'p->r'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_p_vers_r(struct_processus *s_etat_processus)
40: {
41: double angle;
42:
43: struct_liste_chainee *l_element_courant;
44: struct_liste_chainee *l_element_precedent;
45:
46: struct_objet *s_copie_argument;
47: struct_objet *s_objet_argument;
48: struct_objet *s_objet_resultat;
49:
50: (*s_etat_processus).erreur_execution = d_ex;
51:
52: if ((*s_etat_processus).affichage_arguments == 'Y')
53: {
54: printf("\n P->R ");
55:
56: if ((*s_etat_processus).langue == 'F')
57: {
58: printf("(coordonnées polaires vers cartésiennes)\n\n");
59: }
60: else
61: {
62: printf("(polar to cartesian coordinates)\n\n");
63: }
64:
65: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
66: printf("-> 1: %s\n\n", d_CPL);
67:
68: printf(" 1: %s, %s\n", d_NOM, d_ALG);
69: printf("-> 1: %s\n\n", d_ALG);
70:
71: printf(" 1: %s\n", d_RPN);
72: printf("-> 1: %s\n", d_RPN);
73:
74: return;
75: }
76: else if ((*s_etat_processus).test_instruction == 'Y')
77: {
78: (*s_etat_processus).nombre_arguments = -1;
79: return;
80: }
81:
82: if (test_cfsf(s_etat_processus, 31) == d_vrai)
83: {
84: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
85: {
86: return;
87: }
88: }
89:
90: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
91: &s_objet_argument) == d_erreur)
92: {
93: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
94: return;
95: }
96:
97: /*
98: --------------------------------------------------------------------------------
99: Conversion d'un entier ou d'un réel
100: --------------------------------------------------------------------------------
101: */
102:
103: if (((*s_objet_argument).type == INT) ||
104: ((*s_objet_argument).type == REL))
105: {
106: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
107: {
108: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
109: return;
110: }
111:
112: if ((*s_objet_argument).type == INT)
113: {
114: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle
115: = (real8) (*((integer8 *) (*s_objet_argument).objet));
116: }
117: else
118: {
119: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle
120: = (*((real8 *) (*s_objet_argument).objet));
121: }
122:
123: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_imaginaire
124: = 0;
125: }
126:
127: /*
128: --------------------------------------------------------------------------------
129: Conversion d'un complexe
130: --------------------------------------------------------------------------------
131: */
132:
133: else if ((*s_objet_argument).type == CPL)
134: {
135: if ((s_objet_resultat = allocation(s_etat_processus, CPL)) == NULL)
136: {
137: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
138: return;
139: }
140:
141: angle = (*((struct_complexe16 *) (*s_objet_argument).objet))
142: .partie_imaginaire;
143:
144: if (test_cfsf(s_etat_processus, 60) == d_faux)
145: {
146: conversion_degres_vers_radians(&angle);
147: }
148:
149: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
150: (*((struct_complexe16 *) (*s_objet_argument).objet))
151: .partie_reelle * cos(angle);
152: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_imaginaire =
153: (*((struct_complexe16 *) (*s_objet_argument).objet))
154: .partie_reelle * sin(angle);
155: }
156:
157: /*
158: --------------------------------------------------------------------------------
159: Conversion d'un nom
160: --------------------------------------------------------------------------------
161: */
162:
163: else if ((*s_objet_argument).type == NOM)
164: {
165: if ((s_objet_resultat = allocation(s_etat_processus, ALG)) == NULL)
166: {
167: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
168: return;
169: }
170:
171: if (((*s_objet_resultat).objet =
172: allocation_maillon(s_etat_processus)) == NULL)
173: {
174: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
175: return;
176: }
177:
178: l_element_courant = (*s_objet_resultat).objet;
179:
180: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
181: == NULL)
182: {
183: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
184: return;
185: }
186:
187: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
188: .nombre_arguments = 0;
189: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
190: .fonction = instruction_vers_niveau_superieur;
191:
192: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
193: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
194: {
195: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
196: return;
197: }
198:
199: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
200: .nom_fonction, "<<");
201:
202: if (((*l_element_courant).suivant =
203: allocation_maillon(s_etat_processus)) == NULL)
204: {
205: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
206: return;
207: }
208:
209: l_element_courant = (*l_element_courant).suivant;
210: (*l_element_courant).donnee = s_objet_argument;
211:
212: if (((*l_element_courant).suivant =
213: allocation_maillon(s_etat_processus)) == NULL)
214: {
215: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
216: return;
217: }
218:
219: l_element_courant = (*l_element_courant).suivant;
220:
221: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
222: == NULL)
223: {
224: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
225: return;
226: }
227:
228: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
229: .nombre_arguments = 1;
230: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
231: .fonction = instruction_p_vers_r;
232:
233: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
234: .nom_fonction = malloc(5 * sizeof(unsigned char))) == NULL)
235: {
236: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
237: return;
238: }
239:
240: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
241: .nom_fonction, "P->R");
242:
243: if (((*l_element_courant).suivant =
244: allocation_maillon(s_etat_processus)) == NULL)
245: {
246: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
247: return;
248: }
249:
250: l_element_courant = (*l_element_courant).suivant;
251:
252: if (((*l_element_courant).donnee = allocation(s_etat_processus, FCT))
253: == NULL)
254: {
255: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
256: return;
257: }
258:
259: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
260: .nombre_arguments = 0;
261: (*((struct_fonction *) (*(*l_element_courant).donnee).objet))
262: .fonction = instruction_vers_niveau_inferieur;
263:
264: if (((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
265: .nom_fonction = malloc(3 * sizeof(unsigned char))) == NULL)
266: {
267: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
268: return;
269: }
270:
271: strcpy((*((struct_fonction *) (*(*l_element_courant).donnee).objet))
272: .nom_fonction, ">>");
273:
274: (*l_element_courant).suivant = NULL;
275: s_objet_argument = NULL;
276: }
277:
278: /*
279: --------------------------------------------------------------------------------
280: Conversion d'une expression
281: --------------------------------------------------------------------------------
282: */
283:
284: else if (((*s_objet_argument).type == ALG) ||
285: ((*s_objet_argument).type == RPN))
286: {
287: if ((s_copie_argument = copie_objet(s_etat_processus, s_objet_argument,
288: 'N')) == NULL)
289: {
290: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
291: return;
292: }
293:
294: l_element_courant = (struct_liste_chainee *)
295: (*s_copie_argument).objet;
296: l_element_precedent = l_element_courant;
297:
298: while((*l_element_courant).suivant != NULL)
299: {
300: l_element_precedent = l_element_courant;
301: l_element_courant = (*l_element_courant).suivant;
302: }
303:
304: if (((*l_element_precedent).suivant =
305: allocation_maillon(s_etat_processus)) == NULL)
306: {
307: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
308: return;
309: }
310:
311: if (((*(*l_element_precedent).suivant).donnee =
312: allocation(s_etat_processus, FCT)) == NULL)
313: {
314: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
315: return;
316: }
317:
318: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
319: .donnee).objet)).nombre_arguments = 1;
320: (*((struct_fonction *) (*(*(*l_element_precedent).suivant)
321: .donnee).objet)).fonction = instruction_p_vers_r;
322:
323: if (((*((struct_fonction *) (*(*(*l_element_precedent)
324: .suivant).donnee).objet)).nom_fonction =
325: malloc(5 * sizeof(unsigned char))) == NULL)
326: {
327: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
328: return;
329: }
330:
331: strcpy((*((struct_fonction *) (*(*(*l_element_precedent)
332: .suivant).donnee).objet)).nom_fonction, "P->R");
333:
334: (*(*l_element_precedent).suivant).suivant = l_element_courant;
335:
336: s_objet_resultat = s_copie_argument;
337: }
338:
339: /*
340: --------------------------------------------------------------------------------
341: Réalisation impossible de la fonction P->R
342: --------------------------------------------------------------------------------
343: */
344:
345: else
346: {
347: liberation(s_etat_processus, s_objet_argument);
348:
349: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
350: return;
351: }
352:
353: liberation(s_etat_processus, s_objet_argument);
354:
355: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
356: s_objet_resultat) == d_erreur)
357: {
358: return;
359: }
360:
361: return;
362: }
363:
364:
365: /*
366: ================================================================================
367: Fonction 'put'
368: ================================================================================
369: Entrées : pointeur sur une structure struct_processus
370: --------------------------------------------------------------------------------
371: Sorties :
372: --------------------------------------------------------------------------------
373: Effets de bord : néant
374: ================================================================================
375: */
376:
377: static int
378: fonction_comparaison(const void *argument_1, const void *argument_2)
379: {
380: return(strcmp((unsigned char *) argument_1,
381: (unsigned char *) (**((struct_objet **) argument_2)).objet));
382: }
383:
384:
385: void
386: instruction_put(struct_processus *s_etat_processus)
387: {
388: logical1 variable_partagee;
389:
390: struct_liste_chainee *l_element_courant;
391:
392: struct_objet *s_copie_3;
393: struct_objet *s_copie_4;
394: struct_objet **s_enregistrement;
395: struct_objet *s_objet_1;
396: struct_objet *s_objet_2;
397: struct_objet *s_objet_3;
398: struct_objet *s_objet_4;
399: struct_objet *s_objet_element;
400:
401: integer8 i;
402: integer8 indice_i;
403: integer8 indice_j;
404: integer8 j;
405: integer8 nombre_dimensions;
406:
407: void *tampon;
408:
409: (*s_etat_processus).erreur_execution = d_ex;
410:
411: if ((*s_etat_processus).affichage_arguments == 'Y')
412: {
413: printf("\n PUT ");
414:
415: if ((*s_etat_processus).langue == 'F')
416: {
417: printf("(change un élément)\n\n");
418: }
419: else
420: {
421: printf("(change element)\n\n");
422: }
423:
424: printf(" 3: %s, %s, %s\n", d_VIN, d_VRL, d_VCX);
425: printf(" 2: %s\n", d_LST);
426: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
427: printf("-> 1: %s, %s, %s\n\n", d_VIN, d_VRL, d_VCX);
428:
429: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
430: printf(" 2: %s\n", d_LST);
431: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
432: printf("-> 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
433:
434: printf(" 3: %s\n", d_LST);
435: printf(" 2: %s\n", d_INT);
436: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
437: " %s, %s, %s, %s, %s,\n"
438: " %s, %s, %s, %s, %s,\n"
439: " %s, %s, %s, %s,\n"
440: " %s, %s, %s\n",
441: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
442: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
443: d_SQL, d_SLB, d_PRC, d_MTX, d_REC);
444: printf("-> 1: %s\n\n", d_LST);
445:
446: printf(" 3: %s\n", d_TAB);
447: printf(" 2: %s\n", d_LST);
448: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
449: " %s, %s, %s, %s, %s,\n"
450: " %s, %s, %s, %s, %s,\n"
451: " %s, %s, %s, %s,\n"
452: " %s, %s, %s\n",
453: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
454: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
455: d_SQL, d_SLB, d_PRC, d_MTX, d_REC);
456: printf("-> 1: %s\n\n", d_TAB);
457:
458: printf(" 3: %s\n", d_REC);
459: printf(" 2: %s\n", d_CHN);
460: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
461: " %s, %s, %s, %s, %s,\n"
462: " %s, %s, %s, %s, %s,\n"
463: " %s, %s, %s, %s,\n"
464: " %s, %s, %s\n",
465: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
466: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
467: d_SQL, d_SLB, d_PRC, d_MTX, d_REC);
468: printf("-> 1: %s\n\n", d_REC);
469:
470: printf(" 3: %s\n", d_NOM);
471: printf(" 2: %s, %s\n", d_LST, d_INT);
472: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
473: " %s, %s, %s, %s, %s,\n"
474: " %s, %s, %s, %s, %s,\n"
475: " %s, %s, %s, %s,\n"
476: " %s, %s, %s\n",
477: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
478: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
479: d_SQL, d_SLB, d_PRC, d_MTX, d_REC);
480:
481: return;
482: }
483: else if ((*s_etat_processus).test_instruction == 'Y')
484: {
485: (*s_etat_processus).nombre_arguments = -1;
486: return;
487: }
488:
489: if (test_cfsf(s_etat_processus, 31) == d_vrai)
490: {
491: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
492: {
493: return;
494: }
495: }
496:
497: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
498: &s_objet_1) == d_erreur)
499: {
500: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
501: return;
502: }
503:
504: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
505: &s_objet_2) == d_erreur)
506: {
507: liberation(s_etat_processus, s_objet_1);
508:
509: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
510: return;
511: }
512:
513: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
514: &s_objet_3) == d_erreur)
515: {
516: liberation(s_etat_processus, s_objet_1);
517: liberation(s_etat_processus, s_objet_2);
518:
519: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
520: return;
521: }
522:
523: /*
524: --------------------------------------------------------------------------------
525: Traitement des éléments des vecteurs
526: --------------------------------------------------------------------------------
527: */
528:
529: if (((*s_objet_3).type == VIN) ||
530: ((*s_objet_3).type == VRL) ||
531: ((*s_objet_3).type == VCX))
532: {
533: if ((*s_objet_2).type != LST)
534: {
535: liberation(s_etat_processus, s_objet_1);
536: liberation(s_etat_processus, s_objet_2);
537: liberation(s_etat_processus, s_objet_3);
538:
539: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
540: return;
541: }
542:
543: l_element_courant = (*s_objet_2).objet;
544: nombre_dimensions = 0;
545:
546: while(l_element_courant != NULL)
547: {
548: nombre_dimensions++;
549: l_element_courant = (*l_element_courant).suivant;
550: }
551:
552: if (nombre_dimensions != 1)
553: {
554: liberation(s_etat_processus, s_objet_1);
555: liberation(s_etat_processus, s_objet_2);
556: liberation(s_etat_processus, s_objet_3);
557:
558: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
559: return;
560: }
561:
562: l_element_courant = (*s_objet_2).objet;
563:
564: if ((*(*l_element_courant).donnee).type != INT)
565: {
566: liberation(s_etat_processus, s_objet_1);
567: liberation(s_etat_processus, s_objet_2);
568: liberation(s_etat_processus, s_objet_3);
569:
570: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
571: return;
572: }
573:
574: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
575: {
576: liberation(s_etat_processus, s_objet_1);
577: liberation(s_etat_processus, s_objet_2);
578: liberation(s_etat_processus, s_objet_3);
579:
580: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
581: return;
582: }
583: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
584: (integer8) (*((struct_vecteur *) (*s_objet_3).objet)).taille)
585: {
586: liberation(s_etat_processus, s_objet_1);
587: liberation(s_etat_processus, s_objet_2);
588: liberation(s_etat_processus, s_objet_3);
589:
590: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
591: return;
592: }
593:
594: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
595:
596: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'Q')) == NULL)
597: {
598: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
599: return;
600: }
601:
602: liberation(s_etat_processus, s_objet_3);
603: s_objet_3 = s_copie_3;
604:
605: if ((*s_objet_3).type == VIN)
606: {
607: /*
608: * Vecteur d'entiers
609: */
610:
611: if ((*s_objet_1).type == INT)
612: {
613: /*
614: * Aucune conversion de type
615: */
616:
617: ((integer8 *) (*((struct_vecteur *) (*s_objet_3).objet))
618: .tableau)[indice_i - 1] = (*((integer8 *)
619: (*s_objet_1).objet));
620: }
621: else if ((*s_objet_1).type == REL)
622: {
623: /*
624: * Conversion du vecteur en vecteur réel
625: */
626:
627: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
628: (*s_objet_3).objet)).tableau);
629:
630: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'R';
631: (*s_objet_3).type = VRL;
632:
633: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
634: = malloc(((size_t) (*((struct_vecteur *)
635: (*s_objet_3).objet)).taille) * sizeof(real8)))
636: == NULL)
637: {
638: (*s_etat_processus).erreur_systeme =
639: d_es_allocation_memoire;
640: return;
641: }
642:
643: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
644: .taille; i++)
645: {
646: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
647: .tableau)[i] = (real8) (((integer8 *) tampon)[i]);
648: }
649:
650: free((integer8 *) tampon);
651:
652: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
653: .tableau)[indice_i - 1] = (*((real8 *)
654: (*s_objet_1).objet));
655: }
656: else if ((*s_objet_1).type == CPL)
657: {
658: /*
659: * Conversion du vecteur en vecteur complexe
660: */
661:
662: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
663: (*s_objet_3).objet)).tableau);
664:
665: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'C';
666: (*s_objet_3).type = VCX;
667:
668: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
669: = malloc(((size_t) (*((struct_vecteur *)
670: (*s_objet_3).objet)).taille) *
671: sizeof(struct_complexe16))) == NULL)
672: {
673: (*s_etat_processus).erreur_systeme =
674: d_es_allocation_memoire;
675: return;
676: }
677:
678: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
679: .taille; i++)
680: {
681: ((struct_complexe16 *) (*((struct_vecteur *)
682: (*s_objet_3).objet)).tableau)[i].partie_reelle =
683: (real8) (((integer8 *) tampon)[i]);
684: ((struct_complexe16 *) (*((struct_vecteur *)
685: (*s_objet_3).objet)).tableau)[i]
686: .partie_imaginaire = (real8) 0;
687: }
688:
689: free((integer8 *) tampon);
690:
691: ((struct_complexe16 *) (*((struct_vecteur *)
692: (*s_objet_3).objet)).tableau)[indice_i - 1]
693: .partie_reelle = (*((struct_complexe16 *)
694: (*s_objet_1).objet)).partie_reelle;
695: ((struct_complexe16 *) (*((struct_vecteur *)
696: (*s_objet_3).objet)).tableau)[indice_i - 1]
697: .partie_imaginaire = (*((struct_complexe16 *)
698: (*s_objet_1).objet)).partie_imaginaire;
699: }
700: else
701: {
702: liberation(s_etat_processus, s_objet_1);
703: liberation(s_etat_processus, s_objet_2);
704: liberation(s_etat_processus, s_objet_3);
705:
706: (*s_etat_processus).erreur_execution =
707: d_ex_erreur_type_argument;
708: return;
709: }
710: }
711: else if ((*s_objet_3).type == VRL)
712: {
713: /*
714: * Vecteur de réels
715: */
716:
717: if ((*s_objet_1).type == INT)
718: {
719: /*
720: * Conversion de l'élément à insérer en réel
721: */
722:
723: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
724: .tableau)[indice_i - 1] = (real8) (*((integer8 *)
725: (*s_objet_1).objet));
726: }
727: else if ((*s_objet_1).type == REL)
728: {
729: /*
730: * Aucune conversion de type
731: */
732:
733: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
734: .tableau)[indice_i - 1] = (*((real8 *)
735: (*s_objet_1).objet));
736: }
737: else if ((*s_objet_1).type == CPL)
738: {
739: /*
740: * Conversion du vecteur en vecteur complexe
741: */
742:
743: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
744: (*s_objet_3).objet)).tableau);
745:
746: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'C';
747: (*s_objet_3).type = VCX;
748:
749: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
750: = malloc(((size_t) (*((struct_vecteur *)
751: (*s_objet_3).objet)).taille) *
752: sizeof(struct_complexe16))) == NULL)
753: {
754: (*s_etat_processus).erreur_systeme =
755: d_es_allocation_memoire;
756: return;
757: }
758:
759: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
760: .taille; i++)
761: {
762: ((struct_complexe16 *) (*((struct_vecteur *)
763: (*s_objet_3).objet)).tableau)[i].partie_reelle =
764: ((real8 *) tampon)[i];
765: ((struct_complexe16 *) (*((struct_vecteur *)
766: (*s_objet_3).objet)).tableau)[i]
767: .partie_imaginaire = (real8) 0;
768: }
769:
770: free((real8 *) tampon);
771:
772: ((struct_complexe16 *) (*((struct_vecteur *)
773: (*s_objet_3).objet)).tableau)[indice_i - 1]
774: .partie_reelle = (*((struct_complexe16 *)
775: (*s_objet_1).objet)).partie_reelle;
776: ((struct_complexe16 *) (*((struct_vecteur *)
777: (*s_objet_3).objet)).tableau)[indice_i - 1]
778: .partie_imaginaire = (*((struct_complexe16 *)
779: (*s_objet_1).objet)).partie_imaginaire;
780: }
781: else
782: {
783: liberation(s_etat_processus, s_objet_1);
784: liberation(s_etat_processus, s_objet_2);
785: liberation(s_etat_processus, s_objet_3);
786:
787: (*s_etat_processus).erreur_execution =
788: d_ex_erreur_type_argument;
789: return;
790: }
791: }
792: else
793: {
794: /*
795: * Vecteur de complexes
796: */
797:
798: if ((*s_objet_1).type == INT)
799: {
800: /*
801: * Conversion de l'élément à insérer en complexe
802: */
803:
804: ((struct_complexe16 *) (*((struct_vecteur *)
805: (*s_objet_3).objet)).tableau)[indice_i - 1]
806: .partie_reelle = (real8) (*((integer8 *)
807: (*s_objet_1).objet));
808: ((struct_complexe16 *) (*((struct_vecteur *)
809: (*s_objet_3).objet)).tableau)[indice_i - 1]
810: .partie_imaginaire = (real8) 0;
811: }
812: else if ((*s_objet_1).type == REL)
813: {
814: /*
815: * Conversion de l'élément à insérer en complexe
816: */
817:
818: ((struct_complexe16 *) (*((struct_vecteur *)
819: (*s_objet_3).objet)).tableau)[indice_i - 1]
820: .partie_reelle = (*((real8 *) (*s_objet_1).objet));
821: ((struct_complexe16 *) (*((struct_vecteur *)
822: (*s_objet_3).objet)).tableau)[indice_i - 1]
823: .partie_imaginaire = (real8) 0;
824: }
825: else if ((*s_objet_1).type == CPL)
826: {
827: /*
828: * Aucune conversion de type
829: */
830:
831: ((struct_complexe16 *) (*((struct_vecteur *)
832: (*s_objet_3).objet)).tableau)[indice_i - 1]
833: .partie_reelle = (*((struct_complexe16 *)
834: (*s_objet_1).objet)).partie_reelle;
835: ((struct_complexe16 *) (*((struct_vecteur *)
836: (*s_objet_3).objet)).tableau)[indice_i - 1]
837: .partie_imaginaire = (*((struct_complexe16 *)
838: (*s_objet_1).objet)).partie_imaginaire;
839: }
840: else
841: {
842: liberation(s_etat_processus, s_objet_1);
843: liberation(s_etat_processus, s_objet_2);
844: liberation(s_etat_processus, s_objet_3);
845:
846: (*s_etat_processus).erreur_execution =
847: d_ex_erreur_type_argument;
848: return;
849: }
850: }
851:
852: liberation(s_etat_processus, s_objet_1);
853: liberation(s_etat_processus, s_objet_2);
854:
855: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
856: s_objet_3) == d_erreur)
857: {
858: return;
859: }
860: }
861:
862: /*
863: --------------------------------------------------------------------------------
864: Traitement des éléments des matrices
865: --------------------------------------------------------------------------------
866: */
867:
868: else if (((*s_objet_3).type == MIN) ||
869: ((*s_objet_3).type == MRL) ||
870: ((*s_objet_3).type == MCX))
871: {
872: if ((*s_objet_2).type != LST)
873: {
874: liberation(s_etat_processus, s_objet_1);
875: liberation(s_etat_processus, s_objet_2);
876: liberation(s_etat_processus, s_objet_3);
877:
878: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
879: return;
880: }
881:
882: l_element_courant = (*s_objet_2).objet;
883: nombre_dimensions = 0;
884:
885: while(l_element_courant != NULL)
886: {
887: nombre_dimensions++;
888: l_element_courant = (*l_element_courant).suivant;
889: }
890:
891: if (nombre_dimensions != 2)
892: {
893: liberation(s_etat_processus, s_objet_1);
894: liberation(s_etat_processus, s_objet_2);
895: liberation(s_etat_processus, s_objet_3);
896:
897: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
898: return;
899: }
900:
901: l_element_courant = (*s_objet_2).objet;
902:
903: indice_i = 0;
904: indice_j = 0;
905:
906: while(l_element_courant != NULL)
907: {
908: if ((*(*l_element_courant).donnee).type != INT)
909: {
910: liberation(s_etat_processus, s_objet_1);
911: liberation(s_etat_processus, s_objet_2);
912: liberation(s_etat_processus, s_objet_3);
913:
914: (*s_etat_processus).erreur_execution =
915: d_ex_erreur_type_argument;
916: return;
917: }
918:
919: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
920: {
921: liberation(s_etat_processus, s_objet_1);
922: liberation(s_etat_processus, s_objet_2);
923: liberation(s_etat_processus, s_objet_3);
924:
925: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
926: return;
927: }
928:
929: if (indice_i == 0)
930: {
931: indice_i = (*((integer8 *)
932: (*(*l_element_courant).donnee).objet));
933: }
934: else
935: {
936: indice_j = (*((integer8 *)
937: (*(*l_element_courant).donnee).objet));
938: }
939:
940: l_element_courant = (*l_element_courant).suivant;
941: }
942:
943: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
944: .nombre_lignes) || (indice_j > (*((struct_matrice *)
945: (*s_objet_3).objet)).nombre_colonnes))
946: {
947: liberation(s_etat_processus, s_objet_1);
948: liberation(s_etat_processus, s_objet_2);
949: liberation(s_etat_processus, s_objet_3);
950:
951: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
952: return;
953: }
954:
955: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'Q')) == NULL)
956: {
957: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
958: return;
959: }
960:
961: liberation(s_etat_processus, s_objet_3);
962: s_objet_3 = s_copie_3;
963:
964: if ((*s_objet_3).type == MIN)
965: {
966: /*
967: * Matrice d'entiers
968: */
969:
970: if ((*s_objet_1).type == INT)
971: {
972: /*
973: * Aucune conversion de type
974: */
975:
976: ((integer8 **) (*((struct_matrice *) (*s_objet_3).objet))
977: .tableau)[indice_i - 1][indice_j - 1] =
978: (*((integer8 *) (*s_objet_1).objet));
979: }
980: else if ((*s_objet_1).type == REL)
981: {
982: /*
983: * Conversion de la matrice en matrice réelle
984: */
985:
986: tampon = (void *) ((integer8 **) (*((struct_matrice *)
987: (*s_objet_3).objet)).tableau);
988:
989: (*((struct_matrice *) (*s_objet_3).objet)).type = 'R';
990: (*s_objet_3).type = MRL;
991:
992: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
993: = malloc(((size_t) (*((struct_matrice *)
994: (*s_objet_3).objet)).nombre_lignes) * sizeof(real8 *)))
995: == NULL)
996: {
997: (*s_etat_processus).erreur_systeme =
998: d_es_allocation_memoire;
999: return;
1000: }
1001:
1002: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
1003: .nombre_lignes; i++)
1004: {
1005: if ((((real8 **) (*((struct_matrice *)
1006: (*s_objet_3).objet)).tableau)[i]
1007: = malloc(((size_t) (*((struct_matrice *)
1008: (*s_objet_3).objet)).nombre_colonnes) *
1009: sizeof(real8))) == NULL)
1010: {
1011: (*s_etat_processus).erreur_systeme =
1012: d_es_allocation_memoire;
1013: return;
1014: }
1015:
1016: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
1017: .nombre_colonnes; j++)
1018: {
1019: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
1020: .tableau)[i][j] = (real8) (((integer8 **)
1021: tampon)[i][j]);
1022: }
1023:
1024: free(((integer8 **) tampon)[i]);
1025: }
1026:
1027: free((integer8 **) tampon);
1028:
1029: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
1030: .tableau)[indice_i - 1][indice_j - 1] = (*((real8 *)
1031: (*s_objet_1).objet));
1032: }
1033: else if ((*s_objet_1).type == CPL)
1034: {
1035: /*
1036: * Conversion de la matrice en matrice complexe
1037: */
1038:
1039: tampon = (void *) ((integer8 **) (*((struct_matrice *)
1040: (*s_objet_3).objet)).tableau);
1041:
1042: (*((struct_matrice *) (*s_objet_3).objet)).type = 'C';
1043: (*s_objet_3).type = MCX;
1044:
1045: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
1046: = malloc(((size_t) (*((struct_matrice *)
1047: (*s_objet_3).objet)).nombre_lignes) *
1048: sizeof(struct_complexe16 *))) == NULL)
1049: {
1050: (*s_etat_processus).erreur_systeme =
1051: d_es_allocation_memoire;
1052: return;
1053: }
1054:
1055: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
1056: .nombre_lignes; i++)
1057: {
1058: if ((((struct_complexe16 **) (*((struct_matrice *)
1059: (*s_objet_3).objet)).tableau)[i]
1060: = malloc(((size_t) (*((struct_matrice *)
1061: (*s_objet_3).objet)).nombre_colonnes) *
1062: sizeof(struct_complexe16))) == NULL)
1063: {
1064: (*s_etat_processus).erreur_systeme =
1065: d_es_allocation_memoire;
1066: return;
1067: }
1068:
1069: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
1070: .nombre_colonnes; j++)
1071: {
1072: ((struct_complexe16 **) (*((struct_matrice *)
1073: (*s_objet_3).objet)).tableau)[i][j]
1074: .partie_reelle = (real8) (((integer8 **)
1075: tampon)[i][j]);
1076: ((struct_complexe16 **) (*((struct_matrice *)
1077: (*s_objet_3).objet)).tableau)[i][j]
1078: .partie_imaginaire = (real8) 0;
1079: }
1080:
1081: free(((integer8 **) tampon)[i]);
1082: }
1083:
1084: free((integer8 **) tampon);
1085:
1086: ((struct_complexe16 **) (*((struct_matrice *)
1087: (*s_objet_3).objet)).tableau)[indice_i - 1]
1088: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
1089: (*s_objet_1).objet)).partie_reelle;
1090: ((struct_complexe16 **) (*((struct_matrice *)
1091: (*s_objet_3).objet)).tableau)[indice_i - 1]
1092: [indice_j - 1].partie_imaginaire =
1093: (*((struct_complexe16 *)
1094: (*s_objet_1).objet)).partie_imaginaire;
1095: }
1096: else
1097: {
1098: liberation(s_etat_processus, s_objet_1);
1099: liberation(s_etat_processus, s_objet_2);
1100: liberation(s_etat_processus, s_objet_3);
1101:
1102: (*s_etat_processus).erreur_execution =
1103: d_ex_erreur_type_argument;
1104: return;
1105: }
1106: }
1107: else if ((*s_objet_3).type == MRL)
1108: {
1109: /*
1110: * Matrice de réels
1111: */
1112:
1113: if ((*s_objet_1).type == INT)
1114: {
1115: /*
1116: * Conversion de l'élément à insérer en réel
1117: */
1118:
1119: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
1120: .tableau)[indice_i - 1][indice_j - 1] =
1121: (real8) (*((integer8 *) (*s_objet_1).objet));
1122: }
1123: else if ((*s_objet_1).type == REL)
1124: {
1125: /*
1126: * Aucune conversion de type
1127: */
1128:
1129: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
1130: .tableau)[indice_i - 1][indice_j - 1] = (*((real8 *)
1131: (*s_objet_1).objet));
1132: }
1133: else if ((*s_objet_1).type == CPL)
1134: {
1135: /*
1136: * Conversion de la matrice en matrice complexe
1137: */
1138:
1139: tampon = (void *) ((real8 **) (*((struct_matrice *)
1140: (*s_objet_3).objet)).tableau);
1141:
1142: (*((struct_matrice *) (*s_objet_3).objet)).type = 'C';
1143: (*s_objet_3).type = MCX;
1144:
1145: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
1146: = malloc(((size_t) (*((struct_matrice *)
1147: (*s_objet_3).objet)).nombre_lignes) *
1148: sizeof(struct_complexe16 *))) == NULL)
1149: {
1150: (*s_etat_processus).erreur_systeme =
1151: d_es_allocation_memoire;
1152: return;
1153: }
1154:
1155: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
1156: .nombre_lignes; i++)
1157: {
1158: if ((((struct_complexe16 **) (*((struct_matrice *)
1159: (*s_objet_3).objet)).tableau)[i]
1160: = malloc(((size_t) (*((struct_matrice *)
1161: (*s_objet_3).objet)).nombre_colonnes) *
1162: sizeof(struct_complexe16))) == NULL)
1163: {
1164: (*s_etat_processus).erreur_systeme =
1165: d_es_allocation_memoire;
1166: return;
1167: }
1168:
1169: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
1170: .nombre_colonnes; j++)
1171: {
1172: ((struct_complexe16 **) (*((struct_matrice *)
1173: (*s_objet_3).objet)).tableau)[i][j]
1174: .partie_reelle = (((real8 **)
1175: tampon)[i][j]);
1176: ((struct_complexe16 **) (*((struct_matrice *)
1177: (*s_objet_3).objet)).tableau)[i][j]
1178: .partie_imaginaire = (real8) 0;
1179: }
1180:
1181: free(((integer8 **) tampon)[i]);
1182: }
1183:
1184: free((integer8 **) tampon);
1185:
1186: ((struct_complexe16 **) (*((struct_matrice *)
1187: (*s_objet_3).objet)).tableau)[indice_i - 1]
1188: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
1189: (*s_objet_1).objet)).partie_reelle;
1190: ((struct_complexe16 **) (*((struct_matrice *)
1191: (*s_objet_3).objet)).tableau)[indice_i - 1]
1192: [indice_j - 1].partie_imaginaire =
1193: (*((struct_complexe16 *)
1194: (*s_objet_1).objet)).partie_imaginaire;
1195: }
1196: else
1197: {
1198: liberation(s_etat_processus, s_objet_1);
1199: liberation(s_etat_processus, s_objet_2);
1200: liberation(s_etat_processus, s_objet_3);
1201:
1202: (*s_etat_processus).erreur_execution =
1203: d_ex_erreur_type_argument;
1204: return;
1205: }
1206: }
1207: else
1208: {
1209: /*
1210: * Matrice de complexes
1211: */
1212:
1213: if ((*s_objet_1).type == INT)
1214: {
1215: /*
1216: * Conversion de l'élément à insérer en complexe
1217: */
1218:
1219: ((struct_complexe16 **) (*((struct_matrice *)
1220: (*s_objet_3).objet)).tableau)[indice_i - 1]
1221: [indice_j - 1].partie_reelle = (real8) (*((integer8 *)
1222: (*s_objet_1).objet));
1223: ((struct_complexe16 **) (*((struct_matrice *)
1224: (*s_objet_3).objet)).tableau)[indice_i - 1]
1225: [indice_j - 1].partie_imaginaire = (real8) 0;
1226: }
1227: else if ((*s_objet_1).type == REL)
1228: {
1229: /*
1230: * Conversion de l'élément à insérer en complexe
1231: */
1232:
1233: ((struct_complexe16 **) (*((struct_matrice *)
1234: (*s_objet_3).objet)).tableau)[indice_i - 1]
1235: [indice_j - 1].partie_reelle =
1236: (*((real8 *) (*s_objet_1).objet));
1237: ((struct_complexe16 **) (*((struct_matrice *)
1238: (*s_objet_3).objet)).tableau)[indice_i - 1]
1239: [indice_j - 1].partie_imaginaire = (real8) 0;
1240: }
1241: else if ((*s_objet_1).type == CPL)
1242: {
1243: /*
1244: * Aucune conversion de type
1245: */
1246:
1247: ((struct_complexe16 **) (*((struct_matrice *)
1248: (*s_objet_3).objet)).tableau)[indice_i - 1]
1249: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
1250: (*s_objet_1).objet)).partie_reelle;
1251: ((struct_complexe16 **) (*((struct_matrice *)
1252: (*s_objet_3).objet)).tableau)[indice_i - 1]
1253: [indice_j - 1].partie_imaginaire =
1254: (*((struct_complexe16 *)
1255: (*s_objet_1).objet)).partie_imaginaire;
1256: }
1257: else
1258: {
1259: liberation(s_etat_processus, s_objet_1);
1260: liberation(s_etat_processus, s_objet_2);
1261: liberation(s_etat_processus, s_objet_3);
1262:
1263: (*s_etat_processus).erreur_execution =
1264: d_ex_erreur_type_argument;
1265: return;
1266: }
1267: }
1268:
1269: liberation(s_etat_processus, s_objet_1);
1270: liberation(s_etat_processus, s_objet_2);
1271:
1272: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1273: s_objet_3) == d_erreur)
1274: {
1275: return;
1276: }
1277: }
1278:
1279: /*
1280: --------------------------------------------------------------------------------
1281: Traitement des éléments des listes
1282: --------------------------------------------------------------------------------
1283: */
1284:
1285: else if ((*s_objet_3).type == LST)
1286: {
1287: if ((*s_objet_2).type != INT)
1288: {
1289: liberation(s_etat_processus, s_objet_1);
1290: liberation(s_etat_processus, s_objet_2);
1291: liberation(s_etat_processus, s_objet_3);
1292:
1293: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1294: return;
1295: }
1296:
1297: indice_i = (*((integer8 *) (*s_objet_2).objet));
1298: indice_j = 1;
1299:
1300: if ((*s_objet_3).nombre_occurrences > 1)
1301: {
1302: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'N'))
1303: == NULL)
1304: {
1305: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1306: return;
1307: }
1308:
1309: liberation(s_etat_processus, s_objet_3);
1310: s_objet_3 = s_copie_3;
1311: }
1312:
1313: l_element_courant = (*s_objet_3).objet;
1314:
1315: while((l_element_courant != NULL) && (indice_j != indice_i))
1316: {
1317: l_element_courant = (*l_element_courant).suivant;
1318: indice_j++;
1319: }
1320:
1321: if (l_element_courant != NULL)
1322: {
1323: liberation(s_etat_processus, (*l_element_courant).donnee);
1324: (*l_element_courant).donnee = s_objet_1;
1325: }
1326: else
1327: {
1328: liberation(s_etat_processus, s_objet_1);
1329: liberation(s_etat_processus, s_objet_2);
1330: liberation(s_etat_processus, s_objet_3);
1331:
1332: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1333: return;
1334: }
1335:
1336: liberation(s_etat_processus, s_objet_2);
1337:
1338: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1339: s_objet_3) == d_erreur)
1340: {
1341: return;
1342: }
1343: }
1344:
1345: /*
1346: --------------------------------------------------------------------------------
1347: Traitement des éléments des tables
1348: --------------------------------------------------------------------------------
1349: */
1350:
1351: else if ((*s_objet_3).type == TBL)
1352: {
1353: if ((*s_objet_2).type != LST)
1354: {
1355: liberation(s_etat_processus, s_objet_1);
1356: liberation(s_etat_processus, s_objet_2);
1357: liberation(s_etat_processus, s_objet_3);
1358:
1359: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1360: return;
1361: }
1362:
1363: if ((*s_objet_3).nombre_occurrences > 1)
1364: {
1365: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'N'))
1366: == NULL)
1367: {
1368: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1369: return;
1370: }
1371:
1372: liberation(s_etat_processus, s_objet_3);
1373: s_objet_3 = s_copie_3;
1374: }
1375:
1376: s_objet_element = s_objet_3;
1377: l_element_courant = (*s_objet_2).objet;
1378: indice_i = 0;
1379:
1380: while(l_element_courant != NULL)
1381: {
1382: if ((*(*l_element_courant).donnee).type != INT)
1383: {
1384: liberation(s_etat_processus, s_objet_1);
1385: liberation(s_etat_processus, s_objet_2);
1386: liberation(s_etat_processus, s_objet_3);
1387:
1388: (*s_etat_processus).erreur_execution =
1389: d_ex_erreur_type_argument;
1390: return;
1391: }
1392:
1393: if ((*s_objet_element).type != TBL)
1394: {
1395: liberation(s_etat_processus, s_objet_1);
1396: liberation(s_etat_processus, s_objet_2);
1397: liberation(s_etat_processus, s_objet_3);
1398:
1399: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1400: return;
1401: }
1402:
1403: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1404:
1405: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
1406: (*s_objet_element).objet)).nombre_elements))
1407: {
1408: liberation(s_etat_processus, s_objet_1);
1409: liberation(s_etat_processus, s_objet_2);
1410: liberation(s_etat_processus, s_objet_3);
1411:
1412: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1413: return;
1414: }
1415:
1416: if ((*l_element_courant).suivant != NULL)
1417: {
1418: s_objet_element = (*((struct_tableau *) (*s_objet_element)
1419: .objet)).elements[indice_i - 1];
1420: }
1421:
1422: l_element_courant = (*l_element_courant).suivant;
1423: }
1424:
1425: liberation(s_etat_processus, (*((struct_tableau *)
1426: (*s_objet_element).objet)).elements[indice_i - 1]);
1427: (*((struct_tableau *) (*s_objet_element).objet)).elements[indice_i - 1]
1428: = s_objet_1;
1429:
1430: liberation(s_etat_processus, s_objet_2);
1431:
1432: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1433: s_objet_3) == d_erreur)
1434: {
1435: return;
1436: }
1437: }
1438:
1439: /*
1440: --------------------------------------------------------------------------------
1441: Traitement des enregistrements
1442: --------------------------------------------------------------------------------
1443: */
1444:
1445: else if ((*s_objet_3).type == REC)
1446: {
1447: if ((*s_objet_2).type != CHN)
1448: {
1449: liberation(s_etat_processus, s_objet_1);
1450: liberation(s_etat_processus, s_objet_2);
1451: liberation(s_etat_processus, s_objet_3);
1452:
1453: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1454: return;
1455: }
1456:
1457: if ((*s_objet_3).nombre_occurrences > 1)
1458: {
1459: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'N'))
1460: == NULL)
1461: {
1462: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1463: return;
1464: }
1465:
1466: liberation(s_etat_processus, s_objet_3);
1467: s_objet_3 = s_copie_3;
1468: }
1469:
1470: if ((s_enregistrement = bsearch((unsigned char *) (*s_objet_2).objet,
1471: (*((struct_tableau *) (*(*((struct_record *)
1472: (*s_objet_3).objet)).noms).objet)).elements,
1473: (size_t) (*((struct_tableau *) (*(*((struct_record *)
1474: (*s_objet_3).objet)).noms).objet)).nombre_elements,
1475: sizeof(struct_objet *), fonction_comparaison)) == NULL)
1476: {
1477: liberation(s_etat_processus, s_objet_1);
1478: liberation(s_etat_processus, s_objet_2);
1479: liberation(s_etat_processus, s_objet_3);
1480:
1481: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1482: return;
1483: }
1484:
1485: indice_i = s_enregistrement - (*((struct_tableau *)
1486: (*(*((struct_record *) (*s_objet_3).objet)).noms).objet))
1487: .elements;
1488:
1489: liberation(s_etat_processus, (*((struct_tableau *)
1490: (*(*((struct_record *) (*s_objet_3).objet)).donnees).objet))
1491: .elements[indice_i]);
1492: (*((struct_tableau *) (*(*((struct_record *) (*s_objet_3).objet))
1493: .donnees).objet)).elements[indice_i] = s_objet_1;
1494:
1495: liberation(s_etat_processus, s_objet_2);
1496:
1497: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1498: s_objet_3) == d_erreur)
1499: {
1500: return;
1501: }
1502: }
1503:
1504: /*
1505: --------------------------------------------------------------------------------
1506: Traitement des noms
1507: --------------------------------------------------------------------------------
1508: */
1509:
1510: else if ((*s_objet_3).type == NOM)
1511: {
1512: variable_partagee = d_faux;
1513:
1514: if (recherche_variable(s_etat_processus, (*((struct_nom *)
1515: (*s_objet_3).objet)).nom) == d_faux)
1516: {
1517: (*s_etat_processus).erreur_systeme = d_es;
1518: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
1519:
1520: liberation(s_etat_processus, s_objet_1);
1521: liberation(s_etat_processus, s_objet_2);
1522: liberation(s_etat_processus, s_objet_3);
1523:
1524: return;
1525: }
1526:
1527: if ((*(*s_etat_processus).pointeur_variable_courante)
1528: .variable_verrouillee == d_vrai)
1529: {
1530: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
1531:
1532: liberation(s_etat_processus, s_objet_1);
1533: liberation(s_etat_processus, s_objet_2);
1534: liberation(s_etat_processus, s_objet_3);
1535:
1536: return;
1537: }
1538:
1539: s_objet_4 = (*(*s_etat_processus).pointeur_variable_courante).objet;
1540:
1541: if (s_objet_4 == NULL)
1542: {
1543: if (recherche_variable_partagee(s_etat_processus,
1544: (*(*s_etat_processus).pointeur_variable_courante).nom,
1545: (*(*s_etat_processus).pointeur_variable_courante)
1546: .variable_partagee, (*(*s_etat_processus)
1547: .pointeur_variable_courante).origine) == NULL)
1548: {
1549: (*s_etat_processus).erreur_systeme = d_es;
1550: (*s_etat_processus).erreur_execution =
1551: d_ex_variable_non_definie;
1552:
1553: liberation(s_etat_processus, s_objet_1);
1554: liberation(s_etat_processus, s_objet_2);
1555: liberation(s_etat_processus, s_objet_3);
1556:
1557: return;
1558: }
1559:
1560: s_objet_4 = (*(*s_etat_processus)
1561: .pointeur_variable_partagee_courante).objet;
1562: variable_partagee = d_vrai;
1563: }
1564:
1565: if (((*s_objet_4).type == VIN) ||
1566: ((*s_objet_4).type == VRL) ||
1567: ((*s_objet_4).type == VCX))
1568: {
1569: if ((*s_objet_2).type != LST)
1570: {
1571: if (variable_partagee == d_vrai)
1572: {
1573: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1574: .pointeur_variable_partagee_courante).mutex)) != 0)
1575: {
1576: (*s_etat_processus).erreur_systeme = d_es_processus;
1577: return;
1578: }
1579: }
1580:
1581: liberation(s_etat_processus, s_objet_1);
1582: liberation(s_etat_processus, s_objet_2);
1583: liberation(s_etat_processus, s_objet_3);
1584:
1585: (*s_etat_processus).erreur_execution =
1586: d_ex_erreur_type_argument;
1587: return;
1588: }
1589:
1590: l_element_courant = (*s_objet_2).objet;
1591: nombre_dimensions = 0;
1592:
1593: while(l_element_courant != NULL)
1594: {
1595: nombre_dimensions++;
1596: l_element_courant = (*l_element_courant).suivant;
1597: }
1598:
1599: if (nombre_dimensions != 1)
1600: {
1601: if (variable_partagee == d_vrai)
1602: {
1603: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1604: .pointeur_variable_partagee_courante).mutex)) != 0)
1605: {
1606: (*s_etat_processus).erreur_systeme = d_es_processus;
1607: return;
1608: }
1609: }
1610:
1611: liberation(s_etat_processus, s_objet_1);
1612: liberation(s_etat_processus, s_objet_2);
1613: liberation(s_etat_processus, s_objet_3);
1614:
1615: (*s_etat_processus).erreur_execution =
1616: d_ex_dimensions_invalides;
1617: return;
1618: }
1619:
1620: l_element_courant = (*s_objet_2).objet;
1621:
1622: if ((*(*l_element_courant).donnee).type != INT)
1623: {
1624: if (variable_partagee == d_vrai)
1625: {
1626: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1627: .pointeur_variable_partagee_courante).mutex)) != 0)
1628: {
1629: (*s_etat_processus).erreur_systeme = d_es_processus;
1630: return;
1631: }
1632: }
1633:
1634: liberation(s_etat_processus, s_objet_1);
1635: liberation(s_etat_processus, s_objet_2);
1636: liberation(s_etat_processus, s_objet_3);
1637:
1638: (*s_etat_processus).erreur_execution =
1639: d_ex_erreur_type_argument;
1640: return;
1641: }
1642:
1643: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1644: {
1645: if (variable_partagee == d_vrai)
1646: {
1647: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1648: .pointeur_variable_partagee_courante).mutex)) != 0)
1649: {
1650: (*s_etat_processus).erreur_systeme = d_es_processus;
1651: return;
1652: }
1653: }
1654:
1655: liberation(s_etat_processus, s_objet_1);
1656: liberation(s_etat_processus, s_objet_2);
1657: liberation(s_etat_processus, s_objet_3);
1658:
1659: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1660: return;
1661: }
1662: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
1663: (integer8) (*((struct_vecteur *) (*s_objet_4).objet))
1664: .taille)
1665: {
1666: if (variable_partagee == d_vrai)
1667: {
1668: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1669: .pointeur_variable_partagee_courante).mutex)) != 0)
1670: {
1671: (*s_etat_processus).erreur_systeme = d_es_processus;
1672: return;
1673: }
1674: }
1675:
1676: liberation(s_etat_processus, s_objet_1);
1677: liberation(s_etat_processus, s_objet_2);
1678: liberation(s_etat_processus, s_objet_3);
1679:
1680: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1681: return;
1682: }
1683:
1684: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1685:
1686: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'Q'))
1687: == NULL)
1688: {
1689: if (variable_partagee == d_vrai)
1690: {
1691: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1692: .pointeur_variable_partagee_courante).mutex)) != 0)
1693: {
1694: (*s_etat_processus).erreur_systeme = d_es_processus;
1695: return;
1696: }
1697: }
1698:
1699: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1700: return;
1701: }
1702:
1703: liberation(s_etat_processus, s_objet_4);
1704: s_objet_4 = s_copie_4;
1705:
1706: if ((*s_objet_4).type == VIN)
1707: {
1708: /*
1709: * Vecteur d'entiers
1710: */
1711:
1712: if ((*s_objet_1).type == INT)
1713: {
1714: /*
1715: * Aucune conversion de type
1716: */
1717:
1718: ((integer8 *) (*((struct_vecteur *) (*s_objet_4).objet))
1719: .tableau)[indice_i - 1] = (*((integer8 *)
1720: (*s_objet_1).objet));
1721: }
1722: else if ((*s_objet_1).type == REL)
1723: {
1724: /*
1725: * Conversion du vecteur en vecteur réel
1726: */
1727:
1728: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
1729: (*s_objet_4).objet)).tableau);
1730:
1731: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'R';
1732: (*s_objet_4).type = VRL;
1733:
1734: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
1735: = malloc(((size_t) (*((struct_vecteur *)
1736: (*s_objet_4).objet)).taille) * sizeof(real8)))
1737: == NULL)
1738: {
1739: if (variable_partagee == d_vrai)
1740: {
1741: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1742: .pointeur_variable_partagee_courante)
1743: .mutex)) != 0)
1744: {
1745: (*s_etat_processus).erreur_systeme =
1746: d_es_processus;
1747: return;
1748: }
1749: }
1750:
1751: (*s_etat_processus).erreur_systeme =
1752: d_es_allocation_memoire;
1753: return;
1754: }
1755:
1756: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
1757: .taille; i++)
1758: {
1759: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
1760: .tableau)[i] = (real8) (((integer8 *)
1761: tampon)[i]);
1762: }
1763:
1764: free((integer8 *) tampon);
1765:
1766: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
1767: .tableau)[indice_i - 1] = (*((real8 *)
1768: (*s_objet_1).objet));
1769: }
1770: else if ((*s_objet_1).type == CPL)
1771: {
1772: /*
1773: * Conversion du vecteur en vecteur complexe
1774: */
1775:
1776: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
1777: (*s_objet_4).objet)).tableau);
1778:
1779: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'C';
1780: (*s_objet_4).type = VCX;
1781:
1782: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
1783: = malloc(((size_t) (*((struct_vecteur *)
1784: (*s_objet_4).objet)).taille) *
1785: sizeof(struct_complexe16))) == NULL)
1786: {
1787: if (variable_partagee == d_vrai)
1788: {
1789: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1790: .pointeur_variable_partagee_courante)
1791: .mutex)) != 0)
1792: {
1793: (*s_etat_processus).erreur_systeme =
1794: d_es_processus;
1795: return;
1796: }
1797: }
1798:
1799: (*s_etat_processus).erreur_systeme =
1800: d_es_allocation_memoire;
1801: return;
1802: }
1803:
1804: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
1805: .taille; i++)
1806: {
1807: ((struct_complexe16 *) (*((struct_vecteur *)
1808: (*s_objet_4).objet)).tableau)[i].partie_reelle =
1809: (real8) (((integer8 *) tampon)[i]);
1810: ((struct_complexe16 *) (*((struct_vecteur *)
1811: (*s_objet_4).objet)).tableau)[i]
1812: .partie_imaginaire = (real8) 0;
1813: }
1814:
1815: free((integer8 *) tampon);
1816:
1817: ((struct_complexe16 *) (*((struct_vecteur *)
1818: (*s_objet_4).objet)).tableau)[indice_i - 1]
1819: .partie_reelle = (*((struct_complexe16 *)
1820: (*s_objet_1).objet)).partie_reelle;
1821: ((struct_complexe16 *) (*((struct_vecteur *)
1822: (*s_objet_4).objet)).tableau)[indice_i - 1]
1823: .partie_imaginaire = (*((struct_complexe16 *)
1824: (*s_objet_1).objet)).partie_imaginaire;
1825: }
1826: else
1827: {
1828: if (variable_partagee == d_vrai)
1829: {
1830: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1831: .pointeur_variable_partagee_courante).mutex))
1832: != 0)
1833: {
1834: (*s_etat_processus).erreur_systeme =
1835: d_es_processus;
1836: return;
1837: }
1838: }
1839:
1840: liberation(s_etat_processus, s_objet_1);
1841: liberation(s_etat_processus, s_objet_2);
1842: liberation(s_etat_processus, s_objet_3);
1843:
1844: (*s_etat_processus).erreur_execution =
1845: d_ex_erreur_type_argument;
1846: return;
1847: }
1848: }
1849: else if ((*s_objet_4).type == VRL)
1850: {
1851: /*
1852: * Vecteur de réels
1853: */
1854:
1855: if ((*s_objet_1).type == INT)
1856: {
1857: /*
1858: * Conversion de l'élément à insérer en réel
1859: */
1860:
1861: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
1862: .tableau)[indice_i - 1] = (real8) (*((integer8 *)
1863: (*s_objet_1).objet));
1864: }
1865: else if ((*s_objet_1).type == REL)
1866: {
1867: /*
1868: * Aucune conversion de type
1869: */
1870:
1871: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
1872: .tableau)[indice_i - 1] = (*((real8 *)
1873: (*s_objet_1).objet));
1874: }
1875: else if ((*s_objet_1).type == CPL)
1876: {
1877: /*
1878: * Conversion du vecteur en vecteur complexe
1879: */
1880:
1881: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
1882: (*s_objet_4).objet)).tableau);
1883:
1884: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'C';
1885: (*s_objet_4).type = VCX;
1886:
1887: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
1888: = malloc(((size_t) (*((struct_vecteur *)
1889: (*s_objet_4).objet)).taille) *
1890: sizeof(struct_complexe16))) == NULL)
1891: {
1892: if (variable_partagee == d_vrai)
1893: {
1894: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1895: .pointeur_variable_partagee_courante)
1896: .mutex)) != 0)
1897: {
1898: (*s_etat_processus).erreur_systeme =
1899: d_es_processus;
1900: return;
1901: }
1902: }
1903:
1904: (*s_etat_processus).erreur_systeme =
1905: d_es_allocation_memoire;
1906: return;
1907: }
1908:
1909: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
1910: .taille; i++)
1911: {
1912: ((struct_complexe16 *) (*((struct_vecteur *)
1913: (*s_objet_4).objet)).tableau)[i].partie_reelle =
1914: ((real8 *) tampon)[i];
1915: ((struct_complexe16 *) (*((struct_vecteur *)
1916: (*s_objet_4).objet)).tableau)[i]
1917: .partie_imaginaire = (real8) 0;
1918: }
1919:
1920: free((real8 *) tampon);
1921:
1922: ((struct_complexe16 *) (*((struct_vecteur *)
1923: (*s_objet_4).objet)).tableau)[indice_i - 1]
1924: .partie_reelle = (*((struct_complexe16 *)
1925: (*s_objet_1).objet)).partie_reelle;
1926: ((struct_complexe16 *) (*((struct_vecteur *)
1927: (*s_objet_4).objet)).tableau)[indice_i - 1]
1928: .partie_imaginaire = (*((struct_complexe16 *)
1929: (*s_objet_1).objet)).partie_imaginaire;
1930: }
1931: else
1932: {
1933: if (variable_partagee == d_vrai)
1934: {
1935: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1936: .pointeur_variable_partagee_courante).mutex))
1937: != 0)
1938: {
1939: (*s_etat_processus).erreur_systeme =
1940: d_es_processus;
1941: return;
1942: }
1943: }
1944:
1945: liberation(s_etat_processus, s_objet_1);
1946: liberation(s_etat_processus, s_objet_2);
1947: liberation(s_etat_processus, s_objet_3);
1948:
1949: (*s_etat_processus).erreur_execution =
1950: d_ex_erreur_type_argument;
1951: return;
1952: }
1953: }
1954: else
1955: {
1956: /*
1957: * Vecteur de complexes
1958: */
1959:
1960: if ((*s_objet_1).type == INT)
1961: {
1962: /*
1963: * Conversion de l'élément à insérer en complexe
1964: */
1965:
1966: ((struct_complexe16 *) (*((struct_vecteur *)
1967: (*s_objet_4).objet)).tableau)[indice_i - 1]
1968: .partie_reelle = (real8) (*((integer8 *)
1969: (*s_objet_1).objet));
1970: ((struct_complexe16 *) (*((struct_vecteur *)
1971: (*s_objet_4).objet)).tableau)[indice_i - 1]
1972: .partie_imaginaire = (real8) 0;
1973: }
1974: else if ((*s_objet_1).type == REL)
1975: {
1976: /*
1977: * Conversion de l'élément à insérer en complexe
1978: */
1979:
1980: ((struct_complexe16 *) (*((struct_vecteur *)
1981: (*s_objet_4).objet)).tableau)[indice_i - 1]
1982: .partie_reelle = (*((real8 *) (*s_objet_1).objet));
1983: ((struct_complexe16 *) (*((struct_vecteur *)
1984: (*s_objet_4).objet)).tableau)[indice_i - 1]
1985: .partie_imaginaire = (real8) 0;
1986: }
1987: else if ((*s_objet_1).type == CPL)
1988: {
1989: /*
1990: * Aucune conversion de type
1991: */
1992:
1993: ((struct_complexe16 *) (*((struct_vecteur *)
1994: (*s_objet_4).objet)).tableau)[indice_i - 1]
1995: .partie_reelle = (*((struct_complexe16 *)
1996: (*s_objet_1).objet)).partie_reelle;
1997: ((struct_complexe16 *) (*((struct_vecteur *)
1998: (*s_objet_4).objet)).tableau)[indice_i - 1]
1999: .partie_imaginaire = (*((struct_complexe16 *)
2000: (*s_objet_1).objet)).partie_imaginaire;
2001: }
2002: else
2003: {
2004: if (variable_partagee == d_vrai)
2005: {
2006: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2007: .pointeur_variable_partagee_courante).mutex))
2008: != 0)
2009: {
2010: (*s_etat_processus).erreur_systeme =
2011: d_es_processus;
2012: return;
2013: }
2014: }
2015:
2016: liberation(s_etat_processus, s_objet_1);
2017: liberation(s_etat_processus, s_objet_2);
2018: liberation(s_etat_processus, s_objet_3);
2019:
2020: (*s_etat_processus).erreur_execution =
2021: d_ex_erreur_type_argument;
2022: return;
2023: }
2024: }
2025:
2026: if (variable_partagee == d_faux)
2027: {
2028: (*(*s_etat_processus).pointeur_variable_courante).objet =
2029: s_objet_4;
2030: }
2031: else
2032: {
2033: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
2034: (*(*s_etat_processus).pointeur_variable_partagee_courante)
2035: .objet = s_objet_4;
2036:
2037: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2038: .pointeur_variable_partagee_courante).mutex)) != 0)
2039: {
2040: (*s_etat_processus).erreur_systeme = d_es_processus;
2041: return;
2042: }
2043: }
2044:
2045: liberation(s_etat_processus, s_objet_1);
2046: liberation(s_etat_processus, s_objet_2);
2047: liberation(s_etat_processus, s_objet_3);
2048: }
2049: else if (((*s_objet_4).type == MIN) ||
2050: ((*s_objet_4).type == MRL) ||
2051: ((*s_objet_4).type == MCX))
2052: {
2053: if ((*s_objet_2).type != LST)
2054: {
2055: if (variable_partagee == d_vrai)
2056: {
2057: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2058: .pointeur_variable_partagee_courante).mutex)) != 0)
2059: {
2060: (*s_etat_processus).erreur_systeme = d_es_processus;
2061: return;
2062: }
2063: }
2064:
2065: liberation(s_etat_processus, s_objet_1);
2066: liberation(s_etat_processus, s_objet_2);
2067: liberation(s_etat_processus, s_objet_3);
2068:
2069: (*s_etat_processus).erreur_execution =
2070: d_ex_erreur_type_argument;
2071: return;
2072: }
2073:
2074: l_element_courant = (*s_objet_2).objet;
2075: nombre_dimensions = 0;
2076:
2077: while(l_element_courant != NULL)
2078: {
2079: nombre_dimensions++;
2080: l_element_courant = (*l_element_courant).suivant;
2081: }
2082:
2083: if (nombre_dimensions != 2)
2084: {
2085: if (variable_partagee == d_vrai)
2086: {
2087: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2088: .pointeur_variable_partagee_courante).mutex)) != 0)
2089: {
2090: (*s_etat_processus).erreur_systeme = d_es_processus;
2091: return;
2092: }
2093: }
2094:
2095: liberation(s_etat_processus, s_objet_1);
2096: liberation(s_etat_processus, s_objet_2);
2097: liberation(s_etat_processus, s_objet_3);
2098:
2099: (*s_etat_processus).erreur_execution =
2100: d_ex_dimensions_invalides;
2101: return;
2102: }
2103:
2104: l_element_courant = (*s_objet_2).objet;
2105:
2106: indice_i = 0;
2107: indice_j = 0;
2108:
2109: while(l_element_courant != NULL)
2110: {
2111: if ((*(*l_element_courant).donnee).type != INT)
2112: {
2113: if (variable_partagee == d_vrai)
2114: {
2115: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2116: .pointeur_variable_partagee_courante).mutex))
2117: != 0)
2118: {
2119: (*s_etat_processus).erreur_systeme = d_es_processus;
2120: return;
2121: }
2122: }
2123:
2124: liberation(s_etat_processus, s_objet_1);
2125: liberation(s_etat_processus, s_objet_2);
2126: liberation(s_etat_processus, s_objet_3);
2127:
2128: (*s_etat_processus).erreur_execution =
2129: d_ex_erreur_type_argument;
2130: return;
2131: }
2132:
2133: if ((*((integer8 *) (*(*l_element_courant).donnee).objet))
2134: <= 0)
2135: {
2136: if (variable_partagee == d_vrai)
2137: {
2138: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2139: .pointeur_variable_partagee_courante).mutex))
2140: != 0)
2141: {
2142: (*s_etat_processus).erreur_systeme = d_es_processus;
2143: return;
2144: }
2145: }
2146:
2147: liberation(s_etat_processus, s_objet_1);
2148: liberation(s_etat_processus, s_objet_2);
2149: liberation(s_etat_processus, s_objet_3);
2150:
2151: (*s_etat_processus).erreur_execution =
2152: d_ex_argument_invalide;
2153: return;
2154: }
2155:
2156: if (indice_i == 0)
2157: {
2158: indice_i = (*((integer8 *)
2159: (*(*l_element_courant).donnee).objet));
2160: }
2161: else
2162: {
2163: indice_j = (*((integer8 *)
2164: (*(*l_element_courant).donnee).objet));
2165: }
2166:
2167: l_element_courant = (*l_element_courant).suivant;
2168: }
2169:
2170: if ((indice_i > (*((struct_matrice *) (*s_objet_4).objet))
2171: .nombre_lignes) || (indice_j > (*((struct_matrice *)
2172: (*s_objet_4).objet)).nombre_colonnes))
2173: {
2174: if (variable_partagee == d_vrai)
2175: {
2176: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2177: .pointeur_variable_partagee_courante).mutex)) != 0)
2178: {
2179: (*s_etat_processus).erreur_systeme = d_es_processus;
2180: return;
2181: }
2182: }
2183:
2184: liberation(s_etat_processus, s_objet_1);
2185: liberation(s_etat_processus, s_objet_2);
2186: liberation(s_etat_processus, s_objet_3);
2187:
2188: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2189: return;
2190: }
2191:
2192: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'Q'))
2193: == NULL)
2194: {
2195: if (variable_partagee == d_vrai)
2196: {
2197: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2198: .pointeur_variable_partagee_courante).mutex)) != 0)
2199: {
2200: (*s_etat_processus).erreur_systeme = d_es_processus;
2201: return;
2202: }
2203: }
2204:
2205: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2206: return;
2207: }
2208:
2209: liberation(s_etat_processus, s_objet_4);
2210: s_objet_4 = s_copie_4;
2211:
2212: if ((*s_objet_4).type == MIN)
2213: {
2214: /*
2215: * Matrice d'entiers
2216: */
2217:
2218: if ((*s_objet_1).type == INT)
2219: {
2220: /*
2221: * Aucune conversion de type
2222: */
2223:
2224: ((integer8 **) (*((struct_matrice *) (*s_objet_4).objet))
2225: .tableau)[indice_i - 1][indice_j - 1] =
2226: (*((integer8 *) (*s_objet_1).objet));
2227: }
2228: else if ((*s_objet_1).type == REL)
2229: {
2230: /*
2231: * Conversion de la matrice en matrice réelle
2232: */
2233:
2234: tampon = (void *) ((integer8 **) (*((struct_matrice *)
2235: (*s_objet_4).objet)).tableau);
2236:
2237: (*((struct_matrice *) (*s_objet_4).objet)).type = 'R';
2238: (*s_objet_4).type = MRL;
2239:
2240: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
2241: = malloc(((size_t) (*((struct_matrice *)
2242: (*s_objet_4).objet)).nombre_lignes) *
2243: sizeof(real8 *))) == NULL)
2244: {
2245: if (variable_partagee == d_vrai)
2246: {
2247: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2248: .pointeur_variable_partagee_courante)
2249: .mutex)) != 0)
2250: {
2251: (*s_etat_processus).erreur_systeme =
2252: d_es_processus;
2253: return;
2254: }
2255: }
2256:
2257: (*s_etat_processus).erreur_systeme =
2258: d_es_allocation_memoire;
2259: return;
2260: }
2261:
2262: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
2263: .nombre_lignes; i++)
2264: {
2265: if ((((real8 **) (*((struct_matrice *)
2266: (*s_objet_4).objet)).tableau)[i]
2267: = malloc(((size_t) (*((struct_matrice *)
2268: (*s_objet_4).objet)).nombre_colonnes) *
2269: sizeof(real8))) == NULL)
2270: {
2271: if (variable_partagee == d_vrai)
2272: {
2273: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2274: .pointeur_variable_partagee_courante)
2275: .mutex)) != 0)
2276: {
2277: (*s_etat_processus).erreur_systeme =
2278: d_es_processus;
2279: return;
2280: }
2281: }
2282:
2283: (*s_etat_processus).erreur_systeme =
2284: d_es_allocation_memoire;
2285: return;
2286: }
2287:
2288: for(j = 0; j < (*((struct_matrice *)
2289: (*s_objet_4).objet)).nombre_colonnes; j++)
2290: {
2291: ((real8 **) (*((struct_matrice *) (*s_objet_4)
2292: .objet)).tableau)[i][j] = (real8)
2293: (((integer8 **) tampon)[i][j]);
2294: }
2295:
2296: free(((integer8 **) tampon)[i]);
2297: }
2298:
2299: free((integer8 **) tampon);
2300:
2301: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
2302: .tableau)[indice_i - 1][indice_j - 1] =
2303: (*((real8 *) (*s_objet_1).objet));
2304: }
2305: else if ((*s_objet_1).type == CPL)
2306: {
2307: /*
2308: * Conversion de la matrice en matrice complexe
2309: */
2310:
2311: tampon = (void *) ((integer8 **) (*((struct_matrice *)
2312: (*s_objet_4).objet)).tableau);
2313:
2314: (*((struct_matrice *) (*s_objet_4).objet)).type = 'C';
2315: (*s_objet_4).type = MCX;
2316:
2317: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
2318: = malloc(((size_t) (*((struct_matrice *)
2319: (*s_objet_4).objet)).nombre_lignes) *
2320: sizeof(struct_complexe16 *))) == NULL)
2321: {
2322: if (variable_partagee == d_vrai)
2323: {
2324: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2325: .pointeur_variable_partagee_courante)
2326: .mutex)) != 0)
2327: {
2328: (*s_etat_processus).erreur_systeme =
2329: d_es_processus;
2330: return;
2331: }
2332: }
2333:
2334: (*s_etat_processus).erreur_systeme =
2335: d_es_allocation_memoire;
2336: return;
2337: }
2338:
2339: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
2340: .nombre_lignes; i++)
2341: {
2342: if ((((struct_complexe16 **) (*((struct_matrice *)
2343: (*s_objet_4).objet)).tableau)[i]
2344: = malloc(((size_t) (*((struct_matrice *)
2345: (*s_objet_4).objet)).nombre_colonnes) *
2346: sizeof(struct_complexe16))) == NULL)
2347: {
2348: if (variable_partagee == d_vrai)
2349: {
2350: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2351: .pointeur_variable_partagee_courante)
2352: .mutex)) != 0)
2353: {
2354: (*s_etat_processus).erreur_systeme =
2355: d_es_processus;
2356: return;
2357: }
2358: }
2359:
2360: (*s_etat_processus).erreur_systeme =
2361: d_es_allocation_memoire;
2362: return;
2363: }
2364:
2365: for(j = 0; j < (*((struct_matrice *)
2366: (*s_objet_4).objet)).nombre_colonnes; j++)
2367: {
2368: ((struct_complexe16 **) (*((struct_matrice *)
2369: (*s_objet_4).objet)).tableau)[i][j]
2370: .partie_reelle = (real8) (((integer8 **)
2371: tampon)[i][j]);
2372: ((struct_complexe16 **) (*((struct_matrice *)
2373: (*s_objet_4).objet)).tableau)[i][j]
2374: .partie_imaginaire = (real8) 0;
2375: }
2376:
2377: free(((integer8 **) tampon)[i]);
2378: }
2379:
2380: free((integer8 **) tampon);
2381:
2382: ((struct_complexe16 **) (*((struct_matrice *)
2383: (*s_objet_4).objet)).tableau)[indice_i - 1]
2384: [indice_j - 1].partie_reelle =
2385: (*((struct_complexe16 *)
2386: (*s_objet_1).objet)).partie_reelle;
2387: ((struct_complexe16 **) (*((struct_matrice *)
2388: (*s_objet_4).objet)).tableau)[indice_i - 1]
2389: [indice_j - 1].partie_imaginaire =
2390: (*((struct_complexe16 *)
2391: (*s_objet_1).objet)).partie_imaginaire;
2392: }
2393: else
2394: {
2395: if (variable_partagee == d_vrai)
2396: {
2397: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2398: .pointeur_variable_partagee_courante).mutex))
2399: != 0)
2400: {
2401: (*s_etat_processus).erreur_systeme =
2402: d_es_processus;
2403: return;
2404: }
2405: }
2406:
2407: liberation(s_etat_processus, s_objet_1);
2408: liberation(s_etat_processus, s_objet_2);
2409: liberation(s_etat_processus, s_objet_3);
2410:
2411: (*s_etat_processus).erreur_execution =
2412: d_ex_erreur_type_argument;
2413: return;
2414: }
2415: }
2416: else if ((*s_objet_4).type == MRL)
2417: {
2418: /*
2419: * Matrice de réels
2420: */
2421:
2422: if ((*s_objet_1).type == INT)
2423: {
2424: /*
2425: * Conversion de l'élément à insérer en réel
2426: */
2427:
2428: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
2429: .tableau)[indice_i - 1][indice_j - 1] =
2430: (real8) (*((integer8 *) (*s_objet_1).objet));
2431: }
2432: else if ((*s_objet_1).type == REL)
2433: {
2434: /*
2435: * Aucune conversion de type
2436: */
2437:
2438: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
2439: .tableau)[indice_i - 1][indice_j - 1] =
2440: (*((real8 *) (*s_objet_1).objet));
2441: }
2442: else if ((*s_objet_1).type == CPL)
2443: {
2444: /*
2445: * Conversion de la matrice en matrice complexe
2446: */
2447:
2448: tampon = (void *) ((real8 **) (*((struct_matrice *)
2449: (*s_objet_4).objet)).tableau);
2450:
2451: (*((struct_matrice *) (*s_objet_4).objet)).type = 'C';
2452: (*s_objet_4).type = MCX;
2453:
2454: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
2455: = malloc(((size_t) (*((struct_matrice *)
2456: (*s_objet_4).objet)).nombre_lignes) *
2457: sizeof(struct_complexe16 *))) == NULL)
2458: {
2459: if (variable_partagee == d_vrai)
2460: {
2461: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2462: .pointeur_variable_partagee_courante)
2463: .mutex)) != 0)
2464: {
2465: (*s_etat_processus).erreur_systeme =
2466: d_es_processus;
2467: return;
2468: }
2469: }
2470:
2471: (*s_etat_processus).erreur_systeme =
2472: d_es_allocation_memoire;
2473: return;
2474: }
2475:
2476: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
2477: .nombre_lignes; i++)
2478: {
2479: if ((((struct_complexe16 **) (*((struct_matrice *)
2480: (*s_objet_4).objet)).tableau)[i]
2481: = malloc(((size_t) (*((struct_matrice *)
2482: (*s_objet_4).objet)).nombre_colonnes) *
2483: sizeof(struct_complexe16))) == NULL)
2484: {
2485: if (variable_partagee == d_vrai)
2486: {
2487: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2488: .pointeur_variable_partagee_courante)
2489: .mutex)) != 0)
2490: {
2491: (*s_etat_processus).erreur_systeme =
2492: d_es_processus;
2493: return;
2494: }
2495: }
2496:
2497: (*s_etat_processus).erreur_systeme =
2498: d_es_allocation_memoire;
2499: return;
2500: }
2501:
2502: for(j = 0; j < (*((struct_matrice *)
2503: (*s_objet_4).objet)).nombre_colonnes; j++)
2504: {
2505: ((struct_complexe16 **) (*((struct_matrice *)
2506: (*s_objet_4).objet)).tableau)[i][j]
2507: .partie_reelle = (((real8 **)
2508: tampon)[i][j]);
2509: ((struct_complexe16 **) (*((struct_matrice *)
2510: (*s_objet_4).objet)).tableau)[i][j]
2511: .partie_imaginaire = (real8) 0;
2512: }
2513:
2514: free(((integer8 **) tampon)[i]);
2515: }
2516:
2517: free((integer8 **) tampon);
2518:
2519: ((struct_complexe16 **) (*((struct_matrice *)
2520: (*s_objet_4).objet)).tableau)[indice_i - 1]
2521: [indice_j - 1].partie_reelle =
2522: (*((struct_complexe16 *)
2523: (*s_objet_1).objet)).partie_reelle;
2524: ((struct_complexe16 **) (*((struct_matrice *)
2525: (*s_objet_4).objet)).tableau)[indice_i - 1]
2526: [indice_j - 1].partie_imaginaire =
2527: (*((struct_complexe16 *)
2528: (*s_objet_1).objet)).partie_imaginaire;
2529: }
2530: else
2531: {
2532: if (variable_partagee == d_vrai)
2533: {
2534: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2535: .pointeur_variable_partagee_courante).mutex))
2536: != 0)
2537: {
2538: (*s_etat_processus).erreur_systeme =
2539: d_es_processus;
2540: return;
2541: }
2542: }
2543:
2544: liberation(s_etat_processus, s_objet_1);
2545: liberation(s_etat_processus, s_objet_2);
2546: liberation(s_etat_processus, s_objet_3);
2547:
2548: (*s_etat_processus).erreur_execution =
2549: d_ex_erreur_type_argument;
2550: return;
2551: }
2552: }
2553: else
2554: {
2555: /*
2556: * Matrice de complexes
2557: */
2558:
2559: if ((*s_objet_1).type == INT)
2560: {
2561: /*
2562: * Conversion de l'élément à insérer en complexe
2563: */
2564:
2565: ((struct_complexe16 **) (*((struct_matrice *)
2566: (*s_objet_4).objet)).tableau)[indice_i - 1]
2567: [indice_j - 1].partie_reelle = (real8)
2568: (*((integer8 *) (*s_objet_1).objet));
2569: ((struct_complexe16 **) (*((struct_matrice *)
2570: (*s_objet_4).objet)).tableau)[indice_i - 1]
2571: [indice_j - 1].partie_imaginaire = (real8) 0;
2572: }
2573: else if ((*s_objet_1).type == REL)
2574: {
2575: /*
2576: * Conversion de l'élément à insérer en complexe
2577: */
2578:
2579: ((struct_complexe16 **) (*((struct_matrice *)
2580: (*s_objet_4).objet)).tableau)[indice_i - 1]
2581: [indice_j - 1].partie_reelle =
2582: (*((real8 *) (*s_objet_1).objet));
2583: ((struct_complexe16 **) (*((struct_matrice *)
2584: (*s_objet_4).objet)).tableau)[indice_i - 1]
2585: [indice_j - 1].partie_imaginaire = (real8) 0;
2586: }
2587: else if ((*s_objet_1).type == CPL)
2588: {
2589: /*
2590: * Aucune conversion de type
2591: */
2592:
2593: ((struct_complexe16 **) (*((struct_matrice *)
2594: (*s_objet_4).objet)).tableau)[indice_i - 1]
2595: [indice_j - 1].partie_reelle =
2596: (*((struct_complexe16 *)
2597: (*s_objet_1).objet)).partie_reelle;
2598: ((struct_complexe16 **) (*((struct_matrice *)
2599: (*s_objet_4).objet)).tableau)[indice_i - 1]
2600: [indice_j - 1].partie_imaginaire =
2601: (*((struct_complexe16 *)
2602: (*s_objet_1).objet)).partie_imaginaire;
2603: }
2604: else
2605: {
2606: if (variable_partagee == d_vrai)
2607: {
2608: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2609: .pointeur_variable_partagee_courante).mutex))
2610: != 0)
2611: {
2612: (*s_etat_processus).erreur_systeme =
2613: d_es_processus;
2614: return;
2615: }
2616: }
2617:
2618: liberation(s_etat_processus, s_objet_1);
2619: liberation(s_etat_processus, s_objet_2);
2620: liberation(s_etat_processus, s_objet_3);
2621:
2622: (*s_etat_processus).erreur_execution =
2623: d_ex_erreur_type_argument;
2624: return;
2625: }
2626: }
2627:
2628: if (variable_partagee == d_faux)
2629: {
2630: (*(*s_etat_processus).pointeur_variable_courante).objet =
2631: s_objet_4;
2632: }
2633: else
2634: {
2635: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
2636: (*(*s_etat_processus).pointeur_variable_partagee_courante)
2637: .objet = s_objet_4;
2638:
2639: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2640: .pointeur_variable_partagee_courante).mutex)) != 0)
2641: {
2642: (*s_etat_processus).erreur_systeme =
2643: d_es_processus;
2644: return;
2645: }
2646: }
2647:
2648: liberation(s_etat_processus, s_objet_1);
2649: liberation(s_etat_processus, s_objet_2);
2650: liberation(s_etat_processus, s_objet_3);
2651: }
2652: else if ((*s_objet_4).type == LST)
2653: {
2654: if ((*s_objet_2).type != INT)
2655: {
2656: if (variable_partagee == d_vrai)
2657: {
2658: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2659: .pointeur_variable_partagee_courante).mutex)) != 0)
2660: {
2661: (*s_etat_processus).erreur_systeme =
2662: d_es_processus;
2663: return;
2664: }
2665: }
2666:
2667: liberation(s_etat_processus, s_objet_1);
2668: liberation(s_etat_processus, s_objet_2);
2669: liberation(s_etat_processus, s_objet_3);
2670:
2671: (*s_etat_processus).erreur_execution =
2672: d_ex_erreur_type_argument;
2673: return;
2674: }
2675:
2676: indice_i = (*((integer8 *) (*s_objet_2).objet));
2677: indice_j = 1;
2678:
2679: if ((*s_objet_4).nombre_occurrences > 1)
2680: {
2681: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'N'))
2682: == NULL)
2683: {
2684: if (variable_partagee == d_vrai)
2685: {
2686: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2687: .pointeur_variable_partagee_courante).mutex))
2688: != 0)
2689: {
2690: (*s_etat_processus).erreur_systeme =
2691: d_es_processus;
2692: return;
2693: }
2694: }
2695:
2696: (*s_etat_processus).erreur_systeme =
2697: d_es_allocation_memoire;
2698: return;
2699: }
2700:
2701: liberation(s_etat_processus, s_objet_4);
2702: s_objet_4 = s_copie_4;
2703: }
2704:
2705: l_element_courant = (*s_objet_4).objet;
2706:
2707: while((l_element_courant != NULL) && (indice_j != indice_i))
2708: {
2709: l_element_courant = (*l_element_courant).suivant;
2710: indice_j++;
2711: }
2712:
2713: if (l_element_courant != NULL)
2714: {
2715: liberation(s_etat_processus, (*l_element_courant).donnee);
2716: (*l_element_courant).donnee = s_objet_1;
2717: }
2718: else
2719: {
2720: if (variable_partagee == d_vrai)
2721: {
2722: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2723: .pointeur_variable_partagee_courante).mutex)) != 0)
2724: {
2725: (*s_etat_processus).erreur_systeme =
2726: d_es_processus;
2727: return;
2728: }
2729: }
2730:
2731: liberation(s_etat_processus, s_objet_1);
2732: liberation(s_etat_processus, s_objet_2);
2733: liberation(s_etat_processus, s_objet_3);
2734:
2735: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2736: return;
2737: }
2738:
2739: if (variable_partagee == d_faux)
2740: {
2741: (*(*s_etat_processus).pointeur_variable_courante).objet =
2742: s_objet_4;
2743: }
2744: else
2745: {
2746: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
2747: (*(*s_etat_processus).pointeur_variable_partagee_courante)
2748: .objet = s_objet_4;
2749:
2750: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2751: .pointeur_variable_partagee_courante).mutex)) != 0)
2752: {
2753: (*s_etat_processus).erreur_systeme =
2754: d_es_processus;
2755: return;
2756: }
2757: }
2758:
2759: liberation(s_etat_processus, s_objet_2);
2760: liberation(s_etat_processus, s_objet_3);
2761: }
2762: else if ((*s_objet_4).type == TBL)
2763: {
2764: if ((*s_objet_2).type != LST)
2765: {
2766: if (variable_partagee == d_vrai)
2767: {
2768: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2769: .pointeur_variable_partagee_courante).mutex)) != 0)
2770: {
2771: (*s_etat_processus).erreur_systeme =
2772: d_es_processus;
2773: return;
2774: }
2775: }
2776:
2777: liberation(s_etat_processus, s_objet_1);
2778: liberation(s_etat_processus, s_objet_2);
2779: liberation(s_etat_processus, s_objet_3);
2780:
2781: (*s_etat_processus).erreur_execution =
2782: d_ex_erreur_type_argument;
2783: return;
2784: }
2785:
2786: if ((*s_objet_4).nombre_occurrences > 1)
2787: {
2788: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'N'))
2789: == NULL)
2790: {
2791: if (variable_partagee == d_vrai)
2792: {
2793: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2794: .pointeur_variable_partagee_courante).mutex))
2795: != 0)
2796: {
2797: (*s_etat_processus).erreur_systeme =
2798: d_es_processus;
2799: return;
2800: }
2801: }
2802:
2803: (*s_etat_processus).erreur_systeme =
2804: d_es_allocation_memoire;
2805: return;
2806: }
2807:
2808: liberation(s_etat_processus, s_objet_4);
2809: s_objet_4 = s_copie_4;
2810: }
2811:
2812: s_objet_element = s_objet_4;
2813: l_element_courant = (*s_objet_2).objet;
2814: indice_i = 0;
2815:
2816: while(l_element_courant != NULL)
2817: {
2818: if ((*(*l_element_courant).donnee).type != INT)
2819: {
2820: if (variable_partagee == d_vrai)
2821: {
2822: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2823: .pointeur_variable_partagee_courante).mutex))
2824: != 0)
2825: {
2826: (*s_etat_processus).erreur_systeme =
2827: d_es_processus;
2828: return;
2829: }
2830: }
2831:
2832: liberation(s_etat_processus, s_objet_1);
2833: liberation(s_etat_processus, s_objet_2);
2834: liberation(s_etat_processus, s_objet_3);
2835:
2836: (*s_etat_processus).erreur_execution =
2837: d_ex_erreur_type_argument;
2838: return;
2839: }
2840:
2841: if ((*s_objet_element).type != TBL)
2842: {
2843: if (variable_partagee == d_vrai)
2844: {
2845: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2846: .pointeur_variable_partagee_courante).mutex))
2847: != 0)
2848: {
2849: (*s_etat_processus).erreur_systeme =
2850: d_es_processus;
2851: return;
2852: }
2853: }
2854:
2855: liberation(s_etat_processus, s_objet_1);
2856: liberation(s_etat_processus, s_objet_2);
2857: liberation(s_etat_processus, s_objet_3);
2858:
2859: (*s_etat_processus).erreur_execution =
2860: d_ex_element_inexistant;
2861: return;
2862: }
2863:
2864: indice_i = (*((integer8 *) (*(*l_element_courant)
2865: .donnee).objet));
2866:
2867: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
2868: (*s_objet_element).objet)).nombre_elements))
2869: {
2870: if (variable_partagee == d_vrai)
2871: {
2872: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2873: .pointeur_variable_partagee_courante).mutex))
2874: != 0)
2875: {
2876: (*s_etat_processus).erreur_systeme =
2877: d_es_processus;
2878: return;
2879: }
2880: }
2881:
2882: liberation(s_etat_processus, s_objet_1);
2883: liberation(s_etat_processus, s_objet_2);
2884: liberation(s_etat_processus, s_objet_3);
2885:
2886: (*s_etat_processus).erreur_execution =
2887: d_ex_element_inexistant;
2888: return;
2889: }
2890:
2891: if ((*l_element_courant).suivant != NULL)
2892: {
2893: s_objet_element = (*((struct_tableau *) (*s_objet_element)
2894: .objet)).elements[indice_i - 1];
2895: }
2896:
2897: l_element_courant = (*l_element_courant).suivant;
2898: }
2899:
2900: liberation(s_etat_processus, (*((struct_tableau *)
2901: (*s_objet_element).objet)).elements[indice_i - 1]);
2902: (*((struct_tableau *) (*s_objet_element).objet)).elements
2903: [indice_i - 1] = s_objet_1;
2904:
2905: if (variable_partagee == d_faux)
2906: {
2907: (*(*s_etat_processus).pointeur_variable_courante).objet =
2908: s_objet_4;
2909: }
2910: else
2911: {
2912: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
2913: (*(*s_etat_processus).pointeur_variable_partagee_courante)
2914: .objet = s_objet_4;
2915:
2916: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2917: .pointeur_variable_partagee_courante).mutex)) != 0)
2918: {
2919: (*s_etat_processus).erreur_systeme =
2920: d_es_processus;
2921: return;
2922: }
2923: }
2924:
2925: liberation(s_etat_processus, s_objet_2);
2926: }
2927: else if ((*s_objet_4).type == REC)
2928: {
2929: if ((*s_objet_2).type != CHN)
2930: {
2931: if (variable_partagee == d_vrai)
2932: {
2933: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2934: .pointeur_variable_partagee_courante).mutex)) != 0)
2935: {
2936: (*s_etat_processus).erreur_systeme =
2937: d_es_processus;
2938: return;
2939: }
2940: }
2941:
2942: liberation(s_etat_processus, s_objet_1);
2943: liberation(s_etat_processus, s_objet_2);
2944: liberation(s_etat_processus, s_objet_3);
2945:
2946: (*s_etat_processus).erreur_execution =
2947: d_ex_erreur_type_argument;
2948: return;
2949: }
2950:
2951: if ((*s_objet_4).nombre_occurrences > 1)
2952: {
2953: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_3, 'N'))
2954: == NULL)
2955: {
2956: if (variable_partagee == d_vrai)
2957: {
2958: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2959: .pointeur_variable_partagee_courante).mutex))
2960: != 0)
2961: {
2962: (*s_etat_processus).erreur_systeme =
2963: d_es_processus;
2964: return;
2965: }
2966: }
2967:
2968: (*s_etat_processus).erreur_systeme =
2969: d_es_allocation_memoire;
2970: return;
2971: }
2972:
2973: liberation(s_etat_processus, s_objet_4);
2974: s_objet_4 = s_copie_4;
2975: }
2976:
2977: if ((s_enregistrement = bsearch(
2978: (unsigned char *) (*s_objet_2).objet,
2979: (*((struct_tableau *) (*(*((struct_record *)
2980: (*s_objet_4).objet)).noms).objet)).elements,
2981: (size_t) (*((struct_tableau *) (*(*((struct_record *)
2982: (*s_objet_4).objet)).noms).objet)).nombre_elements,
2983: sizeof(struct_objet *), fonction_comparaison)) == NULL)
2984: {
2985: if (variable_partagee == d_vrai)
2986: {
2987: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2988: .pointeur_variable_partagee_courante).mutex))
2989: != 0)
2990: {
2991: (*s_etat_processus).erreur_systeme =
2992: d_es_processus;
2993: return;
2994: }
2995: }
2996:
2997: liberation(s_etat_processus, s_objet_1);
2998: liberation(s_etat_processus, s_objet_2);
2999: liberation(s_etat_processus, s_objet_3);
3000:
3001: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
3002: return;
3003: }
3004:
3005: indice_i = s_enregistrement - (*((struct_tableau *)
3006: (*(*((struct_record *) (*s_objet_4).objet)).noms).objet))
3007: .elements;
3008:
3009: liberation(s_etat_processus, (*((struct_tableau *)
3010: (*(*((struct_record *) (*s_objet_4).objet)).donnees).objet))
3011: .elements[indice_i]);
3012: (*((struct_tableau *) (*(*((struct_record *) (*s_objet_4).objet))
3013: .donnees).objet)).elements[indice_i] = s_objet_1;
3014:
3015: if (variable_partagee == d_faux)
3016: {
3017: (*(*s_etat_processus).pointeur_variable_courante).objet =
3018: s_objet_4;
3019: }
3020: else
3021: {
3022: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
3023: (*(*s_etat_processus).pointeur_variable_partagee_courante)
3024: .objet = s_objet_4;
3025:
3026: if (pthread_mutex_unlock(&((*(*s_etat_processus)
3027: .pointeur_variable_partagee_courante).mutex)) != 0)
3028: {
3029: (*s_etat_processus).erreur_systeme =
3030: d_es_processus;
3031: return;
3032: }
3033: }
3034:
3035: liberation(s_etat_processus, s_objet_2);
3036: }
3037: else
3038: {
3039: if (variable_partagee == d_vrai)
3040: {
3041: if (pthread_mutex_unlock(&((*(*s_etat_processus)
3042: .pointeur_variable_partagee_courante).mutex)) != 0)
3043: {
3044: (*s_etat_processus).erreur_systeme =
3045: d_es_processus;
3046: return;
3047: }
3048: }
3049:
3050: liberation(s_etat_processus, s_objet_1);
3051: liberation(s_etat_processus, s_objet_2);
3052: liberation(s_etat_processus, s_objet_3);
3053:
3054: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3055: return;
3056: }
3057: }
3058:
3059: /*
3060: --------------------------------------------------------------------------------
3061: Arguments incompatibles
3062: --------------------------------------------------------------------------------
3063: */
3064:
3065: else
3066: {
3067: liberation(s_etat_processus, s_objet_1);
3068: liberation(s_etat_processus, s_objet_2);
3069: liberation(s_etat_processus, s_objet_3);
3070:
3071: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3072: return;
3073: }
3074:
3075: return;
3076: }
3077:
3078:
3079: /*
3080: ================================================================================
3081: Fonction 'puti'
3082: ================================================================================
3083: Entrées : pointeur sur une structure struct_processus
3084: --------------------------------------------------------------------------------
3085: Sorties :
3086: --------------------------------------------------------------------------------
3087: Effets de bord : néant
3088: ================================================================================
3089: */
3090:
3091: void
3092: instruction_puti(struct_processus *s_etat_processus)
3093: {
3094: logical1 variable_partagee;
3095:
3096: struct_liste_chainee *l_element_courant;
3097:
3098: struct_objet *s_copie_2;
3099: struct_objet *s_copie_3;
3100: struct_objet *s_copie_4;
3101: struct_objet *s_objet_1;
3102: struct_objet *s_objet_2;
3103: struct_objet *s_objet_3;
3104: struct_objet *s_objet_4;
3105:
3106: integer8 i;
3107: integer8 indice_i;
3108: integer8 indice_j;
3109: integer8 j;
3110: integer8 nombre_dimensions;
3111: integer8 nombre_elements;
3112:
3113: void *tampon;
3114:
3115: (*s_etat_processus).erreur_execution = d_ex;
3116:
3117: if ((*s_etat_processus).affichage_arguments == 'Y')
3118: {
3119: printf("\n PUTI ");
3120:
3121: if ((*s_etat_processus).langue == 'F')
3122: {
3123: printf("(change un élément)\n\n");
3124: }
3125: else
3126: {
3127: printf("(change element)\n\n");
3128: }
3129:
3130: printf(" 3: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
3131: printf(" 2: %s\n", d_LST);
3132: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
3133: printf("-> 2: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
3134: printf(" 1: %s\n\n", d_LST);
3135:
3136: printf(" 3: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
3137: printf(" 2: %s\n", d_LST);
3138: printf(" 1: %s, %s, %s\n", d_INT, d_REL, d_CPL);
3139: printf("-> 2: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
3140: printf(" 1: %s\n\n", d_LST);
3141:
3142: printf(" 3: %s, %s\n", d_LST, d_NOM);
3143: printf(" 2: %s\n", d_INT);
3144: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
3145: " %s, %s, %s, %s, %s,\n"
3146: " %s, %s, %s, %s, %s,\n"
3147: " %s, %s, %s, %s,\n"
3148: " %s, %s, %s\n",
3149: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
3150: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
3151: d_SQL, d_SLB, d_PRC, d_MTX, d_REC);
3152: printf("-> 2: %s, %s\n", d_LST, d_NOM);
3153: printf(" 1: %s\n", d_INT);
3154:
3155: return;
3156: }
3157: else if ((*s_etat_processus).test_instruction == 'Y')
3158: {
3159: (*s_etat_processus).nombre_arguments = -1;
3160: return;
3161: }
3162:
3163: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3164: {
3165: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
3166: {
3167: return;
3168: }
3169: }
3170:
3171: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3172: &s_objet_1) == d_erreur)
3173: {
3174: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3175: return;
3176: }
3177:
3178: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3179: &s_objet_2) == d_erreur)
3180: {
3181: liberation(s_etat_processus, s_objet_1);
3182:
3183: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3184: return;
3185: }
3186:
3187: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3188: &s_objet_3) == d_erreur)
3189: {
3190: liberation(s_etat_processus, s_objet_1);
3191: liberation(s_etat_processus, s_objet_2);
3192:
3193: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3194: return;
3195: }
3196:
3197: if ((s_copie_2 = copie_objet(s_etat_processus, s_objet_2, 'O')) == NULL)
3198: {
3199: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3200: return;
3201: }
3202:
3203: liberation(s_etat_processus, s_objet_2);
3204: s_objet_2 = s_copie_2;
3205:
3206: /*
3207: --------------------------------------------------------------------------------
3208: Traitement des éléments des vecteurs
3209: --------------------------------------------------------------------------------
3210: */
3211:
3212: if (((*s_objet_3).type == VIN) ||
3213: ((*s_objet_3).type == VRL) ||
3214: ((*s_objet_3).type == VCX))
3215: {
3216: if ((*s_objet_2).type != LST)
3217: {
3218: liberation(s_etat_processus, s_objet_1);
3219: liberation(s_etat_processus, s_objet_2);
3220: liberation(s_etat_processus, s_objet_3);
3221:
3222: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3223: return;
3224: }
3225:
3226: l_element_courant = (*s_objet_2).objet;
3227: nombre_dimensions = 0;
3228:
3229: while(l_element_courant != NULL)
3230: {
3231: nombre_dimensions++;
3232: l_element_courant = (*l_element_courant).suivant;
3233: }
3234:
3235: if (nombre_dimensions != 1)
3236: {
3237: liberation(s_etat_processus, s_objet_1);
3238: liberation(s_etat_processus, s_objet_2);
3239: liberation(s_etat_processus, s_objet_3);
3240:
3241: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
3242: return;
3243: }
3244:
3245: l_element_courant = (*s_objet_2).objet;
3246:
3247: if ((*(*l_element_courant).donnee).type != INT)
3248: {
3249: liberation(s_etat_processus, s_objet_1);
3250: liberation(s_etat_processus, s_objet_2);
3251: liberation(s_etat_processus, s_objet_3);
3252:
3253: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3254: return;
3255: }
3256:
3257: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
3258: {
3259: liberation(s_etat_processus, s_objet_1);
3260: liberation(s_etat_processus, s_objet_2);
3261: liberation(s_etat_processus, s_objet_3);
3262:
3263: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
3264: return;
3265: }
3266: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
3267: (integer8) (*((struct_vecteur *) (*s_objet_3).objet)).taille)
3268: {
3269: liberation(s_etat_processus, s_objet_1);
3270: liberation(s_etat_processus, s_objet_2);
3271: liberation(s_etat_processus, s_objet_3);
3272:
3273: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
3274: return;
3275: }
3276:
3277: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
3278:
3279: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'Q')) == NULL)
3280: {
3281: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3282: return;
3283: }
3284:
3285: liberation(s_etat_processus, s_objet_3);
3286: s_objet_3 = s_copie_3;
3287:
3288: if ((*s_objet_3).type == VIN)
3289: {
3290: /*
3291: * Vecteur d'entiers
3292: */
3293:
3294: if ((*s_objet_1).type == INT)
3295: {
3296: /*
3297: * Aucune conversion de type
3298: */
3299:
3300: ((integer8 *) (*((struct_vecteur *) (*s_objet_3).objet))
3301: .tableau)[indice_i - 1] = (*((integer8 *)
3302: (*s_objet_1).objet));
3303: }
3304: else if ((*s_objet_1).type == REL)
3305: {
3306: /*
3307: * Conversion du vecteur en vecteur réel
3308: */
3309:
3310: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
3311: (*s_objet_3).objet)).tableau);
3312:
3313: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'R';
3314: (*s_objet_3).type = VRL;
3315:
3316: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
3317: = malloc(((size_t) (*((struct_vecteur *)
3318: (*s_objet_3).objet)).taille) * sizeof(real8)))
3319: == NULL)
3320: {
3321: (*s_etat_processus).erreur_systeme =
3322: d_es_allocation_memoire;
3323: return;
3324: }
3325:
3326: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
3327: .taille; i++)
3328: {
3329: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
3330: .tableau)[i] = (real8) (((integer8 *) tampon)[i]);
3331: }
3332:
3333: free((integer8 *) tampon);
3334:
3335: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
3336: .tableau)[indice_i - 1] = (*((real8 *)
3337: (*s_objet_1).objet));
3338: }
3339: else if ((*s_objet_1).type == CPL)
3340: {
3341: /*
3342: * Conversion du vecteur en vecteur complexe
3343: */
3344:
3345: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
3346: (*s_objet_3).objet)).tableau);
3347:
3348: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'C';
3349: (*s_objet_3).type = VCX;
3350:
3351: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
3352: = malloc(((size_t) (*((struct_vecteur *)
3353: (*s_objet_3).objet)).taille) *
3354: sizeof(struct_complexe16))) == NULL)
3355: {
3356: (*s_etat_processus).erreur_systeme =
3357: d_es_allocation_memoire;
3358: return;
3359: }
3360:
3361: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
3362: .taille; i++)
3363: {
3364: ((struct_complexe16 *) (*((struct_vecteur *)
3365: (*s_objet_3).objet)).tableau)[i].partie_reelle =
3366: (real8) (((integer8 *) tampon)[i]);
3367: ((struct_complexe16 *) (*((struct_vecteur *)
3368: (*s_objet_3).objet)).tableau)[i]
3369: .partie_imaginaire = (real8) 0;
3370: }
3371:
3372: free((integer8 *) tampon);
3373:
3374: ((struct_complexe16 *) (*((struct_vecteur *)
3375: (*s_objet_3).objet)).tableau)[indice_i - 1]
3376: .partie_reelle = (*((struct_complexe16 *)
3377: (*s_objet_1).objet)).partie_reelle;
3378: ((struct_complexe16 *) (*((struct_vecteur *)
3379: (*s_objet_3).objet)).tableau)[indice_i - 1]
3380: .partie_imaginaire = (*((struct_complexe16 *)
3381: (*s_objet_1).objet)).partie_imaginaire;
3382: }
3383: else
3384: {
3385: liberation(s_etat_processus, s_objet_1);
3386: liberation(s_etat_processus, s_objet_2);
3387: liberation(s_etat_processus, s_objet_3);
3388:
3389: (*s_etat_processus).erreur_execution =
3390: d_ex_erreur_type_argument;
3391: return;
3392: }
3393: }
3394: else if ((*s_objet_3).type == VRL)
3395: {
3396: /*
3397: * Vecteur de réels
3398: */
3399:
3400: if ((*s_objet_1).type == INT)
3401: {
3402: /*
3403: * Conversion de l'élément à insérer en réel
3404: */
3405:
3406: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
3407: .tableau)[indice_i - 1] = (real8) (*((integer8 *)
3408: (*s_objet_1).objet));
3409: }
3410: else if ((*s_objet_1).type == REL)
3411: {
3412: /*
3413: * Aucune conversion de type
3414: */
3415:
3416: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
3417: .tableau)[indice_i - 1] = (*((real8 *)
3418: (*s_objet_1).objet));
3419: }
3420: else if ((*s_objet_1).type == CPL)
3421: {
3422: /*
3423: * Conversion du vecteur en vecteur complexe
3424: */
3425:
3426: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
3427: (*s_objet_3).objet)).tableau);
3428:
3429: (*((struct_vecteur *) (*s_objet_3).objet)).type = 'C';
3430: (*s_objet_3).type = VCX;
3431:
3432: if (((*((struct_vecteur *) (*s_objet_3).objet)).tableau
3433: = malloc(((size_t) (*((struct_vecteur *)
3434: (*s_objet_3).objet)).taille) *
3435: sizeof(struct_complexe16))) == NULL)
3436: {
3437: (*s_etat_processus).erreur_systeme =
3438: d_es_allocation_memoire;
3439: return;
3440: }
3441:
3442: for(i = 0; i < (*((struct_vecteur *) (*s_objet_3).objet))
3443: .taille; i++)
3444: {
3445: ((struct_complexe16 *) (*((struct_vecteur *)
3446: (*s_objet_3).objet)).tableau)[i].partie_reelle =
3447: ((real8 *) tampon)[i];
3448: ((struct_complexe16 *) (*((struct_vecteur *)
3449: (*s_objet_3).objet)).tableau)[i]
3450: .partie_imaginaire = (real8) 0;
3451: }
3452:
3453: free((real8 *) tampon);
3454:
3455: ((struct_complexe16 *) (*((struct_vecteur *)
3456: (*s_objet_3).objet)).tableau)[indice_i - 1]
3457: .partie_reelle = (*((struct_complexe16 *)
3458: (*s_objet_1).objet)).partie_reelle;
3459: ((struct_complexe16 *) (*((struct_vecteur *)
3460: (*s_objet_3).objet)).tableau)[indice_i - 1]
3461: .partie_imaginaire = (*((struct_complexe16 *)
3462: (*s_objet_1).objet)).partie_imaginaire;
3463: }
3464: else
3465: {
3466: liberation(s_etat_processus, s_objet_1);
3467: liberation(s_etat_processus, s_objet_2);
3468: liberation(s_etat_processus, s_objet_3);
3469:
3470: (*s_etat_processus).erreur_execution =
3471: d_ex_erreur_type_argument;
3472: return;
3473: }
3474: }
3475: else
3476: {
3477: /*
3478: * Vecteur de complexes
3479: */
3480:
3481: if ((*s_objet_1).type == INT)
3482: {
3483: /*
3484: * Conversion de l'élément à insérer en complexe
3485: */
3486:
3487: ((struct_complexe16 *) (*((struct_vecteur *)
3488: (*s_objet_3).objet)).tableau)[indice_i - 1]
3489: .partie_reelle = (real8) (*((integer8 *)
3490: (*s_objet_1).objet));
3491: ((struct_complexe16 *) (*((struct_vecteur *)
3492: (*s_objet_3).objet)).tableau)[indice_i - 1]
3493: .partie_imaginaire = (real8) 0;
3494: }
3495: else if ((*s_objet_1).type == REL)
3496: {
3497: /*
3498: * Conversion de l'élément à insérer en complexe
3499: */
3500:
3501: ((struct_complexe16 *) (*((struct_vecteur *)
3502: (*s_objet_3).objet)).tableau)[indice_i - 1]
3503: .partie_reelle = (*((real8 *) (*s_objet_1).objet));
3504: ((struct_complexe16 *) (*((struct_vecteur *)
3505: (*s_objet_3).objet)).tableau)[indice_i - 1]
3506: .partie_imaginaire = (real8) 0;
3507: }
3508: else if ((*s_objet_1).type == CPL)
3509: {
3510: /*
3511: * Aucune conversion de type
3512: */
3513:
3514: ((struct_complexe16 *) (*((struct_vecteur *)
3515: (*s_objet_3).objet)).tableau)[indice_i - 1]
3516: .partie_reelle = (*((struct_complexe16 *)
3517: (*s_objet_1).objet)).partie_reelle;
3518: ((struct_complexe16 *) (*((struct_vecteur *)
3519: (*s_objet_3).objet)).tableau)[indice_i - 1]
3520: .partie_imaginaire = (*((struct_complexe16 *)
3521: (*s_objet_1).objet)).partie_imaginaire;
3522: }
3523: else
3524: {
3525: liberation(s_etat_processus, s_objet_1);
3526: liberation(s_etat_processus, s_objet_2);
3527: liberation(s_etat_processus, s_objet_3);
3528:
3529: (*s_etat_processus).erreur_execution =
3530: d_ex_erreur_type_argument;
3531: return;
3532: }
3533: }
3534:
3535: liberation(s_etat_processus, s_objet_1);
3536:
3537: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3538: s_objet_3) == d_erreur)
3539: {
3540: return;
3541: }
3542:
3543: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
3544: (indice_i % (*((struct_vecteur *) (*s_objet_3).objet))
3545: .taille) + 1;
3546:
3547: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3548: s_objet_2) == d_erreur)
3549: {
3550: return;
3551: }
3552: }
3553:
3554: /*
3555: --------------------------------------------------------------------------------
3556: Traitement des éléments des matrices
3557: --------------------------------------------------------------------------------
3558: */
3559:
3560: else if (((*s_objet_3).type == MIN) ||
3561: ((*s_objet_3).type == MRL) ||
3562: ((*s_objet_3).type == MCX))
3563: {
3564: if ((*s_objet_2).type != LST)
3565: {
3566: liberation(s_etat_processus, s_objet_1);
3567: liberation(s_etat_processus, s_objet_2);
3568: liberation(s_etat_processus, s_objet_3);
3569:
3570: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3571: return;
3572: }
3573:
3574: l_element_courant = (*s_objet_2).objet;
3575: nombre_dimensions = 0;
3576:
3577: while(l_element_courant != NULL)
3578: {
3579: nombre_dimensions++;
3580: l_element_courant = (*l_element_courant).suivant;
3581: }
3582:
3583: if (nombre_dimensions != 2)
3584: {
3585: liberation(s_etat_processus, s_objet_1);
3586: liberation(s_etat_processus, s_objet_2);
3587: liberation(s_etat_processus, s_objet_3);
3588:
3589: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
3590: return;
3591: }
3592:
3593: l_element_courant = (*s_objet_2).objet;
3594:
3595: indice_i = 0;
3596: indice_j = 0;
3597:
3598: while(l_element_courant != NULL)
3599: {
3600: if ((*(*l_element_courant).donnee).type != INT)
3601: {
3602: liberation(s_etat_processus, s_objet_1);
3603: liberation(s_etat_processus, s_objet_2);
3604: liberation(s_etat_processus, s_objet_3);
3605:
3606: (*s_etat_processus).erreur_execution =
3607: d_ex_erreur_type_argument;
3608: return;
3609: }
3610:
3611: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
3612: {
3613: liberation(s_etat_processus, s_objet_1);
3614: liberation(s_etat_processus, s_objet_2);
3615: liberation(s_etat_processus, s_objet_3);
3616:
3617: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
3618: return;
3619: }
3620:
3621: if (indice_i == 0)
3622: {
3623: indice_i = (*((integer8 *)
3624: (*(*l_element_courant).donnee).objet));
3625: }
3626: else
3627: {
3628: indice_j = (*((integer8 *)
3629: (*(*l_element_courant).donnee).objet));
3630: }
3631:
3632: l_element_courant = (*l_element_courant).suivant;
3633: }
3634:
3635: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
3636: .nombre_lignes) || (indice_j > (*((struct_matrice *)
3637: (*s_objet_3).objet)).nombre_colonnes))
3638: {
3639: liberation(s_etat_processus, s_objet_1);
3640: liberation(s_etat_processus, s_objet_2);
3641: liberation(s_etat_processus, s_objet_3);
3642:
3643: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
3644: return;
3645: }
3646:
3647: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'Q')) == NULL)
3648: {
3649: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
3650: return;
3651: }
3652:
3653: liberation(s_etat_processus, s_objet_3);
3654: s_objet_3 = s_copie_3;
3655:
3656: if ((*s_objet_3).type == MIN)
3657: {
3658: /*
3659: * Matrice d'entiers
3660: */
3661:
3662: if ((*s_objet_1).type == INT)
3663: {
3664: /*
3665: * Aucune conversion de type
3666: */
3667:
3668: ((integer8 **) (*((struct_matrice *) (*s_objet_3).objet))
3669: .tableau)[indice_i - 1][indice_j - 1] =
3670: (*((integer8 *) (*s_objet_1).objet));
3671: }
3672: else if ((*s_objet_1).type == REL)
3673: {
3674: /*
3675: * Conversion de la matrice en matrice réelle
3676: */
3677:
3678: tampon = (void *) ((integer8 **) (*((struct_matrice *)
3679: (*s_objet_3).objet)).tableau);
3680:
3681: (*((struct_matrice *) (*s_objet_3).objet)).type = 'R';
3682: (*s_objet_3).type = MRL;
3683:
3684: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
3685: = malloc(((size_t) (*((struct_matrice *)
3686: (*s_objet_3).objet)).nombre_lignes) * sizeof(real8 *)))
3687: == NULL)
3688: {
3689: (*s_etat_processus).erreur_systeme =
3690: d_es_allocation_memoire;
3691: return;
3692: }
3693:
3694: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
3695: .nombre_lignes; i++)
3696: {
3697: if ((((real8 **) (*((struct_matrice *)
3698: (*s_objet_3).objet)).tableau)[i]
3699: = malloc(((size_t) (*((struct_matrice *)
3700: (*s_objet_3).objet)).nombre_colonnes) *
3701: sizeof(real8))) == NULL)
3702: {
3703: (*s_etat_processus).erreur_systeme =
3704: d_es_allocation_memoire;
3705: return;
3706: }
3707:
3708: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
3709: .nombre_colonnes; j++)
3710: {
3711: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
3712: .tableau)[i][j] = (real8) (((integer8 **)
3713: tampon)[i][j]);
3714: }
3715:
3716: free(((integer8 **) tampon)[i]);
3717: }
3718:
3719: free((integer8 **) tampon);
3720:
3721: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
3722: .tableau)[indice_i - 1][indice_j - 1] = (*((real8 *)
3723: (*s_objet_1).objet));
3724: }
3725: else if ((*s_objet_1).type == CPL)
3726: {
3727: /*
3728: * Conversion de la matrice en matrice complexe
3729: */
3730:
3731: tampon = (void *) ((integer8 **) (*((struct_matrice *)
3732: (*s_objet_3).objet)).tableau);
3733:
3734: (*((struct_matrice *) (*s_objet_3).objet)).type = 'C';
3735: (*s_objet_3).type = MCX;
3736:
3737: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
3738: = malloc(((size_t) (*((struct_matrice *)
3739: (*s_objet_3).objet)).nombre_lignes) *
3740: sizeof(struct_complexe16 *))) == NULL)
3741: {
3742: (*s_etat_processus).erreur_systeme =
3743: d_es_allocation_memoire;
3744: return;
3745: }
3746:
3747: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
3748: .nombre_lignes; i++)
3749: {
3750: if ((((struct_complexe16 **) (*((struct_matrice *)
3751: (*s_objet_3).objet)).tableau)[i]
3752: = malloc(((size_t) (*((struct_matrice *)
3753: (*s_objet_3).objet)).nombre_colonnes) *
3754: sizeof(struct_complexe16))) == NULL)
3755: {
3756: (*s_etat_processus).erreur_systeme =
3757: d_es_allocation_memoire;
3758: return;
3759: }
3760:
3761: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
3762: .nombre_colonnes; j++)
3763: {
3764: ((struct_complexe16 **) (*((struct_matrice *)
3765: (*s_objet_3).objet)).tableau)[i][j]
3766: .partie_reelle = (real8) (((integer8 **)
3767: tampon)[i][j]);
3768: ((struct_complexe16 **) (*((struct_matrice *)
3769: (*s_objet_3).objet)).tableau)[i][j]
3770: .partie_imaginaire = (real8) 0;
3771: }
3772:
3773: free(((integer8 **) tampon)[i]);
3774: }
3775:
3776: free((integer8 **) tampon);
3777:
3778: ((struct_complexe16 **) (*((struct_matrice *)
3779: (*s_objet_3).objet)).tableau)[indice_i - 1]
3780: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
3781: (*s_objet_1).objet)).partie_reelle;
3782: ((struct_complexe16 **) (*((struct_matrice *)
3783: (*s_objet_3).objet)).tableau)[indice_i - 1]
3784: [indice_j - 1].partie_imaginaire =
3785: (*((struct_complexe16 *)
3786: (*s_objet_1).objet)).partie_imaginaire;
3787: }
3788: else
3789: {
3790: liberation(s_etat_processus, s_objet_1);
3791: liberation(s_etat_processus, s_objet_2);
3792: liberation(s_etat_processus, s_objet_3);
3793:
3794: (*s_etat_processus).erreur_execution =
3795: d_ex_erreur_type_argument;
3796: return;
3797: }
3798: }
3799: else if ((*s_objet_3).type == MRL)
3800: {
3801: /*
3802: * Matrice de réels
3803: */
3804:
3805: if ((*s_objet_1).type == INT)
3806: {
3807: /*
3808: * Conversion de l'élément à insérer en réel
3809: */
3810:
3811: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
3812: .tableau)[indice_i - 1][indice_j - 1] =
3813: (real8) (*((integer8 *) (*s_objet_1).objet));
3814: }
3815: else if ((*s_objet_1).type == REL)
3816: {
3817: /*
3818: * Aucune conversion de type
3819: */
3820:
3821: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
3822: .tableau)[indice_i - 1][indice_j - 1] = (*((real8 *)
3823: (*s_objet_1).objet));
3824: }
3825: else if ((*s_objet_1).type == CPL)
3826: {
3827: /*
3828: * Conversion de la matrice en matrice complexe
3829: */
3830:
3831: tampon = (void *) ((real8 **) (*((struct_matrice *)
3832: (*s_objet_3).objet)).tableau);
3833:
3834: (*((struct_matrice *) (*s_objet_3).objet)).type = 'C';
3835: (*s_objet_3).type = MCX;
3836:
3837: if (((*((struct_matrice *) (*s_objet_3).objet)).tableau
3838: = malloc(((size_t) (*((struct_matrice *)
3839: (*s_objet_3).objet)).nombre_lignes) *
3840: sizeof(struct_complexe16 *))) == NULL)
3841: {
3842: (*s_etat_processus).erreur_systeme =
3843: d_es_allocation_memoire;
3844: return;
3845: }
3846:
3847: for(i = 0; i < (*((struct_matrice *) (*s_objet_3).objet))
3848: .nombre_lignes; i++)
3849: {
3850: if ((((struct_complexe16 **) (*((struct_matrice *)
3851: (*s_objet_3).objet)).tableau)[i]
3852: = malloc(((size_t) (*((struct_matrice *)
3853: (*s_objet_3).objet)).nombre_colonnes) *
3854: sizeof(struct_complexe16))) == NULL)
3855: {
3856: (*s_etat_processus).erreur_systeme =
3857: d_es_allocation_memoire;
3858: return;
3859: }
3860:
3861: for(j = 0; j < (*((struct_matrice *) (*s_objet_3).objet))
3862: .nombre_colonnes; j++)
3863: {
3864: ((struct_complexe16 **) (*((struct_matrice *)
3865: (*s_objet_3).objet)).tableau)[i][j]
3866: .partie_reelle = (((real8 **)
3867: tampon)[i][j]);
3868: ((struct_complexe16 **) (*((struct_matrice *)
3869: (*s_objet_3).objet)).tableau)[i][j]
3870: .partie_imaginaire = (real8) 0;
3871: }
3872:
3873: free(((integer8 **) tampon)[i]);
3874: }
3875:
3876: free((integer8 **) tampon);
3877:
3878: ((struct_complexe16 **) (*((struct_matrice *)
3879: (*s_objet_3).objet)).tableau)[indice_i - 1]
3880: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
3881: (*s_objet_1).objet)).partie_reelle;
3882: ((struct_complexe16 **) (*((struct_matrice *)
3883: (*s_objet_3).objet)).tableau)[indice_i - 1]
3884: [indice_j - 1].partie_imaginaire =
3885: (*((struct_complexe16 *)
3886: (*s_objet_1).objet)).partie_imaginaire;
3887: }
3888: else
3889: {
3890: liberation(s_etat_processus, s_objet_1);
3891: liberation(s_etat_processus, s_objet_2);
3892: liberation(s_etat_processus, s_objet_3);
3893:
3894: (*s_etat_processus).erreur_execution =
3895: d_ex_erreur_type_argument;
3896: return;
3897: }
3898: }
3899: else
3900: {
3901: /*
3902: * Matrice de complexes
3903: */
3904:
3905: if ((*s_objet_1).type == INT)
3906: {
3907: /*
3908: * Conversion de l'élément à insérer en complexe
3909: */
3910:
3911: ((struct_complexe16 **) (*((struct_matrice *)
3912: (*s_objet_3).objet)).tableau)[indice_i - 1]
3913: [indice_j - 1].partie_reelle = (real8) (*((integer8 *)
3914: (*s_objet_1).objet));
3915: ((struct_complexe16 **) (*((struct_matrice *)
3916: (*s_objet_3).objet)).tableau)[indice_i - 1]
3917: [indice_j - 1].partie_imaginaire = (real8) 0;
3918: }
3919: else if ((*s_objet_1).type == REL)
3920: {
3921: /*
3922: * Conversion de l'élément à insérer en complexe
3923: */
3924:
3925: ((struct_complexe16 **) (*((struct_matrice *)
3926: (*s_objet_3).objet)).tableau)[indice_i - 1]
3927: [indice_j - 1].partie_reelle =
3928: (*((real8 *) (*s_objet_1).objet));
3929: ((struct_complexe16 **) (*((struct_matrice *)
3930: (*s_objet_3).objet)).tableau)[indice_i - 1]
3931: [indice_j - 1].partie_imaginaire = (real8) 0;
3932: }
3933: else if ((*s_objet_1).type == CPL)
3934: {
3935: /*
3936: * Aucune conversion de type
3937: */
3938:
3939: ((struct_complexe16 **) (*((struct_matrice *)
3940: (*s_objet_3).objet)).tableau)[indice_i - 1]
3941: [indice_j - 1].partie_reelle = (*((struct_complexe16 *)
3942: (*s_objet_1).objet)).partie_reelle;
3943: ((struct_complexe16 **) (*((struct_matrice *)
3944: (*s_objet_3).objet)).tableau)[indice_i - 1]
3945: [indice_j - 1].partie_imaginaire =
3946: (*((struct_complexe16 *)
3947: (*s_objet_1).objet)).partie_imaginaire;
3948: }
3949: else
3950: {
3951: liberation(s_etat_processus, s_objet_1);
3952: liberation(s_etat_processus, s_objet_2);
3953: liberation(s_etat_processus, s_objet_3);
3954:
3955: (*s_etat_processus).erreur_execution =
3956: d_ex_erreur_type_argument;
3957: return;
3958: }
3959: }
3960:
3961: liberation(s_etat_processus, s_objet_1);
3962:
3963: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3964: s_objet_3) == d_erreur)
3965: {
3966: return;
3967: }
3968:
3969: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
3970: (*s_objet_2).objet)).suivant).donnee).objet))) > (integer8)
3971: (*((struct_matrice *) (*s_objet_3).objet)).nombre_colonnes)
3972: {
3973: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_2)
3974: .objet)).suivant).donnee).objet)) = 1;
3975:
3976: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
3977: (*s_objet_2).objet)).donnee).objet))) > (integer8)
3978: (*((struct_matrice *) (*s_objet_3).objet)).nombre_lignes)
3979: {
3980: (*((integer8 *) (*(*((struct_liste_chainee *)
3981: (*s_objet_2).objet)).donnee).objet)) = 1;
3982: }
3983: }
3984:
3985: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3986: s_objet_2) == d_erreur)
3987: {
3988: return;
3989: }
3990: }
3991:
3992: /*
3993: --------------------------------------------------------------------------------
3994: Traitement des éléments des listes
3995: --------------------------------------------------------------------------------
3996: */
3997:
3998: else if ((*s_objet_3).type == LST)
3999: {
4000: if ((*s_objet_2).type != INT)
4001: {
4002: liberation(s_etat_processus, s_objet_1);
4003: liberation(s_etat_processus, s_objet_2);
4004: liberation(s_etat_processus, s_objet_3);
4005:
4006: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
4007: return;
4008: }
4009:
4010: indice_i = (*((integer8 *) (*s_objet_2).objet));
4011: indice_j = 1;
4012:
4013: if ((*s_objet_3).nombre_occurrences > 1)
4014: {
4015: if ((s_copie_3 = copie_objet(s_etat_processus, s_objet_3, 'N'))
4016: == NULL)
4017: {
4018: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4019: return;
4020: }
4021:
4022: liberation(s_etat_processus, s_objet_3);
4023: s_objet_3 = s_copie_3;
4024: }
4025:
4026: l_element_courant = (*s_objet_3).objet;
4027: nombre_elements = 0;
4028:
4029: while(l_element_courant != NULL)
4030: {
4031: l_element_courant = (*l_element_courant).suivant;
4032: nombre_elements++;
4033: }
4034:
4035: l_element_courant = (*s_objet_3).objet;
4036:
4037: while((l_element_courant != NULL) && (indice_j != indice_i))
4038: {
4039: l_element_courant = (*l_element_courant).suivant;
4040: indice_j++;
4041: }
4042:
4043: if (l_element_courant != NULL)
4044: {
4045: liberation(s_etat_processus, (*l_element_courant).donnee);
4046: (*l_element_courant).donnee = s_objet_1;
4047: }
4048: else
4049: {
4050: liberation(s_etat_processus, s_objet_1);
4051: liberation(s_etat_processus, s_objet_2);
4052: liberation(s_etat_processus, s_objet_3);
4053:
4054: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
4055: return;
4056: }
4057:
4058: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4059: s_objet_3) == d_erreur)
4060: {
4061: return;
4062: }
4063:
4064: (*((integer8 *) (*s_objet_2).objet)) =
4065: (indice_i % nombre_elements) + 1;
4066:
4067: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
4068: s_objet_2) == d_erreur)
4069: {
4070: return;
4071: }
4072: }
4073:
4074: /*
4075: --------------------------------------------------------------------------------
4076: Traitement des noms
4077: --------------------------------------------------------------------------------
4078: */
4079:
4080: else if ((*s_objet_3).type == NOM)
4081: {
4082: variable_partagee = d_faux;
4083:
4084: if (recherche_variable(s_etat_processus, (*((struct_nom *)
4085: (*s_objet_3).objet)).nom) == d_faux)
4086: {
4087: (*s_etat_processus).erreur_systeme = d_es;
4088: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
4089:
4090: liberation(s_etat_processus, s_objet_1);
4091: liberation(s_etat_processus, s_objet_2);
4092: liberation(s_etat_processus, s_objet_3);
4093:
4094: return;
4095: }
4096:
4097: if ((*(*s_etat_processus).pointeur_variable_courante)
4098: .variable_verrouillee == d_vrai)
4099: {
4100: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
4101:
4102: liberation(s_etat_processus, s_objet_1);
4103: liberation(s_etat_processus, s_objet_2);
4104: liberation(s_etat_processus, s_objet_3);
4105:
4106: return;
4107: }
4108:
4109: s_objet_4 = (*(*s_etat_processus).pointeur_variable_courante).objet;
4110:
4111: if (s_objet_4 == NULL)
4112: {
4113: if (recherche_variable_partagee(s_etat_processus,
4114: (*(*s_etat_processus).pointeur_variable_courante).nom,
4115: (*(*s_etat_processus).pointeur_variable_courante)
4116: .variable_partagee, (*(*s_etat_processus)
4117: .pointeur_variable_courante).origine) == NULL)
4118: {
4119: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4120: .pointeur_variable_partagee_courante).mutex)) != 0)
4121: {
4122: (*s_etat_processus).erreur_systeme = d_es_processus;
4123: return;
4124: }
4125:
4126: (*s_etat_processus).erreur_systeme = d_es;
4127: (*s_etat_processus).erreur_execution =
4128: d_ex_variable_non_definie;
4129:
4130: liberation(s_etat_processus, s_objet_1);
4131: liberation(s_etat_processus, s_objet_2);
4132: liberation(s_etat_processus, s_objet_3);
4133:
4134: return;
4135: }
4136:
4137: s_objet_4 = (*(*s_etat_processus)
4138: .pointeur_variable_partagee_courante).objet;
4139: variable_partagee = d_vrai;
4140: }
4141:
4142: if (((*s_objet_4).type == VIN) ||
4143: ((*s_objet_4).type == VRL) ||
4144: ((*s_objet_4).type == VCX))
4145: {
4146: if ((*s_objet_2).type != LST)
4147: {
4148: if (variable_partagee == d_vrai)
4149: {
4150: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4151: .pointeur_variable_partagee_courante).mutex)) != 0)
4152: {
4153: (*s_etat_processus).erreur_systeme = d_es_processus;
4154: return;
4155: }
4156: }
4157:
4158: liberation(s_etat_processus, s_objet_1);
4159: liberation(s_etat_processus, s_objet_2);
4160: liberation(s_etat_processus, s_objet_3);
4161:
4162: (*s_etat_processus).erreur_execution =
4163: d_ex_erreur_type_argument;
4164: return;
4165: }
4166:
4167: l_element_courant = (*s_objet_2).objet;
4168: nombre_dimensions = 0;
4169:
4170: while(l_element_courant != NULL)
4171: {
4172: nombre_dimensions++;
4173: l_element_courant = (*l_element_courant).suivant;
4174: }
4175:
4176: if (nombre_dimensions != 1)
4177: {
4178: if (variable_partagee == d_vrai)
4179: {
4180: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4181: .pointeur_variable_partagee_courante).mutex)) != 0)
4182: {
4183: (*s_etat_processus).erreur_systeme = d_es_processus;
4184: return;
4185: }
4186: }
4187:
4188: liberation(s_etat_processus, s_objet_1);
4189: liberation(s_etat_processus, s_objet_2);
4190: liberation(s_etat_processus, s_objet_3);
4191:
4192: (*s_etat_processus).erreur_execution =
4193: d_ex_dimensions_invalides;
4194: return;
4195: }
4196:
4197: l_element_courant = (*s_objet_2).objet;
4198:
4199: if ((*(*l_element_courant).donnee).type != INT)
4200: {
4201: if (variable_partagee == d_vrai)
4202: {
4203: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4204: .pointeur_variable_partagee_courante).mutex)) != 0)
4205: {
4206: (*s_etat_processus).erreur_systeme = d_es_processus;
4207: return;
4208: }
4209: }
4210:
4211: liberation(s_etat_processus, s_objet_1);
4212: liberation(s_etat_processus, s_objet_2);
4213: liberation(s_etat_processus, s_objet_3);
4214:
4215: (*s_etat_processus).erreur_execution =
4216: d_ex_erreur_type_argument;
4217: return;
4218: }
4219:
4220: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
4221: {
4222: if (variable_partagee == d_vrai)
4223: {
4224: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4225: .pointeur_variable_partagee_courante).mutex)) != 0)
4226: {
4227: (*s_etat_processus).erreur_systeme = d_es_processus;
4228: return;
4229: }
4230: }
4231:
4232: liberation(s_etat_processus, s_objet_1);
4233: liberation(s_etat_processus, s_objet_2);
4234: liberation(s_etat_processus, s_objet_3);
4235:
4236: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
4237: return;
4238: }
4239: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
4240: (integer8) (*((struct_vecteur *) (*s_objet_4).objet))
4241: .taille)
4242: {
4243: if (variable_partagee == d_vrai)
4244: {
4245: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4246: .pointeur_variable_partagee_courante).mutex)) != 0)
4247: {
4248: (*s_etat_processus).erreur_systeme = d_es_processus;
4249: return;
4250: }
4251: }
4252:
4253: liberation(s_etat_processus, s_objet_1);
4254: liberation(s_etat_processus, s_objet_2);
4255: liberation(s_etat_processus, s_objet_3);
4256:
4257: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
4258: return;
4259: }
4260:
4261: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
4262:
4263: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'Q'))
4264: == NULL)
4265: {
4266: if (variable_partagee == d_vrai)
4267: {
4268: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4269: .pointeur_variable_partagee_courante).mutex)) != 0)
4270: {
4271: (*s_etat_processus).erreur_systeme = d_es_processus;
4272: return;
4273: }
4274: }
4275:
4276: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4277: return;
4278: }
4279:
4280: liberation(s_etat_processus, s_objet_4);
4281: s_objet_4 = s_copie_4;
4282:
4283: if ((*s_objet_4).type == VIN)
4284: {
4285: /*
4286: * Vecteur d'entiers
4287: */
4288:
4289: if ((*s_objet_1).type == INT)
4290: {
4291: /*
4292: * Aucune conversion de type
4293: */
4294:
4295: ((integer8 *) (*((struct_vecteur *) (*s_objet_4).objet))
4296: .tableau)[indice_i - 1] = (*((integer8 *)
4297: (*s_objet_1).objet));
4298: }
4299: else if ((*s_objet_1).type == REL)
4300: {
4301: /*
4302: * Conversion du vecteur en vecteur réel
4303: */
4304:
4305: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
4306: (*s_objet_4).objet)).tableau);
4307:
4308: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'R';
4309: (*s_objet_4).type = VRL;
4310:
4311: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
4312: = malloc(((size_t) (*((struct_vecteur *)
4313: (*s_objet_4).objet)).taille) * sizeof(real8)))
4314: == NULL)
4315: {
4316: if (variable_partagee == d_vrai)
4317: {
4318: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4319: .pointeur_variable_partagee_courante)
4320: .mutex)) != 0)
4321: {
4322: (*s_etat_processus).erreur_systeme =
4323: d_es_processus;
4324: return;
4325: }
4326: }
4327:
4328: (*s_etat_processus).erreur_systeme =
4329: d_es_allocation_memoire;
4330: return;
4331: }
4332:
4333: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
4334: .taille; i++)
4335: {
4336: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
4337: .tableau)[i] = (real8) (((integer8 *)
4338: tampon)[i]);
4339: }
4340:
4341: free((integer8 *) tampon);
4342:
4343: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
4344: .tableau)[indice_i - 1] = (*((real8 *)
4345: (*s_objet_1).objet));
4346: }
4347: else if ((*s_objet_1).type == CPL)
4348: {
4349: /*
4350: * Conversion du vecteur en vecteur complexe
4351: */
4352:
4353: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
4354: (*s_objet_4).objet)).tableau);
4355:
4356: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'C';
4357: (*s_objet_4).type = VCX;
4358:
4359: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
4360: = malloc(((size_t) (*((struct_vecteur *)
4361: (*s_objet_4).objet)).taille) *
4362: sizeof(struct_complexe16))) == NULL)
4363: {
4364: if (variable_partagee == d_vrai)
4365: {
4366: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4367: .pointeur_variable_partagee_courante)
4368: .mutex)) != 0)
4369: {
4370: (*s_etat_processus).erreur_systeme =
4371: d_es_processus;
4372: return;
4373: }
4374: }
4375:
4376: (*s_etat_processus).erreur_systeme =
4377: d_es_allocation_memoire;
4378: return;
4379: }
4380:
4381: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
4382: .taille; i++)
4383: {
4384: ((struct_complexe16 *) (*((struct_vecteur *)
4385: (*s_objet_4).objet)).tableau)[i].partie_reelle =
4386: (real8) (((integer8 *) tampon)[i]);
4387: ((struct_complexe16 *) (*((struct_vecteur *)
4388: (*s_objet_4).objet)).tableau)[i]
4389: .partie_imaginaire = (real8) 0;
4390: }
4391:
4392: free((integer8 *) tampon);
4393:
4394: ((struct_complexe16 *) (*((struct_vecteur *)
4395: (*s_objet_4).objet)).tableau)[indice_i - 1]
4396: .partie_reelle = (*((struct_complexe16 *)
4397: (*s_objet_1).objet)).partie_reelle;
4398: ((struct_complexe16 *) (*((struct_vecteur *)
4399: (*s_objet_4).objet)).tableau)[indice_i - 1]
4400: .partie_imaginaire = (*((struct_complexe16 *)
4401: (*s_objet_1).objet)).partie_imaginaire;
4402: }
4403: else
4404: {
4405: if (variable_partagee == d_vrai)
4406: {
4407: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4408: .pointeur_variable_partagee_courante).mutex))
4409: != 0)
4410: {
4411: (*s_etat_processus).erreur_systeme =
4412: d_es_processus;
4413: return;
4414: }
4415: }
4416:
4417: liberation(s_etat_processus, s_objet_1);
4418: liberation(s_etat_processus, s_objet_2);
4419: liberation(s_etat_processus, s_objet_3);
4420:
4421: (*s_etat_processus).erreur_execution =
4422: d_ex_erreur_type_argument;
4423: return;
4424: }
4425: }
4426: else if ((*s_objet_4).type == VRL)
4427: {
4428: /*
4429: * Vecteur de réels
4430: */
4431:
4432: if ((*s_objet_1).type == INT)
4433: {
4434: /*
4435: * Conversion de l'élément à insérer en réel
4436: */
4437:
4438: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
4439: .tableau)[indice_i - 1] = (real8) (*((integer8 *)
4440: (*s_objet_1).objet));
4441: }
4442: else if ((*s_objet_1).type == REL)
4443: {
4444: /*
4445: * Aucune conversion de type
4446: */
4447:
4448: ((real8 *) (*((struct_vecteur *) (*s_objet_4).objet))
4449: .tableau)[indice_i - 1] = (*((real8 *)
4450: (*s_objet_1).objet));
4451: }
4452: else if ((*s_objet_1).type == CPL)
4453: {
4454: /*
4455: * Conversion du vecteur en vecteur complexe
4456: */
4457:
4458: tampon = (void *) ((integer8 *) (*((struct_vecteur *)
4459: (*s_objet_4).objet)).tableau);
4460:
4461: (*((struct_vecteur *) (*s_objet_4).objet)).type = 'C';
4462: (*s_objet_4).type = VCX;
4463:
4464: if (((*((struct_vecteur *) (*s_objet_4).objet)).tableau
4465: = malloc(((size_t) (*((struct_vecteur *)
4466: (*s_objet_4).objet)).taille) *
4467: sizeof(struct_complexe16))) == NULL)
4468: {
4469: if (variable_partagee == d_vrai)
4470: {
4471: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4472: .pointeur_variable_partagee_courante)
4473: .mutex)) != 0)
4474: {
4475: (*s_etat_processus).erreur_systeme =
4476: d_es_processus;
4477: return;
4478: }
4479: }
4480:
4481: (*s_etat_processus).erreur_systeme =
4482: d_es_allocation_memoire;
4483: return;
4484: }
4485:
4486: for(i = 0; i < (*((struct_vecteur *) (*s_objet_4).objet))
4487: .taille; i++)
4488: {
4489: ((struct_complexe16 *) (*((struct_vecteur *)
4490: (*s_objet_4).objet)).tableau)[i].partie_reelle =
4491: ((real8 *) tampon)[i];
4492: ((struct_complexe16 *) (*((struct_vecteur *)
4493: (*s_objet_4).objet)).tableau)[i]
4494: .partie_imaginaire = (real8) 0;
4495: }
4496:
4497: free((real8 *) tampon);
4498:
4499: ((struct_complexe16 *) (*((struct_vecteur *)
4500: (*s_objet_4).objet)).tableau)[indice_i - 1]
4501: .partie_reelle = (*((struct_complexe16 *)
4502: (*s_objet_1).objet)).partie_reelle;
4503: ((struct_complexe16 *) (*((struct_vecteur *)
4504: (*s_objet_4).objet)).tableau)[indice_i - 1]
4505: .partie_imaginaire = (*((struct_complexe16 *)
4506: (*s_objet_1).objet)).partie_imaginaire;
4507: }
4508: else
4509: {
4510: if (variable_partagee == d_vrai)
4511: {
4512: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4513: .pointeur_variable_partagee_courante)
4514: .mutex)) != 0)
4515: {
4516: (*s_etat_processus).erreur_systeme =
4517: d_es_processus;
4518: return;
4519: }
4520: }
4521:
4522: liberation(s_etat_processus, s_objet_1);
4523: liberation(s_etat_processus, s_objet_2);
4524: liberation(s_etat_processus, s_objet_3);
4525:
4526: (*s_etat_processus).erreur_execution =
4527: d_ex_erreur_type_argument;
4528: return;
4529: }
4530: }
4531: else
4532: {
4533: /*
4534: * Vecteur de complexes
4535: */
4536:
4537: if ((*s_objet_1).type == INT)
4538: {
4539: /*
4540: * Conversion de l'élément à insérer en complexe
4541: */
4542:
4543: ((struct_complexe16 *) (*((struct_vecteur *)
4544: (*s_objet_4).objet)).tableau)[indice_i - 1]
4545: .partie_reelle = (real8) (*((integer8 *)
4546: (*s_objet_1).objet));
4547: ((struct_complexe16 *) (*((struct_vecteur *)
4548: (*s_objet_4).objet)).tableau)[indice_i - 1]
4549: .partie_imaginaire = (real8) 0;
4550: }
4551: else if ((*s_objet_1).type == REL)
4552: {
4553: /*
4554: * Conversion de l'élément à insérer en complexe
4555: */
4556:
4557: ((struct_complexe16 *) (*((struct_vecteur *)
4558: (*s_objet_4).objet)).tableau)[indice_i - 1]
4559: .partie_reelle = (*((real8 *) (*s_objet_1).objet));
4560: ((struct_complexe16 *) (*((struct_vecteur *)
4561: (*s_objet_4).objet)).tableau)[indice_i - 1]
4562: .partie_imaginaire = (real8) 0;
4563: }
4564: else if ((*s_objet_1).type == CPL)
4565: {
4566: /*
4567: * Aucune conversion de type
4568: */
4569:
4570: ((struct_complexe16 *) (*((struct_vecteur *)
4571: (*s_objet_4).objet)).tableau)[indice_i - 1]
4572: .partie_reelle = (*((struct_complexe16 *)
4573: (*s_objet_1).objet)).partie_reelle;
4574: ((struct_complexe16 *) (*((struct_vecteur *)
4575: (*s_objet_4).objet)).tableau)[indice_i - 1]
4576: .partie_imaginaire = (*((struct_complexe16 *)
4577: (*s_objet_1).objet)).partie_imaginaire;
4578: }
4579: else
4580: {
4581: if (variable_partagee == d_vrai)
4582: {
4583: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4584: .pointeur_variable_partagee_courante)
4585: .mutex)) != 0)
4586: {
4587: (*s_etat_processus).erreur_systeme =
4588: d_es_processus;
4589: return;
4590: }
4591: }
4592:
4593: liberation(s_etat_processus, s_objet_1);
4594: liberation(s_etat_processus, s_objet_2);
4595: liberation(s_etat_processus, s_objet_3);
4596:
4597: (*s_etat_processus).erreur_execution =
4598: d_ex_erreur_type_argument;
4599: return;
4600: }
4601: }
4602:
4603: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
4604: (indice_i % (*((struct_vecteur *) (*s_objet_4).objet))
4605: .taille) + 1;
4606:
4607: if (variable_partagee == d_faux)
4608: {
4609: (*(*s_etat_processus).pointeur_variable_courante).objet =
4610: s_objet_4;
4611: }
4612: else
4613: {
4614: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
4615: (*(*s_etat_processus)
4616: .pointeur_variable_partagee_courante).objet = s_objet_4;
4617:
4618: if (variable_partagee == d_vrai)
4619: {
4620: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4621: .pointeur_variable_partagee_courante).mutex)) != 0)
4622: {
4623: (*s_etat_processus).erreur_systeme = d_es_processus;
4624: return;
4625: }
4626: }
4627: }
4628:
4629: liberation(s_etat_processus, s_objet_1);
4630: }
4631: else if (((*s_objet_4).type == MIN) ||
4632: ((*s_objet_4).type == MRL) ||
4633: ((*s_objet_4).type == MCX))
4634: {
4635: if ((*s_objet_2).type != LST)
4636: {
4637: if (variable_partagee == d_vrai)
4638: {
4639: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4640: .pointeur_variable_partagee_courante).mutex)) != 0)
4641: {
4642: (*s_etat_processus).erreur_systeme = d_es_processus;
4643: return;
4644: }
4645: }
4646:
4647: liberation(s_etat_processus, s_objet_1);
4648: liberation(s_etat_processus, s_objet_2);
4649: liberation(s_etat_processus, s_objet_3);
4650:
4651: (*s_etat_processus).erreur_execution =
4652: d_ex_erreur_type_argument;
4653: return;
4654: }
4655:
4656: l_element_courant = (*s_objet_2).objet;
4657: nombre_dimensions = 0;
4658:
4659: while(l_element_courant != NULL)
4660: {
4661: nombre_dimensions++;
4662: l_element_courant = (*l_element_courant).suivant;
4663: }
4664:
4665: if (nombre_dimensions != 2)
4666: {
4667: if (variable_partagee == d_vrai)
4668: {
4669: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4670: .pointeur_variable_partagee_courante).mutex)) != 0)
4671: {
4672: (*s_etat_processus).erreur_systeme = d_es_processus;
4673: return;
4674: }
4675: }
4676:
4677: liberation(s_etat_processus, s_objet_1);
4678: liberation(s_etat_processus, s_objet_2);
4679: liberation(s_etat_processus, s_objet_3);
4680:
4681: (*s_etat_processus).erreur_execution =
4682: d_ex_dimensions_invalides;
4683: return;
4684: }
4685:
4686: l_element_courant = (*s_objet_2).objet;
4687:
4688: indice_i = 0;
4689: indice_j = 0;
4690:
4691: while(l_element_courant != NULL)
4692: {
4693: if ((*(*l_element_courant).donnee).type != INT)
4694: {
4695: if (variable_partagee == d_vrai)
4696: {
4697: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4698: .pointeur_variable_partagee_courante).mutex))
4699: != 0)
4700: {
4701: (*s_etat_processus).erreur_systeme = d_es_processus;
4702: return;
4703: }
4704: }
4705:
4706: liberation(s_etat_processus, s_objet_1);
4707: liberation(s_etat_processus, s_objet_2);
4708: liberation(s_etat_processus, s_objet_3);
4709:
4710: (*s_etat_processus).erreur_execution =
4711: d_ex_erreur_type_argument;
4712: return;
4713: }
4714:
4715: if ((*((integer8 *) (*(*l_element_courant).donnee).objet))
4716: <= 0)
4717: {
4718: if (variable_partagee == d_vrai)
4719: {
4720: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4721: .pointeur_variable_partagee_courante).mutex))
4722: != 0)
4723: {
4724: (*s_etat_processus).erreur_systeme = d_es_processus;
4725: return;
4726: }
4727: }
4728:
4729: liberation(s_etat_processus, s_objet_1);
4730: liberation(s_etat_processus, s_objet_2);
4731: liberation(s_etat_processus, s_objet_3);
4732:
4733: (*s_etat_processus).erreur_execution =
4734: d_ex_argument_invalide;
4735: return;
4736: }
4737:
4738: if (indice_i == 0)
4739: {
4740: indice_i = (*((integer8 *)
4741: (*(*l_element_courant).donnee).objet));
4742: }
4743: else
4744: {
4745: indice_j = (*((integer8 *)
4746: (*(*l_element_courant).donnee).objet));
4747: }
4748:
4749: l_element_courant = (*l_element_courant).suivant;
4750: }
4751:
4752: if ((indice_i > (*((struct_matrice *) (*s_objet_4).objet))
4753: .nombre_lignes) || (indice_j > (*((struct_matrice *)
4754: (*s_objet_4).objet)).nombre_colonnes))
4755: {
4756: if (variable_partagee == d_vrai)
4757: {
4758: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4759: .pointeur_variable_partagee_courante).mutex)) != 0)
4760: {
4761: (*s_etat_processus).erreur_systeme = d_es_processus;
4762: return;
4763: }
4764: }
4765:
4766: liberation(s_etat_processus, s_objet_1);
4767: liberation(s_etat_processus, s_objet_2);
4768: liberation(s_etat_processus, s_objet_3);
4769:
4770: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
4771: return;
4772: }
4773:
4774: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'Q'))
4775: == NULL)
4776: {
4777: if (variable_partagee == d_vrai)
4778: {
4779: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4780: .pointeur_variable_partagee_courante).mutex)) != 0)
4781: {
4782: (*s_etat_processus).erreur_systeme = d_es_processus;
4783: return;
4784: }
4785: }
4786:
4787: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
4788: return;
4789: }
4790:
4791: liberation(s_etat_processus, s_objet_4);
4792: s_objet_4 = s_copie_4;
4793:
4794: if ((*s_objet_4).type == MIN)
4795: {
4796: /*
4797: * Matrice d'entiers
4798: */
4799:
4800: if ((*s_objet_1).type == INT)
4801: {
4802: /*
4803: * Aucune conversion de type
4804: */
4805:
4806: ((integer8 **) (*((struct_matrice *) (*s_objet_4).objet))
4807: .tableau)[indice_i - 1][indice_j - 1] =
4808: (*((integer8 *) (*s_objet_1).objet));
4809: }
4810: else if ((*s_objet_1).type == REL)
4811: {
4812: /*
4813: * Conversion de la matrice en matrice réelle
4814: */
4815:
4816: tampon = (void *) ((integer8 **) (*((struct_matrice *)
4817: (*s_objet_4).objet)).tableau);
4818:
4819: (*((struct_matrice *) (*s_objet_4).objet)).type = 'R';
4820: (*s_objet_4).type = MRL;
4821:
4822: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
4823: = malloc(((size_t) (*((struct_matrice *)
4824: (*s_objet_4).objet)).nombre_lignes) *
4825: sizeof(real8 *))) == NULL)
4826: {
4827: if (variable_partagee == d_vrai)
4828: {
4829: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4830: .pointeur_variable_partagee_courante)
4831: .mutex)) != 0)
4832: {
4833: (*s_etat_processus).erreur_systeme =
4834: d_es_processus;
4835: return;
4836: }
4837: }
4838:
4839: (*s_etat_processus).erreur_systeme =
4840: d_es_allocation_memoire;
4841: return;
4842: }
4843:
4844: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
4845: .nombre_lignes; i++)
4846: {
4847: if ((((real8 **) (*((struct_matrice *)
4848: (*s_objet_4).objet)).tableau)[i]
4849: = malloc(((size_t) (*((struct_matrice *)
4850: (*s_objet_4).objet)).nombre_colonnes) *
4851: sizeof(real8))) == NULL)
4852: {
4853: if (variable_partagee == d_vrai)
4854: {
4855: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4856: .pointeur_variable_partagee_courante)
4857: .mutex)) != 0)
4858: {
4859: (*s_etat_processus).erreur_systeme =
4860: d_es_processus;
4861: return;
4862: }
4863: }
4864:
4865: (*s_etat_processus).erreur_systeme =
4866: d_es_allocation_memoire;
4867: return;
4868: }
4869:
4870: for(j = 0; j < (*((struct_matrice *)
4871: (*s_objet_4).objet)).nombre_colonnes; j++)
4872: {
4873: ((real8 **) (*((struct_matrice *) (*s_objet_4)
4874: .objet)).tableau)[i][j] = (real8)
4875: (((integer8 **) tampon)[i][j]);
4876: }
4877:
4878: free(((integer8 **) tampon)[i]);
4879: }
4880:
4881: free((integer8 **) tampon);
4882:
4883: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
4884: .tableau)[indice_i - 1][indice_j - 1] =
4885: (*((real8 *) (*s_objet_1).objet));
4886: }
4887: else if ((*s_objet_1).type == CPL)
4888: {
4889: /*
4890: * Conversion de la matrice en matrice complexe
4891: */
4892:
4893: tampon = (void *) ((integer8 **) (*((struct_matrice *)
4894: (*s_objet_4).objet)).tableau);
4895:
4896: (*((struct_matrice *) (*s_objet_4).objet)).type = 'C';
4897: (*s_objet_4).type = MCX;
4898:
4899: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
4900: = malloc(((size_t) (*((struct_matrice *)
4901: (*s_objet_4).objet)).nombre_lignes) *
4902: sizeof(struct_complexe16 *))) == NULL)
4903: {
4904: if (variable_partagee == d_vrai)
4905: {
4906: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4907: .pointeur_variable_partagee_courante)
4908: .mutex)) != 0)
4909: {
4910: (*s_etat_processus).erreur_systeme =
4911: d_es_processus;
4912: return;
4913: }
4914: }
4915:
4916: (*s_etat_processus).erreur_systeme =
4917: d_es_allocation_memoire;
4918: return;
4919: }
4920:
4921: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
4922: .nombre_lignes; i++)
4923: {
4924: if ((((struct_complexe16 **) (*((struct_matrice *)
4925: (*s_objet_4).objet)).tableau)[i]
4926: = malloc(((size_t) (*((struct_matrice *)
4927: (*s_objet_4).objet)).nombre_colonnes) *
4928: sizeof(struct_complexe16))) == NULL)
4929: {
4930: if (variable_partagee == d_vrai)
4931: {
4932: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4933: .pointeur_variable_partagee_courante)
4934: .mutex)) != 0)
4935: {
4936: (*s_etat_processus).erreur_systeme =
4937: d_es_processus;
4938: return;
4939: }
4940: }
4941:
4942: (*s_etat_processus).erreur_systeme =
4943: d_es_allocation_memoire;
4944: return;
4945: }
4946:
4947: for(j = 0; j < (*((struct_matrice *)
4948: (*s_objet_4).objet)).nombre_colonnes; j++)
4949: {
4950: ((struct_complexe16 **) (*((struct_matrice *)
4951: (*s_objet_4).objet)).tableau)[i][j]
4952: .partie_reelle = (real8) (((integer8 **)
4953: tampon)[i][j]);
4954: ((struct_complexe16 **) (*((struct_matrice *)
4955: (*s_objet_4).objet)).tableau)[i][j]
4956: .partie_imaginaire = (real8) 0;
4957: }
4958:
4959: free(((integer8 **) tampon)[i]);
4960: }
4961:
4962: free((integer8 **) tampon);
4963:
4964: ((struct_complexe16 **) (*((struct_matrice *)
4965: (*s_objet_4).objet)).tableau)[indice_i - 1]
4966: [indice_j - 1].partie_reelle =
4967: (*((struct_complexe16 *)
4968: (*s_objet_1).objet)).partie_reelle;
4969: ((struct_complexe16 **) (*((struct_matrice *)
4970: (*s_objet_4).objet)).tableau)[indice_i - 1]
4971: [indice_j - 1].partie_imaginaire =
4972: (*((struct_complexe16 *)
4973: (*s_objet_1).objet)).partie_imaginaire;
4974: }
4975: else
4976: {
4977: if (variable_partagee == d_vrai)
4978: {
4979: if (pthread_mutex_unlock(&((*(*s_etat_processus)
4980: .pointeur_variable_partagee_courante).mutex))
4981: != 0)
4982: {
4983: (*s_etat_processus).erreur_systeme =
4984: d_es_processus;
4985: return;
4986: }
4987: }
4988:
4989: liberation(s_etat_processus, s_objet_1);
4990: liberation(s_etat_processus, s_objet_2);
4991: liberation(s_etat_processus, s_objet_3);
4992:
4993: (*s_etat_processus).erreur_execution =
4994: d_ex_erreur_type_argument;
4995: return;
4996: }
4997: }
4998: else if ((*s_objet_4).type == MRL)
4999: {
5000: /*
5001: * Matrice de réels
5002: */
5003:
5004: if ((*s_objet_1).type == INT)
5005: {
5006: /*
5007: * Conversion de l'élément à insérer en réel
5008: */
5009:
5010: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
5011: .tableau)[indice_i - 1][indice_j - 1] =
5012: (real8) (*((integer8 *) (*s_objet_1).objet));
5013: }
5014: else if ((*s_objet_1).type == REL)
5015: {
5016: /*
5017: * Aucune conversion de type
5018: */
5019:
5020: ((real8 **) (*((struct_matrice *) (*s_objet_4).objet))
5021: .tableau)[indice_i - 1][indice_j - 1] =
5022: (*((real8 *) (*s_objet_1).objet));
5023: }
5024: else if ((*s_objet_1).type == CPL)
5025: {
5026: /*
5027: * Conversion de la matrice en matrice complexe
5028: */
5029:
5030: tampon = (void *) ((real8 **) (*((struct_matrice *)
5031: (*s_objet_4).objet)).tableau);
5032:
5033: (*((struct_matrice *) (*s_objet_4).objet)).type = 'C';
5034: (*s_objet_4).type = MCX;
5035:
5036: if (((*((struct_matrice *) (*s_objet_4).objet)).tableau
5037: = malloc(((size_t) (*((struct_matrice *)
5038: (*s_objet_4).objet)).nombre_lignes) *
5039: sizeof(struct_complexe16 *))) == NULL)
5040: {
5041: if (variable_partagee == d_vrai)
5042: {
5043: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5044: .pointeur_variable_partagee_courante)
5045: .mutex)) != 0)
5046: {
5047: (*s_etat_processus).erreur_systeme =
5048: d_es_processus;
5049: return;
5050: }
5051: }
5052:
5053: (*s_etat_processus).erreur_systeme =
5054: d_es_allocation_memoire;
5055: return;
5056: }
5057:
5058: for(i = 0; i < (*((struct_matrice *) (*s_objet_4).objet))
5059: .nombre_lignes; i++)
5060: {
5061: if ((((struct_complexe16 **) (*((struct_matrice *)
5062: (*s_objet_4).objet)).tableau)[i]
5063: = malloc(((size_t) (*((struct_matrice *)
5064: (*s_objet_4).objet)).nombre_colonnes) *
5065: sizeof(struct_complexe16))) == NULL)
5066: {
5067: if (variable_partagee == d_vrai)
5068: {
5069: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5070: .pointeur_variable_partagee_courante)
5071: .mutex)) != 0)
5072: {
5073: (*s_etat_processus).erreur_systeme =
5074: d_es_processus;
5075: return;
5076: }
5077: }
5078:
5079: (*s_etat_processus).erreur_systeme =
5080: d_es_allocation_memoire;
5081: return;
5082: }
5083:
5084: for(j = 0; j < (*((struct_matrice *)
5085: (*s_objet_4).objet)).nombre_colonnes; j++)
5086: {
5087: ((struct_complexe16 **) (*((struct_matrice *)
5088: (*s_objet_4).objet)).tableau)[i][j]
5089: .partie_reelle = (((real8 **)
5090: tampon)[i][j]);
5091: ((struct_complexe16 **) (*((struct_matrice *)
5092: (*s_objet_4).objet)).tableau)[i][j]
5093: .partie_imaginaire = (real8) 0;
5094: }
5095:
5096: free(((integer8 **) tampon)[i]);
5097: }
5098:
5099: free((integer8 **) tampon);
5100:
5101: ((struct_complexe16 **) (*((struct_matrice *)
5102: (*s_objet_4).objet)).tableau)[indice_i - 1]
5103: [indice_j - 1].partie_reelle =
5104: (*((struct_complexe16 *)
5105: (*s_objet_1).objet)).partie_reelle;
5106: ((struct_complexe16 **) (*((struct_matrice *)
5107: (*s_objet_4).objet)).tableau)[indice_i - 1]
5108: [indice_j - 1].partie_imaginaire =
5109: (*((struct_complexe16 *)
5110: (*s_objet_1).objet)).partie_imaginaire;
5111: }
5112: else
5113: {
5114: if (variable_partagee == d_vrai)
5115: {
5116: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5117: .pointeur_variable_partagee_courante).mutex))
5118: != 0)
5119: {
5120: (*s_etat_processus).erreur_systeme =
5121: d_es_processus;
5122: return;
5123: }
5124: }
5125:
5126: liberation(s_etat_processus, s_objet_1);
5127: liberation(s_etat_processus, s_objet_2);
5128: liberation(s_etat_processus, s_objet_3);
5129:
5130: (*s_etat_processus).erreur_execution =
5131: d_ex_erreur_type_argument;
5132: return;
5133: }
5134: }
5135: else
5136: {
5137: /*
5138: * Matrice de complexes
5139: */
5140:
5141: if ((*s_objet_1).type == INT)
5142: {
5143: /*
5144: * Conversion de l'élément à insérer en complexe
5145: */
5146:
5147: ((struct_complexe16 **) (*((struct_matrice *)
5148: (*s_objet_4).objet)).tableau)[indice_i - 1]
5149: [indice_j - 1].partie_reelle = (real8)
5150: (*((integer8 *) (*s_objet_1).objet));
5151: ((struct_complexe16 **) (*((struct_matrice *)
5152: (*s_objet_4).objet)).tableau)[indice_i - 1]
5153: [indice_j - 1].partie_imaginaire = (real8) 0;
5154: }
5155: else if ((*s_objet_1).type == REL)
5156: {
5157: /*
5158: * Conversion de l'élément à insérer en complexe
5159: */
5160:
5161: ((struct_complexe16 **) (*((struct_matrice *)
5162: (*s_objet_4).objet)).tableau)[indice_i - 1]
5163: [indice_j - 1].partie_reelle =
5164: (*((real8 *) (*s_objet_1).objet));
5165: ((struct_complexe16 **) (*((struct_matrice *)
5166: (*s_objet_4).objet)).tableau)[indice_i - 1]
5167: [indice_j - 1].partie_imaginaire = (real8) 0;
5168: }
5169: else if ((*s_objet_1).type == CPL)
5170: {
5171: /*
5172: * Aucune conversion de type
5173: */
5174:
5175: ((struct_complexe16 **) (*((struct_matrice *)
5176: (*s_objet_4).objet)).tableau)[indice_i - 1]
5177: [indice_j - 1].partie_reelle =
5178: (*((struct_complexe16 *)
5179: (*s_objet_1).objet)).partie_reelle;
5180: ((struct_complexe16 **) (*((struct_matrice *)
5181: (*s_objet_4).objet)).tableau)[indice_i - 1]
5182: [indice_j - 1].partie_imaginaire =
5183: (*((struct_complexe16 *)
5184: (*s_objet_1).objet)).partie_imaginaire;
5185: }
5186: else
5187: {
5188: if (variable_partagee == d_vrai)
5189: {
5190: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5191: .pointeur_variable_partagee_courante).mutex))
5192: != 0)
5193: {
5194: (*s_etat_processus).erreur_systeme =
5195: d_es_processus;
5196: return;
5197: }
5198: }
5199:
5200: liberation(s_etat_processus, s_objet_1);
5201: liberation(s_etat_processus, s_objet_2);
5202: liberation(s_etat_processus, s_objet_3);
5203:
5204: (*s_etat_processus).erreur_execution =
5205: d_ex_erreur_type_argument;
5206: return;
5207: }
5208: }
5209:
5210: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
5211: (*s_objet_2).objet)).suivant).donnee).objet))) > (integer8)
5212: (*((struct_matrice *) (*s_objet_4).objet)).nombre_colonnes)
5213: {
5214: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_2)
5215: .objet)).suivant).donnee).objet)) = 1;
5216:
5217: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
5218: (*s_objet_2).objet)).donnee).objet))) > (integer8)
5219: (*((struct_matrice *) (*s_objet_4).objet))
5220: .nombre_lignes)
5221: {
5222: (*((integer8 *) (*(*((struct_liste_chainee *)
5223: (*s_objet_2).objet)).donnee).objet)) = 1;
5224: }
5225: }
5226:
5227: if (variable_partagee == d_faux)
5228: {
5229: (*(*s_etat_processus).pointeur_variable_courante).objet =
5230: s_objet_4;
5231: }
5232: else
5233: {
5234: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
5235: (*(*s_etat_processus).pointeur_variable_partagee_courante)
5236: .objet = s_objet_4;
5237:
5238: if (variable_partagee == d_vrai)
5239: {
5240: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5241: .pointeur_variable_partagee_courante).mutex)) != 0)
5242: {
5243: (*s_etat_processus).erreur_systeme =
5244: d_es_processus;
5245: return;
5246: }
5247: }
5248: }
5249:
5250: liberation(s_etat_processus, s_objet_1);
5251: }
5252: else if ((*s_objet_4).type == LST)
5253: {
5254: if ((*s_objet_2).type != INT)
5255: {
5256: if (variable_partagee == d_vrai)
5257: {
5258: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5259: .pointeur_variable_partagee_courante).mutex)) != 0)
5260: {
5261: (*s_etat_processus).erreur_systeme =
5262: d_es_processus;
5263: return;
5264: }
5265: }
5266:
5267: liberation(s_etat_processus, s_objet_1);
5268: liberation(s_etat_processus, s_objet_2);
5269: liberation(s_etat_processus, s_objet_3);
5270:
5271: (*s_etat_processus).erreur_execution =
5272: d_ex_erreur_type_argument;
5273: return;
5274: }
5275:
5276: indice_i = (*((integer8 *) (*s_objet_2).objet));
5277: indice_j = 1;
5278:
5279: if ((*s_objet_4).nombre_occurrences > 1)
5280: {
5281: if ((s_copie_4 = copie_objet(s_etat_processus, s_objet_4, 'N'))
5282: == NULL)
5283: {
5284: if (variable_partagee == d_vrai)
5285: {
5286: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5287: .pointeur_variable_partagee_courante).mutex))
5288: != 0)
5289: {
5290: (*s_etat_processus).erreur_systeme =
5291: d_es_processus;
5292: return;
5293: }
5294: }
5295:
5296: (*s_etat_processus).erreur_systeme =
5297: d_es_allocation_memoire;
5298: return;
5299: }
5300:
5301: liberation(s_etat_processus, s_objet_4);
5302: s_objet_4 = s_copie_4;
5303: }
5304:
5305: l_element_courant = (*s_objet_4).objet;
5306: nombre_elements = 0;
5307:
5308: while(l_element_courant != NULL)
5309: {
5310: l_element_courant = (*l_element_courant).suivant;
5311: nombre_elements++;
5312: }
5313:
5314: l_element_courant = (*s_objet_4).objet;
5315:
5316: while((l_element_courant != NULL) && (indice_j != indice_i))
5317: {
5318: l_element_courant = (*l_element_courant).suivant;
5319: indice_j++;
5320: }
5321:
5322: if (l_element_courant != NULL)
5323: {
5324: liberation(s_etat_processus, (*l_element_courant).donnee);
5325: (*l_element_courant).donnee = s_objet_1;
5326: }
5327: else
5328: {
5329: if (variable_partagee == d_vrai)
5330: {
5331: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5332: .pointeur_variable_partagee_courante).mutex)) != 0)
5333: {
5334: (*s_etat_processus).erreur_systeme =
5335: d_es_processus;
5336: return;
5337: }
5338: }
5339:
5340: liberation(s_etat_processus, s_objet_1);
5341: liberation(s_etat_processus, s_objet_2);
5342: liberation(s_etat_processus, s_objet_3);
5343:
5344: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
5345: return;
5346: }
5347:
5348: (*((integer8 *) (*s_objet_2).objet)) =
5349: (indice_i % nombre_elements) + 1;
5350:
5351: if (variable_partagee == d_faux)
5352: {
5353: (*(*s_etat_processus).pointeur_variable_courante).objet =
5354: s_objet_4;
5355: }
5356: else
5357: {
5358: (*(*s_etat_processus).pointeur_variable_courante).objet = NULL;
5359: (*(*s_etat_processus).pointeur_variable_partagee_courante)
5360: .objet = s_objet_4;
5361:
5362: if (variable_partagee == d_vrai)
5363: {
5364: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5365: .pointeur_variable_partagee_courante).mutex)) != 0)
5366: {
5367: (*s_etat_processus).erreur_systeme =
5368: d_es_processus;
5369: return;
5370: }
5371: }
5372: }
5373: }
5374: else
5375: {
5376: if (variable_partagee == d_vrai)
5377: {
5378: if (pthread_mutex_unlock(&((*(*s_etat_processus)
5379: .pointeur_variable_partagee_courante).mutex)) != 0)
5380: {
5381: (*s_etat_processus).erreur_systeme =
5382: d_es_processus;
5383: return;
5384: }
5385: }
5386:
5387: liberation(s_etat_processus, s_objet_1);
5388: liberation(s_etat_processus, s_objet_2);
5389: liberation(s_etat_processus, s_objet_3);
5390:
5391: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
5392: return;
5393: }
5394:
5395: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
5396: s_objet_3) == d_erreur)
5397: {
5398: return;
5399: }
5400:
5401: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
5402: s_objet_2) == d_erreur)
5403: {
5404: return;
5405: }
5406: }
5407:
5408: /*
5409: --------------------------------------------------------------------------------
5410: Arguments incompatibles
5411: --------------------------------------------------------------------------------
5412: */
5413:
5414: else
5415: {
5416: liberation(s_etat_processus, s_objet_1);
5417: liberation(s_etat_processus, s_objet_2);
5418: liberation(s_etat_processus, s_objet_3);
5419:
5420: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
5421: return;
5422: }
5423:
5424: return;
5425: }
5426:
5427: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>