#ifndef _COC_CLIENT_H_ #define _COC_CLIENT_H_ #include "myc_buf.h" #include "coc_util.h" typedef struct { void (* func) (char *, void *); void *arg; } OutFunc; typedef struct { void *adr; int type, size; char *cmd; } CocArg; typedef struct { int fd; /* private */ int port; StrBuf cmdbuf; /* for sending command */ StrBuf resbuf; /* for response */ char cmdbuf_[COC_CMD_LEN]; char resbuf_[COC_RES_LEN]; CocArg args[16]; int nargs; char host[64]; char magic[32]; char startcmd[512]; char synch; } CocConn; int CocInitClient(CocConn *conn, char *host, int port, char *magic, int bufsize, char *startcmd); /* initialize a connection to the server process */ int CocSendMagic(CocConn *conn, char *magic); /* send magic word to the server for changing access rights */ void CocReset(CocConn *conn); int CocPutStr(CocConn *conn, const char *name, const char *value); int CocPutFloat(CocConn *conn, const char *name, float value); int CocPutInt(CocConn *conn, const char *name, int value); int CocPutArray(CocConn *conn, const char *name, float *value, int value_size); int CocGetStr(CocConn *conn, const char *name, char *value, int value_len); int CocGetFloat(CocConn *conn, const char *name, float *value); int CocGetInt(CocConn *conn, const char *name, int *value); int CocGetArray(CocConn *conn, const char *name, float *value, int value_size); int CocGetOut(CocConn *conn, const char *name, OutFunc *f); int CocDoIt(CocConn *conn, char *error, int error_len); int CocCheck(CocConn *conn); /* returns 1, if not yet open returns 0, if connection o.k. returns -1 (error message), if connection died */ int CocWatchLog(CocConn *conn, char *list); /* Watch indefinitely for log messages */ int CocSet(CocConn *conn, const char *name, const char *value); /* set one variable */ int CocGetN(CocConn *conn, const char *name, char *value, int reslen); #define CocGet(C,N,V) CocGetN(C,N,V,sizeof(V)) /* read one variable. Use the macro if value is a fixed length array */ int CocSetGetN(CocConn *conn, const char *name, const char *cmd, char *value, int reslen); #define CocSetGet(C,N,S,V) CocSetGetN(C,N,S,V,sizeof(V)) /* set and get a variable. Use the macro if value is a fixed length array */ void CocCloseClient(CocConn *conn); /* close the connection to the server */ #endif /* _COC_CLIENT_H_ */