M.Z.
This commit is contained in:
34
tecs/six.c
34
tecs/six.c
@ -49,18 +49,25 @@ int CocCreateSockAdr(
|
|||||||
int readWrite(int fd, int skip) {
|
int readWrite(int fd, int skip) {
|
||||||
char msg[128];
|
char msg[128];
|
||||||
int l, i, go, iret, ires, n;
|
int l, i, go, iret, ires, n;
|
||||||
|
/*
|
||||||
|
* read from fd and write to stdout until a key pressed,
|
||||||
|
* a timeout occured (1 or 5 sec.), or a <go ahead> message
|
||||||
|
* received.
|
||||||
|
* skip=0: timeout 1 sec (normal behaviour)
|
||||||
|
* skip>0: timeout 5 sec.
|
||||||
|
* skip>1: swallow text
|
||||||
|
* skip=1,2: return 0 if SICS not found in message text
|
||||||
|
* skip=3: return 0 if not acknowledged
|
||||||
|
*/
|
||||||
n=0;
|
n=0;
|
||||||
go=0;
|
go=0;
|
||||||
ires=0;
|
ires=0;
|
||||||
iret=term_wait_fd(fd, skip?5000:1000);
|
iret=term_wait_fd(fd, skip?5000:1000);
|
||||||
while (iret==1) {
|
while (iret==1) {
|
||||||
ERR_SI(l=recv(fd, msg, sizeof(msg)-1, 0));
|
ERR_SI(l=recv(fd, msg, sizeof(msg)-1, 0));
|
||||||
if (l==0) return(0);
|
/* if (l==0) return(0); */
|
||||||
msg[l]='\0';
|
msg[l]='\0';
|
||||||
if (skip==4) {
|
if (skip==3) {
|
||||||
ires=1;
|
|
||||||
} else if (skip==3) {
|
|
||||||
if (NULL!=strstr(msg, "Acknowledged")) ires=1;
|
if (NULL!=strstr(msg, "Acknowledged")) ires=1;
|
||||||
} else if (skip==1 || skip==2) {
|
} else if (skip==1 || skip==2) {
|
||||||
if (NULL!=strstr(msg, "SICS")) ires=1;
|
if (NULL!=strstr(msg, "SICS")) ires=1;
|
||||||
@ -81,6 +88,7 @@ int readWrite(int fd, int skip) {
|
|||||||
if (go) break;
|
if (go) break;
|
||||||
iret=term_wait_fd(fd, skip?5000:1000);
|
iret=term_wait_fd(fd, skip?5000:1000);
|
||||||
}
|
}
|
||||||
|
if (n==0 && ires==1) return 1;
|
||||||
return ires*n;
|
return ires*n;
|
||||||
OnError: return -1;
|
OnError: return -1;
|
||||||
}
|
}
|
||||||
@ -139,7 +147,7 @@ int main (int argc, char *argv[]) {
|
|||||||
printf("rejected\n");
|
printf("rejected\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("reading welcome message ...\n");
|
if (skip==2) printf("reading welcome message ...\n");
|
||||||
if (j==0) {
|
if (j==0) {
|
||||||
rights=getenv("six_rights");
|
rights=getenv("six_rights");
|
||||||
if (rights!=NULL && 0==strcmp(rights, instr)) {
|
if (rights!=NULL && 0==strcmp(rights, instr)) {
|
||||||
@ -149,7 +157,7 @@ int main (int argc, char *argv[]) {
|
|||||||
sprintf(ibuf, "%suser", instr);
|
sprintf(ibuf, "%suser", instr);
|
||||||
str_lowcase(ibuf, ibuf);
|
str_lowcase(ibuf, ibuf);
|
||||||
us=ibuf;
|
us=ibuf;
|
||||||
ps="02lns1";
|
ps="03lns1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(buf, "config Rights %s %s\r\n", us, ps);
|
sprintf(buf, "config Rights %s %s\r\n", us, ps);
|
||||||
@ -158,13 +166,14 @@ int main (int argc, char *argv[]) {
|
|||||||
if (!i) {
|
if (!i) {
|
||||||
us="Spy";
|
us="Spy";
|
||||||
}
|
}
|
||||||
printf("logged in to SICS as %s on %s%s\n", us, instr, sim);
|
printf("\rlogged in to SICS as %s on %s%s\n", us, instr, sim);
|
||||||
|
/*
|
||||||
if (*sim!='\0') {
|
if (*sim!='\0') {
|
||||||
strcpy(buf, "sync\r\n");
|
strcpy(buf, "sync\r\n");
|
||||||
ERR_SI(send(fd, buf, strlen(buf), 0));
|
ERR_SI(send(fd, buf, strlen(buf), 0));
|
||||||
ERR_I(i=readWrite(fd,4));
|
ERR_I(i=readWrite(fd,1));
|
||||||
printf("synchronized (%d chars read)\n", i);
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
iret=1;
|
iret=1;
|
||||||
buf[0]='\0';
|
buf[0]='\0';
|
||||||
pos=0;
|
pos=0;
|
||||||
@ -185,7 +194,7 @@ int main (int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
fputs("\n", stdout);
|
fputs("\n", stdout);
|
||||||
skip=0;
|
skip=0;
|
||||||
if (0==strcmp(lbuf,"sync")) skip=4;
|
if (0==strcmp(lbuf,"sync")) skip=1;
|
||||||
l=strlen(buf);
|
l=strlen(buf);
|
||||||
/*
|
/*
|
||||||
printf("sent> %s[%d chars]\n", buf, l);
|
printf("sent> %s[%d chars]\n", buf, l);
|
||||||
@ -194,9 +203,6 @@ int main (int argc, char *argv[]) {
|
|||||||
buf[l+1]=10;
|
buf[l+1]=10;
|
||||||
ERR_SI(send(fd, buf, l+2, 0));
|
ERR_SI(send(fd, buf, l+2, 0));
|
||||||
ERR_I(i=readWrite(fd,skip));
|
ERR_I(i=readWrite(fd,skip));
|
||||||
if (skip==4) {
|
|
||||||
printf("synchronize (%d chars read)\n", i);
|
|
||||||
}
|
|
||||||
buf[0]='\0';
|
buf[0]='\0';
|
||||||
pos=0;
|
pos=0;
|
||||||
} else if (iret<0) { /* ?? */
|
} else if (iret<0) { /* ?? */
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
print *,'No PGPLOT-Device defined'
|
print *,'No PGPLOT-Device defined'
|
||||||
goto 9
|
goto 9
|
||||||
endif
|
endif
|
||||||
|
call sys_setenv('PGPLOT_DEV', device)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call pgqcol(i,ncol)
|
call pgqcol(i,ncol)
|
||||||
|
Reference in New Issue
Block a user