83 if(
id < 0)
return 0.0f;
95 if(cptr == NULL)
return -1;
100 if(cptr == NULL || *cptr ==
'\0')
break;
101 if(*cptr !=
',' && *cptr !=
'\"')
103 sscanf(cptr,
"%d",&array[ret++]);
104 cptr = strchr(cptr,
',');
105 if(cptr != NULL) cptr++;
106 if(ret >= nmax)
break;
120 if(cptr == NULL)
return -1;
125 if(cptr == NULL || *cptr ==
'\0')
break;
126 if(*cptr !=
',' && *cptr !=
'\"')
128 sscanf(cptr,
"%f",&array[ret++]);
129 cptr = strchr(cptr,
',');
130 if(cptr != NULL) cptr++;
131 if(ret >= nmax)
break;
145 if(
id < 0)
return NULL;
155 if(
id < 0)
return -1;
165 if(
id < 0)
return -1;
178 if(num <= 0)
return -1;
182 for(ind=0; ind<num; ind++)
184 sprintf(val,
"%d,",array[ind]);
185 if(ipos+(
int)strlen(val) >= nmax)
return -1;
197 if(num <= 0)
return -1;
201 for(ind=0; ind<num; ind++)
203 sprintf(val,
"%f,",array[ind]);
204 if(ipos+(
int)strlen(val) >= nmax)
return -1;
213 if(
id < 0)
return -1;
217 strings[id] =
new char[strlen(str)+1];
227 if(
id < 0)
return -1;
238 if(
id < 0)
return -1;
283 sscanf(interpreter.
line,
"int(%d,%d)",&
id,&ival);
286 else if(interpreter.
isCommand(
"intAndReset("))
288 sscanf(interpreter.
line,
"intAndReset(%d,%d)",&
id,&ival);
293 sscanf(interpreter.
line,
"float(%d,%f)",&
id,&fval);
296 else if(interpreter.
isCommand(
"string("))
298 sscanf(interpreter.
line,
"string(%d,",&
id);
302 else if(interpreter.
isCommand(
"getInt("))
304 sscanf(interpreter.
line,
"getInt(%d)",&
id);
307 else if(interpreter.
isCommand(
"getIntAndReset("))
309 sscanf(interpreter.
line,
"getIntAndReset(%d)",&
id);
312 else if(interpreter.
isCommand(
"getInt0Semaphore("))
316 else if(interpreter.
isCommand(
"getFloat("))
318 sscanf(interpreter.
line,
"getFloat(%d)",&
id);
321 else if(interpreter.
isCommand(
"getString("))
323 sscanf(interpreter.
line,
"getString(%d)",&
id);
325 if(cptr == NULL) socket->
printf(
"stringResult(\"\")\n");
326 else socket->
printf(
"stringResult(\"%s\")\n",cptr);
333 #define CLIENT_TIMEOUT 1000
350 socket->
printf(
"getInt(%d)\n",
id);
375 socket->
printf(
"getFloat(%d)\n",
id);
396 const char *cptr =
getString(socket,
id,&status);
397 if(status != 0)
return -1;
402 if(cptr == NULL || *cptr ==
'\0')
break;
403 if(*cptr !=
',' && *cptr !=
'\"')
405 sscanf(cptr,
"%d",&array[ret++]);
406 cptr = strchr(cptr,
',');
407 if(cptr != NULL) cptr++;
408 if(ret >= nmax)
break;
421 const char *cptr =
getString(socket,
id,&status);
422 if(status != 0)
return -1;
427 if(cptr == NULL || *cptr ==
'\0')
break;
428 if(*cptr !=
',' && *cptr !=
'\"')
430 sscanf(cptr,
"%f",&array[ret++]);
431 cptr = strchr(cptr,
',');
432 if(cptr != NULL) cptr++;
433 if(ret >= nmax)
break;
449 socket->
printf(
"getString(%d)\n",
id);
470 return socket->
printf(
"int(%d,%d)\n",
id,i);
476 return socket->
printf(
"float(%d,%d)\n",
id,f);
484 if(num <= 0)
return -1;
486 sprintf(buf,
"string(%d,\"",
id);
488 for(ind=0; ind<num; ind++)
490 sprintf(val,
"%d,",i[ind]);
491 if(ipos+(
int)strlen(val) >= nmax)
return -1;
496 return socket->
printf(buf);
504 if(num <= 0)
return -1;
506 sprintf(buf,
"string(%d,\"",
id);
508 for(ind=0; ind<num; ind++)
510 sprintf(val,
"%f,",f[ind]);
511 if(ipos+(
int)strlen(val) >= nmax)
return -1;
516 return socket->
printf(buf);
522 return socket->
printf(
"string(%d,\"%d\")\n",
id,str);
531 socket->
printf(
"getIntAndReset(%d)\n",
id);
552 return socket->
printf(
"intAndReset(%d,%d)\n",
id,i);
561 socket->
printf(
"getInt0Semaphore()\n");
563 if(ret == 0) { *status = -2;
return 0; }
584 if(arg == NULL)
return NULL;
600 if(arg == NULL)
return NULL;
602 if(provider_threads == NULL)
return NULL;
609 worker_data.
thread = provider_threads;
630 if(
port <= 0)
return;
631 if(
port >= 256*256)
return;