Annotation of rpl/src/instructions_k1.c, revision 1.1
1.1 ! bertrand 1: /*
! 2: ================================================================================
! 3: RPL/2 (R) version 4.0.9
! 4: Copyright (C) 1989-2010 Dr. BERTRAND Joël
! 5:
! 6: This file is part of RPL/2.
! 7:
! 8: RPL/2 is free software; you can redistribute it and/or modify it
! 9: under the terms of the CeCILL V2 License as published by the french
! 10: CEA, CNRS and INRIA.
! 11:
! 12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
! 13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! 14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
! 15: for more details.
! 16:
! 17: You should have received a copy of the CeCILL License
! 18: along with RPL/2. If not, write to info@cecill.info.
! 19: ================================================================================
! 20: */
! 21:
! 22:
! 23: #include "rpl.conv.h"
! 24:
! 25:
! 26: /*
! 27: ================================================================================
! 28: Fonction 'kill'
! 29: ================================================================================
! 30: Entrées :
! 31: --------------------------------------------------------------------------------
! 32: Sorties :
! 33: --------------------------------------------------------------------------------
! 34: Effets de bord : néant
! 35: ================================================================================
! 36: */
! 37:
! 38: void
! 39: instruction_kill(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 KILL ");
! 46:
! 47: if ((*s_etat_processus).langue == 'F')
! 48: {
! 49: printf("(abandon du processus en cours)\n\n");
! 50: printf(" Aucun argument\n");
! 51: }
! 52: else
! 53: {
! 54: printf("(current process abort)\n\n");
! 55: printf(" No argument\n");
! 56: }
! 57:
! 58: return;
! 59: }
! 60: else if ((*s_etat_processus).test_instruction == 'Y')
! 61: {
! 62: (*s_etat_processus).nombre_arguments = -1;
! 63: return;
! 64: }
! 65:
! 66: if (test_cfsf(s_etat_processus, 31) == d_vrai)
! 67: {
! 68: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
! 69: {
! 70: return;
! 71: }
! 72: }
! 73:
! 74: (*s_etat_processus).requete_arret = 'Y';
! 75:
! 76: if ((*s_etat_processus).traitement_instruction_halt == d_vrai)
! 77: {
! 78: (*s_etat_processus).execution_pas_suivant = d_vrai;
! 79: }
! 80:
! 81: return;
! 82: }
! 83:
! 84:
! 85: /*
! 86: ================================================================================
! 87: Fonction 'key'
! 88: ================================================================================
! 89: Entrées :
! 90: --------------------------------------------------------------------------------
! 91: Sorties :
! 92: --------------------------------------------------------------------------------
! 93: Effets de bord : néant
! 94: ================================================================================
! 95: */
! 96:
! 97: void
! 98: instruction_key(struct_processus *s_etat_processus)
! 99: {
! 100: int unite;
! 101:
! 102: struct_objet *s_objet_caractere;
! 103: struct_objet *s_objet_drapeau;
! 104:
! 105: struct termios tp;
! 106:
! 107: tcflag_t drapeaux;
! 108:
! 109: unsigned char caractere;
! 110:
! 111: (*s_etat_processus).erreur_execution = d_ex;
! 112:
! 113: if ((*s_etat_processus).affichage_arguments == 'Y')
! 114: {
! 115: printf("\n KEY ");
! 116:
! 117: if ((*s_etat_processus).langue == 'F')
! 118: {
! 119: printf("(saisit une entrée au vol)\n\n");
! 120: }
! 121: else
! 122: {
! 123: printf("(non blocking character input)\n\n");
! 124: }
! 125:
! 126: printf("-> 1: %s (0)\n\n", d_INT);
! 127:
! 128: printf("-> 2: %s\n", d_CHN);
! 129: printf(" 1: %s (-1)\n", d_INT);
! 130:
! 131: return;
! 132: }
! 133: else if ((*s_etat_processus).test_instruction == 'Y')
! 134: {
! 135: (*s_etat_processus).nombre_arguments = -1;
! 136: return;
! 137: }
! 138:
! 139: if (test_cfsf(s_etat_processus, 31) == d_vrai)
! 140: {
! 141: if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
! 142: {
! 143: return;
! 144: }
! 145: }
! 146:
! 147: if (tcgetattr(0, &tp) == -1)
! 148: {
! 149: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 150: return;
! 151: }
! 152:
! 153: drapeaux = (ECHO | ECHOK | ICANON);
! 154: tp.c_lflag &= (~drapeaux);
! 155:
! 156: if (tcsetattr(0, TCSANOW, &tp) == -1)
! 157: {
! 158: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 159: return;
! 160: }
! 161:
! 162: if ((unite = open(ttyname(0), O_NONBLOCK|O_NOCTTY)) == -1)
! 163: {
! 164: tp.c_lflag |= drapeaux;
! 165:
! 166: if (tcsetattr(0, TCSANOW, &tp) == -1)
! 167: {
! 168: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 169: return;
! 170: }
! 171:
! 172: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 173: return;
! 174: }
! 175:
! 176: if ((s_objet_drapeau = allocation(s_etat_processus, INT)) == NULL)
! 177: {
! 178: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 179: return;
! 180: }
! 181:
! 182: if (read_atomic(s_etat_processus, unite, (void *) &caractere, 1) == -1)
! 183: {
! 184: (*((integer8 *) (*s_objet_drapeau).objet)) = 0;
! 185:
! 186: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 187: s_objet_drapeau) == d_erreur)
! 188: {
! 189: return;
! 190: }
! 191: }
! 192: else
! 193: {
! 194: if ((s_objet_caractere = allocation(s_etat_processus, CHN)) == NULL)
! 195: {
! 196: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 197: return;
! 198: }
! 199:
! 200: if (((*s_objet_caractere).objet = malloc(2 *
! 201: sizeof(unsigned char))) == NULL)
! 202: {
! 203: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 204: return;
! 205: }
! 206:
! 207: ((unsigned char *) (*s_objet_caractere).objet)[0] = caractere;
! 208: ((unsigned char *) (*s_objet_caractere).objet)[1] = d_code_fin_chaine;
! 209:
! 210: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 211: s_objet_caractere) == d_erreur)
! 212: {
! 213: return;
! 214: }
! 215:
! 216: (*((integer8 *) (*s_objet_drapeau).objet)) = -1;
! 217:
! 218: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 219: s_objet_drapeau) == d_erreur)
! 220: {
! 221: return;
! 222: }
! 223: }
! 224:
! 225: if (close(unite) == -1)
! 226: {
! 227: tp.c_lflag |= drapeaux;
! 228:
! 229: if (tcsetattr(0, TCSANOW, &tp) == -1)
! 230: {
! 231: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 232: return;
! 233: }
! 234:
! 235: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 236: return;
! 237: }
! 238:
! 239: tp.c_lflag |= drapeaux;
! 240:
! 241: if (tcsetattr(0, TCSANOW, &tp) == -1)
! 242: {
! 243: (*s_etat_processus).erreur_systeme = d_es_peripherique_stdin;
! 244: return;
! 245: }
! 246:
! 247: return;
! 248: }
! 249:
! 250:
! 251: /*
! 252: ================================================================================
! 253: Fonction 'kind'
! 254: ================================================================================
! 255: Entrées : structure processus
! 256: --------------------------------------------------------------------------------
! 257: Sorties :
! 258: --------------------------------------------------------------------------------
! 259: Effets de bord : néant
! 260: ================================================================================
! 261: */
! 262:
! 263: void
! 264: instruction_kind(struct_processus *s_etat_processus)
! 265: {
! 266: struct_objet *s_objet_argument;
! 267: struct_objet *s_objet_resultat;
! 268:
! 269: (*s_etat_processus).erreur_execution = d_ex;
! 270:
! 271: if ((*s_etat_processus).affichage_arguments == 'Y')
! 272: {
! 273: printf("\n KIND ");
! 274:
! 275: if ((*s_etat_processus).langue == 'F')
! 276: {
! 277: printf("(variété d'objet)\n\n");
! 278: }
! 279: else
! 280: {
! 281: printf("(kind of object)\n\n");
! 282: }
! 283:
! 284: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
! 285: " %s, %s, %s\n",
! 286: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX);
! 287: printf("-> 1: %s\n", d_INT);
! 288:
! 289: return;
! 290: }
! 291: else if ((*s_etat_processus).test_instruction == 'Y')
! 292: {
! 293: (*s_etat_processus).nombre_arguments = -1;
! 294: return;
! 295: }
! 296:
! 297: if (test_cfsf(s_etat_processus, 31) == d_vrai)
! 298: {
! 299: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
! 300: {
! 301: return;
! 302: }
! 303: }
! 304:
! 305: if (depilement(s_etat_processus, &((*s_etat_processus)
! 306: .l_base_pile), &s_objet_argument) == d_erreur)
! 307: {
! 308: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
! 309: return;
! 310: }
! 311:
! 312: if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL)
! 313: {
! 314: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 315: return;
! 316: }
! 317:
! 318: if (((*s_objet_argument).type == INT) ||
! 319: ((*s_objet_argument).type == VIN) ||
! 320: ((*s_objet_argument).type == MIN))
! 321: {
! 322: (*((integer8 *) (*s_objet_resultat).objet)) = 0;
! 323: }
! 324: else if (((*s_objet_argument).type == REL) ||
! 325: ((*s_objet_argument).type == VRL) ||
! 326: ((*s_objet_argument).type == MRL))
! 327: {
! 328: (*((integer8 *) (*s_objet_resultat).objet)) = 1;
! 329: }
! 330: else if (((*s_objet_argument).type == CPL) ||
! 331: ((*s_objet_argument).type == VCX) ||
! 332: ((*s_objet_argument).type == MCX))
! 333: {
! 334: (*((integer8 *) (*s_objet_resultat).objet)) = 2;
! 335: }
! 336: else
! 337: {
! 338: /*
! 339: * Les autres types de données sont des types non numériques.
! 340: */
! 341:
! 342: liberation(s_etat_processus, s_objet_argument);
! 343:
! 344: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
! 345: return;
! 346: }
! 347:
! 348: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 349: s_objet_resultat) == d_erreur)
! 350: {
! 351: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 352: return;
! 353: }
! 354:
! 355: liberation(s_etat_processus, s_objet_argument);
! 356:
! 357: return;
! 358: }
! 359:
! 360:
! 361: /*
! 362: ================================================================================
! 363: Fonction 'keytitle'
! 364: ================================================================================
! 365: Entrées :
! 366: --------------------------------------------------------------------------------
! 367: Sorties :
! 368: --------------------------------------------------------------------------------
! 369: Effets de bord : néant
! 370: ================================================================================
! 371: */
! 372:
! 373: void
! 374: instruction_keytitle(struct_processus *s_etat_processus)
! 375: {
! 376: struct_objet *s_objet;
! 377:
! 378: (*s_etat_processus).erreur_execution = d_ex;
! 379:
! 380: if ((*s_etat_processus).affichage_arguments == 'Y')
! 381: {
! 382: printf("\n KEYTITLE ");
! 383:
! 384: if ((*s_etat_processus).langue == 'F')
! 385: {
! 386: printf("(titre de la légende d'un graphique)\n\n");
! 387: }
! 388: else
! 389: {
! 390: printf("(title of graphic key)\n\n");
! 391: }
! 392:
! 393: printf(" 1: %s\n", d_CHN);
! 394:
! 395: return;
! 396: }
! 397: else if ((*s_etat_processus).test_instruction == 'Y')
! 398: {
! 399: (*s_etat_processus).nombre_arguments = -1;
! 400: return;
! 401: }
! 402:
! 403: if (test_cfsf(s_etat_processus, 31) == d_vrai)
! 404: {
! 405: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
! 406: {
! 407: return;
! 408: }
! 409: }
! 410:
! 411: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 412: &s_objet) == d_erreur)
! 413: {
! 414: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
! 415: return;
! 416: }
! 417:
! 418: if ((*s_objet).type == CHN)
! 419: {
! 420: free((*s_etat_processus).legende);
! 421:
! 422: if (((*s_etat_processus).legende = malloc((strlen((unsigned char *)
! 423: (*s_objet).objet) + 1) * sizeof(unsigned char))) == NULL)
! 424: {
! 425: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 426: return;
! 427: }
! 428:
! 429: strcpy((*s_etat_processus).legende, (unsigned char *) (*s_objet).objet);
! 430: liberation(s_etat_processus, s_objet);
! 431:
! 432: (*s_etat_processus).mise_a_jour_trace_requise = d_vrai;
! 433: }
! 434: else
! 435: {
! 436: liberation(s_etat_processus, s_objet);
! 437:
! 438: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
! 439: return;
! 440: }
! 441:
! 442: return;
! 443: }
! 444:
! 445:
! 446: /*
! 447: ================================================================================
! 448: Fonction 'keylabel'
! 449: ================================================================================
! 450: Entrées :
! 451: --------------------------------------------------------------------------------
! 452: Sorties :
! 453: --------------------------------------------------------------------------------
! 454: Effets de bord : néant
! 455: ================================================================================
! 456: */
! 457:
! 458: void
! 459: instruction_keylabel(struct_processus *s_etat_processus)
! 460: {
! 461: struct_fichier_graphique *l_element_courant;
! 462:
! 463: struct_objet *s_objet;
! 464:
! 465: (*s_etat_processus).erreur_execution = d_ex;
! 466:
! 467: if ((*s_etat_processus).affichage_arguments == 'Y')
! 468: {
! 469: printf("\n KEYLABEL ");
! 470:
! 471: if ((*s_etat_processus).langue == 'F')
! 472: {
! 473: printf("(label du graphique courant)\n\n");
! 474: }
! 475: else
! 476: {
! 477: printf("(current graphic label)\n\n");
! 478: }
! 479:
! 480: printf(" 1: %s\n", d_CHN);
! 481:
! 482: return;
! 483: }
! 484: else if ((*s_etat_processus).test_instruction == 'Y')
! 485: {
! 486: (*s_etat_processus).nombre_arguments = -1;
! 487: return;
! 488: }
! 489:
! 490: if (test_cfsf(s_etat_processus, 31) == d_vrai)
! 491: {
! 492: if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
! 493: {
! 494: return;
! 495: }
! 496: }
! 497:
! 498: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 499: &s_objet) == d_erreur)
! 500: {
! 501: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
! 502: return;
! 503: }
! 504:
! 505: if ((*s_objet).type == CHN)
! 506: {
! 507: l_element_courant = (*s_etat_processus).fichiers_graphiques;
! 508:
! 509: if (l_element_courant == NULL)
! 510: {
! 511: liberation(s_etat_processus, s_objet);
! 512:
! 513: (*s_etat_processus).erreur_execution =
! 514: d_ex_absence_graphique_courant;
! 515: return;
! 516: }
! 517:
! 518: while((*l_element_courant).suivant != NULL)
! 519: {
! 520: l_element_courant = (*l_element_courant).suivant;
! 521: }
! 522:
! 523: if ((*l_element_courant).legende != NULL)
! 524: {
! 525: free((*l_element_courant).legende);
! 526: }
! 527:
! 528: if (((*l_element_courant).legende = malloc((strlen((unsigned char *)
! 529: (*s_objet).objet) + 1) * sizeof(unsigned char))) == NULL)
! 530: {
! 531: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
! 532: return;
! 533: }
! 534:
! 535: strcpy((*l_element_courant).legende, (unsigned char *)
! 536: (*s_objet).objet);
! 537: liberation(s_etat_processus, s_objet);
! 538:
! 539: (*s_etat_processus).mise_a_jour_trace_requise = d_vrai;
! 540: }
! 541: else
! 542: {
! 543: liberation(s_etat_processus, s_objet);
! 544:
! 545: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
! 546: return;
! 547: }
! 548:
! 549: return;
! 550: }
! 551:
! 552: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>