void disconnect(char *reason) { if (!conflag) { logent(value(HOST), "", DV, "call terminated"); return; } if (reason == NOSTR) { logent(value(HOST), "", acu->acu_name, "call terminated"); if (boolean(value(VERBOSE))) printf("\r\ndisconnecting..."); } else logent(value(HOST), "", acu->acu_name, reason); (*acu->acu_disconnect)(); }
/* * Dial up on a BIZCOMP Model 1031 with either * tone dialing (mod = "f") * pulse dialing (mod = "w") */ static int biz_dialer(char *num, char *mod) { int connected = 0; if (!bizsync(FD)) { logent(value(HOST), "", "biz", "out of sync"); (void) printf("bizcomp out of sync\n"); delock(uucplock); exit(0); } if (boolean(value(VERBOSE))) (void) printf("\nstarting call..."); echo("#\rk$\r$\n"); /* disable auto-answer */ echo("$>$.$ #\r"); /* tone/pulse dialing */ echo(mod); echo("$\r$\n"); echo("$>$.$ #\re$ "); /* disconnection sequence */ echo(DISCONNECT_CMD); echo("\r$\n$\r$\n"); echo("$>$.$ #\rr$ "); /* repeat dial */ echo(num); echo("\r$\n"); if (boolean(value(VERBOSE))) (void) printf("ringing..."); /* * The reply from the BIZCOMP should be: * `^G NO CONNECTION\r\n^G\r\n' failure * ` CONNECTION\r\n^G' success */ connected = detect(" "); #ifdef ACULOG if (timeout) { char line[80]; (void) sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "biz", line); } #endif if (!connected) flush(" NO CONNECTION\r\n\07\r\n"); else flush("CONNECTION\r\n\07"); if (timeout) biz31_disconnect(); /* insurance */ return (connected); }
static int chat(int nf, char *flds[], int fn, char *phstr1, char *phstr2) { char *want, *altern; int k, ok; for (k = 0; k < nf; k += 2) { want = flds[k]; ok = FAIL; while (ok != 0) { altern = index(want, '-'); if (altern != NULL) *altern++ = NULLCHAR; ok = expect(want, fn); if (ok == 0) break; if (altern == NULL) { Uerror = SS_LOGIN_FAILED; logent(UERRORTEXT, "FAILED"); return (FAIL); } want = index(altern, '-'); if (want != NULL) *want++ = NULLCHAR; sendthem(altern, fn, phstr1, phstr2); } (void) sleep(2); if (flds[k+1]) sendthem(flds[k+1], fn, phstr1, phstr2); } return (0); }
static void unidialer_disconnect(void) { int okay, retries; acu_flush (); /* flush any clutter */ unidialer_tty_clocal (TRUE); /* first hang up the modem*/ ioctl (FD, TIOCCDTR, 0); acu_nap (250); ioctl (FD, TIOCSDTR, 0); /* * If AT&D2, then dropping DTR *should* just hangup the modem. But * some modems reset anyway; also, the modem may be programmed to reset * anyway with AT&D3. Play it safe and wait for the full reset time before * proceeding. */ acu_nap (reset_delay); if (!unidialer_waitfor_modem_ready (reset_delay)) { #ifdef DEBUG printf ("unidialer_disconnect: warning CTS low.\r\n"); #endif } /* * If not strapped for DTR control, try to get command mode. */ for (retries = okay = 0; retries < MAXRETRY && !okay; retries++) { int timeout_value; /* flush any clutter */ if (!acu_flush ()) { #ifdef DEBUG printf ("unidialer_disconnect: warning flush failed.\r\n"); #endif } timeout_value = escape_guard_time; timeout_value += (timeout_value * retries / MAXRETRY); acu_nap (timeout_value); acu_flush (); /* flush any clutter */ unidialer_modem_cmd (FD, escape_sequence); acu_nap (timeout_value); unidialer_modem_cmd (FD, hangup_command); okay = unidialer_get_okay (reset_delay); } if (!okay) { logent(value(HOST), "", modem_name, "can't hang up modem"); if (boolean(value(VERBOSE))) printf("hang up failed\n"); } (void) acu_flush (); close (FD); }
void multitech_disconnect () { int okay, retries; for (retries = okay = 0; retries < 3 && !okay; retries++) { /* first hang up the modem*/ ioctl (FD, TIOCCDTR, 0); acu_nap (escape_guard_time); ioctl (FD, TIOCSDTR, 0); acu_nap (escape_guard_time); /* * If not strapped for DTR control, try to get command mode. */ acu_nap (escape_guard_time); multitech_write_str (FD, escape_sequence); acu_nap (escape_guard_time); multitech_write_str (FD, hangup_command); okay = multitech_swallow ("\r\nOK\r\n"); } if (!okay) { #if ACULOG logent(value(HOST), "", "multitech", "can't hang up modem"); #endif if (boolean(value(VERBOSE))) printf("hang up failed\n"); } close (FD); }
static int expect_str(char *str, int fn) { static char rdvec[MR]; char *rp = rdvec; int kr, c; char nextch; *rp = 0; CDEBUG(4, "expect: (%s", ""); for (c = 0; (kr = str[c]) != 0; c++) if (kr < 040) { /*EMPTY*/ CDEBUG(4, "^%c", kr | 0100); } else { /*EMPTY*/ CDEBUG(4, "%c", kr); } CDEBUG(4, ")\n%s", ""); if (EQUALS(str, "\"\"")) { CDEBUG(4, "got it\n%s", ""); return (0); } if (*str == '\0') return (0); if (setjmp(Sjbuf)) return (FAIL); (void) signal(SIGALRM, alarmtr); (void) alarm(expecttime); while (notin(str, rdvec)) { errno = 0; kr = (*Read)(fn, &nextch, 1); if (kr <= 0) { (void) alarm(0); CDEBUG(4, "lost line errno - %d\n", errno); logent("LOGIN", "LOST LINE"); return (FAIL); } c = nextch & 0177; CDEBUG(4, "%s", c < 040 ? "^" : ""); CDEBUG(4, "%c", c < 040 ? c | 0100 : c); if ((*rp = nextch & 0177) != NULLCHAR) rp++; if (rp >= rdvec + MR) { CDEBUG(4, "enough already\n%s", ""); (void) alarm(0); return (FAIL); } *rp = NULLCHAR; } (void) alarm(0); CDEBUG(4, "got it\n%s", ""); return (0); }
int hay_dialer(char *num, char *acu) { char *cp; int connected = 0; char dummy; struct termios cntrl; #ifdef ACULOG char line[80]; #endif if (hay_sync() == 0) /* make sure we can talk to the modem */ return(0); if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); tcgetattr(FD, &cntrl); cntrl.c_cflag |= HUPCL; tcsetattr(FD, TCSANOW, &cntrl); tcflush(FD, TCIOFLUSH); write(FD, "ATv0\r", 5); /* tell modem to use short status codes */ gobble("\r"); gobble("\r"); write(FD, "ATTD", 4); /* send dial command */ for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; write(FD, num, strlen(num)); state = DIALING; write(FD, "\r", 1); connected = 0; if (gobble("\r")) { if ((dummy = gobble("01234")) != '1') error_rep(dummy); else connected = 1; } if (connected) state = CONNECTED; else { state = FAILED; return (connected); /* lets get out of here.. */ } tcflush(FD, TCIOFLUSH); #ifdef ACULOG if (dialtimeout) { (void)snprintf(line, sizeof line, "%ld second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "hayes", line); } #endif if (dialtimeout) hay_disconnect(); /* insurance */ return (connected); }
/* * Dial up on a BIZCOMP Model 1022 with either * tone dialing (mod = "V") * pulse dialing (mod = "W") */ static int biz_dialer(char *num, char *mod) { int connected = 0; char cbuf[40]; if (boolean(value(VERBOSE))) printf("\nstarting call..."); /* * Disable auto-answer and configure for tone/pulse * dialing */ if (cmd("\02K\r")) { printf("can't initialize bizcomp..."); return (0); } strcpy(cbuf, "\02.\r"); cbuf[1] = *mod; if (cmd(cbuf)) { printf("can't set dialing mode..."); return (0); } strcpy(cbuf, "\02D"); strcat(cbuf, num); strcat(cbuf, "\r"); write(FD, cbuf, strlen(cbuf)); if (!detect("7\r")) { printf("can't get dial tone..."); return (0); } if (boolean(value(VERBOSE))) printf("ringing..."); /* * The reply from the BIZCOMP should be: * 2 \r or 7 \r failure * 1 \r success */ connected = detect("1\r"); #if ACULOG if (timeout) { char line[80]; sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "biz1022", line); } #endif if (timeout) biz22_disconnect(); /* insurance */ return (connected); }
/* * Establish connection for tip * * If DU is true, we should dial an ACU whose type is AT. * The phone numbers are in PN, and the call unit is in CU. * * If the PN is an '@', then we consult the PHONES file for * the phone numbers. This file is /etc/phones, unless overriden * by an exported shell variable. * * The data base files must be in the format: * host-name[ \t]*phone-number * with the possibility of multiple phone numbers * for a single host acting as a rotary (in the order * found in the file). */ char * con(void) { char *cp = PN; char *phnum, string[256]; FILE *fd; volatile int tried = 0; if (!DU) { /* regular connect message */ if (CM != NOSTR) parwrite(FD, CM, size(CM)); logent(value(HOST), "", DV, "call completed"); return (NOSTR); } /* * @ =>'s use data base in PHONES environment variable * otherwise, use /etc/phones */ signal(SIGINT, acuabort); signal(SIGQUIT, acuabort); if (setjmp(jmpbuf)) { signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); printf("\ncall aborted\n"); logent(value(HOST), "", "", "call aborted"); if (acu != NOACU) { setboolean(value(VERBOSE), FALSE); if (conflag) disconnect(NOSTR); else (*acu->acu_abort)(); } return ("interrupt"); } if ((acu = acutype(AT)) == NOACU) return ("unknown ACU type"); if (*cp != '@') { while (*cp) { phnum = cp; cp += strcspn(cp, ","); if (*cp != '\0') *cp++ = '\0'; if (strlen(phnum) == 0) continue; conflag = (*acu->acu_dialer)(phnum, CU); if (conflag) break; logent(value(HOST), phnum, acu->acu_name, "call failed"); tried++; } } else { if ((fd = fopen(PH, "r")) == NOFILE) { printf("%s: ", PH); return ("can't open phone number file"); } while (fgets(string, sizeof(string), fd) != NOSTR) { cp = &string[strcspn(string, " \t\n")]; if (*cp != '\0') *cp++ = '\0'; if (strcmp(string, value(HOST)) != 0) continue; cp += strspn(cp, " \t\n"); phnum = cp; *(cp + strcspn(cp, ",\n")) = '\0'; if (strlen(phnum) == 0) continue; conflag = (*acu->acu_dialer)(phnum, CU); if (conflag) break; logent(value(HOST), phnum, acu->acu_name, "call failed"); tried++; } fclose(fd); } if (conflag) { if (CM != NOSTR) parwrite(FD, CM, size(CM)); logent(value(HOST), phnum, acu->acu_name, "call completed"); return (NOSTR); } else if (!tried) { logent(value(HOST), "", acu->acu_name, "missing phone number"); return ("missing phone number"); } else { (*acu->acu_abort)(); return ("call failed"); } }
static int unidialer_dialer(char *num, char *acu) { char *cp; char dial_string [80]; #if ACULOG char line [80]; #endif #ifdef DEBUG dumpmodemparms (modem_name); #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!unidialersync()) { badsynch: printf("tip: can't synchronize with %s\n", modem_name); #if ACULOG logent(value(HOST), num, modem_name, "can't synch up"); #endif return (0); } unidialer_modem_cmd (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) unidialer_verbose_read(); #endif acu_flush (); /* flush any clutter */ unidialer_modem_cmd (FD, init_string); if (!unidialer_get_okay (reset_delay)) goto badsynch; fflush (stdout); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; (void) sprintf (dial_string, dial_command, num); unidialer_modem_cmd (FD, dial_string); connected = unidialer_connect (); if (connected && hw_flow_control) { acu_hw_flow_control (hw_flow_control); } #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, modem_name, line); } #endif if (timeout) unidialer_disconnect (); return (connected); }
int ven_dialer(char *num, char *acu) { char *cp; int connected = 0; char *msg, line[80]; struct termios cntrl; /* * Get in synch with a couple of carriage returns */ if (!vensync(FD)) { printf("can't synchronize with ventel\n"); #ifdef ACULOG logent(value(HOST), num, "ventel", "can't synch up"); #endif return (0); } if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); tcgetattr(FD, &cntrl); cntrl.c_cflag |= HUPCL; tcsetattr(FD, TCSANOW, &cntrl); echo("#k$\r$\n$D$I$A$L$:$ "); for (cp = num; *cp; cp++) { delay(1, 10); write(FD, cp, 1); } delay(1, 10); write(FD, "\r", 1); gobble('\n', line); if (gobble('\n', line)) connected = gobble('!', line); tcflush(FD, TCIOFLUSH); #ifdef ACULOG if (dialtimeout) { (void)snprintf(line, sizeof line, "%ld second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "ventel", line); } #endif if (dialtimeout) ven_disconnect(); /* insurance */ if (connected || dialtimeout || !boolean(value(VERBOSE))) return (connected); /* call failed, parse response for user */ cp = strchr(line, '\r'); if (cp) *cp = '\0'; for (cp = line; (cp = strchr(cp, ' ')) != NULL; cp++) if (cp[1] == ' ') break; if (cp) { while (*cp == ' ') cp++; msg = cp; while (*cp) { if (isupper(*cp)) *cp = tolower(*cp); cp++; } printf("%s...", msg); } return (connected); }
int multitech_dialer (char *num, char *acu) { char *cp; #if ACULOG char line [80]; #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!multitechsync()) { badsynch: printf("can't synchronize with multitech\n"); #if ACULOG logent(value(HOST), num, "multitech", "can't synch up"); #endif return (0); } acu_nap (intercommand_delay); multitech_write_str (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) multitech_verbose_read(); #endif acu_flush (); acu_nap (intercommand_delay); multitech_write_str (FD, init_string); if (!multitech_swallow ("\r\nOK\r\n")) goto badsynch; fflush (stdout); acu_nap (intercommand_delay); multitech_write_str (FD, dial_command); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; multitech_write_str (FD, num); multitech_write_str (FD, "\r"); connected = multitech_connect(); #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "multitech", line); } #endif if (timeout) multitech_disconnect (); return (connected); }
/* * Establish connection for tip * * If DU is true, we should dial an ACU whose type is AT. * The phone numbers are in PN, and the call unit is in CU. * * If the PN is an '@', then we consult the PHONES file for * the phone numbers. This file is /etc/phones, unless overriden * by an exported shell variable. * * The data base files must be in the format: * host-name[ \t]*phone-number * with the possibility of multiple phone numbers * for a single host acting as a rotary (in the order * found in the file). */ char * connect() { register char *cp = PN; char *phnum, string[256]; FILE *fd; int tried = 0; if (!DU) { /* regular connect message */ if (CM != NOSTR) pwrite(FD, CM, size(CM)); logent(value(HOST), "", DV, "call completed"); return (NOSTR); } /* * @ =>'s use data base in PHONES environment variable * otherwise, use /etc/phones */ signal(SIGINT, acuabort); signal(SIGQUIT, acuabort); if (setjmp(jmpbuf)) { signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); printf("\ncall aborted\n"); logent(value(HOST), "", "", "call aborted"); if (acu != NOACU) { boolean(value(VERBOSE)) = FALSE; if (conflag) disconnect(NOSTR); else (*acu->acu_abort)(); } return ("interrupt"); } if ((acu = acutype(AT)) == NOACU) return ("unknown ACU type"); if (*cp != '@') { while (*cp) { for (phnum = cp; *cp && *cp != ','; cp++) ; if (*cp) *cp++ = '\0'; if (conflag = (*acu->acu_dialer)(phnum, CU)) { logent(value(HOST), phnum, acu->acu_name, "call completed"); return (NOSTR); } else logent(value(HOST), phnum, acu->acu_name, "call failed"); tried++; } } else { if ((fd = fopen(PH, "r")) == NOFILE) { printf("%s: ", PH); return ("can't open phone number file"); } while (fgets(string, sizeof(string), fd) != NOSTR) { for (cp = string; !any(*cp, " \t\n"); cp++) ; if (*cp == '\n') { fclose(fd); return ("unrecognizable host name"); } *cp++ = '\0'; if (strcmp(string, value(HOST))) continue; while (any(*cp, " \t")) cp++; if (*cp == '\n') { fclose(fd); return ("missing phone number"); } for (phnum = cp; *cp && *cp != ',' && *cp != '\n'; cp++) ; if (*cp) *cp++ = '\0'; if (conflag = (*acu->acu_dialer)(phnum, CU)) { fclose(fd); logent(value(HOST), phnum, acu->acu_name, "call completed"); return (NOSTR); } else logent(value(HOST), phnum, acu->acu_name, "call failed"); tried++; } fclose(fd); } if (!tried) logent(value(HOST), "", acu->acu_name, "missing phone number"); else (*acu->acu_abort)(); return (tried ? "call failed" : "missing phone number"); }
int ven_dialer(char *num, char *acu) { char *cp; int connected = 0; char *msg, line[80]; /* * Get in synch with a couple of carriage returns */ if (!vensync(FD)) { printf("can't synchronize with ventel\n"); #if ACULOG logent(value(HOST), num, "ventel", "can't synch up"); #endif return (0); } if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); acu_hupcl (); echo("#k$\r$\n$D$I$A$L$:$ "); for (cp = num; *cp; cp++) { delay(1, 10); write(FD, cp, 1); } delay(1, 10); write(FD, "\r", 1); gobble('\n', line); if (gobble('\n', line)) connected = gobble('!', line); acu_flush (); #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "ventel", line); } #endif if (timeout) ven_disconnect(); /* insurance */ if (connected || timeout || !boolean(value(VERBOSE))) return (connected); /* call failed, parse response for user */ cp = index(line, '\r'); if (cp) *cp = '\0'; for (cp = line; (cp = index(cp, ' ')); cp++) if (cp[1] == ' ') break; if (cp) { while (*cp == ' ') cp++; msg = cp; while (*cp) { if (isupper(*cp)) *cp = tolower(*cp); cp++; } printf("%s...", msg); } return (connected); }
/* * get next conversation sequence number * rmtname -> name of remote system * returns: * 0 -> no entery * 1 -> 0 sequence number */ int gnxseq(char *rmtname) { register FILE *fp0, *fp1; register struct tm *tp; int count = 0, ct, ret; char buf[BUFSIZ], name[NAMESIZE]; time_t clock; if (access(SQFILE, 0) != 0) return (0); { int i; for (i = 0; i < 5; i++) if ((ret = mklock(SQLOCK)) == SUCCESS) break; sleep(5); } if (ret != SUCCESS) { logent("CAN'T LOCK", SQLOCK); DEBUG(4, "can't lock %s\n", SQLOCK); return (0); } if ((fp0 = fopen(SQFILE, "r")) == NULL) return (0); if ((fp1 = fopen(SQTMP, "w")) == NULL) { fclose(fp0); return (0); } chmod(SQTMP, DFILEMODE); while (fgets(buf, BUFSIZ, fp0) != NULL) { ret = sscanf(buf, "%s%d", name, &ct); if (ret < 2) ct = 0; name[7] = '\0'; if (ct > 9998) ct = 0; if (strncmp(rmtname, name, SYSNSIZE) != SAME) { fputs(buf, fp1); continue; } /* * found name */ count = ++ct; time(&clock); tp = localtime(&clock); fprintf(fp1, "%s %d %d/%d-%d:%2.2d\n", name, ct, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min); /* * write should be checked */ while (fgets(buf, BUFSIZ, fp0) != NULL) fputs(buf, fp1); } fclose(fp0); fclose(fp1); if (count == 0) { rmlock(SQLOCK); unlink(SQTMP); } return (count); }
int v3451_dialer(char *num, char *acu) { sig_t func; int ok; int slow = number(value(BAUDRATE)) < 1200, rw = 2; char phone[50]; /* * Get in synch */ vawrite("I\r", 1 + slow); vawrite("I\r", 1 + slow); vawrite("I\r", 1 + slow); vawrite("\005\r", 2 + slow); if (!expect("READY")) { printf("can't synchronize with vadic 3451\n"); #if ACULOG logent(value(HOST), num, "vadic", "can't synch up"); #endif return (0); } acu_hupcl (); sleep(1); vawrite("D\r", 2 + slow); if (!expect("NUMBER?")) { printf("Vadic will not accept dial command\n"); #if ACULOG logent(value(HOST), num, "vadic", "will not accept dial"); #endif return (0); } strcpy(phone, num); strcat(phone, "\r"); vawrite(phone, 1 + slow); if (!expect(phone)) { printf("Vadic will not accept phone number\n"); #if ACULOG logent(value(HOST), num, "vadic", "will not accept number"); #endif return (0); } func = signal(SIGINT,SIG_IGN); /* * You cannot interrupt the Vadic when its dialing; * even dropping DTR does not work (definitely a * brain damaged design). */ vawrite("\r", 1 + slow); vawrite("\r", 1 + slow); if (!expect("DIALING:")) { printf("Vadic failed to dial\n"); #if ACULOG logent(value(HOST), num, "vadic", "failed to dial"); #endif return (0); } if (boolean(value(VERBOSE))) printf("\ndialing..."); ok = expect("ON LINE"); signal(SIGINT, func); if (!ok) { printf("call failed\n"); #if ACULOG logent(value(HOST), num, "vadic", "call failed"); #endif return (0); } ioctl(FD, TIOCFLUSH, &rw); return (1); }