new tecs version M.Z.08.2001
This commit is contained in:
@@ -1,11 +1,78 @@
|
||||
#ifndef _SERVER_H_
|
||||
#define _SERVER_H_
|
||||
|
||||
#include "coc_util.h"
|
||||
#include "myc_buf.h"
|
||||
|
||||
struct CocClient { struct CocClient *next; int fd; int mode; char cmd[80]; char res[80]; };
|
||||
void CocVarList(void **varlist);
|
||||
/*
|
||||
instal a variable list
|
||||
*/
|
||||
|
||||
int CocInitServer(int bufsize, int port);
|
||||
void CocFreeVarList(void);
|
||||
/*
|
||||
free variable list
|
||||
*/
|
||||
|
||||
void *CocFindVar(const char *name, void **adr);
|
||||
/*
|
||||
find a variable. returns NULL if not found.
|
||||
*/
|
||||
|
||||
int CocPutVar(const char *name, StrBuf *buf, int separator);
|
||||
/*
|
||||
put a variable named <name> of variable list <varList> to the buffer <buf>
|
||||
*/
|
||||
|
||||
int CocGetVar(const char *name, StrBuf *buf, int separator);
|
||||
/*
|
||||
get a variable named <name> of variable list <varList> from the buffer <buf>
|
||||
*/
|
||||
|
||||
void CocHdl(int (*handler)(int, void *));
|
||||
/*
|
||||
define handler for last defined item
|
||||
*/
|
||||
|
||||
void *CocIntPtr(int *ptr);
|
||||
void *CocFltPtr(float *ptr);
|
||||
void *CocChrPtr(char *ptr);
|
||||
void *CocDefVar(const char *name, void *var, int type, int access);
|
||||
void CocDefVarS(const char *name, const char *tname, void *var, int type);
|
||||
/*
|
||||
Define variables. Call this routines not directly, but through
|
||||
one of the macros below.
|
||||
*/
|
||||
|
||||
#define CocDefInt(V,A) CocDefVar(#V,CocIntPtr(&V),COC_INT,A)
|
||||
#define CocDefFlt(V,A) CocDefVar(#V,CocFltPtr(&V),COC_FLT,A)
|
||||
#define CocDefStr(V,A) CocDefVar(#V,CocChrPtr(V),sizeof(V),A)
|
||||
#define CocDefPtr(V,S) CocDefVarS(#V,#S,&V,(V!=(S *)NULL,COC_PTR));
|
||||
#define CocDefStruct(V,S) CocDefVarS(#V,#S,&V,(&V!=(S *)NULL,COC_STRUCT));
|
||||
#define CocIntFld(S,V,A) CocDefVar(#S":"#V,CocIntPtr(&((S *)NULL)->V),COC_INT,A);
|
||||
#define CocFltFld(S,V,A) CocDefVar(#S":"#V,CocFltPtr(&((S *)NULL)->V),COC_FLT,A);
|
||||
#define CocStrFld(S,V,A) CocDefVar(#S":"#V,CocChrPtr(((S *)NULL)->V),sizeof(((S *)NULL)->V),A);
|
||||
#define CocDefCmd(V) CocDefVar("$",V,sizeof(V),0)
|
||||
#define CocDefStrPtr(V,S,A) CocDefVar(#V,V,S,A)
|
||||
#define CocAlias(A,V) CocDefVar(#A, #V, COC_ALIAS,0);
|
||||
|
||||
#define COC_RDONLY 3
|
||||
#define COC_RDWR 2
|
||||
#define COC_RDWRALL 1
|
||||
|
||||
#define COC_WR 1
|
||||
#define COC_RD 2
|
||||
#define COC_DWR 3
|
||||
#define COC_DRD 4
|
||||
#define COC_SHOW 5
|
||||
|
||||
#define COC_INT -1
|
||||
#define COC_FLT -2
|
||||
#define COC_PTR -3
|
||||
#define COC_STRUCT -4
|
||||
#define COC_TYPE -5
|
||||
#define COC_ALIAS -6
|
||||
|
||||
int CocInitServer(void *(*setDataRtn)(void *), int port);
|
||||
|
||||
int CocHandleRequests(int tmo_msec, int fd);
|
||||
int CocHandle1Request(int tmo_msec, int fd);
|
||||
@@ -30,11 +97,13 @@ int CocHandle1Request(int tmo_msec, int fd);
|
||||
|
||||
*/
|
||||
|
||||
struct CocClient *CocGetNextCmd(void);
|
||||
/*
|
||||
get next client with a pending command
|
||||
/* server handlers removed
|
||||
int CocPushHandler(const char *name);
|
||||
*/
|
||||
|
||||
int CocCallHandlers(void);
|
||||
void CocShowHandlers(char *buf, int buf_len);
|
||||
|
||||
void CocCloseServer(void);
|
||||
|
||||
#endif /* _SERVER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user