2 /***************************************************************************/
6 /* Communications headers */
7 #include "/usr/local/lib/scilab-2.3/routines/libcomm/libCalCom.h"
8 #include "/usr/local/lib/scilab-2.3/routines/libcomm/libCom.h"
10 static void QuitAppli();
11 static void EndAppli();
12 static void ParseMessage();
13 static void MsgError();
16 static actions_messages tb_messages[]={
17 {ID_GeCI,MSG_QUITTER_APPLI,NBP_QUITTER_APPLI,QuitAppli},
18 {ID_GeCI,MSG_FIN_APPLI,NBP_FIN_APPLI,EndAppli},
19 {NULL,MSG_DISTRIB_LISTE_ELMNT,NBP_DISTRIB_LISTE_ELMNT,ParseMessage},
20 {NULL,NULL,0,MsgError}};
22 static void QuitAppli(message)
25 printf("Quit application\n");
29 static void EndAppli(message)
32 printf("End application\n");
35 static void MsgError(message)
38 printf("Bad received message\n");
41 static char *TheAppli;
45 /* ParseMessage is executed when a message is received */
46 static void ParseMessage(message)
49 int lappli, ltype, lmsg;
51 lappli = strlen(message.tableau[0]);
52 if ((TheAppli = (char *)malloc((unsigned)sizeof(char)*(lappli + 1)))
56 strcpy(TheAppli,message.tableau[0]);
58 ltype = strlen(message.tableau[3]);
59 if ((TheType = (char *)malloc((unsigned)sizeof(char)*(ltype + 1)))
63 strcpy(TheType,message.tableau[3]);
65 lmsg = strlen(message.tableau[4]);
66 if ((TheMsg = (char *)malloc((unsigned)sizeof(char)*(lmsg + 1)))
70 strcpy(TheMsg,message.tableau[4]);
73 static int find(s,n,t)
80 if (!strcmp(s,t[i])) return(i);
91 igeci = find("-pipes",argc,argv);
92 if (igeci == -1) exit(1);
94 p1 = atoi(argv[igeci+1]); p2 = atoi(argv[igeci+2]);
96 /* Intialization of communications */
97 init_messages(tb_messages,p1,p2);
99 /* Loop waiting for messages */
102 if (TheType != NULL) {
103 printf("Message received from %s\n",TheAppli);
104 printf(" type: %s\n",TheType);
105 printf(" message: %s\n",TheMsg);
106 TheAppli = NULL; TheType = NULL; TheMsg = NULL;
110 /***************************************************************************/