chat.c (4e83a8fef438ccb47b4424ee88fab459778c45b0) chat.c (e1b4d8d0746069292d84708b0e11b17a7e1ef5e0)
1/*
2 * Chat -- a program for automatic session establishment (i.e. dial
3 * the phone and log in).
4 *
5 * Standard termination codes:
6 * 0 - successful completion of the script
7 * 1 - invalid argument, expect string too large, etc.
8 * 2 - error on an I/O operation or fatal error condition.

--- 955 unchanged lines hidden (view full) ---

964 * process the reply string
965 */
966void chat_send (s)
967register char *s;
968{
969 if (say_next) {
970 say_next = 0;
971 s = clean(s,0);
1/*
2 * Chat -- a program for automatic session establishment (i.e. dial
3 * the phone and log in).
4 *
5 * Standard termination codes:
6 * 0 - successful completion of the script
7 * 1 - invalid argument, expect string too large, etc.
8 * 2 - error on an I/O operation or fatal error condition.

--- 955 unchanged lines hidden (view full) ---

964 * process the reply string
965 */
966void chat_send (s)
967register char *s;
968{
969 if (say_next) {
970 say_next = 0;
971 s = clean(s,0);
972 write(2, s, strlen(s));
972 write(STDERR_FILENO, s, strlen(s));
973 free(s);
974 return;
975 }
976
977 if (hup_next) {
978 hup_next = 0;
979 if (strcmp(s, "OFF") == 0)
980 signal(SIGHUP, SIG_IGN);

--- 132 unchanged lines hidden (view full) ---

1113 fatal(1, "Failed");
1114}
1115
1116int get_char()
1117{
1118 int status;
1119 char c;
1120
973 free(s);
974 return;
975 }
976
977 if (hup_next) {
978 hup_next = 0;
979 if (strcmp(s, "OFF") == 0)
980 signal(SIGHUP, SIG_IGN);

--- 132 unchanged lines hidden (view full) ---

1113 fatal(1, "Failed");
1114}
1115
1116int get_char()
1117{
1118 int status;
1119 char c;
1120
1121 status = read(0, &c, 1);
1121 status = read(STDIN_FILENO, &c, 1);
1122
1123 switch (status) {
1124 case 1:
1125 return ((int)c & 0x7F);
1126
1127 default:
1128 logf("warning: read() on stdin returned %d", status);
1129

--- 11 unchanged lines hidden (view full) ---

1141int put_char(c)
1142int c;
1143{
1144 int status;
1145 char ch = c;
1146
1147 usleep(10000); /* inter-character typing delay (?) */
1148
1122
1123 switch (status) {
1124 case 1:
1125 return ((int)c & 0x7F);
1126
1127 default:
1128 logf("warning: read() on stdin returned %d", status);
1129

--- 11 unchanged lines hidden (view full) ---

1141int put_char(c)
1142int c;
1143{
1144 int status;
1145 char ch = c;
1146
1147 usleep(10000); /* inter-character typing delay (?) */
1148
1149 status = write(1, &ch, 1);
1149 status = write(STDOUT_FILENO, &ch, 1);
1150
1151 switch (status) {
1152 case 1:
1153 return (0);
1154
1155 default:
1156 logf("warning: write() on stdout returned %d", status);
1157

--- 90 unchanged lines hidden (view full) ---

1248 switch (n) {
1249 case '\r': /* ignore '\r' */
1250 break;
1251 case -1:
1252 if (need_lf == 0)
1253 break;
1254 /* fall through */
1255 case '\n':
1150
1151 switch (status) {
1152 case 1:
1153 return (0);
1154
1155 default:
1156 logf("warning: write() on stdout returned %d", status);
1157

--- 90 unchanged lines hidden (view full) ---

1248 switch (n) {
1249 case '\r': /* ignore '\r' */
1250 break;
1251 case -1:
1252 if (need_lf == 0)
1253 break;
1254 /* fall through */
1255 case '\n':
1256 write(2, "\n", 1);
1256 write(STDERR_FILENO, "\n", 1);
1257 need_lf = 0;
1258 break;
1259 default:
1260 s = character(n);
1257 need_lf = 0;
1258 break;
1259 default:
1260 s = character(n);
1261 write(2, s, strlen(s));
1261 write(STDERR_FILENO, s, strlen(s));
1262 need_lf = 1;
1263 break;
1264 }
1265}
1266
1267/*
1268 * 'Wait for' this string to appear on this file descriptor.
1269 */

--- 407 unchanged lines hidden ---
1262 need_lf = 1;
1263 break;
1264 }
1265}
1266
1267/*
1268 * 'Wait for' this string to appear on this file descriptor.
1269 */

--- 407 unchanged lines hidden ---