*** empty log message ***
This commit is contained in:
50
tecs/asynsrv_def.h
Normal file
50
tecs/asynsrv_def.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _asynsrv_def_
|
||||
#define _asynsrv_def_
|
||||
/*------------------------------------------------ AsynSrv_DEF.H Ident V01M
|
||||
*/
|
||||
#ifndef OffsetOf
|
||||
#define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier))
|
||||
#endif
|
||||
|
||||
#ifndef _asynsrv_errcodes_
|
||||
#define _asynsrv_errcodes_
|
||||
#include <asynsrv_errcodes.h>
|
||||
#endif
|
||||
|
||||
#define AsynSrv_MAX_LINK 8
|
||||
/*
|
||||
** Structures needed by AsynSrv_Utility.
|
||||
*/
|
||||
struct AsynSrv__info {
|
||||
int skt; /* The socket number of the connection */
|
||||
char host[20]; /* The name of RS-232-C server */
|
||||
int port; /* The TCP/IP port number of server */
|
||||
int chan; /* The RS-232-C channel number on server */
|
||||
int msg_id;
|
||||
int protocol_code; /* Flag to identify the server's protocol level */
|
||||
char protocol_id[4]; /* ASCII version of server's protocol level */
|
||||
int cmnd_hdr_len; /* Header length for command strings */
|
||||
char cmnd_fmt[8]; /* "sprintf" format for cmnd header conversion */
|
||||
int rply_hdr_len; /* Header length for response strings */
|
||||
char rply_fmt[8]; /* "sscanf" format for rply header conversion */
|
||||
char chan_char[4]; /* ASCII encoded version of chan */
|
||||
char tmo[4]; /* ASCII encoded time-out (deci-secs) */
|
||||
char eot[4]; /* Expected terminators */
|
||||
int max_replies; /* Binary version of #replies in response */
|
||||
int n_replies; /* # of last response returned to caller */
|
||||
void (*idleHandler)(int,int); /* MZ. handler called when waiting on a response */
|
||||
};
|
||||
|
||||
struct AsynSrv_HostPortSkt {
|
||||
char host[30];
|
||||
int port;
|
||||
int skt;
|
||||
int protocol_code;
|
||||
char protocol_id[4];
|
||||
int cmnd_hdr_len;
|
||||
int rply_hdr_len;
|
||||
int usage_cnt;
|
||||
int status;
|
||||
};
|
||||
/*------------------------------------------------ End of AsynSrv_DEF.H --*/
|
||||
#endif /* _asynsrv_def_ */
|
||||
@@ -1,3 +1,5 @@
|
||||
#ifndef _buf_h_
|
||||
#define _buf_h_
|
||||
typedef struct { char *buf; char *start; int size; int usize; int isize, dummy; } buf_type;
|
||||
|
||||
/* input */
|
||||
@@ -10,11 +12,11 @@ int buf_size(buf_type *buf);
|
||||
/* output */
|
||||
void buf_put_start(buf_type *buf);
|
||||
void buf_put_int(buf_type *buf, int val);
|
||||
void buf_put_str(buf_type *buf, char *str);
|
||||
void buf_put_str(buf_type *buf, const char *str);
|
||||
void buf_put_float(buf_type *buf, float val);
|
||||
void buf_put_end(buf_type *buf);
|
||||
|
||||
/* common */
|
||||
buf_type *buf_create(size_t size);
|
||||
void buf_free(buf_type *buf);
|
||||
void buf_log(buf_type *buf);
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "coc.h"
|
||||
|
||||
typedef struct {
|
||||
int fd, dummy;
|
||||
int fd, port;
|
||||
CocVar *varList;
|
||||
buf_type *cmdbuf; /* for sending command */
|
||||
buf_type *resbuf; /* for response */
|
||||
char host[64];
|
||||
char magic[32];
|
||||
char startcmd[64];
|
||||
char startcmd[512];
|
||||
} CocConn;
|
||||
|
||||
void CocInitClient(CocConn *conn, char *host, char *magic, int bufsize, char *startcmd);
|
||||
int CocInitClient(CocConn *conn, char *host, int port, char *magic, int bufsize, char *startcmd);
|
||||
int CocSendMagic(CocConn *conn, char *magic);
|
||||
int CocCmd(CocConn *conn, const char *rwList);
|
||||
void CocCloseClient(CocConn *conn);
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
#include "buf.h"
|
||||
#include "util.h"
|
||||
|
||||
#define CocPORT 9751
|
||||
#define CocPORTS 3
|
||||
|
||||
int CocCreateSockAdr(
|
||||
struct sockaddr_in *sockaddrPtr, /* Socket address */
|
||||
const char *host, /* Host. NULL implies INADDR_ANY */
|
||||
@@ -35,9 +32,9 @@ void CocFreeVarList(CocVar **varList);
|
||||
CocVar *CocFindVar(CocVar *varList, const char *name);
|
||||
int CocPutVar(CocVar *varList, buf_type *buf, const char *name);
|
||||
int CocGetVar(CocVar *varList, buf_type *buf, const char *name);
|
||||
void CocDefFlag(int *flag);
|
||||
|
||||
#define CocDefInt(V,F) CocDefVar(#V,&V,-1,&F)
|
||||
#define CocDefFlt(V,F) CocDefVar(#V,&V,-2,&F)
|
||||
#define CocDefStr(V,F) CocDefVar(#V,V,sizeof(V),&F)
|
||||
#define CocDefCmd(V) CocDefVar("$",V,sizeof(V),&CocWR)
|
||||
#define CocDefStrPtr(V,S,F) CocDefVar(#V,V,S,&F)
|
||||
|
||||
Reference in New Issue
Block a user