Return to instructions_w1.c CVS log | Up to [local] / rpl / src |
1.1 bertrand 1: /*
2: ================================================================================
1.59 ! bertrand 3: RPL/2 (R) version 4.1.7
1.57 bertrand 4: Copyright (C) 1989-2012 Dr. BERTRAND Joël
1.1 bertrand 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:
1.20 bertrand 23: #include "rpl-conv.h"
1.1 bertrand 24:
25:
26: /*
27: ================================================================================
28: Fonction 'while'
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_while(struct_processus *s_etat_processus)
40: {
41: (*s_etat_processus).erreur_execution = d_ex;
42:
43: if ((*s_etat_processus).affichage_arguments == 'Y')
44: {
45: printf("\n WHILE ");
46:
47: if ((*s_etat_processus).langue == 'F')
48: {
49: printf("(structure de contrôle)\n\n");
50: printf(" Utilisation :\n\n");
51: }
52: else
53: {
54: printf("(control statement)\n\n");
55: printf(" Usage:\n\n");
56: }
57:
58: printf(" WHILE\n");
59: printf(" (clause)\n");
60: printf(" REPEAT\n");
61: printf(" (expression 1)\n");
62: printf(" EXIT\n");
63: printf(" (expression 2)\n");
64: printf(" END\n\n");
65:
66: printf(" WHILE\n");
67: printf(" (clause)\n");
68: printf(" REPEAT\n");
69: printf(" (expression)\n");
70: printf(" END\n");
71:
72: return;
73: }
74: else if ((*s_etat_processus).test_instruction == 'Y')
75: {
76: (*s_etat_processus).nombre_arguments = -1;
77: return;
78: }
79:
80: empilement_pile_systeme(s_etat_processus);
81:
82: if ((*s_etat_processus).erreur_systeme != d_es)
83: {
84: return;
85: }
86:
87: (*(*s_etat_processus).l_base_pile_systeme).type_cloture = 'W';
88: (*(*s_etat_processus).l_base_pile_systeme).clause = 'W';
89:
90: if ((*s_etat_processus).mode_execution_programme == 'Y')
91: {
92: (*(*s_etat_processus).l_base_pile_systeme).adresse_retour =
93: (*s_etat_processus).position_courante;
94: }
95: else
96: {
97: if ((*s_etat_processus).expression_courante == NULL)
98: {
99: (*s_etat_processus).erreur_execution =
100: d_ex_erreur_traitement_boucle;
101: return;
102: }
103:
104: (*(*s_etat_processus).l_base_pile_systeme).pointeur_objet_retour =
105: (*s_etat_processus).expression_courante;
106: }
107:
108: return;
109: }
110:
111:
112: /*
113: ================================================================================
114: Fonction 'warranty'
115: ================================================================================
116: Entrées :
117: --------------------------------------------------------------------------------
118: Sorties :
119: --------------------------------------------------------------------------------
120: Effets de bord : néant
121: ================================================================================
122: */
123:
124: void
125: instruction_warranty(struct_processus *s_etat_processus)
126: {
1.20 bertrand 127: # include "garanties-conv.h"
1.1 bertrand 128:
129: (*s_etat_processus).erreur_execution = d_ex;
130:
131: if ((*s_etat_processus).affichage_arguments == 'Y')
132: {
133: printf("\n WARRANTY ");
134:
135: if ((*s_etat_processus).langue == 'F')
136: {
137: printf("(garantie)\n\n");
138: printf(" Aucun argument\n");
139: }
140: else
141: {
142: printf("(warranty)\n\n");
143: printf(" No argument\n");
144: }
145:
146: return;
147: }
148: else if ((*s_etat_processus).test_instruction == 'Y')
149: {
150: (*s_etat_processus).nombre_arguments = -1;
151: return;
152: }
153:
154: printf("%s\n", warranty);
155:
156: if ((*s_etat_processus).hauteur_pile_operationnelle == 0)
157: {
158: printf("\n");
159: }
160:
161: return;
162: }
163:
164:
165: /*
166: ================================================================================
167: Fonction 'wait'
168: ================================================================================
169: Entrées :
170: --------------------------------------------------------------------------------
171: Sorties :
172: --------------------------------------------------------------------------------
173: Effets de bord : néant
174: ================================================================================
175: */
176:
177: void
178: instruction_wait(struct_processus *s_etat_processus)
179: {
180: int code_retour;
181: int erreur;
182:
183: real8 attente;
184:
185: struct_objet *s_objet;
186:
187: struct timespec temporisation;
188:
189: (*s_etat_processus).erreur_execution = d_ex;
190:
191: if ((*s_etat_processus).affichage_arguments == 'Y')
192: {
193: printf("\n WAIT ");
194:
195: if ((*s_etat_processus).langue == 'F')
196: {
197: printf("(attente exprimée en secondes)\n\n");
198: }
199: else
200: {
201: printf("(wait a number of seconds)\n\n");
202: }
203:
204: printf(" 1: %s, %s\n", d_INT, d_REL);
205:
206: return;
207: }
208: else if ((*s_etat_processus).test_instruction == 'Y')
209: {
210: (*s_etat_processus).nombre_arguments = -1;
211: return;
212: }
213:
214: if (test_cfsf(s_etat_processus, 31) == d_vrai)
215: {
216: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
217: {
218: return;
219: }
220: }
221:
222: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
223: &s_objet) == d_erreur)
224: {
225: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
226: return;
227: }
228:
1.30 bertrand 229: if (((*s_objet).type == INT) || ((*s_objet).type == REL))
1.1 bertrand 230: {
231: if ((*s_objet).type == INT)
232: {
233: attente = (real8) (*((integer8 *) (*s_objet).objet));
234: }
235: else
236: {
237: attente = (*((real8 *) (*s_objet).objet));
238: }
239:
240: if (attente < 0)
241: {
242: liberation(s_etat_processus, s_objet);
243:
244: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
245: return;
246: }
247:
248: temporisation.tv_sec = (long) floor((double) attente);
249: temporisation.tv_nsec = (attente - temporisation.tv_sec) *
250: (long) 1000000000;
251:
252: if ((*s_etat_processus).profilage == d_vrai)
253: {
254: profilage(s_etat_processus, "Sleep function (WAIT)");
255:
256: if ((*s_etat_processus).erreur_systeme != d_es)
257: {
258: return;
259: }
260: }
261:
262: do
263: {
1.51 bertrand 264: # ifndef SEMAPHORES_NOMMES
265: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
266: # else
267: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
268: # endif
1.1 bertrand 269: {
270: (*s_etat_processus).erreur_systeme = d_es_processus;
271: return;
272: }
273:
274: code_retour = nanosleep(&temporisation, &temporisation);
275: erreur = errno;
276:
1.51 bertrand 277: # ifndef SEMAPHORES_NOMMES
278: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
279: # else
280: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
281: # endif
1.1 bertrand 282: {
1.50 bertrand 283: if (errno != EINTR)
284: {
285: (*s_etat_processus).erreur_systeme = d_es_processus;
286: return;
287: }
1.1 bertrand 288: }
1.28 bertrand 289:
290: scrutation_injection(s_etat_processus);
291:
292: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
293: {
294: affectation_interruptions_logicielles(s_etat_processus);
295: }
296:
297: if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
298: {
299: traitement_interruptions_logicielles(s_etat_processus);
300: }
1.1 bertrand 301: } while(((code_retour == -1) && (erreur == EINTR))
302: && ((*s_etat_processus).var_volatile_requete_arret == 0));
303:
304: if ((*s_etat_processus).profilage == d_vrai)
305: {
306: profilage(s_etat_processus, NULL);
307: }
308: }
309: else
310: {
311: liberation(s_etat_processus, s_objet);
312:
313: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
314: return;
315: }
316:
317: liberation(s_etat_processus, s_objet);
318:
319: return;
320: }
321:
322:
323: /*
324: ================================================================================
325: Fonction 'wireframe' (passe en mode d'affichage échantillonné)
326: ================================================================================
327: Entrées : structure processus
328: --------------------------------------------------------------------------------
329: Sorties :
330: --------------------------------------------------------------------------------
331: Effets de bord : néant
332: ================================================================================
333: */
334:
335: void
336: instruction_wireframe(struct_processus *s_etat_processus)
337: {
338: (*s_etat_processus).erreur_execution = d_ex;
339:
340: if ((*s_etat_processus).affichage_arguments == 'Y')
341: {
342: printf("\n WIREFRAME ");
343:
344: if ((*s_etat_processus).langue == 'F')
345: {
346: printf("(graphique tridimensionnel grillagé)\n\n");
347: printf(" Aucun argument\n");
348: }
349: else
350: {
351: printf("(wireframe 3D graph)\n\n");
352: printf(" No argument\n");
353: }
354:
355: return;
356: }
357: else if ((*s_etat_processus).test_instruction == 'Y')
358: {
359: (*s_etat_processus).nombre_arguments = -1;
360: return;
361: }
362:
363: strcpy((*s_etat_processus).type_trace_eq, "GRILLE 3D");
364:
365: return;
366: }
367:
368:
369: /*
370: ================================================================================
371: Fonction 'write'
372: ================================================================================
373: Entrées : structure processus
374: --------------------------------------------------------------------------------
375: Sorties :
376: --------------------------------------------------------------------------------
377: Effets de bord : néant
378: ================================================================================
379: */
380:
381: void
382: instruction_write(struct_processus *s_etat_processus)
383: {
1.6 bertrand 384: const char *queue;
385:
1.1 bertrand 386: int adresse[16];
387: int port;
388:
1.8 bertrand 389: integer8 clef;
390: integer8 compteur;
391: integer8 id;
392: integer8 ordre;
393:
394: logical1 mise_a_jour;
395:
1.1 bertrand 396: long longueur_effective;
397: long recursivite;
398:
1.6 bertrand 399: sqlite3_stmt *ppStmt;
400:
1.1 bertrand 401: ssize_t ios;
402:
1.5 bertrand 403: struct_descripteur_fichier *descripteur;
404:
1.8 bertrand 405: struct_liste_chainee *l_element_courant;
406: struct_liste_chainee *l_element_courant_format;
407:
408: struct_objet *s_format;
409: struct_objet *s_element;
1.6 bertrand 410: struct_objet *s_objet_argument_1;
1.1 bertrand 411: struct_objet *s_objet_argument_2;
1.6 bertrand 412: struct_objet *s_objet_argument_3;
1.1 bertrand 413:
414: struct sigaction action;
415: struct sigaction registre;
416:
417: struct sockaddr_in adresse_ipv4;
1.20 bertrand 418: # ifdef IPV6
1.1 bertrand 419: struct sockaddr_in6 adresse_ipv6;
1.20 bertrand 420: # endif
1.1 bertrand 421: struct sockaddr_un adresse_unix;
422:
423: struct flock lock;
424:
425: uint32_t calcul_adresse;
426:
427: unsigned char *chaine;
1.5 bertrand 428: unsigned char *chaine_utf8;
1.8 bertrand 429: unsigned char *clef_utf8;
1.6 bertrand 430: unsigned char *commande;
1.1 bertrand 431:
432: unsigned long i;
433:
434: (*s_etat_processus).erreur_execution = d_ex;
435:
436: if ((*s_etat_processus).affichage_arguments == 'Y')
437: {
438: printf("\n WRITE ");
439:
440: if ((*s_etat_processus).langue == 'F')
441: {
442: printf("(écriture d'un enregistrement d'un fichier)\n\n");
443: }
444: else
445: {
446: printf("(write a record of a file)\n\n");
447: }
448:
449: printf(" 2: %s\n", d_LST);
1.6 bertrand 450: printf(" 1: %s, %s\n\n", d_FCH, d_SCK);
1.1 bertrand 451:
1.6 bertrand 452: printf(" 3: %s\n", d_LST);
1.8 bertrand 453: printf(" 2: %s\n", d_INT);
1.6 bertrand 454: printf(" 1: %s\n", d_FCH);
1.1 bertrand 455: return;
456: }
457: else if ((*s_etat_processus).test_instruction == 'Y')
458: {
459: (*s_etat_processus).nombre_arguments = -1;
460: return;
461: }
462:
463: if (test_cfsf(s_etat_processus, 31) == d_vrai)
464: {
1.6 bertrand 465: if ((*s_etat_processus).l_base_pile == NULL)
1.1 bertrand 466: {
1.6 bertrand 467: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1.1 bertrand 468: return;
469: }
1.6 bertrand 470:
471: if ((*(*(*s_etat_processus).l_base_pile).donnee).type == FCH)
472: {
473: if ((*((struct_fichier *) (*(*(*s_etat_processus).l_base_pile)
1.9 bertrand 474: .donnee).objet)).acces == 'D')
1.6 bertrand 475: {
1.9 bertrand 476: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
1.6 bertrand 477: {
478: return;
479: }
480: }
481: else
482: {
1.9 bertrand 483: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
1.6 bertrand 484: {
485: return;
486: }
487: }
488: }
489: else
490: {
491: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
492: {
493: return;
494: }
495: }
1.1 bertrand 496: }
497:
498: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
499: &s_objet_argument_1) == d_erreur)
500: {
501: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
502: return;
503: }
504:
505: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
506: &s_objet_argument_2) == d_erreur)
507: {
508: liberation(s_etat_processus, s_objet_argument_1);
509:
510: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
511: return;
512: }
513:
1.6 bertrand 514: if ((*s_objet_argument_1).type == FCH)
1.1 bertrand 515: {
1.5 bertrand 516: if ((descripteur = descripteur_fichier(s_etat_processus,
517: (struct_fichier *) (*s_objet_argument_1).objet)) == NULL)
518: {
519: return;
520: }
521:
1.1 bertrand 522: /*
523: * Vérification des verrous
524: */
525:
526: lock.l_type = F_WRLCK;
527: lock.l_whence = SEEK_SET;
528: lock.l_start = 0;
529: lock.l_len = 0;
530: lock.l_pid = getpid();
531: recursivite = 0;
532:
1.5 bertrand 533: if (fcntl(fileno((*descripteur).descripteur_c), F_GETLK, &lock)
534: == -1)
1.1 bertrand 535: {
536: liberation(s_etat_processus, s_objet_argument_2);
537: liberation(s_etat_processus, s_objet_argument_1);
538:
539: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
540: return;
541: }
542:
543: if (lock.l_type != F_UNLCK)
544: {
545: liberation(s_etat_processus, s_objet_argument_2);
546: liberation(s_etat_processus, s_objet_argument_1);
547:
548: (*s_etat_processus).erreur_execution =
549: d_ex_fichier_verrouille;
550: return;
551: }
552:
553: /*
554: * Vérification de l'autorisation d'écriture
555: */
556:
557: if ((*((struct_fichier *) (*s_objet_argument_1).objet))
558: .protection == 'R')
559: {
560: liberation(s_etat_processus, s_objet_argument_2);
561: liberation(s_etat_processus, s_objet_argument_1);
562:
563: (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
564: return;
565: }
566:
567: if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire == 'N')
568: {
569: /*
570: * Fichiers formatés
571: */
572:
1.6 bertrand 573: if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
574: == 'S')
1.1 bertrand 575: {
1.6 bertrand 576: if ((*s_objet_argument_2).type != LST)
577: {
578: liberation(s_etat_processus, s_objet_argument_2);
579: liberation(s_etat_processus, s_objet_argument_1);
580:
581: (*s_etat_processus).erreur_execution =
582: d_ex_erreur_type_argument;
583: return;
584: }
585:
586: if ((chaine = formateur_fichier(s_etat_processus,
587: s_objet_argument_2, (*((struct_fichier *)
588: (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
589: &longueur_effective, &recursivite)) == NULL)
590: {
591: liberation(s_etat_processus, s_objet_argument_2);
592: liberation(s_etat_processus, s_objet_argument_1);
1.1 bertrand 593:
1.6 bertrand 594: return;
595: }
1.1 bertrand 596:
1.5 bertrand 597: BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
598:
599: if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END)
600: != 0)
1.1 bertrand 601: {
602: liberation(s_etat_processus, s_objet_argument_2);
603: liberation(s_etat_processus, s_objet_argument_1);
604:
605: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
606: return;
607: }
608:
1.5 bertrand 609: if ((chaine_utf8 = transliteration(s_etat_processus,
610: chaine, d_locale, "UTF-8")) == NULL)
611: {
1.6 bertrand 612: free(chaine);
613:
1.5 bertrand 614: liberation(s_etat_processus, s_objet_argument_2);
615: liberation(s_etat_processus, s_objet_argument_1);
616:
617: return;
618: }
619:
1.6 bertrand 620: free(chaine);
621:
1.7 bertrand 622: if (fprintf((*descripteur).descripteur_c, "%s\n", chaine_utf8)
623: < 0)
1.1 bertrand 624: {
1.5 bertrand 625: free(chaine_utf8);
626:
1.1 bertrand 627: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
628: return;
629: }
1.5 bertrand 630:
631: free(chaine_utf8);
1.1 bertrand 632: }
633: else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
634: == 'D')
635: {
1.6 bertrand 636: BUG(((*descripteur).type != 'S'), uprintf("Bad filetype !\n"));
637:
638: if ((*s_objet_argument_2).type != INT)
639: {
640: liberation(s_etat_processus, s_objet_argument_2);
641: liberation(s_etat_processus, s_objet_argument_1);
642:
643: (*s_etat_processus).erreur_execution =
644: d_ex_erreur_type_argument;
645: return;
646: }
647:
648: if (depilement(s_etat_processus, &((*s_etat_processus)
649: .l_base_pile), &s_objet_argument_3) == d_erreur)
650: {
651: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
652: return;
653: }
654:
655: if ((*s_objet_argument_3).type != LST)
656: {
657: liberation(s_etat_processus, s_objet_argument_3);
658: liberation(s_etat_processus, s_objet_argument_2);
659: liberation(s_etat_processus, s_objet_argument_1);
660:
661: (*s_etat_processus).erreur_execution =
662: d_ex_erreur_type_argument;
663: return;
664: }
665:
1.8 bertrand 666: // Modification ou création d'un nouvel enregistrement
667:
668: if ((chaine = formateur_fichier(s_etat_processus,
669: s_objet_argument_3, (*((struct_fichier *)
670: (*s_objet_argument_1).objet)).format, 0, 0, ' ',
671: 'F', &longueur_effective, &recursivite)) == NULL)
672: {
673: liberation(s_etat_processus, s_objet_argument_3);
674: liberation(s_etat_processus, s_objet_argument_2);
675: liberation(s_etat_processus, s_objet_argument_1);
676:
677: return;
678: }
679:
680: if ((chaine_utf8 = transliteration(s_etat_processus,
681: chaine, d_locale, "UTF-8")) == NULL)
682: {
683: free(chaine);
684:
685: liberation(s_etat_processus, s_objet_argument_3);
686: liberation(s_etat_processus, s_objet_argument_2);
687: liberation(s_etat_processus, s_objet_argument_1);
688:
689: return;
690: }
691:
692: free(chaine);
693:
694: if (alsprintf(&commande, "insert or replace into data "
695: "(id, data) values (%lld, '%s')", (*((integer8 *)
696: (*s_objet_argument_2).objet)), chaine_utf8) < 0)
697: {
1.9 bertrand 698: (*s_etat_processus).erreur_systeme =
699: d_es_allocation_memoire;
1.8 bertrand 700: return;
701: }
702:
703: free(chaine_utf8);
704:
705: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
706: commande, strlen(commande), &ppStmt, &queue)
707: != SQLITE_OK)
708: {
709: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
710: return;
711: }
712:
713: if (sqlite3_step(ppStmt) != SQLITE_DONE)
714: {
715: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
716: return;
717: }
718:
719: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
720: {
721: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
722: return;
723: }
724:
725: liberation(s_etat_processus, s_objet_argument_3);
726: free(commande);
727: }
728: else // Fichiers indexés
729: {
730: BUG(((*descripteur).type != 'S'), uprintf("Bad filetype !\n"));
731:
732: if ((*s_objet_argument_2).type != LST)
733: {
734: liberation(s_etat_processus, s_objet_argument_2);
735: liberation(s_etat_processus, s_objet_argument_1);
736:
737: (*s_etat_processus).erreur_execution =
738: d_ex_erreur_type_argument;
739: return;
740: }
741:
1.9 bertrand 742: // Récupération de la position de la clef
1.8 bertrand 743:
744: if (alsprintf(&commande, "select key from control "
745: "where id = 1") < 0)
746: {
1.9 bertrand 747: (*s_etat_processus).erreur_systeme =
748: d_es_allocation_memoire;
1.8 bertrand 749: return;
750: }
751:
752: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
753: commande, strlen(commande), &ppStmt, &queue)
754: != SQLITE_OK)
755: {
1.9 bertrand 756: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 757: return;
758: }
759:
760: if (sqlite3_step(ppStmt) != SQLITE_ROW)
761: {
1.9 bertrand 762: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 763: return;
764: }
765:
766: if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER)
767: {
1.9 bertrand 768: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 769: return;
770: }
771:
772: clef = sqlite3_column_int64(ppStmt, 0);
773:
774: if (sqlite3_step(ppStmt) != SQLITE_DONE)
775: {
1.9 bertrand 776: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 777: return;
778: }
779:
780: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
781: {
1.9 bertrand 782: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 783: return;
784: }
785:
786: free(commande);
787:
788: l_element_courant = (struct_liste_chainee *)
789: (*s_objet_argument_2).objet;
790: l_element_courant_format = (struct_liste_chainee *)
791: (*(*((struct_fichier *) (*s_objet_argument_1).objet))
792: .format).objet;
793: compteur = 1;
794:
795: while((l_element_courant != NULL) &&
796: (l_element_courant_format != NULL))
797: {
798: if (compteur == clef)
799: {
800: break;
801: }
802:
803: l_element_courant = (*l_element_courant).suivant;
804: l_element_courant_format = (*l_element_courant_format)
805: .suivant;
806: compteur++;
807: }
808:
809: if ((l_element_courant == NULL) ||
810: (l_element_courant_format == NULL))
811: {
812: (*s_etat_processus).erreur_execution =
813: d_ex_clef_inexistante;
814:
815: liberation(s_etat_processus, s_objet_argument_2);
816: liberation(s_etat_processus, s_objet_argument_1);
817:
818: return;
819: }
820:
821: if ((s_element = allocation(s_etat_processus, LST)) == NULL)
822: {
823: (*s_etat_processus).erreur_systeme =
824: d_es_allocation_memoire;
825: return;
826: }
827:
828: if (((*s_element).objet = allocation_maillon(s_etat_processus))
829: == NULL)
830: {
831: (*s_etat_processus).erreur_systeme =
832: d_es_allocation_memoire;
833: return;
834: }
835:
836: (*((struct_liste_chainee *) (*s_element).objet)).suivant = NULL;
837:
838: if (((*((struct_liste_chainee *) (*s_element).objet))
839: .donnee = copie_objet(s_etat_processus,
840: (*l_element_courant).donnee, 'N')) == NULL)
841: {
842: (*s_etat_processus).erreur_systeme =
843: d_es_allocation_memoire;
844: return;
845: }
846:
847: if ((s_format = allocation(s_etat_processus, LST)) == NULL)
848: {
849: (*s_etat_processus).erreur_systeme =
850: d_es_allocation_memoire;
851: return;
852: }
853:
854: if (((*s_format).objet = allocation_maillon(s_etat_processus))
855: == NULL)
856: {
857: (*s_etat_processus).erreur_systeme =
858: d_es_allocation_memoire;
859: return;
860: }
861:
862: (*((struct_liste_chainee *) (*s_format).objet)).suivant = NULL;
863:
864: if (((*((struct_liste_chainee *) (*s_format).objet))
865: .donnee = copie_objet(s_etat_processus,
866: (*l_element_courant_format).donnee, 'N')) == NULL)
867: {
868: (*s_etat_processus).erreur_systeme =
869: d_es_allocation_memoire;
870: return;
871: }
872:
873: if ((chaine = formateur_fichier(s_etat_processus,
874: s_element, s_format, 0, 0, ' ',
875: 'F', &longueur_effective, &recursivite)) == NULL)
876: {
877: liberation(s_etat_processus, s_element);
878: liberation(s_etat_processus, s_format);
879: liberation(s_etat_processus, s_objet_argument_2);
880: liberation(s_etat_processus, s_objet_argument_1);
881:
882: return;
883: }
884:
885: liberation(s_etat_processus, s_element);
886: liberation(s_etat_processus, s_format);
887:
888: if ((clef_utf8 = transliteration(s_etat_processus,
889: chaine, d_locale, "UTF-8")) == NULL)
890: {
891: liberation(s_etat_processus, s_objet_argument_2);
892: liberation(s_etat_processus, s_objet_argument_1);
893:
894: return;
895: }
896:
897: free(chaine);
898:
899: // Récupération de l'identifiant de la clef
900:
901: if (alsprintf(&commande, "select id from key where key = "
902: "'%s'", clef_utf8) < 0)
903: {
1.9 bertrand 904: (*s_etat_processus).erreur_systeme =
905: d_es_allocation_memoire;
1.8 bertrand 906: return;
907: }
908:
909: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
910: commande, strlen(commande), &ppStmt, &queue)
911: != SQLITE_OK)
912: {
1.9 bertrand 913: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 914: return;
915: }
916:
917: switch(sqlite3_step(ppStmt))
918: {
919: case SQLITE_ROW:
920: {
921: // Une clef existe.
922:
923: mise_a_jour = d_vrai;
924: break;
925: }
926:
927: case SQLITE_DONE:
928: {
929: // Aucune clef n'existe.
930:
931: mise_a_jour = d_faux;
932:
933: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
934: {
935: (*s_etat_processus).erreur_systeme =
936: d_es_erreur_fichier;
937: return;
938: }
939:
940: free(commande);
941:
942: if (alsprintf(&commande, "insert into key "
943: "(key) values ('%s')", clef_utf8) < 0)
944: {
1.9 bertrand 945: (*s_etat_processus).erreur_systeme =
946: d_es_allocation_memoire;
1.8 bertrand 947: return;
948: }
949:
950: if (sqlite3_prepare_v2((*descripteur)
951: .descripteur_sqlite,
952: commande, strlen(commande), &ppStmt, &queue)
953: != SQLITE_OK)
954: {
955: (*s_etat_processus).erreur_systeme =
956: d_es_erreur_fichier;
957: return;
958: }
959:
960: if (sqlite3_step(ppStmt) != SQLITE_DONE)
961: {
962: (*s_etat_processus).erreur_systeme =
963: d_es_erreur_fichier;
964: return;
965: }
966:
967: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
968: {
969: (*s_etat_processus).erreur_systeme =
970: d_es_erreur_fichier;
971: return;
972: }
973:
974: free(commande);
975:
976: if (alsprintf(&commande, "select id from key "
977: "where key = '%s'", clef_utf8) < 0)
978: {
1.9 bertrand 979: (*s_etat_processus).erreur_systeme =
980: d_es_allocation_memoire;
1.8 bertrand 981: return;
982: }
983:
984: if (sqlite3_prepare_v2((*descripteur)
985: .descripteur_sqlite,
986: commande, strlen(commande), &ppStmt, &queue)
987: != SQLITE_OK)
988: {
989: (*s_etat_processus).erreur_systeme =
990: d_es_erreur_fichier;
991: return;
992: }
993:
994: if (sqlite3_step(ppStmt) != SQLITE_ROW)
995: {
996: (*s_etat_processus).erreur_systeme =
997: d_es_erreur_fichier;
998: return;
999: }
1000:
1001: break;
1002: }
1003:
1004: default:
1005: {
1006: (*s_etat_processus).erreur_systeme =
1007: d_es_erreur_fichier;
1008: return;
1009: }
1010: }
1011:
1012: if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER)
1013: {
1.9 bertrand 1014: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1015: return;
1016: }
1017:
1018: id = sqlite3_column_int64(ppStmt, 0);
1019:
1020: if (sqlite3_step(ppStmt) != SQLITE_DONE)
1.6 bertrand 1021: {
1.9 bertrand 1022: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1023: return;
1024: }
1.6 bertrand 1025:
1.8 bertrand 1026: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
1027: {
1.9 bertrand 1028: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1029: return;
1030: }
1031:
1032: free(commande);
1033:
1034: // Modification de la clef
1035:
1036: if (mise_a_jour == d_vrai)
1037: {
1038: if (alsprintf(&commande, "update key set key = '%s' where "
1039: "id = %lld", clef_utf8, id) < 0)
1.6 bertrand 1040: {
1.9 bertrand 1041: (*s_etat_processus).erreur_systeme =
1042: d_es_allocation_memoire;
1.6 bertrand 1043: return;
1044: }
1.8 bertrand 1045:
1046: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
1047: commande, strlen(commande), &ppStmt, &queue)
1048: != SQLITE_OK)
1049: {
1050: (*s_etat_processus).erreur_systeme =
1051: d_es_erreur_fichier;
1052: return;
1053: }
1054:
1055: if (sqlite3_step(ppStmt) != SQLITE_DONE)
1056: {
1057: (*s_etat_processus).erreur_systeme =
1058: d_es_erreur_fichier;
1059: return;
1060: }
1061:
1062: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
1063: {
1064: (*s_etat_processus).erreur_systeme =
1065: d_es_erreur_fichier;
1066: return;
1067: }
1068:
1069: free(commande);
1.6 bertrand 1070: }
1.8 bertrand 1071:
1072: // Effacement de l'enregistrement existant
1073:
1074: if (alsprintf(&commande, "delete from data where "
1075: "key_id = %lld", id) < 0)
1076: {
1.9 bertrand 1077: (*s_etat_processus).erreur_systeme =
1078: d_es_allocation_memoire;
1.8 bertrand 1079: return;
1080: }
1081:
1082: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
1083: commande, strlen(commande), &ppStmt, &queue)
1084: != SQLITE_OK)
1085: {
1.9 bertrand 1086: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1087: return;
1088: }
1089:
1090: if (sqlite3_step(ppStmt) != SQLITE_DONE)
1091: {
1.9 bertrand 1092: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1093: return;
1094: }
1095:
1096: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
1097: {
1.9 bertrand 1098: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.8 bertrand 1099: return;
1100: }
1101:
1102: free(commande);
1103:
1104: // Modification ou création d'un nouvel enregistrement
1105:
1106: l_element_courant = (struct_liste_chainee *)
1107: (*s_objet_argument_2).objet;
1108: l_element_courant_format = (struct_liste_chainee *)
1109: (*(*((struct_fichier *) (*s_objet_argument_1).objet))
1110: .format).objet;
1111: compteur = 1;
1112: ordre = 1;
1113:
1114: while((l_element_courant != NULL) &&
1115: (l_element_courant_format != NULL))
1.6 bertrand 1116: {
1.8 bertrand 1117: if (compteur == clef)
1118: {
1119: l_element_courant = (*l_element_courant).suivant;
1120: l_element_courant_format = (*l_element_courant_format)
1121: .suivant;
1122: compteur++;
1123: continue;
1124: }
1125:
1126: if ((s_element = allocation(s_etat_processus, LST)) == NULL)
1127: {
1128: (*s_etat_processus).erreur_systeme =
1129: d_es_allocation_memoire;
1130: return;
1131: }
1132:
1133: if (((*s_element).objet =
1134: allocation_maillon(s_etat_processus)) == NULL)
1135: {
1136: (*s_etat_processus).erreur_systeme =
1137: d_es_allocation_memoire;
1138: return;
1139: }
1140:
1141: (*((struct_liste_chainee *) (*s_element).objet)).suivant
1142: = NULL;
1143:
1144: if ((s_format = allocation(s_etat_processus, LST)) == NULL)
1145: {
1146: (*s_etat_processus).erreur_systeme =
1147: d_es_allocation_memoire;
1148: return;
1149: }
1150:
1151: if (((*s_format).objet =
1152: allocation_maillon(s_etat_processus)) == NULL)
1153: {
1154: (*s_etat_processus).erreur_systeme =
1155: d_es_allocation_memoire;
1156: return;
1157: }
1158:
1159: (*((struct_liste_chainee *) (*s_format).objet)).suivant
1160: = NULL;
1161:
1162: if (((*((struct_liste_chainee *) (*s_element).objet))
1163: .donnee = copie_objet(s_etat_processus,
1164: (*l_element_courant).donnee, 'N')) == NULL)
1165: {
1166: (*s_etat_processus).erreur_systeme =
1167: d_es_allocation_memoire;
1168: return;
1169: }
1170:
1171: if (((*((struct_liste_chainee *) (*s_format).objet))
1172: .donnee = copie_objet(s_etat_processus,
1173: (*l_element_courant_format).donnee, 'N')) == NULL)
1174: {
1175: (*s_etat_processus).erreur_systeme =
1176: d_es_allocation_memoire;
1177: return;
1178: }
1.6 bertrand 1179:
1180: if ((chaine = formateur_fichier(s_etat_processus,
1.8 bertrand 1181: s_element, s_format, 0, 0, ' ',
1.6 bertrand 1182: 'F', &longueur_effective, &recursivite)) == NULL)
1183: {
1.8 bertrand 1184: free(clef_utf8);
1.9 bertrand 1185:
1.8 bertrand 1186: liberation(s_etat_processus, s_element);
1187: liberation(s_etat_processus, s_format);
1.6 bertrand 1188: liberation(s_etat_processus, s_objet_argument_2);
1189: liberation(s_etat_processus, s_objet_argument_1);
1190:
1191: return;
1192: }
1193:
1194: if ((chaine_utf8 = transliteration(s_etat_processus,
1195: chaine, d_locale, "UTF-8")) == NULL)
1196: {
1.8 bertrand 1197: free(clef_utf8);
1.6 bertrand 1198: free(chaine);
1199:
1200: liberation(s_etat_processus, s_objet_argument_2);
1201: liberation(s_etat_processus, s_objet_argument_1);
1202:
1203: return;
1204: }
1205:
1206: free(chaine);
1207:
1.8 bertrand 1208: if (alsprintf(&commande, "insert into data "
1209: "(data, key_id, sequence) values "
1210: "('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0)
1.6 bertrand 1211: {
1.9 bertrand 1212: (*s_etat_processus).erreur_systeme =
1213: d_es_allocation_memoire;
1.6 bertrand 1214: return;
1215: }
1216:
1.8 bertrand 1217: if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite,
1218: commande, strlen(commande), &ppStmt, &queue)
1219: != SQLITE_OK)
1220: {
1221: (*s_etat_processus).erreur_systeme =
1222: d_es_erreur_fichier;
1223: return;
1224: }
1225:
1226: if (sqlite3_step(ppStmt) != SQLITE_DONE)
1227: {
1228: (*s_etat_processus).erreur_systeme =
1229: d_es_erreur_fichier;
1230: return;
1231: }
1232:
1233: if (sqlite3_finalize(ppStmt) != SQLITE_OK)
1234: {
1235: (*s_etat_processus).erreur_systeme =
1236: d_es_erreur_fichier;
1237: return;
1238: }
1239:
1240: free(commande);
1.6 bertrand 1241: free(chaine_utf8);
1.8 bertrand 1242:
1243: liberation(s_etat_processus, s_element);
1244: liberation(s_etat_processus, s_format);
1245:
1246: l_element_courant = (*l_element_courant).suivant;
1247: l_element_courant_format = (*l_element_courant_format)
1248: .suivant;
1249:
1250: compteur++;
1251: ordre++;
1.6 bertrand 1252: }
1253:
1.8 bertrand 1254: free(clef_utf8);
1.6 bertrand 1255:
1.8 bertrand 1256: if ((l_element_courant != NULL) ||
1257: (l_element_courant_format != NULL))
1.6 bertrand 1258: {
1.8 bertrand 1259: liberation(s_etat_processus, s_objet_argument_1);
1260: liberation(s_etat_processus, s_objet_argument_2);
1.6 bertrand 1261:
1.8 bertrand 1262: (*s_etat_processus).erreur_execution =
1263: d_ex_erreur_format_fichier;
1.6 bertrand 1264: return;
1265: }
1.1 bertrand 1266: }
1267: }
1268: else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire
1269: == 'Y')
1270: {
1271: /*
1272: * Fichiers non formatés
1273: */
1274:
1275: if ((chaine = formateur_fichier(s_etat_processus,
1276: s_objet_argument_2, (*((struct_fichier *)
1277: (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U',
1278: &longueur_effective, &recursivite)) == NULL)
1279: {
1280: liberation(s_etat_processus, s_objet_argument_2);
1281: liberation(s_etat_processus, s_objet_argument_1);
1282:
1283: return;
1284: }
1285:
1286: if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
1287: == 'S')
1288: {
1.5 bertrand 1289: BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
1290:
1291: if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END)
1292: != 0)
1.1 bertrand 1293: {
1294: liberation(s_etat_processus, s_objet_argument_2);
1295: liberation(s_etat_processus, s_objet_argument_1);
1296:
1297: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1298: return;
1299: }
1300:
1301: if (fwrite(chaine, sizeof(unsigned char), longueur_effective,
1.5 bertrand 1302: (*descripteur).descripteur_c) !=
1303: (size_t) longueur_effective)
1.1 bertrand 1304: {
1305: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1306: return;
1307: }
1308: }
1309: else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
1310: == 'D')
1311: {
1312: }
1313: else
1314: {
1315: /* Fichiers indexés : panique totale ! */
1316: }
1317:
1318: free(chaine);
1319: }
1320: else
1321: {
1322: /*
1323: * Fichiers de type FLOW
1324: */
1.33 bertrand 1325:
1326: if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces
1327: == 'S')
1328: {
1329: BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n"));
1330:
1.56 bertrand 1331: if ((*s_objet_argument_2).type != LST)
1332: {
1333: liberation(s_etat_processus, s_objet_argument_2);
1334: liberation(s_etat_processus, s_objet_argument_1);
1335:
1336: (*s_etat_processus).erreur_execution =
1337: d_ex_erreur_type_argument;
1338: return;
1339: }
1340:
1341: if ((*((struct_liste_chainee *) (*s_objet_argument_2).objet))
1342: .donnee == NULL)
1343: {
1344: liberation(s_etat_processus, s_objet_argument_2);
1345: liberation(s_etat_processus, s_objet_argument_1);
1346:
1347: (*s_etat_processus).erreur_execution =
1348: d_ex_erreur_type_argument;
1349: return;
1350: }
1351:
1.33 bertrand 1352: if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet))
1353: .donnee)).type != CHN)
1354: {
1355: liberation(s_etat_processus, s_objet_argument_2);
1356: liberation(s_etat_processus, s_objet_argument_1);
1357:
1358: (*s_etat_processus).erreur_execution =
1359: d_ex_erreur_type_argument;
1360: return;
1361: }
1362:
1363: if ((chaine = formateur_flux(s_etat_processus, (unsigned char *)
1364: (*((*((struct_liste_chainee *) (*s_objet_argument_2)
1365: .objet)).donnee)).objet, &longueur_effective)) == NULL)
1366: {
1367: (*s_etat_processus).erreur_systeme =
1368: d_es_allocation_memoire;
1369: return;
1370: }
1371:
1372: if (fwrite(chaine, sizeof(unsigned char), longueur_effective,
1373: (*descripteur).descripteur_c) !=
1374: (size_t) longueur_effective)
1375: {
1376: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1377: return;
1378: }
1379:
1380: free(chaine);
1381: }
1382: else
1383: {
1384: liberation(s_etat_processus, s_objet_argument_1);
1385: liberation(s_etat_processus, s_objet_argument_2);
1386:
1387: (*s_etat_processus).erreur_execution =
1388: d_ex_erreur_type_fichier;
1389: return;
1390: }
1.1 bertrand 1391: }
1392: }
1393: else if (((*s_objet_argument_2).type == LST) &&
1394: ((*s_objet_argument_1).type == SCK))
1395: {
1396: /*
1397: * Vérification de l'autorisation d'écriture
1398: */
1399:
1400: if ((*((struct_socket *) (*s_objet_argument_1).objet))
1401: .protection == 'R')
1402: {
1403: liberation(s_etat_processus, s_objet_argument_2);
1404: liberation(s_etat_processus, s_objet_argument_1);
1405:
1406: (*s_etat_processus).erreur_execution = d_ex_erreur_acces_fichier;
1407: return;
1408: }
1409:
1410: if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire == 'N')
1411: {
1412: /*
1413: * Sockets formatées
1414: */
1415:
1416: if ((chaine = formateur_fichier(s_etat_processus,
1417: s_objet_argument_2, (*((struct_socket *)
1418: (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F',
1419: &longueur_effective, &recursivite)) == NULL)
1420: {
1421: liberation(s_etat_processus, s_objet_argument_2);
1422: liberation(s_etat_processus, s_objet_argument_1);
1423:
1424: return;
1425: }
1.33 bertrand 1426: }
1427: else if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire
1428: == 'Y')
1429: {
1430: /*
1431: * Sockets non formatées
1432: */
1.38 bertrand 1433:
1434: chaine = NULL;
1.33 bertrand 1435: }
1436: else
1437: {
1438: /*
1439: * Sockets de type FLOW
1440: */
1441:
1442: if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet))
1443: .donnee)).type != CHN)
1444: {
1445: liberation(s_etat_processus, s_objet_argument_2);
1446: liberation(s_etat_processus, s_objet_argument_1);
1447:
1448: (*s_etat_processus).erreur_execution =
1449: d_ex_erreur_type_argument;
1450: return;
1451: }
1452:
1453: if ((chaine = formateur_flux(s_etat_processus, (unsigned char *)
1454: (*((*((struct_liste_chainee *) (*s_objet_argument_2)
1455: .objet)).donnee)).objet, &longueur_effective)) == NULL)
1456: {
1457: liberation(s_etat_processus, s_objet_argument_2);
1458: liberation(s_etat_processus, s_objet_argument_1);
1459:
1460: return;
1461: }
1462: }
1.1 bertrand 1463:
1.33 bertrand 1464: if ((strcmp((*((struct_socket *) (*s_objet_argument_1).objet)).type,
1465: "STREAM") == 0) || (strcmp((*((struct_socket *)
1466: (*s_objet_argument_1).objet)).type,
1467: "SEQUENTIAL DATAGRAM") == 0))
1468: { // Sockets connectées
1469:
1470: action.sa_handler = SIG_IGN;
1471: action.sa_flags = SA_ONSTACK;
1472:
1473: if (sigaction(SIGPIPE, &action, ®istre) != 0)
1474: {
1475: (*s_etat_processus).erreur_systeme = d_es_signal;
1476: return;
1477: }
1478:
1.51 bertrand 1479: # ifndef SEMAPHORES_NOMMES
1480: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
1481: # else
1482: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1483: # endif
1.33 bertrand 1484: {
1485: if (sigaction(SIGPIPE, ®istre, NULL) != 0)
1486: {
1487: (*s_etat_processus).erreur_systeme = d_es_signal;
1488: return;
1489: }
1490:
1491: (*s_etat_processus).erreur_systeme = d_es_processus;
1492: return;
1493: }
1.1 bertrand 1494:
1.33 bertrand 1495: if (send((*((struct_socket *) (*s_objet_argument_1).objet))
1496: .socket, chaine, longueur_effective, 0) < 0)
1497: {
1498: ios = errno;
1.1 bertrand 1499:
1.33 bertrand 1500: if (sigaction(SIGPIPE, ®istre, NULL) != 0)
1.1 bertrand 1501: {
1502: (*s_etat_processus).erreur_systeme = d_es_signal;
1503: return;
1504: }
1505:
1.51 bertrand 1506: # ifndef SEMAPHORES_NOMMES
1507: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
1508: # else
1509: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1510: # endif
1.1 bertrand 1511: {
1.50 bertrand 1512: if (errno != EINTR)
1513: {
1514: (*s_etat_processus).erreur_systeme = d_es_processus;
1515: return;
1516: }
1.33 bertrand 1517: }
1.1 bertrand 1518:
1.33 bertrand 1519: if ((ios == EPIPE) || (ios == ECONNRESET))
1520: {
1521: (*s_etat_processus).erreur_execution =
1522: d_ex_erreur_acces_fichier;
1.1 bertrand 1523: return;
1524: }
1525:
1.33 bertrand 1526: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1527: return;
1528: }
1529:
1.51 bertrand 1530: # ifndef SEMAPHORES_NOMMES
1531: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
1532: # else
1533: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1534: # endif
1.33 bertrand 1535: {
1536: if (errno != EINTR)
1.1 bertrand 1537: {
1538: if (sigaction(SIGPIPE, ®istre, NULL) != 0)
1539: {
1540: (*s_etat_processus).erreur_systeme = d_es_signal;
1541: return;
1542: }
1543:
1.33 bertrand 1544: (*s_etat_processus).erreur_systeme = d_es_processus;
1545: return;
1546: }
1547: }
1548:
1549: if (sigaction(SIGPIPE, ®istre, NULL) != 0)
1550: {
1551: (*s_etat_processus).erreur_systeme = d_es_signal;
1552: return;
1553: }
1554: }
1555: else
1556: { // Sockets non connectées
1557:
1558: /*
1559: * Vérification de l'adresse distante
1560: */
1561:
1562: if (strcmp((*((struct_socket *) (*s_objet_argument_1).objet))
1563: .adresse_distante, "") == 0)
1564: {
1565: liberation(s_etat_processus, s_objet_argument_1);
1566: liberation(s_etat_processus, s_objet_argument_2);
1567:
1568: (*s_etat_processus).erreur_execution =
1569: d_ex_erreur_acces_fichier;
1570: return;
1571: }
1572:
1573: /*
1574: * Création de l'adresse logique
1575: */
1576:
1577: if ((*((struct_socket *) (*s_objet_argument_1).objet))
1578: .domaine == PF_UNIX)
1579: {
1580: adresse_unix.sun_family = AF_UNIX;
1581: strncpy(adresse_unix.sun_path, (*((struct_socket *)
1582: (*s_objet_argument_1).objet)).adresse_distante,
1583: UNIX_PATH_MAX);
1584: adresse_unix.sun_path[UNIX_PATH_MAX - 1] =
1585: d_code_fin_chaine;
1586:
1.51 bertrand 1587: # ifndef SEMAPHORES_NOMMES
1588: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
1589: # else
1590: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1591: # endif
1.33 bertrand 1592: {
1593: (*s_etat_processus).erreur_systeme = d_es_processus;
1594: return;
1595: }
1596:
1597: if (sendto((*((struct_socket *)
1598: (*s_objet_argument_1).objet)).socket, chaine,
1599: longueur_effective, 0, (struct sockaddr *)
1600: &adresse_unix, sizeof(adresse_unix)) < 0)
1601: {
1.38 bertrand 1602: ios = errno;
1603:
1.51 bertrand 1604: # ifndef SEMAPHORES_NOMMES
1605: while(sem_wait(&((*s_etat_processus).semaphore_fork))
1606: != 0)
1607: # else
1608: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1609: # endif
1.1 bertrand 1610: {
1.50 bertrand 1611: if (errno != EINTR)
1612: {
1613: (*s_etat_processus).erreur_systeme = d_es_processus;
1614: return;
1615: }
1.1 bertrand 1616: }
1617:
1.34 bertrand 1618: if ((ios == EPIPE) || (ios == ECONNRESET))
1619: {
1620: (*s_etat_processus).erreur_execution =
1621: d_ex_erreur_acces_fichier;
1622: return;
1623: }
1624:
1625:
1626: (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
1.1 bertrand 1627: return;
1628: }
1629:
1.51 bertrand 1630: # ifndef SEMAPHORES_NOMMES
1631: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
1632: # else
1633: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1634: # endif
1.1 bertrand 1635: {
1.50 bertrand 1636: if (errno != EINTR)
1637: {
1638: (*s_etat_processus).erreur_systeme = d_es_processus;
1639: return;
1640: }
1.1 bertrand 1641: }
1642: }
1.33 bertrand 1643: else if ((*((struct_socket *) (*s_objet_argument_1).objet))
1644: .domaine == PF_INET)
1645: {
1646: if (sscanf((*((struct_socket *)
1647: (*s_objet_argument_1).objet))
1648: .adresse_distante, "%d.%d.%d.%d(%d)",
1649: &(adresse[0]), &(adresse[1]), &(adresse[2]),
1650: &(adresse[3]), &port) == 5)
1651: { // Adresse IPv4
1652: calcul_adresse = 0;
1653: for(i = 0; i < 4; calcul_adresse =
1654: (256 * calcul_adresse) + adresse[i++]);
1655:
1656: memset(&adresse_ipv4, 0, sizeof(adresse_ipv4));
1657: adresse_ipv4.sin_family = AF_INET;
1658: adresse_ipv4.sin_port = htons(port);
1659: adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse);
1.1 bertrand 1660:
1.51 bertrand 1661: # ifndef SEMAPHORES_NOMMES
1662: if (sem_post(&((*s_etat_processus).semaphore_fork))
1663: != 0)
1664: # else
1665: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1666: # endif
1.1 bertrand 1667: {
1668: (*s_etat_processus).erreur_systeme = d_es_processus;
1669: return;
1670: }
1671:
1672: if (sendto((*((struct_socket *)
1673: (*s_objet_argument_1).objet)).socket, chaine,
1.33 bertrand 1674: longueur_effective, 0, (struct sockaddr *)
1675: &adresse_ipv4, sizeof(adresse_ipv4)) < 0)
1.1 bertrand 1676: {
1.51 bertrand 1677: # ifndef SEMAPHORES_NOMMES
1678: while(sem_wait(&((*s_etat_processus)
1679: .semaphore_fork)) != 0)
1680: # else
1681: while(sem_wait((*s_etat_processus)
1682: .semaphore_fork) != 0)
1683: # endif
1.1 bertrand 1684: {
1.50 bertrand 1685: if (errno != EINTR)
1686: {
1687: (*s_etat_processus).erreur_systeme =
1688: d_es_processus;
1689: return;
1690: }
1.1 bertrand 1691: }
1692:
1693: (*s_etat_processus).erreur_systeme =
1694: d_es_erreur_fichier;
1695: return;
1696: }
1697:
1.51 bertrand 1698: # ifndef SEMAPHORES_NOMMES
1699: while(sem_wait(&((*s_etat_processus).semaphore_fork))
1700: != 0)
1701: # else
1702: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1703: # endif
1.1 bertrand 1704: {
1.50 bertrand 1705: if (errno != EINTR)
1706: {
1707: (*s_etat_processus).erreur_systeme = d_es_processus;
1708: return;
1709: }
1.1 bertrand 1710: }
1711: }
1.33 bertrand 1712: else
1.1 bertrand 1713: {
1.33 bertrand 1714: liberation(s_etat_processus, s_objet_argument_1);
1715: liberation(s_etat_processus, s_objet_argument_2);
1.1 bertrand 1716:
1.33 bertrand 1717: (*s_etat_processus).erreur_execution =
1718: d_ex_erreur_parametre_fichier;
1719: return;
1720: }
1721: }
1722: else if ((*((struct_socket *) (*s_objet_argument_1).objet))
1723: .domaine == PF_INET6)
1724: {
1725: if (sscanf((*((struct_socket *) (*s_objet_argument_1)
1726: .objet)).adresse_distante, "%X:%X:%X:%X:%X:"
1727: "%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X(%d)",
1728: &(adresse[0]), &(adresse[1]), &(adresse[2]),
1729: &(adresse[3]), &(adresse[4]), &(adresse[5]),
1730: &(adresse[6]), &(adresse[7]), &(adresse[8]),
1731: &(adresse[9]), &(adresse[10]), &(adresse[11]),
1732: &(adresse[12]), &(adresse[13]), &(adresse[14]),
1733: &(adresse[15]), &port)== 17)
1734: { // Adresse IPv6
1735: # ifdef IPV6
1736: memset(&adresse_ipv6, 0, sizeof(adresse_ipv6));
1737: adresse_ipv6.sin6_family = AF_INET6;
1738: adresse_ipv6.sin6_port = htons((uint16_t) port);
1739:
1740: for(i = 0; i < 16;
1741: adresse_ipv6.sin6_addr.s6_addr[i] =
1742: adresse[i], i++);
1.1 bertrand 1743:
1.51 bertrand 1744: # ifndef SEMAPHORES_NOMMES
1745: if (sem_post(&((*s_etat_processus).semaphore_fork))
1746: != 0)
1747: # else
1748: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1749: # endif
1.33 bertrand 1750: {
1751: (*s_etat_processus).erreur_systeme = d_es_processus;
1752: return;
1753: }
1.1 bertrand 1754:
1.33 bertrand 1755: if (sendto((*((struct_socket *)
1756: (*s_objet_argument_1).objet)).socket, chaine,
1757: longueur_effective, 0, (struct sockaddr *)
1758: &adresse_ipv6, sizeof(adresse_ipv6)) < 0)
1759: {
1.51 bertrand 1760: # ifndef SEMAPHORES_NOMMES
1761: while(sem_wait(&((*s_etat_processus)
1762: .semaphore_fork)) != 0)
1763: # else
1764: while(sem_wait((*s_etat_processus)
1765: .semaphore_fork) != 0)
1766: # endif
1.1 bertrand 1767: {
1.50 bertrand 1768: if (errno != EINTR)
1769: {
1770: (*s_etat_processus).erreur_systeme =
1771: d_es_processus;
1772: return;
1773: }
1.1 bertrand 1774: }
1775:
1.33 bertrand 1776: (*s_etat_processus).erreur_systeme =
1777: d_es_erreur_fichier;
1.1 bertrand 1778: return;
1779: }
1780:
1.51 bertrand 1781: # ifndef SEMAPHORES_NOMMES
1782: while(sem_wait(&((*s_etat_processus).semaphore_fork))
1783: != 0)
1784: # else
1785: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
1786: # endif
1.33 bertrand 1787: {
1.50 bertrand 1788: if (errno != EINTR)
1789: {
1790: (*s_etat_processus).erreur_systeme =
1791: d_es_processus;
1792: return;
1793: }
1.33 bertrand 1794: }
1795: # else
1796: if ((*s_etat_processus).langue == 'F')
1797: {
1798: printf("+++Attention : Support du protocole"
1799: " IPv6 indisponible\n");
1.1 bertrand 1800: }
1801: else
1802: {
1.33 bertrand 1803: printf("+++Warning : IPv6 support "
1804: "unavailable\n");
1.1 bertrand 1805: }
1.33 bertrand 1806: # endif
1.1 bertrand 1807: }
1.33 bertrand 1808: else
1.1 bertrand 1809: {
1810: liberation(s_etat_processus, s_objet_argument_1);
1811: liberation(s_etat_processus, s_objet_argument_2);
1812:
1813: (*s_etat_processus).erreur_execution =
1814: d_ex_erreur_parametre_fichier;
1815: return;
1816: }
1817: }
1.33 bertrand 1818: else
1819: {
1820: liberation(s_etat_processus, s_objet_argument_1);
1821: liberation(s_etat_processus, s_objet_argument_2);
1.1 bertrand 1822:
1.33 bertrand 1823: (*s_etat_processus).erreur_execution =
1824: d_ex_erreur_parametre_fichier;
1825: return;
1826: }
1.1 bertrand 1827: }
1.33 bertrand 1828:
1829: free(chaine);
1.1 bertrand 1830: }
1831: else
1832: {
1833: liberation(s_etat_processus, s_objet_argument_2);
1834: liberation(s_etat_processus, s_objet_argument_1);
1835:
1836: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1837: return;
1838: }
1839:
1840: liberation(s_etat_processus, s_objet_argument_2);
1841: liberation(s_etat_processus, s_objet_argument_1);
1842:
1843: return;
1844: }
1845:
1846:
1847: /*
1848: ================================================================================
1849: Fonction 'wflock'
1850: ================================================================================
1851: Entrées : pointeur sur une structure struct_processus
1852: --------------------------------------------------------------------------------
1853: Sorties :
1854: --------------------------------------------------------------------------------
1855: Effets de bord : néant
1856: ================================================================================
1857: */
1858:
1859: void
1860: instruction_wflock(struct_processus *s_etat_processus)
1861: {
1862: logical1 drapeau;
1863:
1864: struct flock lock;
1865:
1866: struct timespec attente;
1867:
1.5 bertrand 1868: struct_descripteur_fichier *descripteur;
1869:
1.1 bertrand 1870: struct_objet *s_objet_argument_1;
1871: struct_objet *s_objet_argument_2;
1872:
1873: unsigned char *chaine;
1874: unsigned char registre_instruction_valide;
1875:
1876: attente.tv_sec = 0;
1877: attente.tv_nsec = GRANULARITE_us * 1000;
1878:
1879: (*s_etat_processus).erreur_execution = d_ex;
1880:
1881: if ((*s_etat_processus).affichage_arguments == 'Y')
1882: {
1883: printf("\n WFLOCK ");
1884:
1885: if ((*s_etat_processus).langue == 'F')
1886: {
1887: printf("(attente du positionnement d'un verrou sur un fichier)"
1888: "\n\n");
1889: }
1890: else
1891: {
1892: printf("(wait for file lock)\n\n");
1893: }
1894:
1895: printf(" 2: %s\n", d_FCH);
1896: printf(" 1: %s (READ/WRITE/NONE)\n", d_CHN);
1897:
1898: return;
1899: }
1900: else if ((*s_etat_processus).test_instruction == 'Y')
1901: {
1902: (*s_etat_processus).nombre_arguments = -1;
1903: return;
1904: }
1905:
1906: if (test_cfsf(s_etat_processus, 31) == d_vrai)
1907: {
1908: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
1909: {
1910: return;
1911: }
1912: }
1913:
1914: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1915: &s_objet_argument_1) == d_erreur)
1916: {
1917: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1918: return;
1919: }
1920:
1921: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1922: &s_objet_argument_2) == d_erreur)
1923: {
1924: liberation(s_etat_processus, s_objet_argument_1);
1925:
1926: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1927: return;
1928: }
1929:
1930: if (((*s_objet_argument_2).type == FCH) &&
1931: ((*s_objet_argument_1).type == CHN))
1932: {
1933: drapeau = d_faux;
1934:
1935: do
1936: {
1937: if ((chaine = conversion_majuscule((unsigned char *)
1938: (*s_objet_argument_1).objet)) == NULL)
1939: {
1940: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1941: return;
1942: }
1943:
1944: if (strcmp(chaine, "WRITE") == 0)
1945: {
1946: lock.l_type = F_WRLCK;
1947: }
1948: else if (strcmp(chaine, "READ") == 0)
1949: {
1950: lock.l_type = F_RDLCK;
1951: }
1952: else if (strcmp(chaine, "NONE") == 0)
1953: {
1954: lock.l_type = F_UNLCK;
1955: }
1956: else
1957: {
1958: free(chaine);
1959:
1960: liberation(s_etat_processus, s_objet_argument_1);
1961: liberation(s_etat_processus, s_objet_argument_2);
1962:
1963: (*s_etat_processus).erreur_execution = d_ex_verrou_indefini;
1964: return;
1965: }
1966:
1967: free(chaine);
1968:
1969: lock.l_whence = SEEK_SET;
1970: lock.l_start = 0;
1971: lock.l_len = 0;
1972: lock.l_pid = getpid();
1973:
1974: if ((descripteur = descripteur_fichier(s_etat_processus,
1975: (struct_fichier *) (*s_objet_argument_2).objet)) == NULL)
1976: {
1977: return;
1978: }
1979:
1.5 bertrand 1980: if (fcntl(fileno((*descripteur).descripteur_c), F_GETLK, &lock)
1981: == -1)
1.1 bertrand 1982: {
1983: liberation(s_etat_processus, s_objet_argument_1);
1984: liberation(s_etat_processus, s_objet_argument_2);
1985:
1986: (*s_etat_processus).erreur_execution = d_ex_fichier_verrouille;
1987: return;
1988: }
1989:
1.51 bertrand 1990: # ifndef SEMAPHORES_NOMMES
1991: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
1992: # else
1993: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1994: # endif
1.1 bertrand 1995: {
1996: (*s_etat_processus).erreur_systeme = d_es_processus;
1997: return;
1998: }
1.47 bertrand 1999:
1.51 bertrand 2000: # ifndef SEMAPHORES_NOMMES
2001: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
2002: # else
2003: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
2004: # endif
1.12 bertrand 2005: {
1.50 bertrand 2006: if (errno != EINTR)
2007: {
2008: (*s_etat_processus).erreur_systeme = d_es_processus;
2009: return;
2010: }
1.12 bertrand 2011: }
1.1 bertrand 2012:
2013: if (lock.l_type == F_UNLCK)
2014: {
2015: drapeau = d_vrai;
2016: }
2017: else
2018: {
2019: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
2020: {
2021: affectation_interruptions_logicielles(s_etat_processus);
2022: }
2023:
2024: if ((*s_etat_processus).nombre_interruptions_en_queue
2025: != 0)
2026: {
2027: registre_instruction_valide =
2028: (*s_etat_processus).instruction_valide;
2029: traitement_interruptions_logicielles(
2030: s_etat_processus);
2031: (*s_etat_processus).instruction_valide =
2032: registre_instruction_valide;
2033: }
2034:
2035: nanosleep(&attente, NULL);
2036: scrutation_injection(s_etat_processus);
2037:
2038: INCR_GRANULARITE(attente.tv_nsec);
2039: }
2040: } while((drapeau == d_faux) && ((*s_etat_processus)
2041: .var_volatile_requete_arret != -1));
2042: }
2043: else
2044: {
2045: liberation(s_etat_processus, s_objet_argument_1);
2046: liberation(s_etat_processus, s_objet_argument_2);
2047:
2048: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2049: return;
2050: }
2051:
2052: return;
2053: }
2054:
2055:
2056: /*
2057: ================================================================================
2058: Fonction 'wfproc'
2059: ================================================================================
2060: Entrées : pointeur sur une structure struct_processus
2061: --------------------------------------------------------------------------------
2062: Sorties :
2063: --------------------------------------------------------------------------------
2064: Effets de bord : néant
2065: ================================================================================
2066: */
2067:
2068: void
2069: instruction_wfproc(struct_processus *s_etat_processus)
2070: {
2071: logical1 drapeau_fin;
2072:
2073: struct_liste_chainee *l_element_courant;
2074:
2075: struct_objet *s_objet_argument;
2076:
2077: struct timespec attente;
2078:
2079: unsigned char registre_instruction_valide;
2080:
2081: (*s_etat_processus).erreur_execution = d_ex;
2082:
2083: attente.tv_sec = 0;
2084: attente.tv_nsec = GRANULARITE_us * 1000;
2085:
2086: if ((*s_etat_processus).affichage_arguments == 'Y')
2087: {
2088: printf("\n WFPROC ");
2089:
2090: if ((*s_etat_processus).langue == 'F')
2091: {
2092: printf("(attente de la fin d'un processus fils)\n\n");
2093: }
2094: else
2095: {
2096: printf("(wait for child process end)\n\n");
2097: }
2098:
2099: printf(" 1: %s\n", d_PRC);
2100:
2101: return;
2102: }
2103: else if ((*s_etat_processus).test_instruction == 'Y')
2104: {
2105: (*s_etat_processus).nombre_arguments = -1;
2106: return;
2107: }
2108:
2109: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2110: {
2111: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
2112: {
2113: return;
2114: }
2115: }
2116:
2117: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2118: &s_objet_argument) == d_erreur)
2119: {
2120: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2121: return;
2122: }
2123:
2124: if ((*s_objet_argument).type == PRC)
2125: {
2126: drapeau_fin = d_faux;
2127:
2128: if ((*s_etat_processus).profilage == d_vrai)
2129: {
2130: profilage(s_etat_processus, "Interprocess or interthread "
2131: "communications (WFPROC)");
2132:
2133: if ((*s_etat_processus).erreur_systeme != d_es)
2134: {
2135: return;
2136: }
2137: }
2138:
2139: if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
2140: {
2141: if ((*s_etat_processus).profilage == d_vrai)
2142: {
2143: profilage(s_etat_processus, NULL);
2144: }
2145:
2146: (*s_etat_processus).erreur_systeme = d_es_processus;
2147: return;
2148: }
2149:
2150: while(drapeau_fin == d_faux)
2151: {
2152: l_element_courant = (struct_liste_chainee *)
2153: (*s_etat_processus).l_base_pile_processus;
2154:
2155: while(l_element_courant != NULL)
2156: {
2157: if ((*(*((struct_processus_fils *) (*(*l_element_courant)
2158: .donnee).objet)).thread).processus_detache == d_vrai)
2159: {
2160: if ((*(*((struct_processus_fils *)
2161: (*s_objet_argument).objet)).thread)
2162: .processus_detache == d_vrai)
2163: {
2164: if ((*(*((struct_processus_fils *)
2165: (*(*l_element_courant)
2166: .donnee).objet)).thread).pid ==
2167: (*(*((struct_processus_fils *)
2168: (*s_objet_argument).objet)).thread).pid)
2169: {
2170: break;
2171: }
2172: }
2173: }
2174: else
2175: {
2176: if ((*(*((struct_processus_fils *)
2177: (*s_objet_argument).objet)).thread)
2178: .processus_detache == d_faux)
2179: {
2180: if ((pthread_equal((*(*((struct_processus_fils *)
2181: (*(*l_element_courant).donnee).objet)).thread)
2182: .tid, (*(*((struct_processus_fils *)
2183: (*s_objet_argument).objet)).thread).tid) != 0)
2184: && ((*(*((struct_processus_fils *)
2185: (*(*l_element_courant).donnee).objet)).thread)
2186: .pid == (*(*((struct_processus_fils *)
2187: (*s_objet_argument).objet)).thread).pid))
2188: {
2189: break;
2190: }
2191: }
2192: }
2193:
2194: l_element_courant = (*l_element_courant).suivant;
2195: }
2196:
2197: if ((*s_etat_processus).var_volatile_requete_arret != 0)
2198: {
2199: if ((*s_etat_processus).profilage == d_vrai)
2200: {
2201: profilage(s_etat_processus, NULL);
2202: }
2203:
2204: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2205: {
2206: (*s_etat_processus).erreur_systeme = d_es_processus;
2207: return;
2208: }
2209:
2210: liberation(s_etat_processus, s_objet_argument);
2211: return;
2212: }
2213:
2214: if (l_element_courant == NULL)
2215: {
2216: /*
2217: * Si l_element_courant vaut NULL, le processus n'existe plus.
2218: */
2219:
2220: drapeau_fin = d_vrai;
2221: }
2222: else
2223: {
2224: if ((*(*((struct_processus_fils *) (*(*l_element_courant)
2225: .donnee).objet)).thread).processus_detache == d_vrai)
2226: {
1.48 bertrand 2227: if (envoi_signal_processus((*(*((struct_processus_fils *)
1.1 bertrand 2228: (*(*l_element_courant).donnee).objet)).thread).pid,
1.48 bertrand 2229: rpl_signull) != 0)
1.1 bertrand 2230: {
2231: drapeau_fin = d_vrai;
2232: }
2233: else
2234: {
2235: drapeau_fin = d_faux;
2236: }
2237: }
2238: else
2239: {
2240: if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
2241: (*(*l_element_courant).donnee).objet)).thread)
2242: .mutex)) != 0)
2243: {
2244: if ((*s_etat_processus).profilage == d_vrai)
2245: {
2246: profilage(s_etat_processus, NULL);
2247: }
2248:
2249: (*s_etat_processus).erreur_systeme = d_es_processus;
2250: return;
2251: }
2252:
2253: if ((*(*((struct_processus_fils *)
2254: (*(*l_element_courant).donnee).objet)).thread)
2255: .thread_actif == d_faux)
2256: {
2257: drapeau_fin = d_vrai;
2258: }
2259: else
2260: {
2261: drapeau_fin = d_faux;
2262: }
2263:
2264: if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
2265: (*(*l_element_courant).donnee).objet)).thread)
2266: .mutex)) != 0)
2267: {
2268: if ((*s_etat_processus).profilage == d_vrai)
2269: {
2270: profilage(s_etat_processus, NULL);
2271: }
2272:
2273: (*s_etat_processus).erreur_systeme = d_es_processus;
2274: return;
2275: }
2276: }
2277:
2278: if (drapeau_fin == d_faux)
2279: {
2280: /*
2281: * Le processus n'est pas terminé
2282: */
2283:
2284: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2285: {
2286: if ((*s_etat_processus).profilage == d_vrai)
2287: {
2288: profilage(s_etat_processus, NULL);
2289: }
2290:
2291: (*s_etat_processus).erreur_systeme =
2292: d_es_processus;
2293: return;
2294: }
2295:
2296: if ((*s_etat_processus).nombre_interruptions_non_affectees
2297: != 0)
2298: {
2299: affectation_interruptions_logicielles(s_etat_processus);
2300: }
2301:
2302: if ((*s_etat_processus).nombre_interruptions_en_queue
2303: != 0)
2304: {
2305: registre_instruction_valide =
2306: (*s_etat_processus).instruction_valide;
2307: traitement_interruptions_logicielles(
2308: s_etat_processus);
2309: (*s_etat_processus).instruction_valide =
2310: registre_instruction_valide;
2311: }
2312:
1.51 bertrand 2313: # ifndef SEMAPHORES_NOMMES
2314: if (sem_post(&((*s_etat_processus).semaphore_fork))
2315: != 0)
2316: # else
2317: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
2318: # endif
1.1 bertrand 2319: {
2320: (*s_etat_processus).erreur_systeme = d_es_processus;
2321: return;
2322: }
2323:
2324: nanosleep(&attente, NULL);
2325:
1.51 bertrand 2326: # ifndef SEMAPHORES_NOMMES
2327: while(sem_wait(&((*s_etat_processus).semaphore_fork))
2328: != 0)
2329: # else
2330: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
2331: # endif
1.1 bertrand 2332: {
1.50 bertrand 2333: if (errno != EINTR)
2334: {
2335: (*s_etat_processus).erreur_systeme = d_es_processus;
2336: return;
2337: }
1.1 bertrand 2338: }
2339:
2340: scrutation_injection(s_etat_processus);
2341:
2342: if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
2343: {
2344: if ((*s_etat_processus).profilage == d_vrai)
2345: {
2346: profilage(s_etat_processus, NULL);
2347: }
2348:
2349: (*s_etat_processus).erreur_systeme =
2350: d_es_processus;
2351: return;
2352: }
2353: }
2354: }
2355:
2356: INCR_GRANULARITE(attente.tv_nsec);
2357: }
2358:
2359: if ((*s_etat_processus).profilage == d_vrai)
2360: {
2361: profilage(s_etat_processus, NULL);
2362: }
2363:
2364: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2365: {
2366: (*s_etat_processus).erreur_systeme = d_es_processus;
2367: return;
2368: }
2369: }
2370: else
2371: {
2372: liberation(s_etat_processus, s_objet_argument);
2373:
2374: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2375: return;
2376: }
2377:
2378: liberation(s_etat_processus, s_objet_argument);
2379:
2380: return;
2381: }
2382:
2383:
2384: /*
2385: ================================================================================
2386: Fonction 'wfdata'
2387: ================================================================================
2388: Entrées : pointeur sur une structure struct_processus
2389: --------------------------------------------------------------------------------
2390: Sorties :
2391: --------------------------------------------------------------------------------
2392: Effets de bord : néant
2393: ================================================================================
2394: */
2395:
2396: void
2397: instruction_wfdata(struct_processus *s_etat_processus)
2398: {
2399: logical1 drapeau_fin;
2400:
2401: struct_liste_chainee *l_element_courant;
2402:
2403: struct_objet *s_objet_argument;
2404:
2405: struct timespec attente;
2406:
2407: unsigned char registre_instruction_valide;
2408:
2409: (*s_etat_processus).erreur_execution = d_ex;
2410:
2411: attente.tv_sec = 0;
2412: attente.tv_nsec = GRANULARITE_us * 1000;
2413:
2414: if ((*s_etat_processus).affichage_arguments == 'Y')
2415: {
2416: printf("\n WFDATA ");
2417:
2418: if ((*s_etat_processus).langue == 'F')
2419: {
2420: printf("(attente de données d'un processus fils)\n\n");
2421: }
2422: else
2423: {
2424: printf("(wait for data from child process)\n\n");
2425: }
2426:
2427: printf(" 1: %s\n", d_PRC);
2428:
2429: return;
2430: }
2431: else if ((*s_etat_processus).test_instruction == 'Y')
2432: {
2433: (*s_etat_processus).nombre_arguments = -1;
2434: return;
2435: }
2436:
2437: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2438: {
2439: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
2440: {
2441: return;
2442: }
2443: }
2444:
2445: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2446: &s_objet_argument) == d_erreur)
2447: {
2448: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2449: return;
2450: }
2451:
2452: if ((*s_objet_argument).type == PRC)
2453: {
2454: drapeau_fin = d_faux;
2455:
2456: if ((*s_etat_processus).profilage == d_vrai)
2457: {
2458: profilage(s_etat_processus, "Interprocess or interthread "
2459: "communications (WFDATA)");
2460:
2461: if ((*s_etat_processus).erreur_systeme != d_es)
2462: {
2463: return;
2464: }
2465: }
2466:
2467: if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
2468: {
2469: if ((*s_etat_processus).profilage == d_vrai)
2470: {
2471: profilage(s_etat_processus, NULL);
2472: }
2473:
2474: (*s_etat_processus).erreur_systeme = d_es_processus;
2475: return;
2476: }
2477:
2478: while(drapeau_fin == d_faux)
2479: {
2480: l_element_courant = (struct_liste_chainee *)
2481: (*s_etat_processus).l_base_pile_processus;
2482:
2483: while(l_element_courant != NULL)
2484: {
2485: if ((*(*((struct_processus_fils *) (*(*l_element_courant)
2486: .donnee).objet)).thread).processus_detache == d_vrai)
2487: {
2488: if (((*(*((struct_processus_fils *) (*(*l_element_courant)
2489: .donnee).objet)).thread).pid ==
2490: (*(*((struct_processus_fils *)
2491: (*s_objet_argument).objet)).thread).pid)
2492: && ((*(*((struct_processus_fils *)
2493: (*s_objet_argument).objet)).thread)
2494: .processus_detache == d_vrai))
2495: {
2496: break;
2497: }
2498: }
2499: else
2500: {
2501: if ((pthread_equal((*(*((struct_processus_fils *)
2502: (*(*l_element_courant).donnee).objet)).thread).tid,
2503: (*(*((struct_processus_fils *) (*s_objet_argument)
2504: .objet)).thread).tid) != 0) &&
2505: ((*(*((struct_processus_fils *)
2506: (*(*l_element_courant).donnee).objet)).thread).pid
2507: == (*(*((struct_processus_fils *)
2508: (*s_objet_argument).objet)).thread).pid) &&
2509: ((*(*((struct_processus_fils *)
2510: (*s_objet_argument).objet)).thread)
2511: .processus_detache == d_faux))
2512: {
2513: break;
2514: }
2515: }
2516:
2517: l_element_courant = (*l_element_courant).suivant;
2518: }
2519:
2520: if ((*s_etat_processus).var_volatile_requete_arret != 0)
2521: {
2522: if ((*s_etat_processus).profilage == d_vrai)
2523: {
2524: profilage(s_etat_processus, NULL);
2525: }
2526:
2527: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2528: {
2529: (*s_etat_processus).erreur_systeme = d_es_processus;
2530: return;
2531: }
2532:
2533: liberation(s_etat_processus, s_objet_argument);
2534: return;
2535: }
2536:
2537: if (l_element_courant != NULL)
2538: {
2539: if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
2540: (*(*l_element_courant).donnee).objet)).thread).mutex))
2541: != 0)
2542: {
2543: (*s_etat_processus).erreur_systeme = d_es_processus;
2544: return;
2545: }
2546:
2547: if ((*(*((struct_processus_fils *) (*(*l_element_courant)
2548: .donnee).objet)).thread).nombre_objets_dans_pipe != 0)
2549: {
2550: if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
2551: (*(*l_element_courant).donnee).objet)).thread)
2552: .mutex)) != 0)
2553: {
2554: (*s_etat_processus).erreur_systeme = d_es_processus;
2555: return;
2556: }
2557:
2558: drapeau_fin = d_vrai;
2559: }
2560: else
2561: {
2562: if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
2563: (*(*l_element_courant).donnee).objet)).thread)
2564: .mutex)) != 0)
2565: {
2566: (*s_etat_processus).erreur_systeme = d_es_processus;
2567: return;
2568: }
2569:
2570: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2571: {
2572: if ((*s_etat_processus).profilage == d_vrai)
2573: {
2574: profilage(s_etat_processus, NULL);
2575: }
2576:
2577: (*s_etat_processus).erreur_systeme =
2578: d_es_processus;
2579: return;
2580: }
2581:
1.51 bertrand 2582: # ifndef SEMAPHORES_NOMMES
2583: if (sem_post(&((*s_etat_processus).semaphore_fork))
2584: != 0)
2585: # else
2586: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
2587: # endif
1.12 bertrand 2588: {
2589: (*s_etat_processus).erreur_systeme = d_es_processus;
2590: return;
2591: }
1.1 bertrand 2592:
2593: nanosleep(&attente, NULL);
2594:
1.51 bertrand 2595: # ifndef SEMAPHORES_NOMMES
2596: while(sem_wait(&((*s_etat_processus).semaphore_fork))
2597: != 0)
2598: # else
2599: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
2600: # endif
1.1 bertrand 2601: {
1.50 bertrand 2602: if (errno != EINTR)
2603: {
2604: (*s_etat_processus).erreur_systeme = d_es_processus;
2605: return;
2606: }
1.1 bertrand 2607: }
2608:
2609: scrutation_injection(s_etat_processus);
2610:
2611: if ((*s_etat_processus).nombre_interruptions_non_affectees
2612: != 0)
2613: {
2614: affectation_interruptions_logicielles(s_etat_processus);
2615: }
2616:
2617: if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
2618: {
2619: registre_instruction_valide =
2620: (*s_etat_processus).instruction_valide;
2621: traitement_interruptions_logicielles(s_etat_processus);
2622: (*s_etat_processus).instruction_valide =
2623: registre_instruction_valide;
2624: }
2625:
2626: if ((*s_etat_processus).var_volatile_requete_arret != 0)
2627: {
2628: if ((*s_etat_processus).profilage == d_vrai)
2629: {
2630: profilage(s_etat_processus, NULL);
2631: }
2632:
2633: return;
2634: }
2635:
2636: if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0)
2637: {
2638: if ((*s_etat_processus).profilage == d_vrai)
2639: {
2640: profilage(s_etat_processus, NULL);
2641: }
2642:
2643: (*s_etat_processus).erreur_systeme =
2644: d_es_processus;
2645: return;
2646: }
2647: }
2648: }
2649: else
2650: {
2651: drapeau_fin = d_vrai;
2652: (*s_etat_processus).erreur_execution = d_ex_processus;
2653: }
2654:
2655: INCR_GRANULARITE(attente.tv_nsec);
2656: }
2657:
2658: if ((*s_etat_processus).profilage == d_vrai)
2659: {
2660: profilage(s_etat_processus, NULL);
2661: }
2662:
2663: if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0)
2664: {
2665: (*s_etat_processus).erreur_systeme = d_es_processus;
2666: return;
2667: }
2668: }
2669: else
2670: {
2671: liberation(s_etat_processus, s_objet_argument);
2672:
2673: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2674: return;
2675: }
2676:
2677: liberation(s_etat_processus, s_objet_argument);
2678:
2679: return;
2680: }
2681:
2682:
2683: /*
2684: ================================================================================
2685: Fonction 'wfsock'
2686: ================================================================================
2687: Entrées : pointeur sur une structure struct_processus
2688: --------------------------------------------------------------------------------
2689: Sorties :
2690: --------------------------------------------------------------------------------
2691: Effets de bord : néant
2692: ================================================================================
2693: */
2694:
2695: void
2696: instruction_wfsock(struct_processus *s_etat_processus)
2697: {
2698: int erreur;
2699:
2700: logical1 drapeau;
2701:
2702: socklen_t longueur;
2703:
2704: struct_liste_chainee *l_element_courant;
2705:
2706: struct_objet *s_objet_argument;
2707: struct_objet *s_objet_resultat;
2708:
1.54 bertrand 2709: struct pollfd s_poll;
2710:
1.1 bertrand 2711: struct sockaddr_in adresse_ipv4;
1.20 bertrand 2712: # ifdef IPV6
1.1 bertrand 2713: struct sockaddr_in6 adresse_ipv6;
1.20 bertrand 2714: # endif
1.1 bertrand 2715:
2716: unsigned long i;
2717:
2718: if ((*s_etat_processus).affichage_arguments == 'Y')
2719: {
2720: printf("\n WFSOCK ");
2721:
2722: if ((*s_etat_processus).langue == 'F')
2723: {
2724: printf("(attente d'une connexion sur une socket)\n\n");
2725: }
2726: else
2727: {
2728: printf("(wait for connection on a socket)\n\n");
2729: }
2730:
2731: printf(" 1: %s\n", d_SCK);
2732: printf("-> 2: %s\n", d_SCK);
2733: printf(" 1: %s\n", d_SCK);
2734:
2735: return;
2736: }
2737: else if ((*s_etat_processus).test_instruction == 'Y')
2738: {
2739: (*s_etat_processus).nombre_arguments = -1;
2740: return;
2741: }
2742:
2743: if (test_cfsf(s_etat_processus, 31) == d_vrai)
2744: {
2745: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
2746: {
2747: return;
2748: }
2749: }
2750:
2751: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2752: &s_objet_argument) == d_erreur)
2753: {
2754: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
2755: return;
2756: }
2757:
2758: if ((*s_objet_argument).type == SCK)
2759: {
2760: if ((strcmp((*((struct_socket *) (*s_objet_argument).objet)).type,
2761: "STREAM") != 0) && (strcmp((*((struct_socket *)
2762: (*s_objet_argument).objet)).type, "SEQUENTIAL DATAGRAM") != 0))
2763: {
1.54 bertrand 2764: // Mode non connecté : l'attente se fait sur un poll()
2765:
2766: if ((s_objet_resultat = copie_objet(s_etat_processus,
2767: s_objet_argument, 'P')) == NULL)
2768: {
2769: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2770: return;
2771: }
2772:
2773: s_poll.fd = (*((struct_socket *) (*s_objet_argument).objet)).socket;
2774: s_poll.events = POLLIN;
2775: s_poll.revents = 0;
2776:
1.55 bertrand 2777: do
1.54 bertrand 2778: {
1.55 bertrand 2779: drapeau = d_vrai;
2780:
2781: # ifndef SEMAPHORES_NOMMES
2782: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
2783: # else
2784: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
2785: # endif
2786: {
2787: (*s_etat_processus).erreur_systeme = d_es_processus;
2788: return;
2789: }
2790:
2791: if (poll(&s_poll, 1, -1) < 0)
2792: {
2793: erreur = errno;
2794:
2795: # ifndef SEMAPHORES_NOMMES
2796: while(sem_wait(&((*s_etat_processus)
2797: .semaphore_fork)) != 0)
2798: # else
2799: while(sem_wait((*s_etat_processus).semaphore_fork)
2800: != 0)
2801: # endif
2802:
2803: if (erreur != EINTR)
2804: {
2805: liberation(s_etat_processus, s_objet_argument);
2806: liberation(s_etat_processus, s_objet_resultat);
2807:
2808: (*s_etat_processus).erreur_execution =
2809: d_ex_erreur_acces_fichier;
2810: return;
2811: }
2812:
2813: scrutation_injection(s_etat_processus);
2814:
2815: if ((*s_etat_processus).var_volatile_requete_arret != 0)
2816: {
2817: drapeau = d_vrai;
2818: }
2819: else
2820: {
2821: drapeau = d_faux;
2822: }
2823: }
2824: else
1.54 bertrand 2825: {
1.55 bertrand 2826: # ifndef SEMAPHORES_NOMMES
2827: while(sem_wait(&((*s_etat_processus)
2828: .semaphore_fork)) != 0)
2829: # else
2830: while(sem_wait((*s_etat_processus).semaphore_fork)
2831: != 0)
2832: # endif
2833: {
2834: if (errno != EINTR)
2835: {
2836: (*s_etat_processus).erreur_systeme =
2837: d_es_processus;
2838: return;
2839: }
2840: }
1.54 bertrand 2841: }
1.55 bertrand 2842: } while(drapeau == d_faux);
1.54 bertrand 2843:
2844: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2845: s_objet_argument) == d_erreur)
2846: {
2847: return;
2848: }
1.1 bertrand 2849:
1.54 bertrand 2850: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2851: s_objet_resultat) == d_erreur)
2852: {
2853: return;
2854: }
1.1 bertrand 2855: }
1.54 bertrand 2856: else
1.1 bertrand 2857: {
1.54 bertrand 2858: // Mode connecté
1.1 bertrand 2859:
1.54 bertrand 2860: if ((s_objet_resultat = copie_objet(s_etat_processus,
2861: s_objet_argument, 'O')) == NULL)
2862: {
2863: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
2864: return;
2865: }
1.1 bertrand 2866:
1.54 bertrand 2867: (*((struct_socket *) (*s_objet_resultat).objet)).effacement = 'N';
2868: (*((struct_socket *) (*s_objet_resultat).objet)).socket_en_ecoute
2869: = 'N';
1.1 bertrand 2870:
1.54 bertrand 2871: if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine ==
2872: PF_INET)
1.1 bertrand 2873: {
1.54 bertrand 2874: longueur = sizeof(adresse_ipv4);
2875:
2876: do
2877: {
2878: drapeau = d_vrai;
1.1 bertrand 2879:
1.51 bertrand 2880: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 2881: if (sem_post(&((*s_etat_processus).semaphore_fork))
2882: != 0)
1.51 bertrand 2883: # else
1.54 bertrand 2884: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1.51 bertrand 2885: # endif
1.54 bertrand 2886: {
2887: (*s_etat_processus).erreur_systeme = d_es_processus;
2888: return;
2889: }
1.1 bertrand 2890:
1.54 bertrand 2891: if (((*((struct_socket *) (*s_objet_resultat).objet))
2892: .socket = accept((*((struct_socket *)
2893: (*s_objet_argument).objet)).socket,
2894: (struct sockaddr *) &adresse_ipv4, &longueur))
2895: < 0)
2896: {
2897: erreur = errno;
1.1 bertrand 2898:
1.55 bertrand 2899: # ifndef SEMAPHORES_NOMMES
2900: while(sem_wait(&((*s_etat_processus)
2901: .semaphore_fork)) != 0)
2902: # else
2903: while(sem_wait((*s_etat_processus).semaphore_fork)
2904: != 0)
2905: # endif
1.50 bertrand 2906: {
1.54 bertrand 2907: if (errno != EINTR)
2908: {
2909: (*s_etat_processus).erreur_systeme =
2910: d_es_processus;
2911: return;
2912: }
1.50 bertrand 2913: }
1.1 bertrand 2914:
1.54 bertrand 2915: if (erreur != EINTR)
2916: {
2917: liberation(s_etat_processus, s_objet_argument);
2918: liberation(s_etat_processus, s_objet_resultat);
1.1 bertrand 2919:
1.54 bertrand 2920: (*s_etat_processus).erreur_execution =
2921: d_ex_erreur_acces_fichier;
2922: return;
2923: }
1.1 bertrand 2924:
1.54 bertrand 2925: scrutation_injection(s_etat_processus);
1.1 bertrand 2926:
1.54 bertrand 2927: if ((*s_etat_processus).var_volatile_requete_arret != 0)
2928: {
2929: drapeau = d_vrai;
2930: }
2931: else
2932: {
2933: drapeau = d_faux;
2934: }
1.1 bertrand 2935: }
2936: else
2937: {
1.51 bertrand 2938: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 2939: while(sem_wait(&((*s_etat_processus)
2940: .semaphore_fork)) != 0)
1.51 bertrand 2941: # else
1.54 bertrand 2942: while(sem_wait((*s_etat_processus).semaphore_fork)
2943: != 0)
1.51 bertrand 2944: # endif
1.50 bertrand 2945: {
1.54 bertrand 2946: if (errno != EINTR)
2947: {
2948: (*s_etat_processus).erreur_systeme =
2949: d_es_processus;
2950: return;
2951: }
1.50 bertrand 2952: }
1.1 bertrand 2953: }
1.54 bertrand 2954: } while(drapeau == d_faux);
2955:
2956: if (((*((struct_socket *) (*s_objet_resultat).objet))
2957: .adresse_distante = malloc(22 *
2958: sizeof(unsigned char))) == NULL)
2959: {
2960: (*s_etat_processus).erreur_systeme =
2961: d_es_allocation_memoire;
2962: return;
1.1 bertrand 2963: }
2964:
1.54 bertrand 2965: sprintf((*((struct_socket *) (*s_objet_resultat).objet))
2966: .adresse_distante, "%d.%d.%d.%d(%d)",
2967: (ntohl(adresse_ipv4.sin_addr.s_addr) >> 24) & 0xFF,
2968: (ntohl(adresse_ipv4.sin_addr.s_addr) >> 16) & 0xFF,
2969: (ntohl(adresse_ipv4.sin_addr.s_addr) >> 8) & 0xFF,
2970: ntohl(adresse_ipv4.sin_addr.s_addr) & 0xFF,
2971: ntohs(adresse_ipv4.sin_port));
2972: }
2973: else if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine ==
2974: PF_INET6)
1.1 bertrand 2975: {
1.20 bertrand 2976: # ifdef IPV6
1.54 bertrand 2977: longueur = sizeof(adresse_ipv6);
1.1 bertrand 2978:
1.54 bertrand 2979: do
2980: {
2981: drapeau = d_vrai;
1.1 bertrand 2982:
1.51 bertrand 2983: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 2984: if (sem_post(&((*s_etat_processus).semaphore_fork))
2985: != 0)
1.51 bertrand 2986: # else
1.54 bertrand 2987: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1.51 bertrand 2988: # endif
1.54 bertrand 2989: {
2990: (*s_etat_processus).erreur_systeme = d_es_processus;
2991: return;
2992: }
1.1 bertrand 2993:
1.54 bertrand 2994: if (((*((struct_socket *) (*s_objet_resultat).objet))
2995: .socket = accept((*((struct_socket *)
2996: (*s_objet_argument).objet)).socket,
2997: (struct sockaddr *) &adresse_ipv6, &longueur)) < 0)
2998: {
2999: erreur = errno;
1.1 bertrand 3000:
1.51 bertrand 3001: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 3002: while(sem_wait(&((*s_etat_processus)
3003: .semaphore_fork)) != 0)
1.51 bertrand 3004: # else
1.54 bertrand 3005: while(sem_wait((*s_etat_processus).semaphore_fork)
3006: != 0)
1.51 bertrand 3007: # endif
1.50 bertrand 3008: {
1.54 bertrand 3009: if (errno != EINTR)
3010: {
3011: (*s_etat_processus).erreur_systeme =
3012: d_es_processus;
3013: return;
3014: }
1.50 bertrand 3015: }
1.1 bertrand 3016:
1.54 bertrand 3017: if (erreur != EINTR)
3018: {
3019: liberation(s_etat_processus, s_objet_argument);
3020: liberation(s_etat_processus, s_objet_resultat);
1.1 bertrand 3021:
1.54 bertrand 3022: (*s_etat_processus).erreur_execution =
3023: d_ex_erreur_acces_fichier;
3024: return;
3025: }
1.1 bertrand 3026:
1.54 bertrand 3027: scrutation_injection(s_etat_processus);
1.1 bertrand 3028:
1.54 bertrand 3029: if ((*s_etat_processus).var_volatile_requete_arret != 0)
3030: {
3031: drapeau = d_vrai;
3032: }
3033: else
3034: {
3035: drapeau = d_faux;
3036: }
1.1 bertrand 3037: }
3038: else
3039: {
1.51 bertrand 3040: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 3041: while(sem_wait(&((*s_etat_processus)
3042: .semaphore_fork)) != 0)
1.51 bertrand 3043: # else
1.54 bertrand 3044: while(sem_wait((*s_etat_processus).semaphore_fork)
3045: != 0)
1.51 bertrand 3046: # endif
1.50 bertrand 3047: {
1.54 bertrand 3048: if (errno != EINTR)
3049: {
3050: (*s_etat_processus).erreur_systeme =
3051: d_es_processus;
3052: return;
3053: }
1.50 bertrand 3054: }
1.1 bertrand 3055: }
1.54 bertrand 3056: } while(drapeau == d_faux);
3057:
3058: if (((*((struct_socket *) (*s_objet_resultat).objet))
3059: .adresse_distante = malloc(55 *
3060: sizeof(unsigned char))) == NULL)
3061: {
3062: (*s_etat_processus).erreur_systeme =
3063: d_es_allocation_memoire;
3064: return;
1.1 bertrand 3065: }
3066:
1.54 bertrand 3067: (*((struct_socket *) (*s_objet_resultat).objet))
3068: .adresse_distante = d_code_fin_chaine;
1.1 bertrand 3069:
1.54 bertrand 3070: for(i = 0; i < 16; i++)
3071: {
3072: sprintf((*((struct_socket *) (*s_objet_resultat)
3073: .objet)).adresse_distante, (i == 0) ? "%s%X"
3074: : "%s:%X", (*((struct_socket *) (*s_objet_resultat)
3075: .objet)).adresse_distante,
3076: adresse_ipv6.sin6_addr.s6_addr[i]);
3077: }
1.1 bertrand 3078:
3079: sprintf((*((struct_socket *) (*s_objet_resultat)
1.54 bertrand 3080: .objet)).adresse_distante, "%s(%u)",
1.1 bertrand 3081: (*((struct_socket *) (*s_objet_resultat)
3082: .objet)).adresse_distante,
1.54 bertrand 3083: ntohs(adresse_ipv6.sin6_port));
1.20 bertrand 3084: # else
1.54 bertrand 3085: if ((*s_etat_processus).langue == 'F')
3086: {
3087: printf("+++Attention : Support du protocole"
3088: " IPv6 indisponible\n");
3089: }
3090: else
3091: {
3092: printf("+++Warning : IPv6 support "
3093: "unavailable\n");
3094: }
3095: # endif
1.22 bertrand 3096: }
3097: else
3098: {
1.54 bertrand 3099: longueur = 0;
1.1 bertrand 3100:
1.54 bertrand 3101: do
3102: {
3103: drapeau = d_vrai;
1.1 bertrand 3104:
1.51 bertrand 3105: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 3106: if (sem_post(&((*s_etat_processus).semaphore_fork))
3107: != 0)
1.51 bertrand 3108: # else
1.54 bertrand 3109: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
1.51 bertrand 3110: # endif
1.54 bertrand 3111: {
3112: (*s_etat_processus).erreur_systeme = d_es_processus;
3113: return;
3114: }
1.1 bertrand 3115:
1.54 bertrand 3116: if (((*((struct_socket *) (*s_objet_resultat).objet))
3117: .socket = accept((*((struct_socket *)
3118: (*s_objet_argument).objet)).socket, NULL,
3119: &longueur)) < 0)
3120: {
3121: erreur = errno;
1.1 bertrand 3122:
1.51 bertrand 3123: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 3124: while(sem_wait(&((*s_etat_processus)
3125: .semaphore_fork)) != 0)
1.51 bertrand 3126: # else
1.54 bertrand 3127: while(sem_wait((*s_etat_processus).semaphore_fork)
3128: != 0)
1.51 bertrand 3129: # endif
1.50 bertrand 3130: {
1.54 bertrand 3131: if (errno != EINTR)
3132: {
3133: (*s_etat_processus).erreur_systeme =
3134: d_es_processus;
3135: return;
3136: }
1.50 bertrand 3137: }
1.1 bertrand 3138:
1.54 bertrand 3139: if (erreur != EINTR)
3140: {
3141: liberation(s_etat_processus, s_objet_argument);
3142: liberation(s_etat_processus, s_objet_resultat);
1.1 bertrand 3143:
1.54 bertrand 3144: (*s_etat_processus).erreur_execution =
3145: d_ex_erreur_acces_fichier;
3146: return;
3147: }
1.1 bertrand 3148:
1.54 bertrand 3149: scrutation_injection(s_etat_processus);
1.1 bertrand 3150:
1.54 bertrand 3151: if ((*s_etat_processus).var_volatile_requete_arret != 0)
3152: {
3153: drapeau = d_vrai;
3154: }
3155: else
3156: {
3157: drapeau = d_faux;
3158: }
1.1 bertrand 3159: }
3160: else
3161: {
1.51 bertrand 3162: # ifndef SEMAPHORES_NOMMES
1.54 bertrand 3163: while(sem_wait(&((*s_etat_processus)
3164: .semaphore_fork)) != 0)
1.51 bertrand 3165: # else
1.54 bertrand 3166: while(sem_wait((*s_etat_processus).semaphore_fork)
3167: != 0)
1.51 bertrand 3168: # endif
1.50 bertrand 3169: {
1.54 bertrand 3170: if (errno != EINTR)
3171: {
3172: (*s_etat_processus).erreur_systeme =
3173: d_es_processus;
3174: return;
3175: }
1.50 bertrand 3176: }
1.1 bertrand 3177: }
1.54 bertrand 3178: } while(drapeau == d_faux);
3179: }
1.1 bertrand 3180:
1.54 bertrand 3181: // Si accept() renvoie une erreur non récupérée, il ne peut s'agir
3182: // que de EINTR sachant qu'une requête d'arrêt est en court de
3183: // traitement.
1.1 bertrand 3184:
1.54 bertrand 3185: if ((*((struct_socket *) (*s_objet_resultat).objet)).socket >= 0)
3186: {
3187: l_element_courant = (*s_etat_processus).s_sockets;
1.1 bertrand 3188:
1.54 bertrand 3189: if (l_element_courant == NULL)
1.1 bertrand 3190: {
1.54 bertrand 3191: if (((*s_etat_processus).s_sockets =
3192: allocation_maillon(s_etat_processus)) == NULL)
3193: {
3194: (*s_etat_processus).erreur_systeme =
3195: d_es_allocation_memoire;
3196: return;
3197: }
3198:
3199: (*(*s_etat_processus).s_sockets).suivant = NULL;
3200: l_element_courant = (*s_etat_processus).s_sockets;
1.1 bertrand 3201: }
1.54 bertrand 3202: else
3203: {
3204: /*
3205: * Ajout d'un élément à la fin de la liste chaînée
3206: */
1.1 bertrand 3207:
1.54 bertrand 3208: while((*l_element_courant).suivant != NULL)
3209: {
3210: l_element_courant = (*l_element_courant).suivant;
3211: }
3212:
3213: if (((*l_element_courant).suivant =
3214: allocation_maillon(s_etat_processus)) == NULL)
3215: {
3216: (*s_etat_processus).erreur_systeme =
3217: d_es_allocation_memoire;
3218: return;
3219: }
1.1 bertrand 3220:
3221: l_element_courant = (*l_element_courant).suivant;
1.54 bertrand 3222: (*l_element_courant).suivant = NULL;
1.1 bertrand 3223: }
3224:
1.54 bertrand 3225: if (((*l_element_courant).donnee = copie_objet(s_etat_processus,
3226: s_objet_resultat, 'O')) == NULL)
1.1 bertrand 3227: {
3228: (*s_etat_processus).erreur_systeme =
3229: d_es_allocation_memoire;
3230: return;
3231: }
1.54 bertrand 3232: }
1.1 bertrand 3233:
1.54 bertrand 3234: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3235: s_objet_argument) == d_erreur)
3236: {
3237: return;
1.1 bertrand 3238: }
3239:
1.54 bertrand 3240: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3241: s_objet_resultat) == d_erreur)
1.1 bertrand 3242: {
3243: return;
3244: }
3245: }
3246: }
3247: else
3248: {
3249: liberation(s_etat_processus, s_objet_argument);
3250:
3251: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3252: return;
3253: }
3254:
3255: return;
3256: }
3257:
3258:
3259: /*
3260: ================================================================================
3261: Fonction 'wfswi'
3262: ================================================================================
3263: Entrées : pointeur sur une structure struct_processus
3264: --------------------------------------------------------------------------------
3265: Sorties :
3266: --------------------------------------------------------------------------------
3267: Effets de bord : néant
3268: ================================================================================
3269: */
3270:
3271: void
3272: instruction_wfswi(struct_processus *s_etat_processus)
3273: {
3274: integer8 interruption;
3275:
3276: logical1 drapeau_fin;
3277:
3278: struct_objet *s_objet_argument;
3279:
3280: struct timespec attente;
3281:
3282: (*s_etat_processus).erreur_execution = d_ex;
3283:
3284: attente.tv_sec = 0;
3285: attente.tv_nsec = GRANULARITE_us * 1000;
3286:
3287: if ((*s_etat_processus).affichage_arguments == 'Y')
3288: {
3289: printf("\n WFSWI ");
3290:
3291: if ((*s_etat_processus).langue == 'F')
3292: {
3293: printf("(attente d'une interruption)\n\n");
3294: }
3295: else
3296: {
3297: printf("(wait for interrupt)\n\n");
3298: }
3299:
3300: printf(" 1: %s\n", d_INT);
3301:
3302: return;
3303: }
3304: else if ((*s_etat_processus).test_instruction == 'Y')
3305: {
3306: (*s_etat_processus).nombre_arguments = -1;
3307: return;
3308: }
3309:
3310: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3311: {
3312: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
3313: {
3314: return;
3315: }
3316: }
3317:
3318: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
3319: &s_objet_argument) == d_erreur)
3320: {
3321: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
3322: return;
3323: }
3324:
3325: if ((*s_objet_argument).type == INT)
3326: {
3327: drapeau_fin = d_faux;
3328:
3329: interruption = (*((integer8 *) (*s_objet_argument).objet));
3330:
3331: if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
3332: {
3333: liberation(s_etat_processus, s_objet_argument);
3334:
3335: (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
3336: return;
3337: }
3338:
3339: while(drapeau_fin == d_faux)
3340: {
3341: if ((*s_etat_processus).var_volatile_requete_arret != 0)
3342: {
3343: liberation(s_etat_processus, s_objet_argument);
3344: return;
3345: }
3346:
3347: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
3348: {
3349: affectation_interruptions_logicielles(s_etat_processus);
3350: }
3351:
3352: if ((*s_etat_processus).queue_interruptions[interruption - 1] > 0)
3353: {
3354: drapeau_fin = d_vrai;
3355: }
3356: else
3357: {
3358: nanosleep(&attente, NULL);
3359: scrutation_injection(s_etat_processus);
3360: INCR_GRANULARITE(attente.tv_nsec);
3361: }
3362: }
3363: }
3364: else
3365: {
3366: liberation(s_etat_processus, s_objet_argument);
3367:
3368: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
3369: return;
3370: }
3371:
3372: liberation(s_etat_processus, s_objet_argument);
3373:
3374: return;
3375: }
3376:
3377:
3378: /*
3379: ================================================================================
3380: Fonction 'wfpoke'
3381: ================================================================================
3382: Entrées : pointeur sur une structure struct_processus
3383: --------------------------------------------------------------------------------
3384: Sorties :
3385: --------------------------------------------------------------------------------
3386: Effets de bord : néant
3387: ================================================================================
3388: */
3389:
3390: void
3391: instruction_wfpoke(struct_processus *s_etat_processus)
3392: {
3393: struct timespec attente;
3394:
3395: unsigned char registre_instruction_valide;
3396:
3397: (*s_etat_processus).erreur_execution = d_ex;
3398:
3399: attente.tv_sec = 0;
3400: attente.tv_nsec = GRANULARITE_us * 1000;
3401:
3402: if ((*s_etat_processus).affichage_arguments == 'Y')
3403: {
3404: printf("\n WFPOKE ");
3405:
3406: if ((*s_etat_processus).langue == 'F')
3407: {
3408: printf("(attente de données en provenance du processus père)\n\n");
3409: printf(" Aucun argument\n");
3410: }
3411: else
3412: {
3413: printf("(wait for data from parent process)\n\n");
3414: printf(" No argument\n");
3415: }
3416:
3417: return;
3418: }
3419: else if ((*s_etat_processus).test_instruction == 'Y')
3420: {
3421: (*s_etat_processus).nombre_arguments = -1;
3422: return;
3423: }
3424:
3425: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3426: {
3427: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
3428: {
3429: return;
3430: }
3431: }
3432:
3433: if ((*s_etat_processus).presence_pipes == d_faux)
3434: {
3435: (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
3436: return;
3437: }
3438:
3439: if ((*s_etat_processus).nombre_objets_injectes > 0)
3440: {
3441: return;
3442: }
3443:
3444: if ((*s_etat_processus).profilage == d_vrai)
3445: {
3446: profilage(s_etat_processus, "Interprocess or interthread "
3447: "communications (WFPOKE)");
3448:
3449: if ((*s_etat_processus).erreur_systeme != d_es)
3450: {
3451: return;
3452: }
3453: }
3454:
3455: do
3456: {
1.51 bertrand 3457: # ifndef SEMAPHORES_NOMMES
3458: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
3459: # else
3460: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3461: # endif
1.1 bertrand 3462: {
3463: (*s_etat_processus).erreur_systeme = d_es_processus;
3464: return;
3465: }
3466:
3467: nanosleep(&attente, NULL);
3468:
1.51 bertrand 3469: # ifndef SEMAPHORES_NOMMES
3470: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
3471: # else
3472: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
3473: # endif
1.1 bertrand 3474: {
1.50 bertrand 3475: if (errno != EINTR)
3476: {
3477: (*s_etat_processus).erreur_systeme = d_es_processus;
3478: return;
3479: }
1.1 bertrand 3480: }
3481:
3482: scrutation_injection(s_etat_processus);
3483:
3484: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
3485: {
3486: affectation_interruptions_logicielles(s_etat_processus);
3487: }
3488:
3489: if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
3490: {
3491: registre_instruction_valide =
3492: (*s_etat_processus).instruction_valide;
3493: traitement_interruptions_logicielles(s_etat_processus);
3494: (*s_etat_processus).instruction_valide =
3495: registre_instruction_valide;
3496: }
3497:
3498: if ((*s_etat_processus).var_volatile_requete_arret != 0)
3499: {
3500: if ((*s_etat_processus).profilage == d_vrai)
3501: {
3502: profilage(s_etat_processus, NULL);
3503: }
3504:
3505: return;
3506: }
3507:
3508: INCR_GRANULARITE(attente.tv_nsec);
3509: } while((*s_etat_processus).nombre_objets_injectes == 0);
3510:
3511: return;
3512: }
3513:
3514:
3515: /*
3516: ================================================================================
3517: Fonction 'wfack'
3518: ================================================================================
3519: Entrées : pointeur sur une structure struct_processus
3520: --------------------------------------------------------------------------------
3521: Sorties :
3522: --------------------------------------------------------------------------------
3523: Effets de bord : néant
3524: ================================================================================
3525: */
3526:
3527: void
3528: instruction_wfack(struct_processus *s_etat_processus)
3529: {
3530: struct timespec attente;
3531:
3532: unsigned char registre_instruction_valide;
3533:
3534: (*s_etat_processus).erreur_execution = d_ex;
3535:
3536: attente.tv_sec = 0;
3537: attente.tv_nsec = GRANULARITE_us * 1000;
3538:
3539: if ((*s_etat_processus).affichage_arguments == 'Y')
3540: {
3541: printf("\n WFACK ");
3542:
3543: if ((*s_etat_processus).langue == 'F')
3544: {
3545: printf("(attente des acquittements de lecture)\n\n");
3546: printf(" Aucun argument\n");
3547: }
3548: else
3549: {
3550: printf("(wait for reading of data acknowledgement)\n\n");
3551: printf(" No argument\n");
3552: }
3553:
3554: return;
3555: }
3556: else if ((*s_etat_processus).test_instruction == 'Y')
3557: {
3558: (*s_etat_processus).nombre_arguments = -1;
3559: return;
3560: }
3561:
3562: if (test_cfsf(s_etat_processus, 31) == d_vrai)
3563: {
3564: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
3565: {
3566: return;
3567: }
3568: }
3569:
3570: if ((*s_etat_processus).presence_pipes == d_faux)
3571: {
3572: (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
3573: return;
3574: }
3575:
3576: if ((*s_etat_processus).profilage == d_vrai)
3577: {
3578: profilage(s_etat_processus, "Interprocess or interthread communications"
3579: " (WFACK)");
3580:
3581: if ((*s_etat_processus).erreur_systeme != d_es)
3582: {
3583: return;
3584: }
3585: }
3586:
3587: while((*s_etat_processus).nombre_objets_envoyes_non_lus != 0)
3588: {
3589: scrutation_injection(s_etat_processus);
3590:
3591: if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
3592: {
3593: affectation_interruptions_logicielles(s_etat_processus);
3594: }
3595:
3596: if ((*s_etat_processus).nombre_interruptions_en_queue != 0)
3597: {
3598: registre_instruction_valide =
3599: (*s_etat_processus).instruction_valide;
3600: traitement_interruptions_logicielles(s_etat_processus);
3601: (*s_etat_processus).instruction_valide =
3602: registre_instruction_valide;
3603: }
3604:
3605: if ((*s_etat_processus).var_volatile_requete_arret != 0)
3606: {
3607: if ((*s_etat_processus).profilage == d_vrai)
3608: {
3609: profilage(s_etat_processus, NULL);
3610: }
3611:
3612: return;
3613: }
3614:
1.51 bertrand 3615: # ifndef SEMAPHORES_NOMMES
3616: if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
3617: # else
3618: if (sem_post((*s_etat_processus).semaphore_fork) != 0)
3619: # endif
1.12 bertrand 3620: {
3621: (*s_etat_processus).erreur_systeme = d_es_processus;
3622: return;
3623: }
1.1 bertrand 3624:
3625: nanosleep(&attente, NULL);
3626: INCR_GRANULARITE(attente.tv_nsec);
3627:
1.51 bertrand 3628: # ifndef SEMAPHORES_NOMMES
3629: while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
3630: # else
3631: while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
3632: # endif
1.1 bertrand 3633: {
1.50 bertrand 3634: if (errno != EINTR)
3635: {
3636: (*s_etat_processus).erreur_systeme = d_es_processus;
3637: return;
3638: }
1.1 bertrand 3639: }
3640: }
3641:
3642: if ((*s_etat_processus).profilage == d_vrai)
3643: {
3644: profilage(s_etat_processus, NULL);
3645: }
3646:
3647: return;
3648: }
3649:
3650: // vim: ts=4