- bug fix in coc_server.c

- bug fixes in tecs
- new system to determine host:port in six and tecs_client
This commit is contained in:
zolliker
2005-09-21 11:06:23 +00:00
parent 66d9d45dae
commit c7280ec25d
16 changed files with 328 additions and 309 deletions

View File

@@ -10,30 +10,16 @@
#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 TeccStart(char *startcmd, char *host, int port) {
CocConn *conn;
char *code, *cmd, thishost[64], *th;
int iret;
NEW(conn, CocConn);
code=rwCode;
cmd=startcmd;
if (host[0]!='\0') {
gethostname(thishost, sizeof(thishost));
th=getenv(thishost);
if (th==NULL) th=thishost;
if (0!=strcmp(th, host) && host!=strstr(host, th)) {
code=rdCode;
cmd="";
}
}
ERR_I(iret=CocInitClient(conn, host, port, code, 0, cmd));
ERR_I(iret=CocInitClient(conn, host, port, rdCode, 0, startcmd));
if (iret==1) ErrShort("TECS_INIT: can not connect to TecsServer");
return((pTecsClient)conn);
OnError:
@@ -43,17 +29,13 @@ pTecsClient TeccStart(char *startcmd, char *host, int port) {
pTecsClient TeccInit(char *startcmd, int port) {
CocConn *conn=NULL;
char *code, host[64];
int iret;
NEW(conn, CocConn);
code=rwCode;
if (startcmd[0]=='#') {
gethostname(host, sizeof(host));
if (0!=strcmp(startcmd+1, host)) code=rdCode;
ERR_I(iret=CocInitClient(conn, startcmd+1, port, code, 0, ""));
ERR_I(iret=CocInitClient(conn, startcmd+1, port, rdCode, 0, ""));
} else {
ERR_I(iret=CocInitClient(conn, "", port, code, 0, startcmd));
ERR_I(iret=CocInitClient(conn, "", port, rdCode, 0, startcmd));
}
if (iret==1) ErrShort("TECS_INIT: can not connect to TecsServer");
return((pTecsClient)conn);