Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- epicon.c.orig Thu Apr 20 11:58:11 2017
- +++ epicon.c Mon Jan 11 14:10:35 2021
- @@ -64,6 +64,8 @@ int FP1,FP2; /* use to close fi
- int net_flag = 0; /* ip net connect flag */
- int server_ip_flag = 0; /* ip server flag */
- int Twostop = 0; /* 2 stop bit */
- +int Datalen = CS8; /* data bit length */
- +int Parity = 0; /* parity setting */
- int Bin_flag = 0; /* binary mode flag cannot escape */
- int Echo_flag = 0; /* input echo flag mode */
- int ip_socket_bufsize = 1024*1024; /* ip socket buffer size */
- @@ -106,14 +108,14 @@ char *argv[];
- done = i = speed = t_result = epicon_pid = 0;
- extern char *optarg;
- extern int optind;
- - extern int getopt(), convert_speed(), escape_code(), access();
- + extern int getopt(), convert_speed(), escape_code(), access(), convert_mode();
- epicon_pid = getpid();
- sprintf( Epicon_Socket ,"%s%ld",Epicon_Socket_init , epicon_pid);
- unlink( Epicon_Socket );
- strcpy(com_port, COMPORT);
- argv_redirect = argv[argc];
- speed = convert_speed(SPEED);
- - while((i = getopt(argc, argv,"bmMs:d:D:l:e:n:L:f:F:c:pqvz")) != EOF) {
- + while((i = getopt(argc, argv,"bmMs:d:D:l:e:n:L:f:F:c:pqvzx:")) != EOF) {
- switch(i) {
- case 'b':
- Bin_flag = 1; /* cannot escape flag set */
- @@ -201,6 +203,12 @@ char *argv[];
- case 'z':
- AZ_flag = 0;
- break;
- + case 'x':
- + if(convert_mode(optarg) == EOF) {
- + fprintf(stderr,"%s: invalid mode\n", optarg);
- + exit(1);
- + }
- + break;
- default:
- usage(*argv);
- exit(3);
- @@ -249,6 +257,7 @@ char *argv[];
- fprintf(stderr,"\r\n** Welcome to epicon Version-%s Copyright Isamu Yamauchi %s **",VER,DAY);
- if (!Bin_flag) fprintf(stderr,"\r\n exec shell ~! ");
- if (!Bin_flag) fprintf(stderr,"\r\n send binary files ~f");
- + if (!Bin_flag) fprintf(stderr,"\r\n send break ~b");
- if (!Bin_flag) fprintf(stderr,"\r\n call rz,sz,sx,rx ~rz,~sz,~sx,~rx");
- if (!Bin_flag) fprintf(stderr,"\r\n call kermit ~sk,~rk");
- if (!Bin_flag) fprintf(stderr,"\r\n external command ~C ");
- @@ -333,6 +342,36 @@ register char *sp;
- return EOF;
- }
- +convert_mode(arg)
- +register char *arg;
- +{
- + register int i = 0;
- + char c;
- + static int cs[] = {CS5, CS6, CS7, CS8};
- + static int sp[] = {0, CSTOPB};
- + while(c = arg[i]) {
- + if (i > 2) return EOF;
- + if (c == '-') ;/* do nothing */
- + else switch(i) {
- + case 0:
- + if (c < '5' || c > '8') return EOF;
- + Datalen = cs[c - '5'];
- + break;
- + case 1:
- + if (c == 'E' || c == 'e') Parity = PARENB;
- + else if (c == 'O' || c == 'o') Parity = PARENB | PARODD;
- + else if (c == 'N' || c == 'n') Parity = 0;
- + else return EOF;
- + break;
- + case 2:
- + if (c < '1' || c > '2') return EOF;
- + Twostop = sp[c - '1'];
- + break;
- + }
- + i++;
- + }
- + return 0;
- +}
- int escape_code(c)
- register char *c;
- --- epicon_main.c.orig Mon Jan 11 13:51:52 2021
- +++ epicon_main.c Mon Jan 11 14:03:47 2021
- @@ -54,6 +54,7 @@ extern void shell_process();
- extern void send_file();
- extern void msleep();
- extern void send_file_char();
- +extern void send_break();
- extern char esc[];
- extern pid_t ck_pid; /* check to process id */
- extern int com_port_fd; /* com_port file descriptor */
- @@ -604,6 +605,10 @@ check_char_1() {
- set_console_mode(2);
- ch4 = strtok(f3,"\n");
- send_file_char(fp2,ch4);
- + break;
- + case 'b':
- + incount = incount - 2;
- + send_break();
- break;
- default:
- esc_flag = 0;
- --- epicon_uty.c.orig Thu Apr 20 12:00:09 2017
- +++ epicon_uty.c Mon Jan 11 14:02:36 2021
- @@ -55,6 +55,8 @@ extern char *ip_port; /* ip net conne
- extern char *server_ip_port; /* default server port */
- extern char com_port[]; /* tty_dev name */
- extern int Twostop; /* 2 stop bit */
- +extern int Datalen; /* data bit length */
- +extern int Parity; /* parity setting */
- extern int Bin_flag; /* binary mode flag cannot escape */
- extern int Echo_flag; /* input echo mode flag */
- extern int ip_socket_bufsize; /* ip socket buffer size */
- @@ -727,19 +729,14 @@ void set_com_port_mode(speed)
- com_port_set = com_port_save;
- com_port_set.c_iflag &= ~(IXON|IXANY|IXOFF|ISTRIP|INLCR|ICRNL|IGNCR);
- com_port_set.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
- - com_port_set.c_cflag &= ~(PARENB);
- + com_port_set.c_cflag &= ~(PARENB|PARODD|CSTOPB|CSIZE);
- com_port_set.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHONL|ISIG);
- com_port_set.c_cflag |= (CLOCAL|CREAD|IGNPAR);
- + com_port_set.c_cflag |= (Parity|Twostop|Datalen);
- com_port_set.c_oflag = 0;
- - com_port_set.c_cflag &= ~PARENB;
- - com_port_set.c_cflag |= CS8;
- - if (Twostop) {
- - com_port_set.c_cflag |= CSTOPB; /* Set two stop bits */
- - }
- #ifdef CBAUDEX
- com_port_set.c_cflag &= ~(CBAUDEX);
- #endif
- - com_port_set.c_cflag &= ~(PARENB);
- /* com_port_set.c_iflag |= IXOFF; */ /* X/Y modem will clear this */
- // com_port_set.c_cflag |= CLOCAL|(speed); 2009.6.9 delete
- com_port_set.c_cc[VMIN] = 0;
- @@ -807,4 +804,13 @@ msleep(int msec) { /* wait milli second */
- perror("msleep");
- return -1;
- }
- +}
- +
- +send_break()
- +{
- + #ifndef HAVE_TERMIOS
- + ioctl(com_port_fd, TCSBRK, 0);
- + #else
- + tcsendbreak(com_port_fd, 250);
- + #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement