*** empty log message ***

This commit is contained in:
cvs
2000-03-20 07:38:12 +00:00
parent 4dd4d06ba0
commit 72589129c3
12 changed files with 192 additions and 160 deletions

View File

@@ -29,19 +29,16 @@ int CocInitServer(int bufsize, int port) {
/* first try to connect to an existing server */
logfileStamp("start server");
ERR_SI(mainFd=socket(AF_INET, SOCK_STREAM, 0));
i = 1;
ERR_SI(setsockopt(mainFd,SOL_SOCKET,SO_REUSEADDR,&i,sizeof(int))); /* allow quick port reuse */
ERR_I(CocCreateSockAdr(&sadr, NULL, port));
ERR_SI(bind(mainFd, (struct sockaddr *)&sadr, sizeof(sadr)));
logfileOut("created server on port %d\n", port);
logfileOut(LOG_MAIN, "created server on port %d\n", port);
ERR_SI(listen(mainFd, 8));
FD_ZERO(&mask);
FD_SET(mainFd, &mask);
maxfd=mainFd+1;
logfileUpd();
return(0);
OnError: return(-1);
}
@@ -64,7 +61,6 @@ int CocHandle1Request(int tmo_msec, int fd) {
ERR_SI(i=select(maxfd,&rmask,NULL,NULL,&tmo));
if (fd>0 && FD_ISSET(fd, &rmask)) return(1);
logfileStamp("");
if (FD_ISSET(mainFd, &rmask)) {
ERR_SI(newfd=accept(mainFd, (struct sockaddr *)&cadr, &cadrlen));
FD_SET(newfd, &mask);
@@ -78,18 +74,17 @@ int CocHandle1Request(int tmo_msec, int fd) {
cList->next=cl;
h=gethostbyaddr(&cadr.sin_addr, 4, AF_INET);
if (h==NULL) {
logfileOut("(%d) open from %s\n", newfd, "local");
logfileOut(LOG_MAIN, "(%d) open from %s\n", newfd, "local");
} else {
logfileOut("(%d) open from %s\n", newfd, h->h_name);
logfileOut(LOG_MAIN, "(%d) open from %s\n", newfd, h->h_name);
}
logfileUpd();
} else {
cl0=cList; cl=cl0->next;
while (cl!=NULL) {
if (FD_ISSET(cl->fd, &rmask)) {
buf->usize=recv(cl->fd, buf->start, buf->isize, 0);
if (buf->usize<=0) {
logfileOut("(%d) disconnected\n",cl->fd);
logfileOut(LOG_MAIN, "(%d) disconnected\n",cl->fd);
close(cl->fd);
FD_CLR(cl->fd, &mask);
cl0->next=cl->next;
@@ -104,19 +99,21 @@ int CocHandle1Request(int tmo_msec, int fd) {
buf_reset(buf);
err=NULL;
varname=buf_get_str(buf);
logfileOutTmp("(%d) ", cl->fd);
logfileOut(LOG_NET, "(%d) ", cl->fd);
if (varname[0]=='#') { /* access code */
if (0==strcmp(varname,"#rdacc")) {
logfileOutTmp(" set read mode");
logfileOut(LOG_MAIN, " set read mode\n");
cl->mode=1;
} else if (0==strcmp(varname,"#rwacs")) {
logfileOutTmp(" set write mode");
logfileOut(LOG_MAIN, " set write mode\n");
cl->mode=2;
} else {
err="bad access code";
}
buf_put_end(bufo);
} else if (cl->mode==0) {
err="no access";
buf_put_end(bufo);
} else {
while (1) {
if (varname[0]=='[') {
@@ -151,25 +148,25 @@ int CocHandle1Request(int tmo_msec, int fd) {
if (buf_size(buf)<0) { err="syntax error"; break; }
}
buf_reset(buf);
logfileOutBuf(buf);
logfileOutBuf(LOG_NET, buf);
buf_put_end(bufo);
logfileOut(LOG_NET, " |");
logfileOutBuf(LOG_NET, bufo);
}
buf_put_end(bufo);
logfileOutTmp(" |");
logfileOutBuf(bufo);
if (err==NULL) {
logfileOutTmp("\n");
logfileOut(LOG_NET, "\n");
} else {
buf_put_start(bufo); /* reset output */
buf_put_str(bufo, err); /* put error message */
buf_put_end(bufo);
logfileOutTmp(" (%s)\n", err);
logfileOut(LOG_NET, " (%s)\n", err);
logfileMask(LOG_NET);
}
ERR_SI(send(cl->fd, bufo->buf, bufo->size, 0));
}
}
cl0=cl; cl=cl->next;
}
logfileUpd();
}
return(status);
OnError: return(-1);