?? ewsdtest1.c
字號:
Krelease_char
Kconnect_char
Ksend_char
/****************************************************************/
init()
{
struct configst conff[MAX_PORT_NO];
int n,port=0;
FILE *confd;
if ((confd=fopen(CONFIGFILE,"rb"))==NULL)
{
perror("config open");
exit(1);
}
if((n=fread(conff,CONFIGLEN,MAX_PORT_NO,confd))<=0)
{
perror("fread");
exit(0);
}
fclose(confd);
for(port=0;port<n;port++)
{
if (conff[port].data_type==OPERAT)
{
sprintf(ttyname[use_scrn],"/dev/%s",conff[port].omcport);
if ((fd[use_scrn]=open(ttyname[use_scrn],O_WRONLY))<0)
{
perror("comis open");
exit(1);
}
conf[use_scrn].release_char=conff[port].release_char;
Krelease_char=conff[port].release_char;
conf[use_scrn].connect_char=conff[port].connect_char;
Kconnect_char=conff[port].connect_char;
conf[use_scrn].send_char=conff[port].send_char;
Ksend_char=conff[port].send_char;
strcpy(conf[use_scrn].iogtype,conff[port].iogtype);
use_scrn++;
} /* if */
} /* for */
return(use_scrn);
}
/****************************************************************/
send_file(int spc,char *comm)
{
char send_char;
int i,len;
printf("send_file==>%s",comm);
len=strlen(comm);
for(i=0;i<len;i++) comm[i]=toupper(comm[i]);
comm[len-1]=Ksend_char; /* send command */
if (write(spc,comm,nn)!=nn)
{
perror("comis write file");
exit(0);
}
}
/****************************************************************/
exec_comm(int fd1,char *comm)
{int i,t,resul;
char c;
star:
t=0;
resul=0;
while(resul<=0 && t<10)
{
resul=justsend(">",0);
if(resul<0 || t>1)
{
c=Kconnect_char;
write(fd1,&c,1);
nap(1000);
}
resul=justsend("USERID:",0)+justsend("<",0);
/* printf("scan userid or < is==%d\n",resul);*/
i=0;
while(resul==0 && i<5)
{
i++;
nap(1000);
/* printf("scan USERID or < ==%d time /n",i); */
resul=justsend("USERID:",0)+justsend("<",0);
}
t++;
} /* send mm to connect the SWITCH */
if(resul==0) return(0);
resul=justsend("USERID:",0);
if(resul>0)
{
send_file(fd1,PASSUSER);
nap(1000);
resul=justsend("PASSWORD:",0);
i=0;
while(resul==0 && i<10)
{
i++;
nap(1000);
/* printf("scan USERID or < ==%d time /n",i); */
resul=justsend("PASSWORD:",0);
}
if(resul>0) send_file(fd1,PASSUSER);
else goto star;
nap(1000);
} /*** sent userid and password ***/
resul=justsend("<",0);
i=0;
while(resul==0 && i<10)
{
i++;
nap(1000);
/* printf("scan USERID or < ==%d time /n",i); */
resul=justsend("<",0);
}
if(resul>0)
{
send_file(fd1,comm);
nap(3000);
i=0;
resul=0;
while(resul==0 && i<10)
{
i++;
nap(2000);
resul=justsend(">",0);
}
return(1);
}
else goto star;
}
/****************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -