2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: qalib.c /main/4 1996/10/01 16:27:40 drk $ */
24 /*************************************************************
25 * Module Name : qalib.c
26 * Original Author : Panacom
27 * Revision Date : 10/21/92
28 * Revision Author : Randall Robinson
31 * Abstract : This file contains the global variable definitions,
32 and the common function definitions used between
35 * Many variable and functions definitions have been
36 * left in place that were originally used by Panacom,
37 * and are no longer necessary.
38 ***************************************************************/
39 #ifndef _QALIB_INCLUDE
40 #define _QALIB_INCLUDE
42 #include "include_files.h"
53 #define __buf_len 4096
54 #define __ack_time_out 10
56 /* not used functionally */
57 typedef struct __TIME {
58 short Hund, Sec, Min, Hour;
62 typedef struct __INS8250 {
63 short Thr, Rbr, Ier, Iir, Lcr, Mcr, Lsr, Msr;
67 typedef union __REGISTERS {
69 short Ax, Bx, Cx, Dx, Bp, Si, Di, Ds, Es, Flags;
72 uchar Al, Ah, Bl, Bh, Cl, Ch, Dl, Dh;
77 /* not used functionally */
79 _B110, _B150, _B300, _B600, _B1200, _B2400, _B4800, _B9600, _B19200, _B38400
83 /* not used functionally */
84 typedef struct __DATACOM_REC {
86 uchar Parity, Data_Bits, Stop_Bits;
87 Char Intrig, Interm, Hand_Shake;
90 short Xcount, Ea_Count;
93 /* not used functionally */
94 typedef __DATACOM_REC __DATACOM_TYPE[4];
95 typedef uchar __BUFFER_TYPE[__buf_len + 1];
96 typedef __BUFFER_TYPE __BUFFERS[4];
97 typedef short __POINTERS[4];
100 /* These are needed */
101 /* global variables */
102 int fd_test = -1; /* file descriptor for /dev/tty */
103 FILE *f_test = (FILE *)NULL; /* file pointer to /dev/tty */
104 int __DEBUG = 0; /* set from command by "-D:Y */
106 struct termios termio_orig, termio_test; /* for /dev/tty */
109 typedef char __C_BUFFER[BUFSIZ];
113 /* ****** In the john dir: these flags not needed. Config.c file
114 ******** controls these parameters, but they are needed in the
115 ******** other 3 dirs.
120 int DC1_hndshk=1, DC2_hndshk = 0, NO_hndskh=0;
121 int inh_hndshk=0, inh_DC2=1;
124 Char Input_Terminator[4]; /* used */
125 Char Input_Trigger[4]; /* not used yet functionally, but still used
126 in some functions as a variable. RCR */
128 Static FILE *__Message_File; /* for the .LOG file */
129 Static boolean __Group_Not_Running; /* used to have something to do with
131 Static Char __File_Name[256], __Command_Line[256];
132 Static Char __Message_File_NAME[_FNSIZE];
133 Static boolean __Manual, __Log_Every_Thing, __Log_Msg;
136 /* function declarations */
144 /* not used functionally */
145 Static uchar __default_test_term = 1, __default_ref_term = 0,
146 __default_aux_a = 0, __default_aux_b = 0;
148 Static uchar __com_jump_table[4][6] = {
149 { 0x2e, 0xff, 0x16, 0, 0, 1 },
150 { 0x2e, 0xff, 0x16, 0, 0, 2 },
151 { 0x2e, 0xff, 0x16, 0, 0, 3 },
152 { 0x2e, 0xff, 0x16, 0, 0, 4 }
157 Static __INS8250 __rs232[4] = {
158 { 0x3f8, 0x3f8, 0x3f9, 0x3fa, 0x3fb, 0x3fc, 0x3fd, 0x3fe },
159 { 0x2f8, 0x2f8, 0x2f9, 0x2fa, 0x2fb, 0x2fc, 0x2fd, 0x2fe },
160 { 0x3e8, 0x3e8, 0x3e9, 0x3ea, 0x3eb, 0x3ec, 0x3ed, 0x3ee },
161 { 0x2e8, 0x2e8, 0x2e9, 0x2ea, 0x2eb, 0x2ec, 0x2ed, 0x2ee }
165 /* not needed functionally, currently just as place holders. */
166 Static __DATACOM_REC __default_datacom_rec = {
167 _B9600, 0, 8, 1, '\021', '\015', 'E', 60000.0, false, false, 0, 0
169 Static short __com_int_addr = 0, __data_segment = 0;
170 Static uchar Test_Com=0, Ref_Com, Aux_A_Com, Aux_B_Com;
171 Static __DATACOM_TYPE __Data_Com;
172 Static boolean __Refpres, __Aux_A_Pres, __Aux_B_Pres;
176 Static uchar __Rs_Error;
177 Static __BUFFERS __The_Buffs;
178 Static __POINTERS __Heads, __Tails;
179 Static short __Oldcs[4], __Oldip[4];
180 Static __REGISTERS __Regs;
181 Static boolean __Initialized, __Rs_Time_Out;
185 /* These are needed */
186 Char **P_argv; /* pascal global **argv */
187 int P_argc=0; /* pascal gloabal argc */
193 /* ********** start of function definitions ************/
199 sleep( (unsigned int)Sec);
204 SETSTRLEN(Char *S, short E)
206 S[(long)((int)E)] = '\0';
211 STRAPPEND(Char *S1, Char *S2)
213 if ((int) strlen(S1) + (int) strlen(S2) <= 255)
219 STRDELETE(Char *S, short P, short N)
221 MODULE_ERR("STRDELETE not supported");
226 /* STRINSERT and strinsert both not supported yet, Do not understand
230 STRINSERT(Char *S1, Char *S2, short P)
232 MODULE_ERR("STRINSERT not supported yet");
238 /* Starting at "start_pos" from string "input", copy the results into
242 strsub(Char *Result, Char *input, short start_pos, short len)
248 for(i=1; i <= start_pos; i++)
255 /* Do not understand the intent behind STRMOVE. NOT supported yet. */
257 STRMOVE(short N, Char *S1_, short P1, Char *S2, short P2)
260 MODULE_ERR("STRMOVE not supported yet");
268 STRRPT(Char *Result, Char *S, short N)
274 for (I = 1; I <= N; I++)
276 return strcpy(Result, St);
283 return ((short) strlen(S));
287 /* this function only supports returning position of one char (not
288 a string). "num" is the occurance of the character's position to
291 strpos2(Char *S1, Char *S2, short num)
301 if(STR1[index] == S2[0]) {
315 STRPOS(Char *S1, Char *S2)
317 return strpos2(S2, S1, 1);
322 STRLTRIM(Char *Result, Char *S_)
330 return strcpy(Result, S);
332 return strcpy(Result, S);
334 /* strdelete((void *)S, 1, 1); */
335 /* remove the first blank */
336 /* strcpy(S,strchar(S,S[1])); This is not working */
337 tmp = S + sizeof(Char);
347 return strcpy(Result, S);
351 STRRTRIM(Char *Result, Char *S_)
359 return strcpy(Result, S);
360 if (S[(int) strlen(S) - 1] != ' ')
361 return strcpy(Result, S);
363 /* strdelete((void *)S, strlen(S), 1); */
364 /* remove trailing blank */
365 S[(int) strlen(S) - 1]='\0';
367 if (S[(int) strlen(S) - 1] != ' ')
374 return strcpy(Result, S);
379 UPCASE_STRING(Char *Result, Char *S_)
385 FORLIM = (short) strlen(S);
386 for (I = 0; I < FORLIM; I++)
387 S[I] = toupper(S[I]);
388 return strcpy(Result, S);
395 Char STR1[256], STR2[256], STR3[256];
397 strcpy(S, UPCASE_STRING(STR1, STRRTRIM(STR2, STRLTRIM(STR3, S))));
402 TOHEXSTR(Char *Result, short Num)
404 static Char the_chars[16] = "0123456789ABCDEF";
408 for (I = 0; I <= 3; I++)
409 Result[3 - I] = the_chars[(((unsigned)Num) >> (I * 4)) & 0xf];
415 SUBTIME(__TIME Time2, __TIME Time1, __TIME *Time_Out)
417 if (Time1.Hund < Time2.Hund) {
421 Time_Out->Hund = Time1.Hund - Time2.Hund;
422 if (Time1.Sec < Time2.Sec) {
426 Time_Out->Sec = Time1.Sec - Time2.Sec;
427 if (Time1.Min < Time2.Min) {
431 Time_Out->Min = Time1.Min - Time2.Min;
432 Time_Out->Hour = Time1.Hour - Time2.Hour;
437 GET_TIME(__TIME *Cur_Time)
444 COM_INT_ROUTINE(void)
446 uchar Com_Num, In_Char;
453 RS232_CLEANUP(uchar Com)
468 __ERROR(short Num, short Where)
472 printf("\nProgram terminated before completed.\n");
473 printf("Program counter is $%s. Error Number is %d.\n",
474 TOHEXSTR(STR2, Where), Num);
483 if(fprintf(__Message_File, "*** Fatal Error *** %s\n", S) < 0) {
484 perror("MODULE_ERR: fprintf: ");
494 SET_DATA_COM(__BAUD_TYPE Speed, uchar Parity, uchar Stop, uchar Data_Bits,
501 /* Only supporting test terminal (no reference terminal). If support
502 reference terminal, must pass in correct file descriptor. Now,
503 var "Com" is not used. Only left in to keep from having to make
506 FLUSH_BUFFER_COM(short Com)
509 if(tcflush(fd_test,TCIOFLUSH) < 0) {
510 MODULE_ERR("FLUSH_BUFFER_COM: tcflush:");
515 /* No refernece terminal supported, only 1 (test) terminal to flush. */
525 READY(uchar Com, short Time_Out)
533 #define time_out_const 32000
537 RS232_OUT(Char Param, uchar Com)
546 #undef time_out_const
548 /* Only test terminal supported. */
550 __WRITE_BOTH(Char Ch)
554 sprintf(STR1,"%s",Ch);
561 RS232_INIT(uchar Com)
569 INIT_DEFAULTS(int Echo)
572 /* These can be removed, they are not used functionally. Only to keep
573 some having to change some function parameters.
576 Test_Com = __default_test_term;
577 Ref_Com = __default_ref_term;
578 Aux_A_Com = __default_aux_a;
579 Aux_B_Com = __default_aux_b;
580 __Refpres = (__default_ref_term != 0);
581 __Aux_A_Pres = (__default_aux_a != 0);
582 __Aux_B_Pres = (__default_aux_b != 0);
583 __Data_Com[0] = __default_datacom_rec;
584 __Data_Com[1] = __default_datacom_rec;
585 __Data_Com[2] = __default_datacom_rec;
586 __Data_Com[3] = __default_datacom_rec;
587 /* __Rs_Time_Out = false; */
588 /* ****************************************************************/
590 /* Open /dev/tty and obtain file descriptor and FILE pointer. */
591 if((fd_test = open("/dev/tty", O_RDWR)) < 0) {
592 (void) perror("INIT_DEFAULTS: /dev/tty open:");
596 f_test = fdopen(fd_test, "w");
597 (void) setvbuf(f_test, (char *) 0, _IONBF, 0);
599 /* get struct termio for later restoration and use for setting defaults */
600 if(tcgetattr(fd_test, &termio_orig) < 0) {
601 (void) perror("INIT_DEFAULTS: tcgetattr:");
605 /* Default settings determined from PANACOM tests, and translated to
606 HP_UX environment. Along with default settings using struct termios. */
608 /* Canonical Input is OFF */
610 termio_test = termio_orig;
611 termio_test.c_iflag &= ~(ICRNL | IUCLC | IXANY);
612 termio_test.c_iflag |= (IXON | IXOFF);
613 termio_test.c_lflag &= ~(ICANON | ECHO);
614 termio_test.c_cflag |= (CS8 | CREAD);
615 termio_test.c_cc[VMIN] = 1;
616 termio_test.c_cc[VTIME] = 0;
619 /* Canonical Input is ON */
621 termio_test = termio_orig;
622 termio_test.c_iflag |= (IXON | IXOFF);
623 termio_test.c_lflag |= (ICANON);
624 termio_test.c_lflag &= ~(ECHO);
625 termio_test.c_cflag |= CS8;
626 termio_test.c_cc[VINTR] = _POSIX_VDISABLE;
627 termio_test.c_cc[VQUIT] = _POSIX_VDISABLE;
628 termio_test.c_cc[VERASE] = _POSIX_VDISABLE;
629 termio_test.c_cc[VKILL] = _POSIX_VDISABLE;
630 termio_test.c_cc[VEOF] = _POSIX_VDISABLE;
635 /* turn on signal handlers... */
636 (void) signal(SIGHUP, cleanup);
637 (void) signal(SIGINT, cleanup);
638 (void) signal(SIGQUIT, cleanup);
639 (void) signal(SIGTERM, cleanup);
641 /* set a 2 minute timeout... */
642 (void) signal(SIGALRM, timeout);
643 /* (void) alarm(240); */
646 /* set new terminal control attributes */
647 if(tcsetattr(fd_test,TCSADRAIN,&termio_test) < 0) {
648 (void) perror("tcsetattr New");
652 /* default terminal settings */
654 PARITYTEST("4"); /* 8 bit no parity */
655 HANDSHAKE_COM("X"); /* IXON and IXOFF */
656 if (Echo) ECHO_COM("ON"); /* echoing on */
657 else ECHO_COM("OFF"); /* echoing off */
663 CHECK_COM(uchar Test)
671 PORT_ASSIGNMENTS_OK(uchar Test, uchar Ref, uchar Aux_A, uchar Aux_B)
675 Ok = true; /* don't need */
681 /* Local variables for START: */
686 /* Local variables for GET_PARAMS: */
687 struct LOC_GET_PARAMS {
688 struct LOC_START *LINK;
692 /* gets name of program to use for log file name */
694 GET_PROG_NAME(Char *Result, struct LOC_GET_PARAMS *LINK)
699 /* Just using argc and argv to return program name. */
700 return strcpy(Result,P_argv[0]);
704 /* during pasrsing of command line. Sets the value for the 4 different
705 Com ports. Not functionally needed anymore
708 PUT_NUM(uchar *Default, Char *Buffer, struct LOC_GET_PARAMS *LINK)
712 Ok = ((int) strlen(Buffer) == 4);
715 if (Buffer[3] >= '0' && Buffer[3] <= '4')
716 *Default = Buffer[3] - '0';
722 /* Used to grab string that will be place in global var: __Command_Line.
723 This is associated with option: -C.
726 GET_COMMAND_LINE(short *I, Char *Current_, struct LOC_GET_PARAMS *LINK)
732 strcpy(Current, Current_);
733 strcpy(Current, strsub(STR1, Current, strpos2(Current, "\"", 1) + 1,
734 (int) strlen(Current)));
735 sprintf(STR1, "%.*s", strpos2(Current, "\"", 1) - 1, Current);
736 strcpy(Current, STR1);
737 if (Current[0] == ' ')
739 FORLIM = (int) strlen(Current);
740 for (LINK->LINK->J = 2; LINK->LINK->J <= FORLIM; LINK->LINK->J++) {
741 if (Current[LINK->LINK->J - 1] == ' ' && Current[LINK->LINK->J - 2] != ' ')
744 strcpy(__Command_Line, Current);
747 /* Parses command line, looking at each option and doing the right thing. */
749 GET_PARAMS(struct LOC_START *LINK)
751 struct LOC_GET_PARAMS V;
752 Char Buffer[256], Current[256];
761 __Group_Not_Running = true;
763 sprintf(__File_Name, "%s.LOG", GET_PROG_NAME(STR1, &V));
766 *__Command_Line = '\0';
770 while (LINK->I < P_argc && !Bad_Params) {
771 strcpy(Buffer, P_argv[LINK->I]);
772 if ((char) Buffer[0] != '-' || (int) strlen(Buffer) < 2) {
776 switch (toupper(Buffer[1])) {
779 if (!PUT_NUM(&__default_test_term, Buffer, &V))
784 if (!PUT_NUM(&__default_ref_term, Buffer, &V))
789 if (!PUT_NUM(&__default_aux_a, Buffer, &V))
794 if (!PUT_NUM(&__default_aux_b, Buffer, &V))
799 GET_COMMAND_LINE(&LINK->I, P_argv[LINK->I], &V);
803 if (strlen(Buffer) == 4) {
804 if (toupper(Buffer[3]) == 'Y') {
807 else if (toupper(Buffer[3]) != 'Y')
816 __Log_Every_Thing = true;
822 if ((int) strlen(Buffer) > 3)
823 strsub(__File_Name, Buffer, 4, strlen(Buffer));
827 /* __Group_Not_Running = false; */
828 /* Option 'D' is being switched to debug mode. */
840 MODULE_ERR("Bad parameter line. Please see manual for information");
841 if (!PORT_ASSIGNMENTS_OK(__default_test_term, __default_ref_term,
842 __default_aux_a, __default_aux_b))
843 MODULE_ERR("Bad Port assignments in command line. See manual");
844 sprintf(__Command_Line, "NM%s", strcpy(STR2, __Command_Line));
846 __Command_Line[1] = 'A';
848 __Command_Line[0] = 'R';
851 /* Initialize routine. Every program call this. */
852 /* The 4 com ports are not functionally needed. */
854 START(uchar Test, uchar Ref, uchar Aux1, uchar Aux2, int Echo)
862 __Aux_A_Pres = false;
863 __Aux_B_Pres = false;
864 if (!PORT_ASSIGNMENTS_OK(Test, Ref, Aux1, Aux2))
865 MODULE_ERR("Invalid ports specified in START. See manual for details");
870 __Log_Every_Thing = false;
872 /* set system variables based upon input from command line options. */
875 strcpy(__Message_File_NAME, __File_Name);
876 if (__Message_File != NULL)
877 __Message_File = freopen(__Message_File_NAME, "w", __Message_File);
879 __Message_File = fopen(__Message_File_NAME, "w");
880 _SETIO(__Message_File != NULL, FileNotFound);
882 MODULE_ERR("Illegal log file name specified OR not DOS 3.x");
888 /* prints to xxx.LOG file all data read and written thru READ_COM and
889 WRITE_COM. Triggered by option -E, __Log_EveryThing.
892 LOG_IT(char *S, short Howmany, Char Which_Way)
902 strcpy(Who,"Terminal");
906 strcat(Who, " ==> HOST");
910 sprintf(Who, "HOST ==> %s", strcpy(STR1, Who));
914 MODULE_ERR("Bad call to Log_it. Bad \"which_way\"");
919 _SETIO(fprintf(__Message_File, "%s\n", Who) >= 0, FileWriteError);
920 Ok = (P_ioresult == 0);
922 if(fprintf(__Message_File, "%s\n",vis(S)) < 0) {
923 perror("fprintf __Message_File");
929 /* have not seen a use for yet */
930 #define display_row 25
931 #define line_length 79
944 YESNOKEY(Char *Prompt_, boolean Default)
955 ASCIIINT(Char *S, short *Er)
960 if ((int) strlen(S) > 10) {
964 *Er = (sscanf(S, "%hd", &I) == 0);
974 INTASCII(Char *Result, short Num)
978 sprintf(St, "%d", Num);
979 return strcpy(Result, St);
984 READ_COM(int fd, char *terminator)
990 /* Based upon settings of strap G and H determine Handshake scheme. */
991 /* Currently, on support 3 versions of the handshake scheme. */
993 if(!inh_hndshk && inh_DC2)
994 WRITETEST("\021"); /* default, DC1 handshake */
996 else if(inh_hndshk && !inh_DC2) { /* DC1-DC2-DC1 handshake */
1000 else if(inh_hndshk && inh_DC2)
1001 ; /* NO hand shake */
1003 MODULE_ERR("ERROR, illegal combination of hand shake parameters.");
1007 /* Determine termination character for read statements. */
1008 /* Currently just work with auto line feed or not. */
1017 /* Read in data form /dev/tty. Input_Terminator is set globally */
1018 /* Read til get terminating char. */
1019 c=in(fd_test,STR1, sizeof(STR1), terminator);
1021 STR1[(int) strlen(STR1) - 2] = '\0'; /* remove "CR and new line */
1023 STR1[(int) strlen(STR1) - 1] = '\0'; /* just remove terminating char */
1027 /* Reference terminal not supported. */
1036 READTEST(char *Terminator)
1041 tmp = READ_COM(fd_test, Terminator);
1044 if(__Log_Every_Thing)
1045 LOG_IT(STR, sizeof(STR),'R');
1051 STRCOMP(Char *S1, Char *S2)
1054 boolean Still_The_Same;
1056 if (!strcmp(S1, S2)) {
1060 I = (int) strlen(S1);
1061 if ((int) strlen(S2) < I)
1062 I = (int) strlen(S2);
1064 Still_The_Same = true;
1065 while (J <= I && Still_The_Same) {
1066 if (S1[J - 1] != S2[J - 1])
1067 Still_The_Same = false;
1075 /* set termio flag ECHO based on user input from test script */
1076 /* Variable "Com" is not used, it is left in to keep from modifying */
1079 /* Currently, this function only supports a test terminal (no reference
1080 terminal). If reference terminal is to be supported, the correct
1081 termios structure will have to be passed in.
1085 /* ECHO_COM used to return void, but to keep compiler happy, I
1086 changed to return type of int.
1087 Error msg was: Inconsistent type declaration: ECHO_COM */
1091 if(!strcmp(S_,"ON"))
1092 termio_test.c_lflag |= ECHO;
1094 termio_test.c_lflag &= ~ECHO;
1097 /* set new terminal control attributes */
1098 if(tcsetattr(fd_test,TCSADRAIN,&termio_test) < 0) {
1099 (void) perror("tcsetattr: ECHO ");
1107 INTERM_COM(uchar Com, Char *S)
1109 strcpy(Input_Terminator, S);
1115 INTRIG_COM(uchar Com, Char *S)
1117 strcpy(Input_Trigger,S);
1125 uchar I=0; /* "I" is a dummy var */
1137 /* not set up for more than 1 terminal
1138 for (I = 1; I <= 4; I++)
1150 /* not set up for more than 1 terminal
1151 for (I = 1; I <= 4; I++)
1160 if (__Log_Msg) { /*$I-*/
1161 _SETIO(fprintf(__Message_File, "%s\n", S) >= 0, FileWriteError);
1162 if (P_ioresult != 0)
1163 MODULE_ERR("Error writing to Message File. Disk may be full");
1170 GET_PARITY(Char *S_, uchar Com)
1177 PARITY_COM(struct termios *term, Char *Par)
1182 term->c_cflag |= (PARENB | PARODD);
1186 term->c_cflag |= PARENB;
1187 term->c_cflag &= ~(PARODD);
1191 term->c_cflag |= PARENB;
1192 term->c_cflag &= ~(PARODD);
1196 term->c_cflag |= (PARENB | PARODD);
1200 term->c_cflag &= ~(PARENB);
1204 term->c_cflag |= CS8;
1206 term->c_cflag |= CS7;
1208 /* set new terminal control attributes */
1209 if(tcsetattr(fd_test,TCSADRAIN,&termio_test) < 0) {
1210 (void) perror("tcsetattr: attempting to set parity and data bits.");
1217 PARITYREF(Char *Par)
1223 /* PARITYTEST used to return void, but to keep compiler happy, I
1224 changed to return type of int.
1225 Error msg was: Inconsistent type declaration: PARITYTEST */
1227 PARITYTEST(Char *Par)
1229 PARITY_COM(&termio_test, Par);
1236 GET_BAUD(Char *S_, uchar Com, short *Code)
1244 SPEED_COM(struct termios *term, speed_t sp)
1247 if(cfsetospeed(term,sp) < 0) {
1248 (void) perror("cfsetospeed: illegal baud rate");
1250 if(cfsetispeed(term,sp) < 0) {
1251 (void) perror("cfsetispeed: illegal baud rate");
1254 /* set new terminal control attributes */
1255 if(tcsetattr(fd_test,TCSADRAIN,&termio_test)) {
1256 (void) perror("tcsetattr: attempting to set baud rate");
1270 /* SPEEDTEST used to return void, but to keep compiler happy, I
1271 changed to return type of int.
1272 Error msg was: Inconsistent type declaration: SPEEDTEST */
1274 SPEEDTEST(speed_t S)
1277 SPEED_COM(&termio_test,S);
1284 TIMEOUT_COM(uchar Com, Char *S)
1300 WRITE_COM(FILE *f, Char *S)
1302 if(fputs(S,f) < 0) {
1303 MODULE_ERR("WRITE ERROR,fputs");
1314 ; /* refernece terminal not supported */
1318 /* WRITETEST used to return void, but to keep compiler happy, I
1319 changed to return type of int.
1320 Error msg was: Inconsistent type declaration: WRITETEST */
1324 WRITE_COM(f_test, S_);
1325 if(__Log_Every_Thing)
1326 LOG_IT(S_,sizeof(buffer),'W');
1331 /* HANDSHAKE_COM used to return void, but to keep compiler happy, I
1332 changed to return type of int.
1333 Error msg was: Inconsistent type declaration: HANDSHAKE_COM */
1334 /* Not used functionally */
1336 HANDSHAKE_COM(char *S)
1337 /* HANDSHAKE_COM(uchar Com, char *S) */
1339 if (toupper(S[0]) == 'N' || toupper(S[0]) == 'B' ||
1340 toupper(S[0]) == 'X' || toupper(S[0]) == 'E')
1341 HAND_SHAKE = toupper(S[0]);
1343 MODULE_ERR("Bad handshaking driver type in HandShake_Com");
1359 DATACOMM_COM(uchar Com, Char *Baud, Char *Time_Out, Char *Hand,
1360 Char *Echo_Var, Char *Interm_Var, Char *Intrig_Var)
1368 DATACOMM(Char *Baud, Char *Time_Out, Char *Hand, Char *Echo_Var,
1369 Char *Interm_Var, Char *Intrig_Var, boolean Refpres)
1379 strcpy(S, __Command_Line);
1384 __setstrlen(Char *s, short l)
1394 (void) fputs(">> ding!!\n", log);
1399 void timeout(int sig)
1401 /* reset the signal handler... */
1403 (void) signal(sig, timeout);
1405 (void) fprintf(stderr, "timeout!\n");
1410 /* Shutdown orderly and restore terminal back to original condition. */
1411 void cleanup(int sign)
1413 /* reset the signal handler... */
1415 (void) signal(sign, cleanup);
1416 (void)fflush(__Message_File);
1418 /* restore terminal terimo... */
1420 if(tcsetattr(fd_test,TCSAFLUSH,&termio_orig) < 0) {
1421 (void) perror("tcsetattr Cleanup");
1428 /* restore terminal configuration... */
1430 (void) fputs("\033X", f_test); /* turn off format mode.. */
1431 (void) fputs("\033&k0B", f_test); /* turn off block mode. */
1432 (void) fputs("\033&k0A", f_test); /* turn off autolf mode. */
1440 /* Reads from stream until the terminating char is found. */
1442 in(int fd, char *buffer, int bufsiz, char *term)
1444 static char holdbuffer[BUFSIZ];
1445 static int holdbufsiz = 0;
1450 /* copy over the hold buffer... */
1452 #ifdef NOCODE /* not required */
1453 if (holdbufsiz > 0) {
1454 /* copy it over... */
1455 (void) memcpy(buffer, holdbuffer, holdbufsiz);
1457 /* set it's length... */
1468 while (bufsiz > 0) {
1469 for (; i > 0; i--, c++, bufsiz--) {
1470 /* look for a valid terminalter... */
1471 if (strchr(term, *c)) {
1472 /* found a terminator... */
1473 /* move over 1 character... */
1477 /* copy the rest of the string into the hold buffer... */
1479 (void) memcpy(holdbuffer, c, i);
1483 /* null out the next character... */
1486 /* and return string... */
1487 strcat(buffer, term);
1491 if ((i = read(fd, c, bufsiz)) < 0) {
1492 (void) perror("read");
1503 /* prints out all invisible and visible chars */
1507 static char visbuffer[BUFSIZ];
1510 for (c = visbuffer; *buf; ) {
1513 *c++ = '@' + *buf++;
1514 } else if (*buf == '\\') {
1517 } else if (*buf < 0x7f) {
1521 *c++ = '\0' + (*((unsigned char *) buf) >> 6) & 07;
1522 *c++ = '\0' + (*((unsigned char *) buf) >> 3) & 07;
1523 *c++ = '\0' + (*((unsigned char *) buf++) >> 0) & 07;
1527 /* null out end of buffer... */