This commit is contained in:
Pierre Pronchery 2005-09-18 05:19:02 +00:00
parent dc6a01fe8a
commit d4bd39d2b4
3 changed files with 17 additions and 6 deletions

View File

@ -19,6 +19,6 @@ AppClient * appclient_new_event(char * service, Event * event);
void appclient_delete(AppClient * appclient); void appclient_delete(AppClient * appclient);
/* useful */ /* useful */
int appclient_call(AppClient * appclient, char * function, ...); int appclient_call(AppClient * appclient, char * function, int args_cnt, ...);
#endif /* !_APPCLIENT_H */ #endif /* !_APPCLIENT_H */

View File

@ -76,7 +76,7 @@ static int _appclient_write(int fd, AppClient * ac)
} }
memmove(ac->buf_write, &ac->buf_write[len], len); memmove(ac->buf_write, &ac->buf_write[len], len);
ac->buf_write_cnt-=len; ac->buf_write_cnt-=len;
return 0; return ac->buf_write_cnt > 0 ? 0 : 1;
} }
@ -137,7 +137,7 @@ static int _new_connect(AppClient * appclient, char * app)
sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if(connect(appclient->fd, &sa, sizeof(sa)) != 0) if(connect(appclient->fd, &sa, sizeof(sa)) != 0)
return 1; return 1;
if((port = appclient_call(appclient, "port", app)) == -1) if((port = appclient_call(appclient, "port", 1, app)) == -1)
return 1; return 1;
if(port == 0) if(port == 0)
return 0; return 0;
@ -162,7 +162,7 @@ void appclient_delete(AppClient * appclient)
/* useful */ /* useful */
int appclient_call(AppClient * ac, char * function, ...) int appclient_call(AppClient * ac, char * function, int args_cnt, ...)
{ {
va_list arg; va_list arg;
int i; int i;
@ -170,8 +170,8 @@ int appclient_call(AppClient * ac, char * function, ...)
void ** p; void ** p;
struct timeval tv = { 0, 10 }; struct timeval tv = { 0, 10 };
va_start(arg, function); va_start(arg, args_cnt);
for(i = 0; i < 0 /* FIXME XXX */; i++) for(i = 0; i < args_cnt; i++) /* FIXME */
{ {
if((p = realloc(args, i * sizeof(void*))) == NULL) if((p = realloc(args, i * sizeof(void*))) == NULL)
break; break;

View File

@ -194,8 +194,16 @@ int appinterface_call(AppInterface * appinterface, char * call, char buf[],
case AICT_UINT64: case AICT_UINT64:
size = sizeof(int64_t); size = sizeof(int64_t);
break; break;
case AICT_STRING:
_send_string(args[i], buf, buflen, &pos);
continue;
default: default:
/* FIXME */ /* FIXME */
#ifdef DEBUG
fprintf(stderr, "%s, %d: %s", __FILE__,
__LINE__,
"Should not happen\n");
#endif
return -1; return -1;
} }
if(_send_buffer(args[i], size, buf, buflen, &pos) != 0) if(_send_buffer(args[i], size, buf, buflen, &pos) != 0)
@ -218,6 +226,9 @@ static int _send_string(char * string, char * buf, int buflen, int * pos)
{ {
int i = 0; int i = 0;
#ifdef DEBUG
fprintf(stderr, "%s%s%s", "send_string(", string, ");\n");
#endif
while(*pos < buflen) while(*pos < buflen)
{ {
buf[*pos] = string[i++]; buf[*pos] = string[i++];