Moved code to appinterface.{c,h}

This commit is contained in:
Pierre Pronchery 2005-09-18 04:34:57 +00:00
parent 6b0dc65beb
commit f9b7e99725
2 changed files with 0 additions and 111 deletions

View File

@ -1,82 +0,0 @@
/* common.c */
#include <stdint.h>
#ifdef DEBUG
# include <stdio.h>
#endif
#include "common.h"
/* AppServer/AppClient */
/* private */
/* functions */
static int _send_buffer(char * data, int datalen, char * buf, int buflen,
int * pos)
{
if(*pos + datalen > buflen)
return 1;
memcpy(&buf[*pos], data, datalen);
*pos += datalen;
return 0;
}
static int _send_string(char * string, char * buf, int buflen, int * pos)
{
int i = 0;
while(*pos < buflen)
{
buf[*pos] = string[i++];
(*pos)++;
if(string[i] == '\0')
return 0;
}
return 1;
}
/* public */
int asc_send_call(ASCCall * call, char buf[], int buflen, void ** args)
{
int pos = 0;
int i;
int size;
#ifdef DEBUG
fprintf(stderr, "%s%s%s", "asc_send_call(", call->name, ");\n");
#endif
if(_send_string(call->name, buf, buflen, &pos) != 0)
return -1;
for(i = 0; i < call->args_cnt; i++)
{
switch(call->args[i])
{
case ASC_INT8:
case ASC_UINT8:
size = sizeof(int8_t);
break;
case ASC_INT16:
case ASC_UINT16:
size = sizeof(int16_t);
break;
case ASC_INT32:
case ASC_UINT32:
size = sizeof(int32_t);
break;
case ASC_INT64:
case ASC_UINT64:
size = sizeof(int64_t);
break;
default:
/* FIXME */
return -1;
}
if(_send_buffer(args[i], size, buf, buflen, &pos) != 0)
return 1;
}
return 0;
}

View File

@ -1,29 +0,0 @@
/* common.h */
#ifndef COMMON_H
# define COMMON_H
/* AppServer/AppClient */
# define ASC_BUFSIZE 65536
# define ASC_PORT_SESSION 4242
typedef enum _ASCCallType {
ASC_INT8, ASC_INT16, ASC_INT32, ASC_INT64,
ASC_UINT8, ASC_UINT16, ASC_UINT32, ASC_UINT64,
ASC_BUFFER
} ASCCallType;
typedef struct _ASCCall
{
ASCCallType type;
char * name;
ASCCallType * args;
int args_cnt;
} ASCCall;
int asc_send_call(ASCCall * call, char * buf, int buflen, void ** args);
#endif /* !COMMON_H */