55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
#ifndef _COC_CLIENT_H_
|
|
#define _COC_CLIENT_H_
|
|
|
|
#include "coc_util.h"
|
|
|
|
typedef struct {
|
|
/* private */
|
|
int fd, port;
|
|
CocVar *varList;
|
|
Str_Buf *cmdbuf; /* for sending command */
|
|
Str_Buf *resbuf; /* for response */
|
|
char host[64];
|
|
char magic[32];
|
|
char startcmd[512];
|
|
} 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
|
|
*/
|
|
|
|
int CocCmd(CocConn *conn, const char *rwList);
|
|
/* rwList consists of a list of variables to be read or written.
|
|
Variables must be separated with commas, variables to be written
|
|
must be enclosed in square brackets.
|
|
|
|
Example (read p1 and p4, write p2 and p3):
|
|
CocCmd(&conn, "p1,[p2,p3],p4")
|
|
|
|
see COC_UTIL.H for the definiton of variables
|
|
*/
|
|
int CocCheck(CocConn *conn);
|
|
/*
|
|
returns 1, if not yet open
|
|
returns 0, if connection o.k.
|
|
retruns -1 (error message), if connection died
|
|
*/
|
|
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
|
|
*/
|
|
void CocCloseClient(CocConn *conn);
|
|
/*
|
|
close the connection to the server
|
|
*/
|
|
#endif /* _COC_CLIENT_H_ */
|