Lines Matching +full:temp +full:- +full:alarm

2  *	Chat -- a program for automatic session establishment (i.e. dial
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.
9 * 3 - timeout waiting for a simple string.
10 * 4 - the first string declared as "ABORT"
11 * 5 - the second string declared as "ABORT"
12 * 6 - ... and so on for successive ABORT strings.
16 * -----------------
17 * added -T and -U option and \T and \U substitution to pass a phone
37 * we should re-arm the ABORT "NO CARRIER". Hence the CLR_ABORT command.
52 * Added -r "report file" switch & REPORT keyword.
55 * Added -s "use stderr" and -S "don't use syslog" switches.
60 * Added -e "echo" switch & ECHO keyword
75 * (614)451-1883
189 * chat [-esSvV] [-f chat-file] [-r report-file] [-t timeout]
190 * [-T phone-number] [-U phone-number2] [chat-script]
191 * where chat-script has the form:
192 * [...[[expect[-send[-expect...]] send expect[-send[-expect]] ...]]]
194 * Perform a UUCP-dialer-like chat script on stdin and stdout.
203 while ((option = getopt(argc, argv, "ef:r:sSt:T:U:vV")) != -1) { in main()
267 argc -= optind; in main()
297 argc--; in main()
302 argc--; in main()
325 fatal(1, "%s -- open failed: %m", chatfile); in do_file()
388 "Usage: chat [-esSvV] [-f chat-file] [-r report-file] [-t timeout]\n" in usage()
389 " [-T phone-number] [-U phone-number2] [chat-script]\n" in usage()
390 "where chat-script has the form:\n" in usage()
391 " [...[[expect[-send[-expect...]] send expect[-send[-expect]] ...]]]\n"); in usage()
439 alarm(1); in sigalrm()
440 alarmed = 1; /* Reset alarm to avoid race window */ in sigalrm()
443 if ((flags = fcntl(0, F_GETFL, 0)) == -1) in sigalrm()
446 if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) in sigalrm()
450 chat_logf("alarm"); in sigalrm()
476 alarm(0); in init()
511 echo_stderr(-1); in terminate()
522 alarm(1); in terminate()
524 alarm(0); in terminate()
555 char temp[STR_LEN], cur_chr; in clean() local
560 s1 = temp; in clean()
562 while (*s && s1 - temp < (off_t)(sizeof(temp) - 2 - add_return)) { in clean()
669 cur_chr |= *s++ - '0'; in clean()
672 cur_chr |= *s++ - '0'; in clean()
696 return dup_mem (temp, (size_t) (s1 - temp)); /* may have embedded nuls */ in clean()
808 expect = expect_strtok (s, "-"); in chat_expect()
814 reply = expect_strtok (s, "-"); in chat_expect()
823 * If there is a sub-reply string then send it. Otherwise any condition in chat_expect()
853 meta = (c & 0x80) ? "M-" : ""; in character()
907 fatal(1, "Illegal or too-long ABORT string ('%v')", s); in chat_send()
928 fatal(1, "Illegal or too-long CLR_ABORT string ('%v')", s); in chat_send()
936 n_aborts--; in chat_send()
956 if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) in chat_send()
957 fatal(1, "Illegal or too-long REPORT string ('%v')", s); in chat_send()
976 if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) in chat_send()
977 fatal(1, "Illegal or too-long REPORT string ('%v')", s); in chat_send()
985 n_reports--; in chat_send()
1034 case -1: in get_char()
1035 if ((status = fcntl(0, F_GETFL, 0)) == -1) in get_char()
1038 if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) in get_char()
1041 return (-1); in get_char()
1050 usleep(10000); /* inter-character typing delay (?) */ in put_char()
1061 case -1: in put_char()
1062 if ((status = fcntl(0, F_GETFL, 0)) == -1) in put_char()
1065 if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) in put_char()
1068 return (-1); in put_char()
1076 alarm(0); in write_char()
1081 chat_logf(" -- write timed out"); in write_char()
1083 chat_logf(" -- write failed: %m"); in write_char()
1099 alarm(timeout); alarmed = 0; in put_string()
1131 alarm(0); in put_string()
1138 * When called with -1, a '\n' character is generated when
1150 case -1: in echo_stderr()
1172 char temp[STR_LEN]; in get_string() local
1175 char *s = temp, *end = s + STR_LEN; in get_string()
1176 char *logged = temp; in get_string()
1188 minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1; in get_string()
1199 alarm(timeout); in get_string()
1211 chat_logf("%0.*v", s - logged, logged); in get_string()
1218 chat_logf("%0.*v", s - logged, logged); in get_string()
1232 s - temp >= (report_len = strlen(report_string[n])) && in get_string()
1233 strncmp(s - report_len, report_string[n], report_len) == 0) { in get_string()
1258 if ((size_t)(s - temp) >= len && in get_string()
1259 c == string[len - 1] && in get_string()
1260 strncmp(s - len, string, len) == 0) { in get_string()
1263 chat_logf("%0.*v", s - logged, logged); in get_string()
1264 chat_logf(" -- got it\n"); in get_string()
1267 alarm(0); in get_string()
1273 if (s - temp >= (abort_len = strlen(abort_string[n])) && in get_string()
1274 strncmp(s - abort_len, abort_string[n], abort_len) == 0) { in get_string()
1277 chat_logf("%0.*v", s - logged, logged); in get_string()
1278 chat_logf(" -- failed"); in get_string()
1281 alarm(0); in get_string()
1290 if (logged < s - minlen) { in get_string()
1291 chat_logf("%0.*v", s - logged, logged); in get_string()
1294 s -= minlen; in get_string()
1295 memmove(temp, s, minlen); in get_string()
1296 logged = temp + (logged - s); in get_string()
1297 s = temp + minlen; in get_string()
1301 chat_logf("warning: alarm synchronization problem"); in get_string()
1304 alarm(0); in get_string()
1329 * vfmtmsg - format a message into a buffer. Like vsprintf except we
1332 * Doesn't do floating-point formats.
1335 #define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
1351 --buflen; in vfmtmsg()
1356 len = f - fmt; in vfmtmsg()
1361 buflen -= len; in vfmtmsg()
1378 width = width * 10 + c - '0'; in vfmtmsg()
1389 prec = prec * 10 + c - '0'; in vfmtmsg()
1403 val = -i; in vfmtmsg()
1445 --n; in vfmtmsg()
1448 OUTCHAR('-'); in vfmtmsg()
1449 c -= 0x80; in vfmtmsg()
1481 --fmt; /* so %z outputs %z etc. */ in vfmtmsg()
1482 --buflen; in vfmtmsg()
1487 *--str = 0; in vfmtmsg()
1489 *--str = hexchars[val % base]; in vfmtmsg()
1491 if (--prec <= 0 && val == 0) in vfmtmsg()
1496 *--str = '-'; in vfmtmsg()
1499 *--str = 'x'; in vfmtmsg()
1500 *--str = '0'; in vfmtmsg()
1503 len = num + sizeof(num) - 1 - str; in vfmtmsg()
1512 if ((n = width - len) > 0) { in vfmtmsg()
1513 buflen -= n; in vfmtmsg()
1514 for (; n > 0; --n) in vfmtmsg()
1522 buflen -= len; in vfmtmsg()
1525 return buf - buf0; in vfmtmsg()