2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1989, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2N/A/* All Rights Reserved */ 2N/Astatic int chat(
int,
char *[],
int,
char *,
char *);
2N/A * to add a new caller: 2N/A * declare the function that knows how to call on the device, 2N/A * add a line to the callers table giving the name of the device 2N/A * (from Devices file) and the name of the function 2N/A * add the function to the end of this file 2N/A {
"TLI",
tlicall},
/* AT&T Transport Layer Interface */ 2N/A {
"TLIS",
tlicall},
/* AT&T Transport Layer Interface */ 2N/A * exphone - expand phone number for given prefix and number 2N/A * return code - none 2N/A * repphone - Replace \D and \T sequences in arg with phone 2N/A * expanding and translating as appropriate. 2N/A static char *
pbuf;
/* dynamically allocated below */ 2N/A * processdev - Process a line from the Devices file 2N/A * file descriptor - succeeded 2N/A /* set up default "break" routine */ 2N/A /* initialize Devconfig info */ 2N/A /* This will find built-in caller functions */ 2N/A /* if NULL - assume translate */ 2N/A /* needed for for loop later to mark the end */ 2N/A /* restore vanilla unix interface */ 2N/A dev +=
2;
/* Skip to next CALLER and ARG */ 2N/A /* Here if not a built-in caller function */ 2N/A /* We do locking (file and advisory) after open */ 2N/A /* take care of the possible partial open fd */ 2N/A DEBUG(
1,
"generic open timeout\n%s",
"");
2N/A DEBUG(
7,
"opening with O_NDELAY set\n%s",
"");
2N/A /* check locks BEFORE modifying the stream */ 2N/A DEBUG(
7,
"clear O_NDELAY failed, errno %d\n",
2N/A /* any device|system lock files we should remove? */ 2N/A /* configure any requested streams modules */ 2N/A DEBUG(
5,
"STREAMS module configuration failed%s\n",
"");
2N/A /* save initial state of line in case script fails */ 2N/A /* use sdev[] since dev[] is incremented for internal callers */ 2N/A * Now loop through the remaining callers and chat 2N/A * according to scripts in dialers file. 2N/A * Scan Dialers file to find an entry 2N/A if (w <=
2)
/* do nothing - no chat */ 2N/A * Translate the phone number 2N/A /* if NULL - assume no translation */ 2N/A /* needed for for loop to mark the end */ 2N/A /* reset line settings if we got them in the beginning */ 2N/A /* restore vanilla unix interface */ 2N/A * clear_hup() clear the hangup state of the given device 2N/A * translate the pairs of characters present in the first 2N/A * string whenever the first of the pair appears in the second 2N/A * Get the information about the dialer. 2N/A * gdial(type, arps, narps) 2N/A * type -> type of dialer (e.g., penril) 2N/A * arps -> array of pointers returned by gdial 2N/A * narps -> number of elements in array returned by gdial 2N/A * -1 -> Can't open DIALERFILE 2N/A * 0 -> requested type not found 2N/A * >0 -> success - number of fields filled in 2N/A static char *
info;
/* dynamically allocated MAXLINE */ 2N/A DEBUG(
1,
"malloc failed for info in gdial\n", 0);
2N/A * AT&T Transport Layer Interface 2N/A * expected in Devices 2N/A * TLIS line1 - - TLIS 2N/A * returns fd to remote uucp daemon 2N/A /* dev holds device name relative to /dev */ 2N/A /* dev holds full path name of device */ 2N/A /* gimme local transport endpoint */ 2N/A /* allocate tli structures */ 2N/A * Prepare to connect. 2N/A * If address begins with "\x", "\X", "\o", or "\O", 2N/A * assume is hexadecimal or octal address and use stoa() 2N/A * Else is usual uucico address -- only \N's left to process. 2N/A * Walk thru connection address, changing \N's to NULLCHARs. 2N/A * Note: If a NULLCHAR must be part of the connection address, 2N/A * it must be overtly included in the address. One recommended 2N/A * way is to do it in the Devices file, thusly: 2N/A * bsfix() turns \000 into \N and then the loop below makes it a 2N/A * real, included-in-the-length null-byte. 2N/A * The DEBUG must print the strecpy'd address (so that 2N/A * non-printables will have been replaced with C escapes). 2N/A DEBUG(
5,
"tlicall: stoa failed\n%s",
"");
2N/A logent(
"tlicall",
"string-to-address failed");
2N/A /* connect to the service -- some listeners can't handle */ 2N/A /* multiple connect requests, so try it a few times */