This commit is contained in:
cvs
2002-08-12 09:07:08 +00:00
parent bde19bb973
commit 643f0d81be
10 changed files with 187 additions and 73 deletions

View File

@@ -10,23 +10,48 @@
#include "tecs_cli.h"
#include "tecs_data.h"
int gethostname(char *name, int namelen);
static char response[COC_RES_LEN];
static char *rwCode="rwacs";
static char *rdCode="rdacs";
pTecsClient TeccInit(char *startcmd, int port) {
CocConn *conn;
char *code, host[64];
NEW(conn, CocConn);
code=rwCode;
if (startcmd[0]=='#') {
ERR_I(CocInitClient(conn, startcmd+1, port, rdCode, 0, ""));
gethostname(host, sizeof(host));
if (0!=strcmp(startcmd+1, host)) code=rdCode;
ERR_I(CocInitClient(conn, startcmd+1, port, code, 0, ""));
} else {
ERR_I(CocInitClient(conn, "", port, rwCode, 0, startcmd));
ERR_I(CocInitClient(conn, "", port, code, 0, startcmd));
}
return((pTecsClient)conn);
OnError: return(NULL);
}
pTecsClient TeccStart(char *startcmd, char *host, int port) {
CocConn *conn;
char *code, *cmd, thishost[64];
NEW(conn, CocConn);
code=rwCode;
cmd=startcmd;
if (host[0]!='\0') {
gethostname(thishost, sizeof(thishost));
if (0!=strcmp(thishost, host)) {
code=rdCode;
cmd="";
}
}
ERR_I(CocInitClient(conn, host, port, code, 0, cmd));
return((pTecsClient)conn);
OnError: return(NULL);
}
int TeccGet3(pTecsClient conn, float *tC, float *tX, float *tP) {
int iret;
@@ -184,6 +209,16 @@ int F_FUN(tecs_init)(F_CHAR(startcmd), int *port, int startcmd_len) {
OnError: return(-1);
}
int F_FUN(tecs_start)(F_CHAR(startcmd), F_CHAR(host), int *port, int startcmd_len, int host_len) {
char sbuf[132], hbuf[64];
STR_TO_C(sbuf, startcmd);
STR_TO_C(hbuf, host);
ERR_P(conn=TeccStart(sbuf, hbuf, *port));
return(0);
OnError: return(-1);
}
int F_FUN(tecs_rights)(int write) {
if (write) {
ERR_I(CocSendMagic(conn, rwCode));