11
#include "../machine.h"
12
#include "../intersci/cerro.h"
13
#include "../libcomm/libCalCom.h"
14
#include "../libcomm/libCom.h"
16
static char *TheAppli;
20
/* Called when a message comes: see initcom.c */
21
void ParseMessage(message)
24
int lappli, ltype, lmsg;
26
lappli = strlen(message.tableau[0]);
27
if ((TheAppli = (char *)malloc((unsigned)sizeof(char)*(lappli + 1)))
29
cerro("Running out of memory");
32
strcpy(TheAppli,message.tableau[0]);
34
ltype = strlen(message.tableau[3]);
35
if ((TheType = (char *)malloc((unsigned)sizeof(char)*(ltype + 1)))
37
cerro("Running out of memory");
40
strcpy(TheType,message.tableau[3]);
42
lmsg = strlen(message.tableau[4]);
43
if ((TheMsg = (char *)malloc((unsigned)sizeof(char)*(lmsg + 1)))
45
cerro("Running out of memory");
48
strcpy(TheMsg,message.tableau[4]);
51
/* Communication functions for Scilab toplevel */
53
/* sends a message "msg" of type "type" */
54
void C2F(sendmsg)(type,ltype,msg,lmsg)
55
char *type; int *ltype;
60
envoyer_message_parametres_var(ID_GeCI,MSG_POSTER_LISTE_ELMNT,
64
/* gets a message "msg" of type "type" from the application "appli" */
65
void C2F(getmsg)(appli,lappli,type,ltype,msg,lmsg)
66
char **appli; int *lappli;
67
char **type; int *ltype;
68
char ** msg; int *lmsg;
70
TheAppli = ""; TheType = ""; TheMsg = "";
73
*lappli = strlen(TheAppli);
75
*ltype = strlen(TheType);
77
*lmsg = strlen(TheMsg);
84
/* executes the application "appli" on host "host"
85
the command line is "command" */
86
void C2F(execappli)(command,lcommand,host,lhost,appli,lappli)
87
char *command; int *lcommand;
88
char *host; int *lhost;
89
char *appli; int *lappli;
97
command[*lcommand] = '\0';
99
appli[*lappli] = '\0';
101
/* cut the string "command" into "nargs" "args" */
102
if (*command == ' ' || *command == '\t') inword = 0;
106
if (*command == ' ' || *command == '\t' || *command == '\0') {
108
args[nargs] = (char *)malloc((unsigned)(i+1));
109
strcpy(args[nargs],w);
115
command++; /** jpc : I remove * in *command++ cause it's unused **/
116
if (*command != ' ' && *command != '\t') {
127
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
133
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
140
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
147
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
150
args[1],args[2],args[3],
154
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
157
args[1],args[2],args[3],args[4],
161
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
164
args[1],args[2],args[3],args[4],args[5],
168
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
171
args[1],args[2],args[3],args[4],args[5],
176
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
179
args[1],args[2],args[3],args[4],args[5],
184
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
187
args[1],args[2],args[3],args[4],args[5],
188
args[6],args[7],args[8],
192
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
195
args[1],args[2],args[3],args[4],args[5],
196
args[6],args[7],args[8],args[9],
200
/* if more than MAXARGS arguments, discard them! */
201
envoyer_message_parametres_var(ID_GeCI,MSG_LANCER_APPLI,
204
args[1],args[2],args[3],args[4],args[5],
205
args[6],args[7],args[8],args[9],args[10],
211
/* creates a link from application "appli1" to application "appli2" */
212
void C2F(createlink)(appli1,lappli1,appli2,lappli2)
213
char *appli1; int *lappli1;
214
char *appli2; int *lappli2;
216
appli1[*lappli1] = '\0';
217
appli2[*lappli2] = '\0';
218
if (!strcmp(appli1,"SELF"))
219
envoyer_message_parametres_var(ID_GeCI,
221
identificateur_appli(),
224
else if (!strcmp(appli2,"SELF"))
225
envoyer_message_parametres_var(ID_GeCI,
228
identificateur_appli(),
232
envoyer_message_parametres_var(ID_GeCI,
239
/* destroys a link from application "appli1" to application "appli2" */
240
void C2F(destroylink)(appli1,lappli1,appli2,lappli2)
241
char *appli1; int *lappli1;
242
char *appli2; int *lappli2;
244
appli1[*lappli1] = '\0';
245
appli2[*lappli2] = '\0';
246
if (!strcmp(appli1,"SELF"))
247
envoyer_message_parametres_var(ID_GeCI,
248
MSG_DETRUIRE_LIAISON,
249
identificateur_appli(),
252
else if (!strcmp(appli2,"SELF"))
253
envoyer_message_parametres_var(ID_GeCI,
254
MSG_DETRUIRE_LIAISON,
256
identificateur_appli(),
260
envoyer_message_parametres_var(ID_GeCI,
261
MSG_DETRUIRE_LIAISON,
267
/* waits for a message coming from the application "appli"
268
this message is "msg" with type "type" */
269
void C2F(waitmsg)(appli,lappli,type,ltype,msg,lmsg)
270
char *appli; int *lappli;
271
char **type; int *ltype;
272
char ** msg; int *lmsg;
276
appli[*lappli] = '\0';
277
message = attendre_reponse(appli,
278
MSG_DISTRIB_LISTE_ELMNT,
279
NBP_DISTRIB_LISTE_ELMNT);
280
TheAppli = ""; TheType = ""; TheMsg = "";
281
ParseMessage(message);
282
*ltype = strlen(TheType);
284
*lmsg = strlen(TheMsg);