diff --git a/gnu/Makefile b/gnu/Makefile index 30c64596aa1b..64768f45f798 100644 --- a/gnu/Makefile +++ b/gnu/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 5.33.1.1 (Berkeley) 5/6/91 # $FreeBSD$ -SUBDIR= include lib libexec usr.bin usr.sbin +SUBDIR= include lib usr.bin usr.sbin .include diff --git a/gnu/libexec/Makefile b/gnu/libexec/Makefile deleted file mode 100644 index 70e21ad24f6d..000000000000 --- a/gnu/libexec/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ - -.if !defined(NOUUCP) -SUBDIR= uucp -.endif - -.include diff --git a/gnu/libexec/Makefile.inc b/gnu/libexec/Makefile.inc deleted file mode 100644 index 829da300445d..000000000000 --- a/gnu/libexec/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -BINDIR?= /usr/libexec diff --git a/gnu/libexec/uucp/COPYING b/gnu/libexec/uucp/COPYING deleted file mode 100644 index e77696ae8ddf..000000000000 --- a/gnu/libexec/uucp/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/gnu/libexec/uucp/Makefile b/gnu/libexec/uucp/Makefile deleted file mode 100644 index 9f39c61b7807..000000000000 --- a/gnu/libexec/uucp/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This is the Makefile for Taylor UUCP -# $FreeBSD$ - -SUBDIR= libunix libuucp libuuconf cu - -.include diff --git a/gnu/libexec/uucp/Makefile.inc b/gnu/libexec/uucp/Makefile.inc deleted file mode 100644 index 02c21855d7ad..000000000000 --- a/gnu/libexec/uucp/Makefile.inc +++ /dev/null @@ -1,32 +0,0 @@ -.if exists(${.OBJDIR}/../libunix) -LIBUNIX= $(.OBJDIR)/../libunix/libunix.a -.else -LIBUNIX= $(.CURDIR)/../libunix/libunix.a -.endif - -.if exists(${.OBJDIR}/../libuuconf) -LIBUUCONF= $(.OBJDIR)/../libuuconf/libuuconf.a -.else -LIBUUCONF= $(.CURDIR)/../libuuconf/libuuconf.a -.endif - -.if exists(${.OBJDIR}/../libuucp) -LIBUUCP= $(.OBJDIR)/../libuucp/libuucp.a -.else -LIBUUCP= $(.CURDIR)/../libuucp/libuucp.a -.endif - -VERSION= 1.06.1 -owner= uucp -group= uucp -bindir= /usr/bin -sbindir= /usr/sbin -libxdir= /usr/libexec/uucp - -# The directory to look in for new style configuration files (when -# using HAVE_TAYLOR_CONFIG). -newconfigdir= /etc/uucp - -# The directory to look in for BNU (when using HAVE_BNU_CONFIG) or -# V2 (when using HAVE_V2_CONFIG) style configuration files. -oldconfigdir= /etc/uucp diff --git a/gnu/libexec/uucp/common_sources/chat.c b/gnu/libexec/uucp/common_sources/chat.c deleted file mode 100644 index 589cc7da9121..000000000000 --- a/gnu/libexec/uucp/common_sources/chat.c +++ /dev/null @@ -1,1466 +0,0 @@ -/* chat.c - Chat routine for the UUCP package. - - Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char chat_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "prot.h" -#include "system.h" - -/* Local functions. */ - -static int icexpect P((struct sconnection *qconn, int cstrings, - char **azstrings, size_t *aclens, - int ctimeout, boolean fstrip)); -static boolean fcsend P((struct sconnection *qconn, pointer puuconf, - const char *zsend, - const struct uuconf_system *qsys, - const struct uuconf_dialer *qdial, - const char *zphone, - boolean ftranslate, boolean fstrip)); -static boolean fcecho_send_strip P((struct sconnection *qconn, - const char *z, size_t clen)); -static boolean fcecho_send_nostrip P((struct sconnection *qconn, - const char *z, size_t clen)); -static boolean fcecho_send P((struct sconnection *qconn, const char *z, - size_t clen, boolean fstrip)); -static boolean fcphone P((struct sconnection *qconn, - pointer puuconf, - const struct uuconf_dialer *qdial, - const char *zphone, - boolean (*pfwrite) P((struct sconnection *qc, - const char *zwrite, - size_t cwrite)), - boolean ftranslate, boolean *pfquote)); -static boolean fctranslate P((pointer puuconf, const char *zphone, - const char **pzprefix, - const char **pzsuffix)); -static boolean fcprogram P((struct sconnection *qconn, pointer puuconf, - char **pzprogram, - const struct uuconf_system *qsys, - const struct uuconf_dialer *qdial, - const char *zphone, const char *zport, - long ibaud)); - -/* Run a chat script with the other system. The chat script is a - series of expect send pairs. We wait for the expect string to show - up, and then we send the send string. The chat string for a system - holds the expect and send strings separated by a single space. */ - -boolean -fchat (qconn, puuconf, qchat, qsys, qdial, zphone, ftranslate, zport, ibaud) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_chat *qchat; - const struct uuconf_system *qsys; - const struct uuconf_dialer *qdial; - const char *zphone; - boolean ftranslate; - const char *zport; - long ibaud; -{ - int cstrings; - char **azstrings; - size_t *aclens; - char **pzchat; - char *zbuf; - size_t cbuflen; - boolean fret; - int i; - - /* First run the program, if any. */ - if (qchat->uuconf_pzprogram != NULL) - { - if (! fcprogram (qconn, puuconf, qchat->uuconf_pzprogram, qsys, qdial, - zphone, zport, ibaud)) - return FALSE; - } - - /* If there's no chat script, we're done. */ - if (qchat->uuconf_pzchat == NULL) - return TRUE; - - if (qchat->uuconf_pzfail == NULL) - { - cstrings = 1; - azstrings = (char **) xmalloc (sizeof (char *)); - aclens = (size_t *) xmalloc (sizeof (size_t)); - } - else - { - char **pz; - - /* We leave string number 0 for the chat script. */ - cstrings = 1; - for (pz = qchat->uuconf_pzfail; *pz != NULL; pz++) - ++cstrings; - - azstrings = (char **) xmalloc (cstrings * sizeof (char *)); - aclens = (size_t *) xmalloc (cstrings * sizeof (size_t)); - - /* Get the strings into the array, and handle all the escape - characters. */ - for (cstrings = 1, pz = qchat->uuconf_pzfail; - *pz != NULL; - cstrings++, pz++) - { - azstrings[cstrings] = zbufcpy (*pz); - aclens[cstrings] = cescape (azstrings[cstrings]); - } - } - - cbuflen = 0; - zbuf = NULL; - fret = TRUE; - - pzchat = qchat->uuconf_pzchat; - - while (*pzchat != NULL) - { - size_t clen; - - /* Loop over subexpects and subsends. */ - while (TRUE) - { - char *ztimeout; - int ctimeout; - - /* Copy the expect string into the buffer so that we can - modify it in cescape. */ - clen = strlen (*pzchat); - if (clen >= cbuflen) - { - ubuffree (zbuf); - zbuf = zbufalc (clen + 1); - cbuflen = clen; - } - memcpy (zbuf, *pzchat, clen + 1); - - azstrings[0] = zbuf; - if (azstrings[0][0] == '-') - ++azstrings[0]; - - /* \Wnum at the end of the string is a timeout. */ - ctimeout = qchat->uuconf_ctimeout; - ztimeout = strrchr (azstrings[0], '\\'); - if (ztimeout != NULL && ztimeout[1] == 'W') - { - char *zend; - int cval; - - cval = (int) strtol (ztimeout + 2, &zend, 10); - if (zend != ztimeout + 2 && *zend == '\0') - { - ctimeout = cval; - *ztimeout = '\0'; - } - } - - aclens[0] = cescape (azstrings[0]); - - if (aclens[0] == 0 - || (aclens[0] == 2 - && strcmp (azstrings[0], "\"\"") == 0)) - { - /* There is no subexpect sequence. If there is a - subsend sequence we move on to it. Otherwise we let - this expect succeed. This is somewhat inconsistent, - but it seems to be the traditional approach. */ - if (pzchat[1] == NULL || pzchat[1][0] != '-') - break; - } - else - { - int istr; - - istr = icexpect (qconn, cstrings, azstrings, aclens, - ctimeout, qchat->uuconf_fstrip); - - /* If we found the string, break out of the - subexpect/subsend loop. */ - if (istr == 0) - break; - - /* If we got an error, return FALSE. */ - if (istr < -1) - { - fret = FALSE; - break; - } - - /* If we found a failure string, log it and get out. */ - if (istr > 0) - { - ulog (LOG_ERROR, "Chat script failed: Got \"%s\"", - qchat->uuconf_pzfail[istr - 1]); - fret = FALSE; - break; - } - - /* We timed out; look for a send subsequence. If none, - the chat script has failed. */ - if (pzchat[1] == NULL || pzchat[1][0] != '-') - { - ulog (LOG_ERROR, "Timed out in chat script"); - fret = FALSE; - break; - } - } - - /* Send the send subsequence without the leading '-'. A - \"\" will send nothing. An empty string will send a - carriage return. */ - ++pzchat; - if (! fcsend (qconn, puuconf, *pzchat + 1, qsys, qdial, zphone, - ftranslate, qchat->uuconf_fstrip)) - { - fret = FALSE; - break; - } - - /* If there is no expect subsequence, we are done. */ - if (pzchat[1] == NULL || pzchat[1][0] != '-') - break; - - /* Move on to next expect subsequence. */ - ++pzchat; - } - - if (! fret) - break; - - /* Move on to the send string. If there is none, we have - succeeded. */ - do - { - ++pzchat; - } - while (*pzchat != NULL && (*pzchat)[0] == '-'); - - if (*pzchat == NULL) - break; - - if (**pzchat != '\0') - { - if (! fcsend (qconn, puuconf, *pzchat, qsys, qdial, zphone, - ftranslate, qchat->uuconf_fstrip)) - { - fret = FALSE; - break; - } - } - - ++pzchat; - } - - ubuffree (zbuf); - for (i = 1; i < cstrings; i++) - ubuffree (azstrings[i]); - xfree ((pointer) azstrings); - xfree ((pointer) aclens); - - return fret; -} - -/* Read characters and wait for one of a set of memory strings to come - in. This returns the index into the array of the string that - arrives, or -1 on timeout, or -2 on error. */ - -static int -icexpect (qconn, cstrings, azstrings, aclens, ctimeout, fstrip) - struct sconnection *qconn; - int cstrings; - char **azstrings; - size_t *aclens; - int ctimeout; - boolean fstrip; -{ - int i; - size_t cmax; - char *zhave; - size_t chave; - long iendtime; -#if DEBUG > 1 - int cchars; - int iolddebug; -#endif - - cmax = aclens[0]; - for (i = 1; i < cstrings; i++) - if (cmax < aclens[i]) - cmax = aclens[i]; - - zhave = zbufalc (cmax); - chave = 0; - - iendtime = ixsysdep_time ((long *) NULL) + ctimeout; - -#if DEBUG > 1 - cchars = 0; - iolddebug = iDebug; - if (FDEBUGGING (DEBUG_CHAT)) - { - udebug_buffer ("icexpect: Looking for", azstrings[0], - aclens[0]); - ulog (LOG_DEBUG_START, "icexpect: Got \""); - iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT); - } -#endif - - while (TRUE) - { - int bchar; - - /* If we have no more time, get out. */ - if (ctimeout <= 0) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_END, "\" (timed out)"); - iDebug = iolddebug; - } -#endif - ubuffree (zhave); - return -1; - } - - /* Read one character at a time. We could use a more complex - algorithm to read in larger batches, but it's probably not - worth it. If the buffer is full, shift it left; we already - know that no string matches, and the buffer holds the largest - string, so this can't lose a match. */ - if (chave >= cmax) - { - size_t imove; - - for (imove = 0; imove < cmax - 1; imove++) - zhave[imove] = zhave[imove + 1]; - --chave; - } - - /* The timeout/error return values from breceive_char are the - same as for this function. */ - bchar = breceive_char (qconn, ctimeout, TRUE); - if (bchar < 0) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - /* If there was an error, it will probably be logged in - the middle of our string, but this is only debugging - so it's not a big deal. */ - ulog (LOG_DEBUG_END, "\" (%s)", - bchar == -1 ? "timed out" : "error"); - iDebug = iolddebug; - } -#endif - ubuffree (zhave); - return bchar; - } - - /* Strip the parity bit if desired. */ - if (fstrip) - bchar &= 0x7f; - - zhave[chave] = (char) bchar; - ++chave; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - char ab[5]; - - ++cchars; - if (cchars > 60) - { - ulog (LOG_DEBUG_END, "\""); - ulog (LOG_DEBUG_START, "icexpect: Got \""); - cchars = 0; - } - (void) cdebug_char (ab, bchar); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } -#endif - - /* See if any of the strings can be found in the buffer. Since - we read one character at a time, the string can only be found - at the end of the buffer. */ - for (i = 0; i < cstrings; i++) - { - if (aclens[i] <= chave - && memcmp (zhave + chave - aclens[i], azstrings[i], - aclens[i]) == 0) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - if (i == 0) - ulog (LOG_DEBUG_END, "\" (found it)"); - else - { - ulog (LOG_DEBUG_END, "\""); - udebug_buffer ("icexpect: Found", azstrings[i], - aclens[i]); - } - iDebug = iolddebug; - } -#endif - ubuffree (zhave); - return i; - } - } - - ctimeout = (int) (iendtime - ixsysdep_time ((long *) NULL)); - } -} - -#if DEBUG > 1 - -/* Debugging function for fcsend. This takes the fquote variable, the - length of the string (0 if this an informational string which can - be printed directly) and the string itself. It returns the new - value for fquote. The fquote variable is TRUE if the debugging - output is in the middle of a quoted string. */ - -static size_t cCsend_chars; -static int iColddebug; - -static boolean fcsend_debug P((boolean, size_t, const char *)); - -static boolean -fcsend_debug (fquote, clen, zbuf) - boolean fquote; - size_t clen; - const char *zbuf; -{ - size_t cwas; - - if (! FDEBUGGING (DEBUG_CHAT)) - return TRUE; - - cwas = cCsend_chars; - if (clen > 0) - cCsend_chars += clen; - else - cCsend_chars += strlen (zbuf); - if (cCsend_chars > 60 && cwas > 10) - { - ulog (LOG_DEBUG_END, "%s", fquote ? "\"" : ""); - fquote = FALSE; - ulog (LOG_DEBUG_START, "fcsend: Writing"); - cCsend_chars = 0; - } - - if (clen == 0) - { - ulog (LOG_DEBUG_CONTINUE, "%s %s", fquote ? "\"" : "", zbuf); - return FALSE; - } - else - { - int i; - - if (! fquote) - ulog (LOG_DEBUG_CONTINUE, " \""); - for (i = 0; i < clen; i++) - { - char ab[5]; - - (void) cdebug_char (ab, zbuf[i]); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } - - return TRUE; - } -} - -/* Finish up the debugging information for fcsend. */ - -static void ucsend_debug_end P((boolean, boolean)); - -static void -ucsend_debug_end (fquote, ferr) - boolean fquote; - boolean ferr; -{ - if (! FDEBUGGING (DEBUG_CHAT)) - return; - - if (fquote) - ulog (LOG_DEBUG_CONTINUE, "\""); - - if (ferr) - ulog (LOG_DEBUG_CONTINUE, " (error)"); - - ulog (LOG_DEBUG_END, "%s", ""); - - iDebug = iColddebug; -} - -#else /* DEBUG <= 1 */ - -/* Use macro definitions to make fcsend look neater. */ - -#define fcsend_debug(fquote, clen, zbuf) TRUE - -#define ucsend_debug_end(fquote, ferror) - -#endif /* DEBUG <= 1 */ - -/* Send a string out. This has to parse escape sequences as it goes. - Note that it handles the dialer escape sequences (\e, \E, \D, \T) - although they make no sense for chatting with a system. */ - -static boolean -fcsend (qconn, puuconf, z, qsys, qdial, zphone, ftranslate, fstrip) - struct sconnection *qconn; - pointer puuconf; - const char *z; - const struct uuconf_system *qsys; - const struct uuconf_dialer *qdial; - const char *zphone; - boolean ftranslate; - boolean fstrip; -{ - boolean fnocr; - boolean (*pfwrite) P((struct sconnection *, const char *, size_t)); - char *zcallout_login; - char *zcallout_pass; - boolean fquote; - - if (strcmp (z, "\"\"") == 0) - return TRUE; - - fnocr = FALSE; - pfwrite = fconn_write; - zcallout_login = NULL; - zcallout_pass = NULL; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_START, "fcsend: Writing"); - fquote = FALSE; - cCsend_chars = 0; - iColddebug = iDebug; - iDebug &=~ (DEBUG_OUTGOING | DEBUG_PORT); - } -#endif - - while (*z != '\0') - { - const char *zlook; - boolean fsend; - char bsend; - - zlook = z + strcspn ((char *) z, "\\BE"); - - if (zlook > z) - { - size_t c; - - c = zlook - z; - fquote = fcsend_debug (fquote, c, z); - if (! (*pfwrite) (qconn, z, c)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - } - - if (*zlook == '\0') - break; - - z = zlook; - - fsend = FALSE; - switch (*z) - { - case 'B': - if (strncmp (z, "BREAK", 5) == 0) - { - fquote = fcsend_debug (fquote, (size_t) 0, "break"); - if (! fconn_break (qconn)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - fnocr = TRUE; - z += 5; - } - else - { - fsend = TRUE; - bsend = 'B'; - ++z; - } - break; - case 'E': - if (strncmp (z, "EOT", 3) == 0) - { - fsend = TRUE; - bsend = '\004'; - fnocr = TRUE; - z += 3; - } - else - { - fsend = TRUE; - bsend = 'E'; - ++z; - } - break; - case '\\': - ++z; - switch (*z) - { - case '-': - fsend = TRUE; - bsend = '-'; - break; - case 'b': - fsend = TRUE; - bsend = '\b'; - break; - case 'c': - fnocr = TRUE; - break; - case 'd': - fquote = fcsend_debug (fquote, (size_t) 0, "sleep"); - usysdep_sleep (1); - break; - case 'e': - fquote = fcsend_debug (fquote, (size_t) 0, "echo-check-off"); - pfwrite = fconn_write; - break; - case 'E': - fquote = fcsend_debug (fquote, (size_t) 0, "echo-check-on"); - if (fstrip) - pfwrite = fcecho_send_strip; - else - pfwrite = fcecho_send_nostrip; - break; - case 'K': - fquote = fcsend_debug (fquote, (size_t) 0, "break"); - if (! fconn_break (qconn)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - break; - case 'n': - fsend = TRUE; - bsend = '\n'; - break; - case 'N': - fsend = TRUE; - bsend = '\0'; - break; - case 'p': - fquote = fcsend_debug (fquote, (size_t) 0, "pause"); - usysdep_pause (); - break; - case 'r': - fsend = TRUE; - bsend = '\r'; - break; - case 's': - fsend = TRUE; - bsend = ' '; - break; - case 't': - fsend = TRUE; - bsend = '\t'; - break; - case '\0': - --z; - /* Fall through. */ - case '\\': - fsend = TRUE; - bsend = '\\'; - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - fsend = TRUE; - bsend = *z - '0'; - if (z[1] >= '0' && z[1] <= '7') - bsend = (char) (8 * bsend + *++z - '0'); - if (z[1] >= '0' && z[1] <= '7') - bsend = (char) (8 * bsend + *++z - '0'); - break; - case 'x': - fsend = TRUE; - bsend = 0; - while (isxdigit (BUCHAR (z[1]))) - { - if (isdigit (BUCHAR (z[1]))) - bsend = (char) (16 * bsend + *++z - '0'); - else if (isupper (BUCHAR (z[1]))) - bsend = (char) (16 * bsend + *++z - 'A' + 10); - else - bsend = (char) (16 * bsend + *++z - 'a' + 10); - } - break; - case 'L': - { - const char *zlog; - char *zcopy; - size_t clen; - - if (qsys == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\L"); - return FALSE; - } - zlog = qsys->uuconf_zcall_login; - if (zlog == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "No login defined"); - return FALSE; - } - if (zlog[0] == '*' && zlog[1] == '\0') - { - if (zcallout_login == NULL) - { - int iuuconf; - - iuuconf = uuconf_callout (puuconf, qsys, - &zcallout_login, - &zcallout_pass); - if (iuuconf == UUCONF_NOT_FOUND - || zcallout_login == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "No login defined"); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ucsend_debug_end (fquote, TRUE); - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - } - zlog = zcallout_login; - } - zcopy = zbufcpy (zlog); - clen = cescape (zcopy); - fquote = fcsend_debug (fquote, (size_t) 0, "login"); - fquote = fcsend_debug (fquote, clen, zcopy); - if (! (*pfwrite) (qconn, zcopy, clen)) - { - ubuffree (zcopy); - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - ubuffree (zcopy); - } - break; - case 'P': - { - const char *zpass; - char *zcopy; - size_t clen; - - if (qsys == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\P"); - return FALSE; - } - zpass = qsys->uuconf_zcall_password; - if (zpass == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "No password defined"); - return FALSE; - } - if (zpass[0] == '*' && zpass[1] == '\0') - { - if (zcallout_pass == NULL) - { - int iuuconf; - - iuuconf = uuconf_callout (puuconf, qsys, - &zcallout_login, - &zcallout_pass); - if (iuuconf == UUCONF_NOT_FOUND - || zcallout_pass == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "No password defined"); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ucsend_debug_end (fquote, TRUE); - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - } - zpass = zcallout_pass; - } - zcopy = zbufcpy (zpass); - clen = cescape (zcopy); - fquote = fcsend_debug (fquote, (size_t) 0, "password"); - fquote = fcsend_debug (fquote, clen, zcopy); - if (! (*pfwrite) (qconn, zcopy, clen)) - { - ubuffree (zcopy); - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - ubuffree (zcopy); - } - break; - case 'D': - if (qdial == NULL || zphone == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\D"); - return FALSE; - } - fquote = fcsend_debug (fquote, (size_t) 0, "\\D"); - if (! fcphone (qconn, puuconf, qdial, zphone, pfwrite, - ftranslate, &fquote)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - break; - case 'T': - if (qdial == NULL || zphone == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\T"); - return FALSE; - } - fquote = fcsend_debug (fquote, (size_t) 0, "\\T"); - if (! fcphone (qconn, puuconf, qdial, zphone, pfwrite, TRUE, - &fquote)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - break; - case 'M': - if (qdial == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\M"); - return FALSE; - } - fquote = fcsend_debug (fquote, (size_t) 0, "ignore-carrier"); - if (! fconn_carrier (qconn, FALSE)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - break; - case 'm': - if (qdial == NULL) - { - ucsend_debug_end (fquote, TRUE); - ulog (LOG_ERROR, "Illegal use of \\m"); - return FALSE; - } - if (qdial->uuconf_fcarrier) - { - fquote = fcsend_debug (fquote, (size_t) 0, "need-carrier"); - if (! fconn_carrier (qconn, TRUE)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - } - break; - default: - /* This error message will screw up any debugging - information, but it's easily avoidable. */ - ulog (LOG_ERROR, - "Unrecognized escape sequence \\%c in send string", - *z); - fsend = TRUE; - bsend = *z; - break; - } - ++z; - break; -#if DEBUG > 0 - default: - ulog (LOG_FATAL, "fcsend: Can't happen"); - break; -#endif - } - - if (fsend) - { - fquote = fcsend_debug (fquote, (size_t) 1, &bsend); - if (! (*pfwrite) (qconn, &bsend, (size_t) 1)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - } - } - - xfree ((pointer) zcallout_login); - xfree ((pointer) zcallout_pass); - - /* Output a final carriage return, unless there was a \c. Don't - bother to check for an echo. */ - if (! fnocr) - { - char b; - - b = '\r'; - fquote = fcsend_debug (fquote, (size_t) 1, &b); - if (! fconn_write (qconn, &b, (size_t) 1)) - { - ucsend_debug_end (fquote, TRUE); - return FALSE; - } - } - - ucsend_debug_end (fquote, FALSE); - - return TRUE; -} - -/* Write out a phone number with optional dialcode translation. The - pfquote argument is only used for debugging. */ - -static boolean -fcphone (qconn, puuconf, qdial, zphone, pfwrite, ftranslate, pfquote) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_dialer *qdial; - const char *zphone; - boolean (*pfwrite) P((struct sconnection *qc, const char *zwrite, - size_t cwrite)); - boolean ftranslate; - boolean *pfquote; -{ - const char *zprefix, *zsuffix; - - if (ftranslate) - { - if (! fctranslate (puuconf, zphone, &zprefix, &zsuffix)) - return FALSE; - } - else - { - zprefix = zphone; - zsuffix = NULL; - } - - while (zprefix != NULL) - { - while (TRUE) - { - const char *z; - const char *zstr; - - z = zprefix + strcspn ((char *) zprefix, "=-"); - if (z > zprefix) - { - size_t clen; - - clen = z - zprefix; - *pfquote = fcsend_debug (*pfquote, clen, zprefix); - if (! (*pfwrite) (qconn, zprefix, clen)) - return FALSE; - } - - if (*z == '=') - zstr = qdial->uuconf_zdialtone; - else if (*z == '-') - zstr = qdial->uuconf_zpause; - else /* *z == '\0' */ - break; - - if (zstr != NULL) - { - *pfquote = fcsend_debug (*pfquote, strlen (zstr), zstr); - if (! (*pfwrite) (qconn, zstr, strlen (zstr))) - return FALSE; - } - - zprefix = z + 1; - } - - zprefix = zsuffix; - zsuffix = NULL; - } - - return TRUE; -} - -/* Given a phone number, run it through dial code translation - returning two strings. */ - -static boolean -fctranslate (puuconf, zphone, pzprefix, pzsuffix) - pointer puuconf; - const char *zphone; - const char **pzprefix; - const char **pzsuffix; -{ - int iuuconf; - char *zdialcode, *zto; - const char *zfrom; - char *ztrans; - - *pzprefix = zphone; - *pzsuffix = NULL; - - zdialcode = zbufalc (strlen (zphone) + 1); - zfrom = zphone; - zto = zdialcode; - while (*zfrom != '\0' && isalpha (BUCHAR (*zfrom))) - *zto++ = *zfrom++; - *zto = '\0'; - - if (*zdialcode == '\0') - { - ubuffree (zdialcode); - return TRUE; - } - - iuuconf = uuconf_dialcode (puuconf, zdialcode, &ztrans); - - ubuffree (zdialcode); - - if (iuuconf == UUCONF_NOT_FOUND) - return TRUE; - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - else - { - /* We really should figure out a way to free up ztrans here. */ - *pzprefix = ztrans; - *pzsuffix = zfrom; - return TRUE; - } -} - -/* Write out a string making sure the each character is echoed back. - There are two versions of this function, one which strips the - parity bit from the characters and one which does not. This is so - that I can use a single function pointer in fcsend, and to avoid - using any static variables so that I can put chat scripts in a - library some day. */ - -static boolean -fcecho_send_strip (qconn, zwrite, cwrite) - struct sconnection *qconn; - const char *zwrite; - size_t cwrite; -{ - return fcecho_send (qconn, zwrite, cwrite, TRUE); -} - -static boolean -fcecho_send_nostrip (qconn, zwrite, cwrite) - struct sconnection *qconn; - const char *zwrite; - size_t cwrite; -{ - return fcecho_send (qconn, zwrite, cwrite, FALSE); -} - -static boolean -fcecho_send (qconn, zwrite, cwrite, fstrip) - struct sconnection *qconn; - const char *zwrite; - size_t cwrite; - boolean fstrip; -{ - const char *zend; - - zend = zwrite + cwrite; - - for (; zwrite < zend; zwrite++) - { - int b; - char bwrite; - - bwrite = *zwrite; - if (! fconn_write (qconn, &bwrite, (size_t) 1)) - return FALSE; - if (fstrip) - bwrite &= 0x7f; - do - { - /* We arbitrarily wait five seconds for the echo. */ - b = breceive_char (qconn, 5, TRUE); - /* Now b == -1 on timeout, -2 on error. */ - if (b < 0) - { - if (b == -1) - ulog (LOG_ERROR, "Character not echoed"); - return FALSE; - } - if (fstrip) - b &= 0x7f; - } - while (b != BUCHAR (bwrite)); - } - - return TRUE; -} - -/* Run a chat program. Expand any escape sequences and call a system - dependent program to run it. */ - -static boolean -fcprogram (qconn, puuconf, pzprogram, qsys, qdial, zphone, zport, ibaud) - struct sconnection *qconn; - pointer puuconf; - char **pzprogram; - const struct uuconf_system *qsys; - const struct uuconf_dialer *qdial; - const char *zphone; - const char *zport; - long ibaud; -{ - size_t cargs; - char **pzpass, **pzarg; - char **pz; - char *zcallout_login; - char *zcallout_pass; - boolean fret; - - cargs = 1; - for (pz = pzprogram; *pz != NULL; pz++) - ++cargs; - - pzpass = (char **) xmalloc (cargs * sizeof (char *)); - - zcallout_login = NULL; - zcallout_pass = NULL; - fret = TRUE; - - /* Copy the string into memory expanding escape sequences. */ - for (pz = pzprogram, pzarg = pzpass; *pz != NULL; pz++, pzarg++) - { - const char *zfrom; - size_t calc, clen; - char *zto; - - if (strchr (*pz, '\\') == NULL) - { - *pzarg = zbufcpy (*pz); - continue; - } - - *pzarg = NULL; - zto = NULL; - calc = 0; - clen = 0; - - for (zfrom = *pz; *zfrom != '\0'; zfrom++) - { - const char *zadd = NULL; - char *zfree = NULL; - size_t cadd; - char abadd[15]; - - if (*zfrom != '\\') - { - if (clen + 2 > calc) - { - char *znew; - - calc = clen + 50; - znew = zbufalc (calc); - memcpy (znew, *pzarg, clen); - ubuffree (*pzarg); - *pzarg = znew; - zto = znew + clen; - } - *zto++ = *zfrom; - ++clen; - continue; - } - - ++zfrom; - switch (*zfrom) - { - case '\0': - --zfrom; - /* Fall through. */ - case '\\': - zadd = "\\"; - break; - case 'L': - { - const char *zlog; - - if (qsys == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\L"); - fret = FALSE; - break; - } - zlog = qsys->uuconf_zcall_login; - if (zlog == NULL) - { - ulog (LOG_ERROR, "chat-program: No login defined"); - fret = FALSE; - break; - } - if (zlog[0] == '*' && zlog[1] == '\0') - { - if (zcallout_login == NULL) - { - int iuuconf; - - iuuconf = uuconf_callout (puuconf, qsys, - &zcallout_login, - &zcallout_pass); - if (iuuconf == UUCONF_NOT_FOUND - || zcallout_login == NULL) - { - ulog (LOG_ERROR, - "chat-program: No login defined"); - fret = FALSE; - break; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - break; - } - } - zlog = zcallout_login; - } - zfree = zbufcpy (zlog); - (void) cescape (zfree); - zadd = zfree; - } - break; - case 'P': - { - const char *zpass; - - if (qsys == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\P"); - fret = FALSE; - break; - } - zpass = qsys->uuconf_zcall_password; - if (zpass == NULL) - { - ulog (LOG_ERROR, "chat-program: No password defined"); - fret = FALSE; - break; - } - if (zpass[0] == '*' && zpass[1] == '\0') - { - if (zcallout_pass == NULL) - { - int iuuconf; - - iuuconf = uuconf_callout (puuconf, qsys, - &zcallout_login, - &zcallout_pass); - if (iuuconf == UUCONF_NOT_FOUND - || zcallout_pass == NULL) - { - ulog (LOG_ERROR, - "chat-program: No password defined"); - fret = FALSE; - break; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - break; - } - } - zpass = zcallout_pass; - } - zfree = zbufcpy (zpass); - (void) cescape (zfree); - zadd = zfree; - } - break; - case 'D': - if (qdial == NULL || zphone == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\D"); - fret = FALSE; - break; - } - zadd = zphone; - break; - case 'T': - { - const char *zprefix, *zsuffix; - - if (qdial == NULL || zphone == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\T"); - fret = FALSE; - break; - } - - if (! fctranslate (puuconf, zphone, &zprefix, &zsuffix)) - { - fret = FALSE; - break; - } - - if (zsuffix == NULL) - zadd = zprefix; - else - { - size_t cprefix; - - cprefix = strlen (zprefix); - if (clen + cprefix + 1 > calc) - { - char *znew; - - calc = clen + cprefix + 20; - znew = zbufalc (calc); - memcpy (znew, *pzarg, clen); - ubuffree (*pzarg); - *pzarg = znew; - zto = znew + clen; - } - memcpy (zto, zprefix, cprefix); - zto += cprefix; - clen += cprefix; - zadd = zsuffix; - } - } - break; - case 'Y': - if (zLdevice == NULL && zport == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\Y"); - fret = FALSE; - break; - } - /* zLdevice will generally make more sense than zport, but - it might not be set yet. */ - zadd = zLdevice; - if (zadd == NULL) - zadd = zport; - break; - case 'Z': - if (qsys == NULL) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\Z"); - fret = FALSE; - break; - } - zadd = qsys->uuconf_zname; - break; - case 'S': - { - if (ibaud == 0) - { - ulog (LOG_ERROR, "chat-program: Illegal use of \\S"); - fret = FALSE; - break; - } - sprintf (abadd, "%ld", ibaud); - zadd = abadd; - } - break; - default: - { - ulog (LOG_ERROR, - "chat-program: Unrecognized escape sequence \\%c", - *zfrom); - abadd[0] = *zfrom; - abadd[1] = '\0'; - zadd = abadd; - } - break; - } - - if (! fret) - break; - - cadd = strlen (zadd); - if (clen + cadd + 1 > calc) - { - char *znew; - - calc = clen + cadd + 20; - znew = zbufalc (calc); - memcpy (znew, *pzarg, clen); - ubuffree (*pzarg); - *pzarg = znew; - zto = znew + clen; - } - memcpy (zto, zadd, cadd + 1); - zto += cadd; - clen += cadd; - ubuffree (zfree); - } - - if (! fret) - break; - - *zto++ = '\0'; - ++clen; - } - - *pzarg = NULL; - - if (fret) - fret = fconn_run_chat (qconn, pzpass); - - for (pz = pzpass; *pz != NULL; pz++) - ubuffree (*pz); - xfree ((pointer) pzpass); - xfree ((pointer) zcallout_login); - xfree ((pointer) zcallout_pass); - - return fret; -} diff --git a/gnu/libexec/uucp/common_sources/config.h b/gnu/libexec/uucp/common_sources/config.h deleted file mode 100644 index 504d011554fd..000000000000 --- a/gnu/libexec/uucp/common_sources/config.h +++ /dev/null @@ -1,481 +0,0 @@ -/* config.h. Generated automatically by configure. */ -/* Configuration header file for Taylor UUCP. -*- C -*- */ - -/* $FreeBSD$ */ - -/* If your compiler does not use const correctly, then undefine it - here. This #undef is commented out by the configure script if it - determines that const is supported. */ -/* #undef const */ - -/* If your compiler supports prototypes, set HAVE_PROTOTYPES to 1. */ -#define HAVE_PROTOTYPES 1 - -/* Set ECHO_PROGRAM to a program which echoes its arguments; if echo - is a shell builtin you can just use "echo". */ -#define ECHO_PROGRAM "echo" - -/* The following macros indicate what header files you have. Set the - macro to 1 if you have the corresponding header file, or 0 if you - do not. */ -#define HAVE_STDDEF_H 1 /* */ -#define HAVE_STDARG_H 1 /* */ -#define HAVE_STRING_H 1 /* */ -#define HAVE_STRINGS_H 1 /* */ -#define HAVE_UNISTD_H 1 /* */ -#define HAVE_STDLIB_H 1 /* */ -#define HAVE_LIMITS_H 1 /* */ -#define HAVE_TIME_H 1 /* */ -#define HAVE_SYS_WAIT_H 1 /* */ -#define HAVE_SYS_IOCTL_H 1 /* */ -#define HAVE_DIRENT_H 1 /* */ -#define HAVE_MEMORY_H 1 /* */ -#define HAVE_TERMIOS_H 1 /* */ -#define HAVE_SYS_PARAM_H 1 /* */ -#define HAVE_UTIME_H 1 /* */ -#define HAVE_FCNTL_H 1 /* */ -#define HAVE_SYS_FILE_H 1 /* */ -#define HAVE_SYS_TIME_H 1 /* */ -#define HAVE_SYS_TIMES_H 1 /* */ -#define HAVE_LIBC_H 0 /* */ -#define HAVE_SYSEXITS_H 1 /* */ -#define HAVE_POLL_H 0 /* */ -#define HAVE_TIUSER_H 0 /* */ -#define HAVE_XTI_H 0 /* */ -#define HAVE_SYS_TLI_H 0 /* */ -#define HAVE_STROPTS_H 0 /* */ -#define HAVE_FTW_H 0 /* */ -#define HAVE_GLOB_H 1 /* */ -#define HAVE_SYS_SELECT_H 0 /* */ -#define HAVE_SYS_TYPES_TCP_H 0 /* */ -#define HAVE_SYS_MOUNT_H 1 /* */ -#define HAVE_SYS_VFS_H 0 /* */ -#define HAVE_SYS_FILSYS_H 0 /* */ -#define HAVE_SYS_STATFS_H 0 /* */ -#define HAVE_SYS_DUSTAT_H 0 /* */ -#define HAVE_SYS_FS_TYPES_H 0 /* */ -#define HAVE_USTAT_H 0 /* */ -#define HAVE_SYS_STATVFS_H 0 /* */ - -/* If major and minor are not defined in , but are in - , set MAJOR_IN_MKDEV to 1. If they are in - , set MAJOR_IN_SYSMACROS to 1. */ -#define MAJOR_IN_MKDEV 0 -#define MAJOR_IN_SYSMACROS 0 - -/* If the macro offsetof is not defined in , you may give it - a definition here. If you do not, the code will use a definition - (in uucp.h) that should be fairly portable. */ -/* #define offsetof */ - -/* Set RETSIGTYPE to the return type of a signal handler. On newer - systems this will be void; some older systems use int. */ -#define RETSIGTYPE void - -/* If the macro S_ISDIR is defined in , but is incorrect, - define STAT_MACROS_BROKEN to be 1. This is said to be the case on - Tektronix UTekV, Amdahl UTS and Motorola System V/88. */ -#define STAT_MACROS_BROKEN 0 - -/* Set TIME_WITH_SYS_TIME to 1 if and can both - be included in a single source file; if you don't have either or - both of them, it doesn't matter what you set this to. */ -#define TIME_WITH_SYS_TIME 1 - -/* Set TM_IN_SYS_TIME to 1 if struct tm is defined in - rather than in . */ -#define TM_IN_SYS_TIME 0 - -/* Set HAVE_TERMIOS_AND_SYS_IOCTL_H to 1 if and - can both be included in a single source file; if you don't have either - or both of them, it doesn't matter what you set this to. */ -#define HAVE_TERMIOS_AND_SYS_IOCTL_H 1 - -/* If you are configuring by hand, you should set one of the terminal - driver options in policy.h. If you are autoconfiguring, the script - will check whether your system defines CBREAK, which is a terminal - setting; if your system supports CBREAK, and you don't set a terminal - driver in policy.h, the code will assume that you have a BSD style - terminal driver. */ -#define HAVE_CBREAK 1 - -/* The package needs several standard types. If you are using the - configure script, it will look in standard places for these types, - and give default definitions for them here if it doesn't find them. - The default definitions should work on most systems, but you may - want to check them. If you are configuring by hand, you will have - to figure out whether the types are defined on your system, and - what they should be defined to. - - Any type that is not defined on your system should get a macro - definition. The definition should be of the name of the type in - all capital letters. For example, #define PID_T int. If the type - is defined in a standard header file, the macro name should not be - defined. */ - -/* The type pid_t is used to hold a process ID number. It is normally - defined in . This is the type returned by the - functions fork or getpid. Usually int will work fine. */ -/* #undef PID_T */ - -/* The type uid_t is used to hold a user ID number. It is normally - defined in . This is the type returned by the getuid - function. Usually int will work fine. */ -/* #undef UID_T */ - -/* The type gid_t is used to hold a group ID number. It is sometimes - defined in . This is the type returned by the getgid - function. Usually int will work fine. */ -/* #undef GID_T */ - -/* The type off_t is used to hold an offset in a file. It is sometimes - defined in . This is the type of the second argument to - the lseek function. Usually long will work fine. */ -/* #undef OFF_T */ - -/* Set HAVE_SIG_ATOMIC_T_IN_SIGNAL_H if the type sig_atomic_t is defined - in as required by ANSI C. */ -#define HAVE_SIG_ATOMIC_T_IN_SIGNAL_H 1 - -/* Set HAVE_SIG_ATOMIC_T_IN_TYPES_H if the type sig_atomic_t is defined - in . This is ignored if HAVE_SIG_ATOMIC_T_IN_SIGNAL_H is - set to 1. */ -#define HAVE_SIG_ATOMIC_T_IN_TYPES_H 0 - -/* The type sig_atomic_t is used to hold a value which may be - referenced in a single atomic operation. If it is not defined in - either or , you may want to give it a - definition here. If you don't, the code will use char. If your - compiler does not support sig_atomic_t, there is no type which is - really correct; fortunately, for this package it does not really - matter very much. */ -/* #undef SIG_ATOMIC_T */ - -/* Set HAVE_SIZE_T_IN_STDDEF_H to 1 if the type size_t is defined in - as required by ANSI C. */ -#define HAVE_SIZE_T_IN_STDDEF_H 1 - -/* Set HAVE_SIZE_T_IN_TYPES_H to 1 if the type size_t is defined in - . This is ignored if HAVE_SIZE_T_IN_STDDEF_H is set - to 1. */ -#define HAVE_SIZE_T_IN_TYPES_H 1 - -/* The type size_t is used to hold the size of an object. In - particular, an argument of this type is passed as the size argument - to the malloc and realloc functions. If size_t is not defined in - either or , you may want to give it a - definition here. If you don't, the code will use unsigned. */ -/* #undef SIZE_T */ - -/* Set HAVE_TIME_T_IN_TIME_H to 1 if the type time_t is defined in - , as required by the ANSI C standard. */ -#define HAVE_TIME_T_IN_TIME_H 1 - -/* Set HAVE_TIME_T_IN_TYPES_H to 1 if the type time_t is defined in - . This is ignored if HAVE_TIME_T_IN_TIME_H is set to - 1. */ -#define HAVE_TIME_T_IN_TYPES_H 1 - -/* When Taylor UUCP is talking to another instance of itself, it will - tell the other side the size of a file before it is transferred. - If the package can determine how much disk space is available, it - will use this information to avoid filling up the disk. Define one - of the following macros to tell the code how to determine the - amount of available disk space. It is possible that none of these - are appropriate; it will do no harm to use none of them, but, of - course, nothing will then prevent the package from filling up the - disk. Note that this space check is only useful when talking to - another instance of Taylor UUCP. - - STAT_STATVFS statvfs function - STAT_STATFS3_OSF1 three argument statfs function (OSF/1) - STAT_STATFS2_BSIZE two argument statfs function with f_bsize field - STAT_STATFS2_FSIZE two argument statfs function with f_fsize field - STAT_STATFS2_FS_DATA two argument statfs function with fd_req field - STAT_STATFS4 four argument statfs function - STAT_DISK_SPACE disk_space function (QNX) - STAT_USTAT the ustat function with 512 byte blocks. */ -#define STAT_STATVFS 0 -#define STAT_STATFS3_OSF1 0 -#define STAT_STATFS2_BSIZE 1 -#define STAT_STATFS2_FSIZE 0 -#define STAT_STATFS2_FS_DATA 0 -#define STAT_STATFS4 0 -#define STAT_DISK_SPACE 0 -#define STAT_USTAT 0 - -/* Set HAVE_VOID to 1 if the compiler supports declaring functions with - a return type of void and casting values to void. */ -#define HAVE_VOID 1 - -/* Set HAVE_UNSIGNED_CHAR to 1 if the compiler supports the type unsigned - char. */ -#define HAVE_UNSIGNED_CHAR 1 - -/* Set HAVE_ERRNO_DECLARATION to 1 if errno is declared in . */ -#define HAVE_ERRNO_DECLARATION 1 - -/* Set HAVE_TXADDCD to 1 if TXADDCD is defined in , as it - is on AIX. */ -#define HAVE_TXADDCD 0 - -/* Set HAVE_SOCKADDR_SA_LEN to 1 if struct sockaddr has sa_len member. */ -#define HAVE_SOCKADDR_SA_LEN 1 - -/* There are now a number of functions to check for. For each of - these, the macro HAVE_FUNC should be set to 1 if your system has - FUNC. For example, HAVE_VFPRINTF should be set to 1 if your system - has vfprintf, 0 otherwise. */ - -/* Taylor UUCP will take advantage of the following functions if they - are available, but knows how to deal with their absence. */ -#define HAVE_VFPRINTF 1 -#define HAVE_FTRUNCATE 1 -#define HAVE_LTRUNC 0 -#define HAVE_WAITPID 1 -#define HAVE_WAIT4 1 -#define HAVE_GLOB 1 -#define HAVE_SETREUID 1 -#define HAVE_SETEUID 1 - -/* There are several functions which are replaced in the subdirectory - lib. If they are missing, the configure script will automatically - add them to lib/Makefile to force them to be recompiled. If you - are configuring by hand, you will have to do this yourself. The - string @LIBOBJS@ in lib/Makefile.in should be replaced by a list of - object files in lib/Makefile. The following comments tell you - which object file names to add (they are generally fairly obvious, - given that the file names have no more than six characters before - the period). */ - -/* For each of these functions, if it does not exist, the indicated - object file should be added to lib/Makefile. */ -#define HAVE_BSEARCH 1 /* bsrch.o */ -#define HAVE_GETLINE 0 /* getlin.o */ -#define HAVE_MEMCHR 1 /* memchr.o */ -#define HAVE_STRDUP 1 /* strdup.o */ -#define HAVE_STRSTR 1 /* strstr.o */ -#define HAVE_STRTOL 1 /* strtol.o */ -#define HAVE_STRTOUL 1 /* strtou.o */ - -/* If neither of these functions exists, you should add bzero.o to - lib/Makefile. */ -#define HAVE_BZERO 1 -#define HAVE_MEMSET 1 - -/* If neither of these functions exists, you should add memcmp.o to - lib/Makefile. */ -#define HAVE_MEMCMP 1 -#define HAVE_BCMP 1 - -/* If neither of these functions exists, you should add memcpy.o to - lib/Makefile. */ -#define HAVE_MEMCPY 1 -#define HAVE_BCOPY 1 - -/* If neither of these functions exists, you should add strcas.o to - lib/Makefile. */ -#define HAVE_STRCASECMP 1 -#define HAVE_STRICMP 0 - -/* If neither of these functions exists, you should add strncs.o to - lib/Makefile. */ -#define HAVE_STRNCASECMP 1 -#define HAVE_STRNICMP 0 - -/* If neither of these functions exists, you should add strchr.o to - lib/Makefile. */ -#define HAVE_STRCHR 1 -#define HAVE_INDEX 1 - -/* If neither of these functions exists, you should add strrch.o to - lib/Makefile. */ -#define HAVE_STRRCHR 1 -#define HAVE_RINDEX 1 - -/* If neither of these functions exists, you should add getaddrinfo.o to - lib/Makefile. */ -#define HAVE_GETADDRINFO 1 - -/* There are also Unix specific functions which are replaced in the - subdirectory unix. If they are missing, the configure script will - automatically add them to unix/Makefile to force them to be - recompiled. If you are configuring by hand, you will have to do - this yourself. The string @UNIXOBJS@ in unix/Makefile.in should be - replaced by a list of object files in unix/Makefile. The following - comments tell you which object file names to add. */ - -/* For each of these functions, if it does not exist, the indicated - object file should be added to unix/Makefile. */ -#define HAVE_OPENDIR 1 /* dirent.o */ -#define HAVE_DUP2 1 /* dup2.o */ -#define HAVE_FTW 0 /* ftw.o */ -#define HAVE_REMOVE 1 /* remove.o */ -#define HAVE_RENAME 1 /* rename.o */ -#define HAVE_STRERROR 1 /* strerr.o */ - -/* The code needs to know how to create directories. If you have the - mkdir function, set HAVE_MKDIR to 1 and replace @UUDIR@ in - Makefile.in with '# ' (the configure script will set @UUDIR@ - according to the variable UUDIR). Otherwise, set HAVE_MKDIR to 0, - remove @UUDIR@ from Makefile.in, set MKDIR_PROGRAM to the name of - the program which will create a directory named on the command line - (e.g., "/bin/mkdir"), and add mkdir.o to the @UNIXOBJS@ string in - unix/Makefile.in. */ -#define HAVE_MKDIR 1 -#define MKDIR_PROGRAM unused - -/* The code also needs to know how to remove directories. If you have - the rmdir function, set HAVE_RMDIR to 1. Otherwise, set - RMDIR_PROGRAM to the name of the program which will remove a - directory named on the command line (e.g., "/bin/rmdir") and add - rmdir.o to the @UNIXOBJS@ string in unix/Makefile.in. */ -#define HAVE_RMDIR 1 -#define RMDIR_PROGRAM unused - -/* The code needs to know to how to get the name of the current - directory. If getcwd is available it will be used, otherwise if - getwd is available it will be used. Otherwise, set PWD_PROGRAM to - the name of the program which will print the name of the current - working directory (e.g., "/bin/pwd") and add getcwd.o to the - @UNIXOBJS@ string in unix/Makefile.in. */ -#define HAVE_GETCWD 1 -#define HAVE_GETWD 1 -#define PWD_PROGRAM unused - -/* If you have either sigsetjmp or setret, it will be used instead of - setjmp. These functions will only be used if your system restarts - system calls after interrupts (see HAVE_RESTARTABLE_SYSCALLS, - below). */ -#define HAVE_SIGSETJMP 1 -#define HAVE_SETRET 0 - -/* The code needs to know what function to use to set a signal - handler. If will try to use each of the following functions in - turn. If none are available, it will use signal, which is assumed - to always exist. */ -#define HAVE_SIGACTION 1 -#define HAVE_SIGVEC 1 -#define HAVE_SIGSET 0 - -/* If the code is going to use sigvec (HAVE_SIGACTION is 0 and - HAVE_SIGVEC is 1), then HAVE_SIGVEC_SV_FLAGS must be set to 1 if - the sigvec structure contains the sv_flags field, or 0 if the - sigvec structure contains the sv_onstack field. If the code is not - going to use sigvec, it doesn't matter what this is set to. */ -#define HAVE_SIGVEC_SV_FLAGS 1 - -/* The code will try to use each of the following functions in turn - when blocking signals from delivery. If none are available, a - relatively unimportant race condition will exist. */ -#define HAVE_SIGPROCMASK 1 -#define HAVE_SIGBLOCK 1 -#define HAVE_SIGHOLD 0 - -/* If you have either of the following functions, it will be used to - determine the number of file descriptors which may be open. - Otherwise, the code will use OPEN_MAX if defined, then NOFILE if - defined, then 20. */ -#define HAVE_GETDTABLESIZE 1 -#define HAVE_SYSCONF 1 - -/* The code will use one of the following functions when detaching - from a terminal. One of these must exist. */ -#define HAVE_SETPGRP 1 -#define HAVE_SETSID 1 - -/* If you do not specify the local node name in the main configuration - file, Taylor UUCP will try to use each of the following functions - in turn. If neither is available, you must specify the local node - name in the configuration file. */ -#define HAVE_GETHOSTNAME 1 -#define HAVE_UNAME 1 - -/* The code will try to use each of the following functions in turn to - determine the current time. If none are available, it will use - time, which is assumed to always exist. */ -#define HAVE_GETTIMEOFDAY 1 -#define HAVE_FTIME 0 - -/* If neither gettimeofday nor ftime is available, the code will use - times (if available) to measure a span of time. See also the - discussion of TIMES_TICK in policy.h. */ -#define HAVE_TIMES 1 - -/* When a chat script requests a pause of less than a second with \p, - Taylor UUCP will try to use each of the following functions in - turn. If none are available, it will sleep for a full second. - Also, the (non-portable) tstuu program requires either select or - poll. */ -#define HAVE_NAPMS 0 -#define HAVE_NAP 0 -#define HAVE_USLEEP 1 -#define HAVE_POLL 0 -#define HAVE_SELECT 1 - -/* If the getgrent function is available, it will be used to determine - all the groups a user belongs to when checking file access - permissions. */ -#define HAVE_GETGRENT 1 - -/* If the socket function is available, TCP support code will be - compiled in. */ -#define HAVE_SOCKET 1 - -/* If the t_open function is available, TLI support code will be - compiled in. This may require adding a library, such as -lnsl or - -lxti, to the Makefile variables LIBS. */ -#define HAVE_T_OPEN 0 - -/* If the dev_info function is available (QNX only), it will be used - to determine if any other process has the serial port open, and - that will cause uucico and cu to presume the port is locked. */ -#define HAVE_DEV_INFO 0 - -/* That's the end of the list of the functions. Now there are a few - last miscellaneous items. */ - -/* On some systems the following functions are declared in such a way - that the code cannot make a simple extern. On other systems, these - functions are not declared at all, and the extern is required. If - a declaration of the function, as shown, compiles on your system, - set the value to 1. Not all functions declared externally are - listed here, only the ones with which I have had trouble. */ -/* extern long times (); */ -#define TIMES_DECLARATION_OK 0 -/* extern struct passwd *getpwnam (); */ -#define GETPWNAM_DECLARATION_OK 1 -/* extern struct passwd *getpwuid (); */ -#define GETPWUID_DECLARATION_OK 1 -/* extern struct group *getgrent (); */ -#define GETGRENT_DECLARATION_OK 1 - -/* Set HAVE_BSD_PGRP to 1 if your getpgrp call takes 1 argument and - your setpgrp calls takes 2 arguments (on System V they generally - take no arguments). You can safely set this to 1 on System V, - provided the call will compile without any errors. */ -#define HAVE_BSD_PGRP 0 - -/* Set HAVE_UNION_WAIT to 1 if union wait is defined in the header - file . */ -#define HAVE_UNION_WAIT 1 - -/* Set HAVE_LONG_FILE_NAMES to 1 if the system supports file names - longer than 14 characters. */ -#define HAVE_LONG_FILE_NAMES 1 - -/* If slow system calls are restarted after interrupts, set - HAVE_RESTARTABLE_SYSCALLS to 1. This is ignored if HAVE_SIGACTION - is 1 or if HAVE_SIGVEC is 1 and HAVE_SIGVEC_SV_FLAGS is 1 and - SV_INTERRUPT is defined in . In both of these cases - system calls can be prevented from restarting. */ -#define HAVE_RESTARTABLE_SYSCALLS 1 - -/* Some systems supposedly need the following macros to be defined. - These are handled by the configure script. If you are configuring - by hand, you may add appropriate definitions here, or just add them - to CFLAGS when running make. */ -/* #undef _ALL_SOURCE */ -/* #undef _POSIX_SOURCE */ -/* #undef _MINIX */ -/* #undef _POSIX_1_SOURCE */ diff --git a/gnu/libexec/uucp/common_sources/conn.c b/gnu/libexec/uucp/common_sources/conn.c deleted file mode 100644 index 0ba0202d4fe9..000000000000 --- a/gnu/libexec/uucp/common_sources/conn.c +++ /dev/null @@ -1,587 +0,0 @@ -/* conn.c - Connection routines for the Taylor UUCP package. - - Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char conn_rcsid[] = "$FreeBSD$"; -#endif - -#include - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" - -/* Create a new connection. This relies on system dependent functions - to set the qcmds and psysdep fields. If qport is NULL, it opens a - standard input port, in which case ttype is the type of port to - use. */ - -boolean -fconn_init (qport, qconn, ttype) - struct uuconf_port *qport; - struct sconnection *qconn; - enum uuconf_porttype ttype; -{ - qconn->qport = qport; - switch (qport == NULL ? ttype : qport->uuconf_ttype) - { - case UUCONF_PORTTYPE_STDIN: - return fsysdep_stdin_init (qconn); - case UUCONF_PORTTYPE_MODEM: - return fsysdep_modem_init (qconn); - case UUCONF_PORTTYPE_DIRECT: - return fsysdep_direct_init (qconn); -#if HAVE_TCP - case UUCONF_PORTTYPE_TCP: - return fsysdep_tcp_init (qconn); -#endif -#if HAVE_TLI - case UUCONF_PORTTYPE_TLI: - return fsysdep_tli_init (qconn); -#endif - case UUCONF_PORTTYPE_PIPE: - return fsysdep_pipe_init (qconn); - default: - ulog (LOG_ERROR, "Unknown or unsupported port type"); - return FALSE; - } -} - -/* Connection dispatch routines. */ - -/* Free a connection. */ - -void -uconn_free (qconn) - struct sconnection *qconn; -{ - (*qconn->qcmds->pufree) (qconn); -} - -/* Lock a connection. */ - -boolean -fconn_lock (qconn, fin) - struct sconnection *qconn; - boolean fin; -{ - boolean (*pflock) P((struct sconnection *, boolean)); - - pflock = qconn->qcmds->pflock; - if (pflock == NULL) - return TRUE; - return (*pflock) (qconn, fin); -} - -/* Unlock a connection. */ - -boolean -fconn_unlock (qconn) - struct sconnection *qconn; -{ - boolean (*pfunlock) P((struct sconnection *)); - - pfunlock = qconn->qcmds->pfunlock; - if (pfunlock == NULL) - return TRUE; - return (*pfunlock) (qconn); -} - -/* Open a connection. */ - -boolean -fconn_open (qconn, ibaud, ihighbaud, fwait) - struct sconnection *qconn; - long ibaud; - long ihighbaud; - boolean fwait; -{ - boolean fret; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_PORT)) - { - char abspeed[20]; - - if (ibaud == (long) 0) - strcpy (abspeed, "default speed"); - else - sprintf (abspeed, "speed %ld", ibaud); - - if (qconn->qport == NULL) - ulog (LOG_DEBUG, "fconn_open: Opening stdin port (%s)", - abspeed); - else if (qconn->qport->uuconf_zname == NULL) - ulog (LOG_DEBUG, "fconn_open: Opening unnamed port (%s)", - abspeed); - else - ulog (LOG_DEBUG, "fconn_open: Opening port %s (%s)", - qconn->qport->uuconf_zname, abspeed); - } -#endif - - /* If the system provides a range of baud rates, we select the - highest baud rate supported by the port. */ - if (ihighbaud != 0 && qconn->qport != NULL) - { - struct uuconf_port *qport; - - qport = qconn->qport; - ibaud = ihighbaud; - if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM) - { - if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0) - { - if (qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud < ibaud) - ibaud = qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud; - } - else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0) - ibaud = qport->uuconf_u.uuconf_smodem.uuconf_ibaud; - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT) - { - if (qport->uuconf_u.uuconf_sdirect.uuconf_ibaud != 0) - ibaud = qport->uuconf_u.uuconf_sdirect.uuconf_ibaud; - } - } - - /* This will normally be overridden by the port specific open - routine. */ - if (qconn->qport == NULL) - ulog_device ("stdin"); - else - ulog_device (qconn->qport->uuconf_zname); - - fret = (*qconn->qcmds->pfopen) (qconn, ibaud, fwait); - - if (! fret) - ulog_device ((const char *) NULL); - - return fret; -} - -/* Close a connection. */ - -boolean -fconn_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - boolean fret; - - DEBUG_MESSAGE0 (DEBUG_PORT, "fconn_close: Closing connection"); - - /* Don't report hangup signals while we're closing. */ - fLog_sighup = FALSE; - - fret = (*qconn->qcmds->pfclose) (qconn, puuconf, qdialer, fsuccess); - - /* Ignore any SIGHUP we may have gotten, and make sure any signal - reporting has been done before we reset fLog_sighup. */ - afSignal[INDEXSIG_SIGHUP] = FALSE; - ulog (LOG_ERROR, (const char *) NULL); - fLog_sighup = TRUE; - - ulog_device ((const char *) NULL); - - return fret; -} - -/* Dial out on the connection. */ - -boolean -fconn_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialerfound; -{ - struct uuconf_dialer sdialer; - enum tdialerfound tfound; - boolean (*pfdial) P((struct sconnection *, pointer, - const struct uuconf_system *, const char *, - struct uuconf_dialer *, enum tdialerfound *)); - - if (qdialer == NULL) - qdialer = &sdialer; - if (ptdialerfound == NULL) - ptdialerfound = &tfound; - - qdialer->uuconf_zname = NULL; - *ptdialerfound = DIALERFOUND_FALSE; - - pfdial = qconn->qcmds->pfdial; - if (pfdial == NULL) - return TRUE; - return (*pfdial) (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound); -} - -/* Read data from the connection. */ - -boolean -fconn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) - struct sconnection *qconn; - char *zbuf; - size_t *pclen; - size_t cmin; - int ctimeout; - boolean freport; -{ - boolean fret; - - fret = (*qconn->qcmds->pfread) (qconn, zbuf, pclen, cmin, ctimeout, - freport); - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_INCOMING)) - udebug_buffer ("fconn_read: Read", zbuf, *pclen); - else if (FDEBUGGING (DEBUG_PORT)) - ulog (LOG_DEBUG, "fconn_read: Read %lu", (unsigned long) *pclen); -#endif - - return fret; -} - -/* Write data to the connection. */ - -boolean -fconn_write (qconn, zbuf, clen) - struct sconnection *qconn; - const char *zbuf; - size_t clen; -{ -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_OUTGOING)) - udebug_buffer ("fconn_write: Writing", zbuf, clen); - else if (FDEBUGGING (DEBUG_PORT)) - ulog (LOG_DEBUG, "fconn_write: Writing %lu", (unsigned long) clen); -#endif - - return (*qconn->qcmds->pfwrite) (qconn, zbuf, clen); -} - -/* Read and write data. */ - -boolean -fconn_io (qconn, zwrite, pcwrite, zread, pcread) - struct sconnection *qconn; - const char *zwrite; - size_t *pcwrite; - char *zread; - size_t *pcread; -{ - boolean fret; -#if DEBUG > 1 - size_t cwrite = *pcwrite; - size_t cread = *pcread; - - if (cread == 0 || cwrite == 0) - ulog (LOG_FATAL, "fconn_io: cread %lu; cwrite %lu", - (unsigned long) cread, (unsigned long) cwrite); -#endif - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_OUTGOING)) - udebug_buffer ("fconn_io: Writing", zwrite, cwrite); -#endif - - fret = (*qconn->qcmds->pfio) (qconn, zwrite, pcwrite, zread, pcread); - - DEBUG_MESSAGE4 (DEBUG_PORT, - "fconn_io: Wrote %lu of %lu, read %lu of %lu", - (unsigned long) *pcwrite, (unsigned long) cwrite, - (unsigned long) *pcread, (unsigned long) cread); - -#if DEBUG > 1 - if (*pcread > 0 && FDEBUGGING (DEBUG_INCOMING)) - udebug_buffer ("fconn_io: Read", zread, *pcread); -#endif - - return fret; -} - -/* Send a break character to a connection. Some port types may not - support break characters, in which case we just return TRUE. */ - -boolean -fconn_break (qconn) - struct sconnection *qconn; -{ - boolean (*pfbreak) P((struct sconnection *)); - - pfbreak = qconn->qcmds->pfbreak; - if (pfbreak == NULL) - return TRUE; - - DEBUG_MESSAGE0 (DEBUG_PORT, "fconn_break: Sending break character"); - - return (*pfbreak) (qconn); -} - -/* Change the setting of a connection. Some port types may not - support this, in which case we just return TRUE. */ - -boolean -fconn_set (qconn, tparity, tstrip, txonxoff) - struct sconnection *qconn; - enum tparitysetting tparity; - enum tstripsetting tstrip; - enum txonxoffsetting txonxoff; -{ - boolean (*pfset) P((struct sconnection *, enum tparitysetting, - enum tstripsetting, enum txonxoffsetting)); - - pfset = qconn->qcmds->pfset; - if (pfset == NULL) - return TRUE; - - DEBUG_MESSAGE3 (DEBUG_PORT, - "fconn_set: Changing setting to %d, %d, %d", - (int) tparity, (int) tstrip, (int) txonxoff); - - return (*pfset) (qconn, tparity, tstrip, txonxoff); -} - -/* Require or ignore carrier on a connection. */ - -boolean -fconn_carrier (qconn, fcarrier) - struct sconnection *qconn; - boolean fcarrier; -{ - boolean (*pfcarrier) P((struct sconnection *, boolean)); - - pfcarrier = qconn->qcmds->pfcarrier; - if (pfcarrier == NULL) - return TRUE; - return (*pfcarrier) (qconn, fcarrier); -} - -/* Run a chat program on a connection. */ - -boolean -fconn_run_chat (qconn, pzprog) - struct sconnection *qconn; - char **pzprog; -{ - return (*qconn->qcmds->pfchat) (qconn, pzprog); -} - -/* Get the baud rate of a connection. */ - -long -iconn_baud (qconn) - struct sconnection *qconn; -{ - long (*pibaud) P((struct sconnection *)); - - pibaud = qconn->qcmds->pibaud; - if (pibaud == NULL) - return 0; - return (*pibaud) (qconn); -} - -/* Run through a dialer sequence. The pzdialer argument is a list of - strings, which are considered in dialer/token pairs. The dialer - string names a dialer to use. The token string is what \D and \T - in the chat script expand to. If there is no token for the last - dialer, the zphone argument is used. The qdialer argument is - filled in with information for the first dialer, and *ptdialerfound - is set to whether the information should be freed or not. However, - if *ptdialerfound is not DIALERFOUND_FALSE when this function is - called, then the information for the first dialer is already in - qdialer. */ - -boolean -fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone, qdialer, - ptdialerfound) - struct sconnection *qconn; - pointer puuconf; - char **pzdialer; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialerfound; -{ - const char *zname; - boolean ffirst, ffreefirst; - - if (qconn->qport == NULL) - zname = NULL; - else - zname = qconn->qport->uuconf_zname; - ffirst = TRUE; - ffreefirst = FALSE; - while (*pzdialer != NULL) - { - struct uuconf_dialer *q; - struct uuconf_dialer s; - const char *ztoken; - boolean ftranslate; - - if (! ffirst) - q = &s; - else - q = qdialer; - - if (! ffirst || *ptdialerfound == DIALERFOUND_FALSE) - { - int iuuconf; - - iuuconf = uuconf_dialer_info (puuconf, *pzdialer, q); - if (iuuconf == UUCONF_NOT_FOUND) - { - ulog (LOG_ERROR, "%s: Dialer not found", *pzdialer); - if (ffreefirst) - (void) uuconf_dialer_free (puuconf, qdialer); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - if (ffreefirst) - (void) uuconf_dialer_free (puuconf, qdialer); - return FALSE; - } - - if (ffirst) - { - *ptdialerfound = DIALERFOUND_FREE; - ffreefirst = TRUE; - } - } - - ++pzdialer; - ztoken = *pzdialer; - - ftranslate = FALSE; - if (ztoken == NULL - || strcmp (ztoken, "\\D") == 0) - ztoken = zphone; - else if (strcmp (ztoken, "\\T") == 0) - { - ztoken = zphone; - ftranslate = TRUE; - } - - if (! fchat (qconn, puuconf, &q->uuconf_schat, qsys, q, ztoken, - ftranslate, zname, iconn_baud (qconn))) - { - if (q == &s) - (void) uuconf_dialer_free (puuconf, q); - if (ffreefirst) - (void) uuconf_dialer_free (puuconf, qdialer); - return FALSE; - } - - if (ffirst) - ffirst = FALSE; - else - (void) uuconf_dialer_free (puuconf, q); - - if (*pzdialer != NULL) - ++pzdialer; - } - - return TRUE; -} - -/* Modem dialing routine. */ - -/*ARGSUSED*/ -boolean -fmodem_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialerfound; -{ - char **pzdialer; - - *ptdialerfound = DIALERFOUND_FALSE; - - pzdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer; - if (pzdialer != NULL && *pzdialer != NULL) - { - int iuuconf; - boolean fret; - - iuuconf = uuconf_dialer_info (puuconf, *pzdialer, qdialer); - if (iuuconf == UUCONF_NOT_FOUND) - { - ulog (LOG_ERROR, "%s: Dialer not found", *pzdialer); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - *ptdialerfound = DIALERFOUND_FREE; - - fret = (fsysdep_modem_begin_dial (qconn, qdialer) - && fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone, - qdialer, ptdialerfound) - && fsysdep_modem_end_dial (qconn, qdialer)); - - if (! fret) - (void) uuconf_dialer_free (puuconf, qdialer); - - return fret; - } - else if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer != NULL) - { - struct uuconf_dialer *q; - const char *zname; - - q = qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer; - *qdialer = *q; - *ptdialerfound = DIALERFOUND_TRUE; - - if (qconn->qport == NULL) - zname = NULL; - else - zname = qconn->qport->uuconf_zname; - - return (fsysdep_modem_begin_dial (qconn, q) - && fchat (qconn, puuconf, &q->uuconf_schat, qsys, q, - zphone, FALSE, zname, iconn_baud (qconn)) - && fsysdep_modem_end_dial (qconn, q)); - } - else - { - ulog (LOG_ERROR, "No dialer information"); - return FALSE; - } -} diff --git a/gnu/libexec/uucp/common_sources/conn.h b/gnu/libexec/uucp/common_sources/conn.h deleted file mode 100644 index 09235ea2ca20..000000000000 --- a/gnu/libexec/uucp/common_sources/conn.h +++ /dev/null @@ -1,319 +0,0 @@ -/* conn.h - Header file for routines which manipulate connections. - - Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#ifndef CONN_H - -#define CONN_H - -#if ANSI_C -/* These structures are used in prototypes but are not defined in this - header file. */ -struct uuconf_system; -struct uuconf_dialer; -struct uuconf_chat; -#endif - -/* This structure represents a connection. */ - -struct sconnection -{ - /* Pointer to command table for this type of connection. */ - const struct sconncmds *qcmds; - /* Pointer to system dependent information. */ - pointer psysdep; - /* Pointer to system independent information. */ - struct uuconf_port *qport; -}; - -/* Whether fconn_dial got a dialer. */ - -enum tdialerfound -{ - /* Did not find a dialer. */ - DIALERFOUND_FALSE, - /* Found a dialer which does not need to be freed. */ - DIALERFOUND_TRUE, - /* Found a dialer which does need to be freed. */ - DIALERFOUND_FREE -}; - -/* Parity settings to pass to fconn_set. */ - -enum tparitysetting -{ - /* Do not change output parity generation. */ - PARITYSETTING_DEFAULT, - /* No parity (all eight output bits used). */ - PARITYSETTING_NONE, - /* Even parity. */ - PARITYSETTING_EVEN, - /* Odd parity. */ - PARITYSETTING_ODD, - /* Mark parity. */ - PARITYSETTING_MARK, - /* Space parity. */ - PARITYSETTING_SPACE -}; - -/* Type of strip control argument to fconn_set. */ - -enum tstripsetting -{ - /* Do not change the stripping of input characters. */ - STRIPSETTING_DEFAULT, - /* Do not strip input characters to seven bits. */ - STRIPSETTING_EIGHTBITS, - /* Strip input characters to seven bits. */ - STRIPSETTING_SEVENBITS -}; - -/* Type of XON/XOFF control argument to fconn_set. */ - -enum txonxoffsetting -{ - /* Do not change XON/XOFF handshake setting. */ - XONXOFF_DEFAULT, - /* Do not do XON/XOFF handshaking. */ - XONXOFF_OFF, - /* Do XON/XOFF handshaking. */ - XONXOFF_ON -}; - -/* A command table holds the functions which implement actions for - each different kind of connection. */ - -struct sconncmds -{ - /* Free up a connection. */ - void (*pufree) P((struct sconnection *qconn)); - /* Lock the connection. The fin argument is TRUE if the connection - is to be used for an incoming call. May be NULL. */ - boolean (*pflock) P((struct sconnection *qconn, boolean fin)); - /* Unlock the connection. May be NULL. */ - boolean (*pfunlock) P((struct sconnection *qconn)); - /* Open the connection. */ - boolean (*pfopen) P((struct sconnection *qconn, long ibaud, - boolean fwait)); - /* Close the connection. */ - boolean (*pfclose) P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); - /* Dial a number on a connection. This set *qdialer to the dialer - used, if any, and sets *ptdialerfound appropriately. The qsys - and zphone arguments are for the chat script. This field may be - NULL. */ - boolean (*pfdial) P((struct sconnection *qconn, pointer puuconf, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialerfound)); - /* Read data from a connection, with a timeout in seconds. When - called *pclen is the length of the buffer; on successful return - *pclen is the number of bytes read into the buffer. The cmin - argument is the minimum number of bytes to read before returning - ahead of a timeout. */ - boolean (*pfread) P((struct sconnection *qconn, char *zbuf, size_t *pclen, - size_t cmin, int ctimeout, boolean freport)); - /* Write data to the connection. */ - boolean (*pfwrite) P((struct sconnection *qconn, const char *zbuf, - size_t clen)); - /* Read and write data to the connection. This reads and writes - data until either all passed in data has been written or the read - buffer has been filled. When called *pcread is the size of the - read buffer and *pcwrite is the number of bytes to write; on - successful return *pcread is the number of bytes read and - *pcwrite is the number of bytes written. */ - boolean (*pfio) P((struct sconnection *qconn, const char *zwrite, - size_t *pcwrite, char *zread, size_t *pcread)); - /* Send a break character. This field may be NULL. */ - boolean (*pfbreak) P((struct sconnection *qconn)); - /* Change the connection setting. This field may be NULL. */ - boolean (*pfset) P((struct sconnection *qconn, - enum tparitysetting tparity, - enum tstripsetting tstrip, - enum txonxoffsetting txonxoff)); - /* Require or ignore carrer. This field may be NULL. */ - boolean (*pfcarrier) P((struct sconnection *qconn, - boolean fcarrier)); - /* Run a chat program on a connection. */ - boolean (*pfchat) P((struct sconnection *qconn, char **pzprog)); - /* Get the baud rate of a connection. This field may be NULL. */ - long (*pibaud) P((struct sconnection *qconn)); -}; - -/* Connection functions. */ - -/* Initialize a connection. This must be called before any of the - other connection functions are called. It initializes the fields - of qconn. If qport is NULL, this opens standard input as a port - using type ttype. This function returns FALSE on error. */ -extern boolean fconn_init P((struct uuconf_port *qport, - struct sconnection *qconn, - enum uuconf_porttype ttype)); - -/* Free up connection data. */ -extern void uconn_free P((struct sconnection *qconn)); - -/* Lock a connection. The fin argument is TRUE if the port is to be - used for an incoming call; certains type of Unix locking need this - information because they need to open the port. */ -extern boolean fconn_lock P((struct sconnection *qconn, boolean fin)); - -/* Unlock a connection. */ -extern boolean fconn_unlock P((struct sconnection *qconn)); - -/* Open a connection. If ibaud is 0, the natural baud rate of the - port is used. If ihighbaud is not 0, fconn_open chooses the - highest supported baud rate between ibaud and ihighbaud. If fwait - is TRUE, this should wait for an incoming call. */ -extern boolean fconn_open P((struct sconnection *qconn, long ibaud, - long ihighbaud, boolean fwait)); - -/* Close a connection. The fsuccess argument is TRUE if the - conversation completed normally, FALSE if it is being aborted. */ -extern boolean fconn_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); - -/* Dial out on a connection. The qsys and zphone arguments are for - the chat scripts; zphone is the phone number to dial. If qdialer - is not NULL, *qdialer will be set to the dialer information used if - any; *ptdialerfound will be set appropriately. */ -extern boolean fconn_dial P((struct sconnection *q, pointer puuconf, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialerfound)); - -/* Read from a connection. - zbuf -- buffer to read bytes into - *pclen on call -- length of zbuf - *pclen on successful return -- number of bytes read - cmin -- minimum number of bytes to read before returning ahead of timeout - ctimeout -- timeout in seconds, 0 if none - freport -- whether to report errors. */ -extern boolean fconn_read P((struct sconnection *qconn, char *zbuf, - size_t *pclen, size_t cmin, - int ctimeout, boolean freport)); - -/* Write to a connection. */ -extern boolean fconn_write P((struct sconnection *qconn, const char *zbuf, - size_t cbytes)); - -/* Read and write to a connection. This reads and writes data until - either all passed-in data has been written or the read buffer is - full. - zwrite -- buffer to write bytes from - *pcwrite on call -- number of bytes to write - *pcwrite on successful return -- number of bytes written - zread -- buffer to read bytes into - *pcread on call -- size of read buffer - *pcread on successful return -- number of bytes read. */ -extern boolean fconn_io P((struct sconnection *qconn, const char *zwrite, - size_t *pcwrite, char *zread, size_t *pcread)); - -/* Send a break character to a connection. */ -extern boolean fconn_break P((struct sconnection *qconn)); - -/* Change the settings of a connection. This allows independent - control over the parity of output characters, whether to strip - input characters, and whether to do XON/XOFF handshaking. There is - no explicit control over parity checking of input characters. This - function returns FALSE on error. Attempts to set values not - supported by the hardware are silently ignored. */ -extern boolean fconn_set P((struct sconnection *qconn, - enum tparitysetting tparity, - enum tstripsetting tstrip, - enum txonxoffsetting txonxoff)); - -/* Get the baud rate of a connection. */ -extern long iconn_baud P((struct sconnection *qconn)); - -/* Do a chat script with a system. */ -extern boolean fchat P((struct sconnection *qconn, pointer puuconf, - const struct uuconf_chat *qchat, - const struct uuconf_system *qsys, - const struct uuconf_dialer *qdialer, - const char *zphone, boolean ftranslate, - const char *zport, long ibaud)); - -/* Tell the connection to either require or ignore carrier as fcarrier - is TRUE or FALSE respectively. This is called with fcarrier TRUE - when \m is encountered in a chat script, and with fcarrier FALSE - when \M is encountered. */ -extern boolean fconn_carrier P((struct sconnection *qconn, - boolean fcarrier)); - -/* Run a chat program on a connection. */ -extern boolean fconn_run_chat P((struct sconnection *qconn, - char **pzprog)); - -/* Run through a dialer sequence. This is a support routine for the - port type specific dialing routines. */ -extern boolean fconn_dial_sequence P((struct sconnection *qconn, - pointer puuconf, char **pzdialer, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialerfound)); - -/* Dialing out on a modem is partially system independent. This is - the modem dialing routine. */ -extern boolean fmodem_dial P((struct sconnection *qconn, pointer puuconf, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialerfound)); - -/* Begin dialing out. This should open the dialer device if there is - one, toggle DTR if requested and possible, and tell the port to - ignore carrier. It should return FALSE on error. */ -extern boolean fsysdep_modem_begin_dial P((struct sconnection *qconn, - struct uuconf_dialer *qdial)); - -/* Finish dialing out on a modem. This should close the dialer device - if there is one. If the dialer and the port both support carrier, - the connection should be told to pay attention to carrier. If it - is possible to wait for carrier to come on, and the dialer and the - port both the port support carrier, it should wait until carrier - comes on. */ -extern boolean fsysdep_modem_end_dial P((struct sconnection *qconn, - struct uuconf_dialer *qdial)); - -/* System dependent initialization routines. */ -extern boolean fsysdep_stdin_init P((struct sconnection *qconn)); -extern boolean fsysdep_modem_init P((struct sconnection *qconn)); -extern boolean fsysdep_direct_init P((struct sconnection *qconn)); -#if HAVE_TCP -extern boolean fsysdep_tcp_init P((struct sconnection *qconn)); -#endif -#if HAVE_TLI -extern boolean fsysdep_tli_init P((struct sconnection *qconn)); -#endif -extern boolean fsysdep_pipe_init P((struct sconnection *qconn)); - -#endif /* ! defined (CONN_H) */ diff --git a/gnu/libexec/uucp/common_sources/copy.c b/gnu/libexec/uucp/common_sources/copy.c deleted file mode 100644 index a40276a508a2..000000000000 --- a/gnu/libexec/uucp/common_sources/copy.c +++ /dev/null @@ -1,236 +0,0 @@ -/* copy.c - Copy one file to another for the UUCP package. - - Copyright (C) 1991, 1992, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char copy_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "system.h" -#include "sysdep.h" - -#include -#include - -/* Copy one file to another. */ - -#if USE_STDIO - -boolean -fcopy_file (zfrom, zto, fpublic, fmkdirs, fsignals) - const char *zfrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; - boolean fsignals; -{ - FILE *efrom; - boolean fret; - - efrom = fopen (zfrom, BINREAD); - if (efrom == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfrom, strerror (errno)); - return FALSE; - } - - fret = fcopy_open_file (efrom, zto, fpublic, fmkdirs, fsignals); - (void) fclose (efrom); - return fret; -} - -boolean -fcopy_open_file (efrom, zto, fpublic, fmkdirs, fsignals) - FILE *efrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; - boolean fsignals; -{ - FILE *eto; - char ab[8192]; - int c; - - eto = esysdep_fopen (zto, fpublic, FALSE, fmkdirs); - if (eto == NULL) - return FALSE; - - while ((c = fread (ab, sizeof (char), sizeof ab, efrom)) != 0) - { - if (fwrite (ab, sizeof (char), (size_t) c, eto) != c) - { - ulog (LOG_ERROR, "fwrite: %s", strerror (errno)); - (void) fclose (eto); - (void) remove (zto); - return FALSE; - } - if (fsignals && FGOT_SIGNAL ()) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - (void) fclose (eto); - (void) remove (zto); - return FALSE; - } - } - - if (! fsysdep_sync (eto, zto)) - { - (void) fclose (eto); - (void) remove (zto); - return FALSE; - } - - if (fclose (eto) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - return TRUE; -} - -#else /* ! USE_STDIO */ - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -boolean -fcopy_file (zfrom, zto, fpublic, fmkdirs, fsignals) - const char *zfrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; - boolean fsignals; -{ - int ofrom; - boolean fret; - - ofrom = open (zfrom, O_RDONLY | O_NOCTTY, 0); - if (ofrom < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfrom, strerror (errno)); - return FALSE; - } - - fret = fcopy_open_file (ofrom, zto, fpublic, fmkdirs, fsignals); - (void) close (ofrom); - return fret; -} - -boolean -fcopy_open_file (ofrom, zto, fpublic, fmkdirs, fsignals) - int ofrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; - boolean fsignals; -{ - int oto; - char ab[8192]; - int c; - - /* These file mode arguments are from the UNIX version of sysdep.h; - each system dependent header file will need their own - definitions. */ - oto = creat (zto, fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE); - if (oto < 0) - { - if (errno == ENOENT && fmkdirs) - { - if (! fsysdep_make_dirs (zto, fpublic)) - return FALSE; - oto = creat (zto, - fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE); - } - if (oto < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zto, strerror (errno)); - return FALSE; - } - } - - while ((c = read (ofrom, ab, sizeof ab)) > 0) - { - if (write (oto, ab, (size_t) c) != c) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - (void) close (oto); - (void) remove (zto); - return FALSE; - } - if (fsignals && FGOT_SIGNAL ()) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - (void) fclose (eto); - (void) remove (zto); - return FALSE; - } - } - - if (! fsysdep_sync (oto, zto)) - { - (void) close (oto); - (void) remove (zto); - return FALSE; - } - - if (close (oto) < 0) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - if (c < 0) - { - ulog (LOG_ERROR, "read: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - return TRUE; -} - -#endif /* ! USE_STDIO */ diff --git a/gnu/libexec/uucp/common_sources/cu.h b/gnu/libexec/uucp/common_sources/cu.h deleted file mode 100644 index 8c2267031cb7..000000000000 --- a/gnu/libexec/uucp/common_sources/cu.h +++ /dev/null @@ -1,80 +0,0 @@ -/* cu.h - Header file for cu. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* The user settable variables supported by cu. */ - -/* The escape character used to introduce a special command. The - escape character is the first character of this string. */ -extern const char *zCuvar_escape; - -/* Whether to delay for a second before printing the host name after - seeing an escape character. */ -extern boolean fCuvar_delay; - -/* The input characters which finish a line. The escape character is - only recognized following one of these characters. */ -extern const char *zCuvar_eol; - -/* Whether to transfer binary data (nonprintable characters other than - newline and tab) when sending a file. If this is FALSE, then - newline is changed to carriage return. */ -extern boolean fCuvar_binary; - -/* A prefix string to use before sending a binary character from a - file; this is only used if fCuvar_binary is TRUE. */ -extern const char *zCuvar_binary_prefix; - -/* Whether to check for echoes of characters sent when sending a file. - This is ignored if fCuvar_binary is TRUE. */ -extern boolean fCuvar_echocheck; - -/* A character to look for after each newline is sent when sending a - file. The character is the first character in this string, except - that a '\0' means that no echo check is done. */ -extern const char *zCuvar_echonl; - -/* The timeout to use when looking for an character. */ -extern int cCuvar_timeout; - -/* The character to use to kill a line if an echo check fails. The - first character in this string is sent. */ -extern const char *zCuvar_kill; - -/* The number of times to try resending a line if the echo check keeps - failing. */ -extern int cCuvar_resend; - -/* The string to send at the end of a file sent with ~>. */ -extern const char *zCuvar_eofwrite; - -/* The string to look for to finish a file received with ~<. For tip - this is a collection of single characters, but I don't want to do - that because it means that there are characters which cannot be - received. */ -extern const char *zCuvar_eofread; - -/* Whether to provide verbose information when sending or receiving a - file. */ -extern boolean fCuvar_verbose; diff --git a/gnu/libexec/uucp/common_sources/getopt.h b/gnu/libexec/uucp/common_sources/getopt.h deleted file mode 100644 index 61e295409f41..000000000000 --- a/gnu/libexec/uucp/common_sources/getopt.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, November 1992, - for Taylor UUCP, and again in June, 1995. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* Ian Lance Taylor added the following defines for - Taylor UUCP. This avoids reported conflicts with system getopt - definitions. */ -#define getopt gnu_getopt -#define optarg gnu_optarg -#define optind gnu_optind -#define opterr gnu_opterr - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ - const char *name; - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#ifndef P -/* On some systems, includes getopt.h before P is defined by - uucp.h, and the -I arguments cause this version of getopt.h to be - included. Work around that here. */ -#define P(x) () -#define UNDEFINE_P -#endif - -extern int getopt P((int argc, char *const *argv, const char *shortopts)); -extern int getopt_long P((int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind)); -extern int getopt_long_only P((int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind)); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal P((int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only)); - -#ifdef UNDEFINE_P -#undef P -#undef UNDEFINE_P -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/libexec/uucp/common_sources/log.c b/gnu/libexec/uucp/common_sources/log.c deleted file mode 100644 index 6661b3c9b5fc..000000000000 --- a/gnu/libexec/uucp/common_sources/log.c +++ /dev/null @@ -1,775 +0,0 @@ -/* log.c - Routines to add entries to the log files. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char log_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -#if HAVE_STDARG_H -#include -#endif - -#if TM_IN_SYS_TIME -#include -#else -#include -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Local functions. */ - -__inline__ static char *zstpcpy P((char *zto, const char *zfrom)); -static const char *zldate_and_time P((void)); - -/* Program name. Set by main function. */ -const char *zProgram; - -/* Log file name. */ -static const char *zLogfile; - -/* The function to call when a LOG_FATAL error occurs. */ -static void (*pfLfatal) P((void)); - -/* Whether to go to a file. */ -static boolean fLfile; - -/* ID number. */ -static int iLid; - -/* The current user name. */ -static char *zLuser; - -/* The current system name. */ -static char *zLsystem; - -/* The current device name. */ -char *zLdevice; - -/* The open log file. */ -static FILE *eLlog; - -/* Whether we have tried to open the log file. We need this because - we don't want to keep trying to open the log file if we failed the - first time. It can't be static because under HAVE_HDB_LOGGING we - may have to write to various different log files. */ -static boolean fLlog_tried; - -#if DEBUG > 1 -/* Debugging file name. */ -static const char *zLdebugfile; - -/* The open debugging file. */ -static FILE *eLdebug; - -/* Whether we've tried to open the debugging file. */ -static boolean fLdebug_tried; -#endif - -/* Statistics file name. */ -static const char *zLstatsfile; - -/* The open statistics file. */ -static FILE *eLstats; - -/* Whether we've tried to open the statistics file. */ -static boolean fLstats_tried; - -/* The array of signals. The elements are only set to TRUE by the - default signal handler. They are only set to FALSE if we don't - care whether we got the signal or not. */ -volatile sig_atomic_t afSignal[INDEXSIG_COUNT]; - -/* The array of signals to log. The elements are only set to TRUE by - the default signal handler. They are set to FALSE when the signal - is logged in ulog. This means that if a signal comes in at just - the right time we won't log it (or, rather, we'll log it once - instead of twice), but that is not a catatrophe. */ -volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT]; - -/* Flag that indicates SIGHUP is worth logging. */ -boolean fLog_sighup = TRUE; - -/* Signal names to use when logging signals. */ -static const char * const azSignal_names[INDEXSIG_COUNT] = INDEXSIG_NAMES; - -/* If not NULL, ulog calls this function before outputting anything. - This is used to support cu. */ -void (*pfLstart) P((void)); - -/* If not NULL, ulog calls this function after outputting everything. - This is used to support cu. */ -void (*pfLend) P((void)); - -/* Set the function to call on a LOG_FATAL error. */ - -void -ulog_fatal_fn (pfn) - void (*pfn) P((void)); -{ - pfLfatal = pfn; -} - -/* Decide whether to send log message to the file or not. */ - -void -ulog_to_file (puuconf, ffile) - pointer puuconf; - boolean ffile; -{ - int iuuconf; - - iuuconf = uuconf_logfile (puuconf, &zLogfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - iuuconf = uuconf_debugfile (puuconf, &zLdebugfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); -#endif - - iuuconf = uuconf_statsfile (puuconf, &zLstatsfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - fLfile = ffile; -} - -/* Set the ID number. This will be called by the usysdep_initialize - if there is something sensible to set it to. */ - -void -ulog_id (i) - int i; -{ - iLid = i; -} - -/* Set the user we are making log entries for. The arguments will be - copied into memory. */ - -void -ulog_user (zuser) - const char *zuser; -{ - ubuffree (zLuser); - zLuser = zbufcpy (zuser); -} - -/* Set the system name we are making log entries for. The name is copied - into memory. */ - -void -ulog_system (zsystem) - const char *zsystem; -{ - if (zsystem == NULL - || zLsystem == NULL - || strcmp (zsystem, zLsystem) != 0) - { - ubuffree (zLsystem); - zLsystem = zbufcpy (zsystem); -#if HAVE_HDB_LOGGING - /* Under HDB logging we now must write to a different log file. */ - ulog_close (); -#endif /* HAVE_HDB_LOGGING */ - } -} - -/* Set the device name. This is copied into memory. */ - -void -ulog_device (zdevice) - const char *zdevice; -{ - ubuffree (zLdevice); - zLdevice = zbufcpy (zdevice); -} - -/* A helper function for ulog. */ - -__inline__ static char * -zstpcpy (zto, zfrom) - char *zto; - const char *zfrom; -{ - while ((*zto++ = *zfrom++) != '\0') - ; - return zto - 1; -} - -/* Make a log entry. We make a token concession to non ANSI_C systems, - but it clearly won't always work. */ - -#if ! HAVE_PROTOTYPES || ! HAVE_STDARG_H -#undef HAVE_VFPRINTF -#define HAVE_VFPRINTF 0 -#endif - -/*VARARGS2*/ -#if HAVE_VFPRINTF -void -ulog (enum tlog ttype, const char *zmsg, ...) -#else -void -ulog (ttype, zmsg, a, b, c, d, f, g, h, i, j) - enum tlog ttype; - const char *zmsg; -#endif -{ -#if HAVE_VFPRINTF - va_list parg; -#endif - FILE *e, *edebug; - boolean fstart, fend; - const char *zhdr; - char *zprefix; - register char *zset; - char *zformat; - char *zfrom; - - /* Log any received signal. We do it this way to avoid calling ulog - from the signal handler. A few routines call ulog to get this - message out with zmsg == NULL. */ - { - static boolean fdoing_sigs; - - if (! fdoing_sigs) - { - int isig; - - fdoing_sigs = TRUE; - for (isig = 0; isig < INDEXSIG_COUNT; isig++) - { - if (afLog_signal[isig]) - { - afLog_signal[isig] = FALSE; - - /* Apparently SunOS sends SIGINT rather than SIGHUP - when hanging up, so we don't log either signal if - fLog_sighup is FALSE. */ - if ((isig != INDEXSIG_SIGHUP && isig != INDEXSIG_SIGINT) - || fLog_sighup) - ulog (LOG_ERROR, "Got %s signal", azSignal_names[isig]); - } - } - fdoing_sigs = FALSE; - } - } - -#if DEBUG > 1 - /* If we've had a debugging file open in the past, then we want to - write all log file entries to the debugging file even if it's - currently closed. */ - if (fLfile - && eLdebug == NULL - && ! fLdebug_tried - && iDebug != 0) - { - fLdebug_tried = TRUE; - eLdebug = esysdep_fopen (zLdebugfile, FALSE, TRUE, TRUE); - } -#endif /* DEBUG > 1 */ - - if (! fLfile) - e = stderr; -#if DEBUG > 1 - else if ((int) ttype >= (int) LOG_DEBUG) - { - e = eLdebug; - - /* If we can't open the debugging file, don't output any - debugging messages. */ - if (e == NULL) - return; - } -#endif /* DEBUG > 1 */ - else - { - if (eLlog == NULL && ! fLlog_tried) - { - const char *zprint = NULL; - - fLlog_tried = TRUE; -#if ! HAVE_HDB_LOGGING - eLlog = esysdep_fopen (zLogfile, TRUE, TRUE, TRUE); - zprint = zLogfile; -#else /* HAVE_HDB_LOGGING */ - { - const char *zsys; - char *zbase; - char *zlower; - char *zfile; - - /* We want to write to .Log/program/system, e.g. - .Log/uucico/uunet. The system name may not be set. */ - if (zLsystem == NULL) - zsys = "ANY"; - else - zsys = zLsystem; - - zbase = zsysdep_base_name (zProgram); - if (zbase == NULL) - zbase = zbufcpy (zProgram); - - /* On some systems the native uusched will invoke uucico - with an upper case argv[0]. We work around that by - forcing the filename to lower case here. */ - for (zlower = zbase; *zlower != '\0'; zlower++) - if (isupper (*zlower)) - *zlower = tolower (*zlower); - - zfile = zbufalc (strlen (zLogfile) - + strlen (zbase) - + strlen (zsys) - + 1); - sprintf (zfile, zLogfile, zbase, zsys); - ubuffree (zbase); - eLlog = esysdep_fopen (zfile, TRUE, TRUE, TRUE); - if (eLlog != NULL) - ubuffree (zfile); - else - zprint = zfile; - } -#endif /* HAVE_HDB_LOGGING */ - - if (eLlog == NULL) - { - /* We can't open the log file. We report the problem to - stderr. This is not ideal, since if this is uucico - running on an inbound call stderr is actually - connected to a remote system, but is better than - doing nothing. */ - fprintf (stderr, "%s: %s: can not open log file: %s\n", - zProgram, zprint, strerror (errno)); - if (pfLfatal != NULL) - (*pfLfatal) (); - usysdep_exit (FALSE); - } - } - - e = eLlog; - - /* eLlog might be NULL here because we might try to open the log - file recursively via esysdep_fopen. */ - if (e == NULL) - return; - } - - if (zmsg == NULL) - return; - - if (pfLstart != NULL) - (*pfLstart) (); - - edebug = NULL; -#if DEBUG > 1 - if ((int) ttype < (int) LOG_DEBUG) - edebug = eLdebug; -#endif - - fstart = TRUE; - fend = TRUE; - - switch (ttype) - { - case LOG_NORMAL: - zhdr = ""; - break; - case LOG_ERROR: - zhdr = "ERROR: "; - break; - case LOG_FATAL: - zhdr = "FATAL: "; - break; -#if DEBUG > 1 - case LOG_DEBUG: - zhdr = "DEBUG: "; - break; - case LOG_DEBUG_START: - zhdr = "DEBUG: "; - fend = FALSE; - break; - case LOG_DEBUG_CONTINUE: - zhdr = NULL; - fstart = FALSE; - fend = FALSE; - break; - case LOG_DEBUG_END: - zhdr = NULL; - fstart = FALSE; - break; -#endif - default: - zhdr = "???: "; - break; - } - - if (! fstart) - zprefix = zbufcpy (""); - else - { - if (! fLfile) - { - zprefix = zbufalc (strlen (zProgram) + 3); - sprintf (zprefix, "%s: ", zProgram); - } - else - { - zprefix = zbufalc (strlen (zProgram) - + (zLsystem == NULL ? 1 : strlen (zLsystem)) - + (zLuser == NULL ? 4 : strlen (zLuser)) - + sizeof "1991-12-31 12:00:00.00" - + strlen (zhdr) - + 100); - zset = zprefix; -#if HAVE_TAYLOR_LOGGING - { - char *zbase; - - zbase = zsysdep_base_name (zProgram); - if (zbase == NULL) - zbase = zbufcpy (zProgram); - zset = zstpcpy (zset, zbase); - *zset++ = ' '; - ubuffree (zbase); - } -#else /* ! HAVE_TAYLOR_LOGGING */ - zset = zstpcpy (zset, zLuser == NULL ? "uucp" : zLuser); - *zset++ = ' '; -#endif /* HAVE_TAYLOR_LOGGING */ - - zset = zstpcpy (zset, zLsystem == NULL ? "-" : zLsystem); - *zset++ = ' '; - -#if HAVE_TAYLOR_LOGGING - zset = zstpcpy (zset, zLuser == NULL ? "-" : zLuser); - *zset++ = ' '; -#endif /* HAVE_TAYLOR_LOGGING */ - - *zset++ = '('; - zset = zstpcpy (zset, zldate_and_time ()); - - if (iLid != 0) - { -#if ! HAVE_HDB_LOGGING -#if HAVE_TAYLOR_LOGGING - sprintf (zset, " %d", iLid); -#else /* ! HAVE_TAYLOR_LOGGING */ - sprintf (zset, "-%d", iLid); -#endif /* ! HAVE_TAYLOR_LOGGING */ -#else /* HAVE_HDB_LOGGING */ - /* I assume that the second number here is meant to be - some sort of file sequence number, and that it should - correspond to the sequence number in the statistics - file. I don't have any really convenient way to do - this, so I won't unless somebody thinks it's very - important. */ - sprintf (zset, ",%d,%d", iLid, 0); -#endif /* HAVE_HDB_LOGGING */ - - zset += strlen (zset); - } - -#if QNX_LOG_NODE_ID - sprintf (zset, " %ld", (long) getnid ()); - zset += strlen (zset); -#endif - - *zset++ = ')'; - *zset++ = ' '; - - strcpy (zset, zhdr); - } - } - - zformat = zbufalc (2 * strlen (zprefix) + strlen (zmsg) + 2); - - zset = zformat; - zfrom = zprefix; - while (*zfrom != '\0') - { - if (*zfrom == '%') - *zset++ = '%'; - *zset++ = *zfrom++; - } - - ubuffree (zprefix); - - zset = zstpcpy (zset, zmsg); - - if (fend) - { - *zset++ = '\n'; - *zset = '\0'; - } - -#if HAVE_VFPRINTF - va_start (parg, zmsg); - vfprintf (e, zformat, parg); - va_end (parg); - if (edebug != NULL) - { - va_start (parg, zmsg); - vfprintf (edebug, zformat, parg); - va_end (parg); - } -#else /* ! HAVE_VFPRINTF */ - fprintf (e, zformat, a, b, c, d, f, g, h, i, j); - if (edebug != NULL) - fprintf (edebug, zformat, a, b, c, d, f, g, h, i, j); -#endif /* ! HAVE_VFPRINTF */ - - ubuffree (zformat); - - (void) fflush (e); - if (edebug != NULL) - (void) fflush (edebug); - - if (pfLend != NULL) - (*pfLend) (); - - if (ttype == LOG_FATAL) - { - if (pfLfatal != NULL) - (*pfLfatal) (); - usysdep_exit (FALSE); - } - -#if CLOSE_LOGFILES - ulog_close (); -#endif -} - -/* Log a uuconf error. */ - -void -ulog_uuconf (ttype, puuconf, iuuconf) - enum tlog ttype; - pointer puuconf; - int iuuconf; -{ - char ab[512]; - - (void) uuconf_error_string (puuconf, iuuconf, ab, sizeof ab); - ulog (ttype, "%s", ab); -} - -/* Close the log file. There's nothing useful we can do with errors, - so we don't check for them. */ - -void -ulog_close () -{ - /* Make sure we logged any signal we received. */ - ulog (LOG_ERROR, (const char *) NULL); - - if (eLlog != NULL) - { - (void) fclose (eLlog); - eLlog = NULL; - fLlog_tried = FALSE; - } - -#if DEBUG > 1 - if (eLdebug != NULL) - { - (void) fclose (eLdebug); - eLdebug = NULL; - fLdebug_tried = FALSE; - } -#endif -} - -/* Add an entry to the statistics file. We may eventually want to put - failed file transfers in here, but we currently do not. */ - -/*ARGSUSED*/ -void -ustats (fsucceeded, zuser, zsystem, fsent, cbytes, csecs, cmicros, fcaller) - boolean fsucceeded; - const char *zuser; - const char *zsystem; - boolean fsent; - long cbytes; - long csecs; - long cmicros; - boolean fcaller; -{ - long cbps; - - /* The seconds and microseconds are now counted independently, so - they may be out of synch. */ - if (cmicros < 0) - { - csecs -= ((- cmicros) / 1000000L) + 1; - cmicros = 1000000L - ((- cmicros) % 1000000L); - } - if (cmicros >= 1000000L) - { - csecs += cmicros / 10000000L; - cmicros = cmicros % 1000000L; - } - - /* On a system which can determine microseconds we might very well - have both csecs == 0 and cmicros == 0. */ - if (csecs == 0 && cmicros < 1000) - cbps = 0; - else - { - long cmillis, cdiv, crem; - - /* Compute ((csecs * 1000) / cmillis) using integer division. - Where DIV is integer division, we know - a = (a DIV b) * b + a % b - so - a / b = (a DIV b) + (a % b) / b - We compute the latter with a as csecs and b as cmillis, - mixing the multiplication by 1000. */ - cmillis = csecs * 1000 + cmicros / 1000; - cdiv = (cbytes / cmillis) * 1000; - crem = (cbytes % cmillis) * 1000; - cbps = cdiv + (crem / cmillis); - if (cmillis < 0 || cdiv < 0 || crem < 0 || cbps < 0) - { - /* We overflowed using milliseconds, so use seconds. */ - cbps = cbytes / (csecs + ((cmicros > 500000L) ? 1 : 0)); - } - } - - if (eLstats == NULL) - { - if (fLstats_tried) - return; - fLstats_tried = TRUE; - eLstats = esysdep_fopen (zLstatsfile, TRUE, TRUE, TRUE); - if (eLstats == NULL) - return; - } - -#if HAVE_TAYLOR_LOGGING - fprintf (eLstats, - "%s %s (%s) %s%s %ld bytes in %ld.%03ld seconds (%ld bytes/sec) on port %s\n", - zuser, zsystem, zldate_and_time (), - fsucceeded ? "" : "failed after ", - fsent ? "sent" : "received", - cbytes, csecs, cmicros / 1000, cbps, - zLdevice == NULL ? "unknown" : zLdevice); -#endif /* HAVE_TAYLOR_LOGGING */ -#if HAVE_V2_LOGGING - fprintf (eLstats, - "%s %s (%s) (%ld) %s %s %ld bytes %ld seconds\n", - zuser, zsystem, zldate_and_time (), - (long) time ((time_t *) NULL), - fsent ? "sent" : "received", - fsucceeded ? "data" : "failed after", - cbytes, csecs + cmicros / 500000); -#endif /* HAVE_V2_LOGGING */ -#if HAVE_HDB_LOGGING - { - static int iseq; - - /* I don't know what the 'C' means. The sequence number should - probably correspond to the sequence number in the log file, but - that is currently always 0; using this fake sequence number - will still at least reveal which transfers are from different - calls. */ - ++iseq; - fprintf (eLstats, - "%s!%s %c (%s) (C,%d,%d) [%s] %s %ld / %ld.%03ld secs, %ld%s%s\n", - zsystem, zuser, fcaller ? 'M' : 'S', zldate_and_time (), - iLid, iseq, zLdevice == NULL ? "unknown" : zLdevice, - fsent ? "->" : "<-", - cbytes, csecs, cmicros / 1000, cbps, - " bytes/sec", - fsucceeded ? "" : " [PARTIAL FILE]"); - } -#endif /* HAVE_HDB_LOGGING */ - - (void) fflush (eLstats); - -#if CLOSE_LOGFILES - ustats_close (); -#endif -} - -/* Close the statistics file. */ - -void -ustats_close () -{ - if (eLstats != NULL) - { - if (fclose (eLstats) != 0) - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - eLstats = NULL; - fLstats_tried = FALSE; - } -} - -/* Return the date and time in a form used for a log entry. */ - -static const char * -zldate_and_time () -{ - long isecs, imicros; - struct tm s; -#if HAVE_TAYLOR_LOGGING - static char ab[sizeof "1991-12-31 12:00:00.00"]; -#endif -#if HAVE_V2_LOGGING - static char ab[sizeof "12/31-12:00"]; -#endif -#if HAVE_HDB_LOGGING - static char ab[sizeof "12/31-12:00:00"]; -#endif - - isecs = ixsysdep_time (&imicros); - usysdep_localtime (isecs, &s); - -#if HAVE_TAYLOR_LOGGING - sprintf (ab, "%04d-%02d-%02d %02d:%02d:%02d.%02d", - s.tm_year + 1900, s.tm_mon + 1, s.tm_mday, s.tm_hour, - s.tm_min, s.tm_sec, (int) (imicros / 10000)); -#endif -#if HAVE_V2_LOGGING - sprintf (ab, "%d/%d-%02d:%02d", s.tm_mon + 1, s.tm_mday, - s.tm_hour, s.tm_min); -#endif -#if HAVE_HDB_LOGGING - sprintf (ab, "%d/%d-%d:%02d:%02d", s.tm_mon + 1, s.tm_mday, - s.tm_hour, s.tm_min, s.tm_sec); -#endif - - return ab; -} diff --git a/gnu/libexec/uucp/common_sources/policy.h b/gnu/libexec/uucp/common_sources/policy.h deleted file mode 100644 index da118b67c71e..000000000000 --- a/gnu/libexec/uucp/common_sources/policy.h +++ /dev/null @@ -1,703 +0,0 @@ -/* policy.h - Configuration file for policy decisions. To be edited on site. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* This header file contains macro definitions which must be set by - each site before compilation. The first few are system - characteristics that can not be easily discovered by the - configuration script. Most are configuration decisions that must - be made by the local administrator. */ - -/* System characteristics. */ - -/* This code tries to use several ANSI C features, including - prototypes, stdarg.h, the const qualifier and the types void - (including void * pointers) and unsigned char. By default it will - use these features if the compiler defines __STDC__. If your - compiler supports these features but does not define __STDC__, you - should set ANSI_C to 1. If your compiler does not support these - features but defines __STDC__ (no compiler should do this, in my - opinion), you should set ANSI_C to 0. In most cases (or if you're - not sure) just leave the line below commented out. */ -/* #define ANSI_C 1 */ - -/* Set USE_STDIO to 1 if data files should be read using the stdio - routines (fopen, fread, etc.) rather than the UNIX unbuffered I/O - calls (open, read, etc.). Unless you know your stdio is really - rotten, you should leave this as 1. */ -#define USE_STDIO 1 - -/* Exactly one of the following macros must be set to 1. Many modern - systems support more than one of these choices through some form of - compilation environment, in which case the setting will depend on - the compilation environment you use. If you have a reasonable - choice between options, I suspect that TERMIO or TERMIOS will be - more efficient than TTY, but I have not done any head to head - comparisons. - - If you don't set any of these macros, the code below will guess. - It will doubtless be wrong on some systems. - - HAVE_BSD_TTY -- Use the 4.2BSD tty routines - HAVE_SYSV_TERMIO -- Use the System V termio routines - HAVE_POSIX_TERMIOS -- Use the POSIX termios routines - */ -#define HAVE_BSD_TTY 0 -#define HAVE_SYSV_TERMIO 0 -#define HAVE_POSIX_TERMIOS 1 - -/* This code tries to guess which terminal driver to use if you did - not make a choice above. It is in this file to make it easy to - figure out what's happening if something goes wrong. */ - -#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS == 0 -#if HAVE_TERMIOS_H -#undef HAVE_POSIX_TERMIOS -#define HAVE_POSIX_TERMIOS 1 -#else /* ! HAVE_TERMIOS_H */ -#if HAVE_CBREAK -#undef HAVE_BSD_TTY -#define HAVE_BSD_TTY 1 -#else /* ! HAVE_CBREAK */ -#undef HAVE_SYSV_TERMIO -#define HAVE_SYSV_TERMIO 1 -#endif /* ! HAVE_CBREAK */ -#endif /* ! HAVE_TERMIOS_H */ -#endif /* HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS == 0 */ - -/* On some systems a write to a serial port will block even if the - file descriptor has been set to not block. File transfer can be - more efficient if the package knows that a write to the serial port - will not block; however, if the write does block unexpectedly then - data loss is possible at high speeds. - - If writes to a serial port always block even when requested not to, - you should set HAVE_UNBLOCKED_WRITES to 0; otherwise you should set - it to 1. In general on System V releases without STREAMS-based - ttys (e.g., before SVR4) HAVE_UNBLOCKED_WRITES should be 0 and on - BSD or SVR4 it should be 1. - - If HAVE_UNBLOCKED_WRITES is set to 1 when it should be 0 you may - see an unexpectedly large number of transmission errors, or, if you - have hardware handshaking, transfer times may be lower than - expected (but then, they always are). If HAVE_UNBLOCKED_WRITES is - set to 0 when it should be 1, file transfer will use more CPU time - than necessary. If you are unsure, setting HAVE_UNBLOCKED_WRITES - to 0 should always be safe. */ -#define HAVE_UNBLOCKED_WRITES 1 - -/* When the code does do a blocking write, it wants to write the - largest amount of data which the kernel will accept as a single - unit. On BSD this is typically the value of OBUFSIZ in - , usually 100. On System V before SVR4 this is - typically the size of a clist, CLSIZE in , which is - usually 64. On SVR4, which uses STREAMS-based ttys, 2048 is - reasonable. Define SINGLE_WRITE to the correct value for your - system. If SINGLE_WRITE is too large, data loss may occur. If - SINGLE_WRITE is too small, file transfer will use more CPU time - than necessary. If you have no idea, 64 should work on most modern - systems. */ -#define SINGLE_WRITE 100 - -/* Some tty drivers, such as those from SCO and AT&T's Unix PC, have a - bug in the implementation of ioctl() that causes CLOCAL to be - ineffective until the port is opened a second time. If - HAVE_CLOCAL_BUG is set to 1, code will be added to do this second - open on the port. Set this if you are getting messages that say - "Line disconnected" while in the dial chat script after only - writing the first few characters to the port. This bug causes the - resetting of CLOCAL to have no effect, so the "\m" (require - carrier) escape sequence won't function properly in dialer chat - scripts. */ -#define HAVE_CLOCAL_BUG 0 - -/* On some systems, such as SCO Xenix, resetting DTR on a port - apparently prevents getty from working on the port, and thus - prevents anybody from dialing in. If HAVE_RESET_BUG is set to 1, - DTR will not be reset when a serial port is closed. */ -#define HAVE_RESET_BUG 0 - -/* The Sony NEWS reportedly handles no parity by clearing both the odd - and even parity bits in the sgtty structure, unlike most BSD based - systems in which no parity is indicated by setting both the odd and - even parity bits. Setting HAVE_PARITY_BUG to 1 will handle this - correctly. */ -#define HAVE_PARITY_BUG 0 - -#if HAVE_BSD_TTY -#ifdef sony -#undef HAVE_PARITY_BUG -#define HAVE_PARITY_BUG 1 -#endif -#endif - -/* On Ultrix 4.0, at least, setting CBREAK causes input characters to - be stripped, regardless of the setting of LPASS8 and LLITOUT. This - can be worked around by using the termio call to reset ISTRIP. - This probably does not apply to any other operating system. - Setting HAVE_STRIP_BUG to 1 will use this workaround. */ -#define HAVE_STRIP_BUG 0 - -#if HAVE_BSD_TTY -#ifdef __ultrix__ -#ifndef ultrix -#define ultrix -#endif -#endif -#ifdef ultrix -#undef HAVE_STRIP_BUG -#define HAVE_STRIP_BUG 1 -#endif -#endif - -/* If your system implements full duplex pipes, set - HAVE_FULLDUPLEX_PIPES to 1. Everything should work fine if you - leave it set to 0, but setting it to 1 can be slightly more - efficient. */ -#define HAVE_FULLDUPLEX_PIPES 0 - -/* TIMES_TICK is the fraction of a second which times(2) returns (for - example, if times returns 100ths of a second TIMES_TICK should be - set to 100). On a true POSIX system (one which has the sysconf - function and also has _SC_CLK_TCK defined in ) TIMES_TICK - may simply be left as 0. On some systems the environment variable - HZ is what you want for TIMES_TICK, but on some other systems HZ - has the wrong value; check the man page. If you leave this set to - 0, the code will try to guess; it will doubtless be wrong on some - non-POSIX systems. If TIMES_TICK is wrong the code may report - incorrect file transfer times in the statistics file, but on many - systems times(2) will actually not be used and this value will not - matter at all. */ -#define TIMES_TICK 0 - -/* If your system does not support saved set user ID, set - HAVE_SAVED_SETUID to 0. However, this is ignored if your system - has the setreuid function. Most modern Unixes have one or the - other. If your system has the setreuid function, don't worry about - this define, or about the following discussion. - - If you set HAVE_SAVED_SETUID to 0, you will not be able to use uucp - to transfer files that the uucp user can not read. Basically, you - will only be able to use uucp on world-readable files. If you set - HAVE_SAVED_SETUID to 1, but your system does not have saved set - user ID, uucp will fail with an error message whenever anybody - other than the uucp user uses it. */ -#define HAVE_SAVED_SETUID 0 - -/* On some systems, such as 4.4BSD-Lite, NetBSD, the DG Aviion and, - possibly, the RS/6000, the setreuid function is broken. It should - be possible to use setreuid to swap the real and effective user - ID's, but on some systems it will not change the real user ID (I - believe this is due to a misreading of the POSIX standard). On - such a system you must set HAVE_BROKEN_SETREUID to 1; if you do - not, you will get error messages from setreuid. Systems on which - setreuid exists but is broken pretty much always have saved setuid. */ -#define HAVE_BROKEN_SETREUID 0 - -/* On a few systems, such as NextStep 3.3, the POSIX macro F_SETLKW is - defined, but does not work. On such systems, you must set - HAVE_BROKEN_SETLKW to 1. If you do not, uux will hang, or log - peculiar error messages, every time it is run. */ -#define HAVE_BROKEN_SETLKW 0 - -/* On the 3B2, and possibly other systems, nap takes an argument in - hundredths of a second rather than milliseconds. I don't know of - any way to test for this. Set HAVE_HUNDREDTHS_NAP to 1 if this is - true on your system. This does not matter if your system does not - have the nap function. */ -#define HAVE_HUNDREDTHS_NAP 0 - -/* Set MAIL_PROGRAM to a program which can be used to send mail. It - will be used for mail to both local and remote users. Set - MAIL_PROGRAM_TO_BODY to 1 if the recipient should be specified as a - To: line in the body of the message; otherwise, the recipient will - be provided as an argument to MAIL_PROGRAM. Set - MAIL_PROGRAM_SUBJECT_BODY if the subject should be specified as a - Subject: line in the body of the message; otherwise, the subject - will be provided using the -s option to MAIL_PROGRAM (if your mail - program does not support the -s option, you must set - MAIL_PROGRAM_SUBJECT_BODY to 1). If your system uses sendmail, use - the sendmail choice below. Otherwise, select one of the other - choices as appropriate. */ -#if 1 -#define MAIL_PROGRAM "/usr/sbin/sendmail -t" -#define MAIL_PROGRAM_TO_BODY 1 -#define MAIL_PROGRAM_SUBJECT_BODY 1 -#endif -#if 0 -#define MAIL_PROGRAM "/usr/ucb/mail" -#define MAIL_PROGRAM_TO_BODY 0 -#define MAIL_PROGRAM_SUBJECT_BODY 0 -#endif -#if 0 -#define MAIL_PROGRAM "/bin/mail" -#define MAIL_PROGRAM_TO_BODY 0 -#define MAIL_PROGRAM_SUBJECT_BODY 1 -#endif - -/* Set PS_PROGRAM to the program to run to get a process status, - including the arguments to pass it. This is used by ``uustat -p''. - Set HAVE_PS_MULTIPLE to 1 if a comma separated list of process - numbers may be appended (e.g. ``ps -flp1,10,100''). Otherwise ps - will be invoked several times, with a single process number append - each time. The default definitions should work on most systems, - although some (such as the NeXT) will complain about the 'p' - option; for those, use the second set of definitions. The third - set of definitions are appropriate for System V. To use the second - or third set of definitions, change the ``#if 1'' to ``#if 0'' and - change the appropriate ``#if 0'' to ``#if 1''. */ -#if 1 -#define PS_PROGRAM "/bin/ps -lp" -#define HAVE_PS_MULTIPLE 0 -#endif -#if 0 -#define PS_PROGRAM "/bin/ps -l" -#define HAVE_PS_MULTIPLE 0 -#endif -#if 0 -#define PS_PROGRAM "/bin/ps -flp" -#define HAVE_PS_MULTIPLE 1 -#endif -#ifdef __QNX__ -/* Use this for QNX, along with HAVE_QNX_LOCKFILES. */ -#undef PS_PROGRAM -#undef HAVE_PS_MULTIPLE -#define PS_PROGRAM "/bin/ps -l -n -p" -#define HAVE_PS_MULTIPLE 0 -#endif - -/* If you use other programs that also lock devices, such as cu or - uugetty, the other programs and UUCP must agree on whether a device - is locked. This is typically done by creating a lock file in a - specific directory; the lock files are generally named - LCK..something or LK.something. If the LOCKDIR macro is defined, - these lock files will be placed in the named directory; otherwise - they will be placed in the default spool directory. On some HDB - systems the lock files are placed in /etc/locks. On some they are - placed in /usr/spool/locks. On the NeXT they are placed in - /usr/spool/uucp/LCK. */ -/* #define LOCKDIR "/usr/spool/uucp" */ -/* #define LOCKDIR "/etc/locks" */ -/* #define LOCKDIR "/usr/spool/locks" */ -/* #define LOCKDIR "/usr/spool/uucp/LCK" */ -#define LOCKDIR "/var/spool/lock" - -/* You must also specify the format of the lock files by setting - exactly one of the following macros to 1. Check an existing lock - file to decide which of these choices is more appropriate. - - The HDB style is to write the locking process ID in ASCII, passed - to ten characters, followed by a newline. - - The V2 style is to write the locking process ID as four binary - bytes in the host byte order. Many BSD derived systems use this - type of lock file, including the NeXT. - - SCO lock files are similar to HDB lock files, but always lock the - lowercase version of the tty (i.e., LCK..tty2a is created if you - are locking tty2A). They are appropriate if you are using Taylor - UUCP on an SCO Unix, SCO Xenix, or SCO Open Desktop system. - - SVR4 lock files are also similar to HDB lock files, but they use a - different naming convention. The filenames are LK.xxx.yyy.zzz, - where xxx is the major device number of the device holding the - special device file, yyy is the major device number of the port - device itself, and zzz is the minor device number of the port - device. - - Sequent DYNIX/ptx (but perhaps not Dynix 3.x) uses yet another - naming convention. The lock file for /dev/ttyXA/XAAP is named - LCK..ttyXAAP. - - Coherent use a completely different method of terminal locking. - See unix/cohtty for details. For locks other than for terminals, - HDB type lock files are used. - - QNX lock files are similar to HDB lock files except that the node - ID must be stored in addition to the process ID and for serial - devices the node ID must be included in the lock file name. QNX - boxes are generally used in bunches, and all of them behave like - one big machine to some extent. Thus, processes on different - machines will be sharing the files in the spool directory. To - detect if a process has died and a lock is thus stale, you need the - node ID of the process as well as the process ID. The process ID - is stored as a number written using ASCII digits padded to 10 - characters, followed by a space, followed by the node ID written - using ASCII digits padded to 10 characters, followed by a newline. - The format for QNX lock files was made up just for Taylor UUCP. - QNX doesn't come with a version of UUCP. */ -#define HAVE_V2_LOCKFILES 0 -#define HAVE_HDB_LOCKFILES 1 -#define HAVE_SCO_LOCKFILES 0 -#define HAVE_SVR4_LOCKFILES 0 -#define HAVE_SEQUENT_LOCKFILES 0 -#define HAVE_COHERENT_LOCKFILES 0 -#define HAVE_QNX_LOCKFILES 0 - -/* This tries to pick a default based on preprocessor definitions. - Ignore it if you have explicitly set one of the above values. */ -#if HAVE_V2_LOCKFILES + HAVE_HDB_LOCKFILES + HAVE_SCO_LOCKFILES + HAVE_SVR4_LOCKFILES + HAVE_SEQUENT_LOCKFILES + HAVE_COHERENT_LOCKFILES + HAVE_QNX_LOCKFILES == 0 -#ifdef __QNX__ -#undef HAVE_QNX_LOCKFILES -#define HAVE_QNX_LOCKFILES 1 -#else /* ! defined (__QNX__) */ -#ifdef __COHERENT__ -#undef HAVE_COHERENT_LOCKFILES -#define HAVE_COHERENT_LOCKFILES 1 -#else /* ! defined (__COHERENT__) */ -#ifdef _SEQUENT_ -#undef HAVE_SEQUENT_LOCKFILES -#define HAVE_SEQUENT_LOCKFILES 1 -#else /* ! defined (_SEQUENT) */ -#ifdef sco -#undef HAVE_SCO_LOCKFILES -#define HAVE_SCO_LOCKFILES 1 -#else /* ! defined (sco) */ -#ifdef __svr4__ -#undef HAVE_SVR4_LOCKFILES -#define HAVE_SVR4_LOCKFILES 1 -#else /* ! defined (__svr4__) */ -/* Final default is HDB. There's no way to tell V2 from HDB. */ -#undef HAVE_HDB_LOCKFILES -#define HAVE_HDB_LOCKFILES 1 -#endif /* ! defined (__svr4__) */ -#endif /* ! defined (sco) */ -#endif /* ! defined (_SEQUENT) */ -#endif /* ! defined (__COHERENT__) */ -#endif /* ! defined (__QNX__) */ -#endif /* no LOCKFILES define */ - -/* If your system supports Internet mail addresses (which look like - user@host.domain rather than system!user), HAVE_INTERNET_MAIL - should be set to 1. This is checked by uuxqt and uustat when - sending notifications to the person who submitted the job. - - If your system does not understand addresses of the form user@host, - you must set HAVE_INTERNET_MAIL to 0. - - If your system does not understand addresses of the form host!user, - which is unlikely, you must set HAVE_INTERNET_MAIL to 1. - - If your system sends mail addressed to "A!B@C" to host C (i.e., it - parses the address as "(A!B)@C"), you must set HAVE_INTERNET_MAIL - to 1. - - If your system sends mail addressed to "A!B@C" to host A (i.e., it - parses the address as "A!(B@C)"), you must set HAVE_INTERNET_MAIL - to 0. - - Note that in general it is best to avoid addresses of the form - "A!B@C" because of this ambiguity of precedence. UUCP will not - intentionally generate addresses of this form, but it can occur in - certain rather complex cases. */ -#define HAVE_INTERNET_MAIL 1 - -/* Adminstrative decisions. */ - -/* Set USE_RCS_ID to 1 if you want the RCS ID strings compiled into - the executable. Leaving them out will decrease the executable - size. Leaving them in will make it easier to determine which - version you are running. */ -#define USE_RCS_ID 1 - -/* DEBUG controls how much debugging information is compiled into the - code. If DEBUG is defined as 0, no sanity checks will be done and - no debugging messages will be compiled in. If DEBUG is defined as - 1 sanity checks will be done but there will still be no debugging - messages. If DEBUG is 2 than debugging messages will be compiled - in. When initially testing, DEBUG should be 2, and you should - probably leave it at 2 unless a small reduction in the executable - file size will be very helpful. */ -#define DEBUG 2 - -/* Set HAVE_ENCRYPTED_PASSWORDS to 1 if you want login passwords to be - encrypted before comparing them against the values in the file. - This only applies when uucico is run with the -l or -e switches and - is doing its own login prompting. Note that the passwords used are - from the UUCP password file, not the system /etc/passwd file. See - the documentation for further details. If you set this, you are - responsible for encrypting the passwords in the UUCP password file. - The function crypt will be used to do comparisons. */ -#define HAVE_ENCRYPTED_PASSWORDS 0 - -/* Set the default grade to use for a uucp command if the -g option is - not used. The grades, from highest to lowest, are 0 to 9, A to Z, - a to z. */ -#define BDEFAULT_UUCP_GRADE ('N') - -/* Set the default grade to use for a uux command if the -g option is - not used. */ -#define BDEFAULT_UUX_GRADE ('N') - -/* To compile in use of the new style of configuration files described - in the documentation, set HAVE_TAYLOR_CONFIG to 1. */ -#define HAVE_TAYLOR_CONFIG 1 - -/* To compile in use of V2 style configuration files (L.sys, L-devices - and so on), set HAVE_V2_CONFIG to 1. To compile in use of HDB - style configuration files (Systems, Devices and so on) set - HAVE_HDB_CONFIG to 1. The files will be looked up in the - oldconfigdir directory as defined in the Makefile. - - You may set any or all of HAVE_TAYLOR_CONFIG, HAVE_V2_CONFIG and - HAVE_HDB_CONFIG to 1 (you must set at least one of the macros). - When looking something up (a system, a port, etc.) the new style - configuration files will be read first, followed by the V2 - configuration files, followed by the HDB configuration files. */ -#define HAVE_V2_CONFIG 0 -#define HAVE_HDB_CONFIG 1 - -/* Exactly one of the following macros must be set to 1. The exact - format of the spool directories is explained in unix/spool.c. - - SPOOLDIR_V2 -- Use a Version 2 (original UUCP) style spool directory - SPOOLDIR_BSD42 -- Use a BSD 4.2 style spool directory - SPOOLDIR_BSD43 -- Use a BSD 4.3 style spool directory - SPOOLDIR_HDB -- Use a HDB (BNU) style spool directory - SPOOLDIR_ULTRIX -- Use an Ultrix style spool directory - SPOOLDIR_SVR4 -- Use a System V Release 4 spool directory - SPOOLDIR_TAYLOR -- Use a new style spool directory - - If you are not worried about compatibility with a currently running - UUCP, use SPOOLDIR_TAYLOR. */ -#define SPOOLDIR_V2 0 -#define SPOOLDIR_BSD42 0 -#define SPOOLDIR_BSD43 0 -#define SPOOLDIR_HDB 0 -#define SPOOLDIR_ULTRIX 0 -#define SPOOLDIR_SVR4 0 -#define SPOOLDIR_TAYLOR 1 - -/* The status file generated by UUCP can use either the traditional - HDB upper case comments or new easier to read lower case comments. - This affects the display of uustat -m or uustat -q. Some - third-party programs read these status files and expect them to be - in a certain format. The default is to use the traditional - comments when using an HDB or SVR4 spool directory, and to use - lower case comments otherwise. */ -#define USE_TRADITIONAL_STATUS (SPOOLDIR_HDB || SPOOLDIR_SVR4) - -/* You must select which type of logging you want by setting exactly - one of the following to 1. These control output to the log file - and to the statistics file. - - If you define HAVE_TAYLOR_LOGGING, each line in the log file will - look something like this: - - uucico uunet uucp (1991-12-10 09:04:34.45 16390) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uucp uunet (1991-12-10 09:04:40.20) received 2371 bytes in 5 seconds (474 bytes/sec) - - If you define HAVE_V2_LOGGING, each line in the log file will look - something like this: - - uucico uunet uucp (12/10-09:04 16390) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uucp uunet (12/10-09:04 16390) (692373862) received data 2371 bytes 5 seconds - - If you define HAVE_HDB_LOGGING, each program will by default use a - separate log file. For uucico talking to uunet, for example, it - will be /usr/spool/uucp/.Log/uucico/uunet. Each line will look - something like this: - - uucp uunet (12/10-09:04:22,16390,1) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, 474 bytes/sec - - The main reason to prefer one format over another is that you may - have shell scripts which expect the files to have a particular - format. If you have none, choose whichever format you find more - appealing. */ -#define HAVE_TAYLOR_LOGGING 1 -#define HAVE_V2_LOGGING 0 -#define HAVE_HDB_LOGGING 0 - -/* If QNX_LOG_NODE_ID is set to 1, log messages will include the QNX - node ID just after the process ID. This is a policy decision - because it changes the log file entry format, which can break other - programs (e.g., some of the ones in the contrib directory) which - expect to read the standard log file format. */ -#ifdef __QNX__ -#define QNX_LOG_NODE_ID 1 -#else -#define QNX_LOG_NODE_ID 0 -#endif - -/* If LOG_DEVICE_PREFIX is 1, log messages will give the full - pathname of a device rather than just the final component. This is - important because on QNX //2/dev/ser2 refers to a different device - than //4/dev/ser2. */ -#ifdef __QNX__ -#define LOG_DEVICE_PREFIX 1 -#else -#define LOG_DEVICE_PREFIX 0 -#endif - -/* If you would like the log, debugging and statistics files to be - closed after each message, set CLOSE_LOGFILES to 1. This will - permit the log files to be easily moved. If a log file does not - exist when a new message is written out, it will be created. - Setting CLOSE_LOGFILES to 1 will obviously require slightly more - processing time. */ -#define CLOSE_LOGFILES 0 - -/* The name of the default spool directory. If HAVE_TAYLOR_CONFIG is - set to 1, this may be overridden by the ``spool'' command in the - configuration file. */ -/* #define SPOOLDIR "/usr/spool/uucp" */ -#define SPOOLDIR "/var/spool/uucp" - -/* The name of the default public directory. If HAVE_TAYLOR_CONFIG is - set to 1, this may be overridden by the ``pubdir'' command in the - configuration file. Also, a particular system may be given a - specific public directory by using the ``pubdir'' command in the - system file. */ -/* #define PUBDIR "/usr/spool/uucppublic" */ -#define PUBDIR "/var/spool/uucppublic" - -/* The default command path. This is a space separated list of - directories. Remote command executions requested by uux are looked - up using this path. If you are using HAVE_TAYLOR_CONFIG, the - command path may be overridden for a particular system. For most - systems, you should just make sure that the programs rmail and - rnews can be found using this path. */ -#define CMDPATH "/bin /usr/bin /usr/local/bin" - -/* The default amount of free space to require for systems that do not - specify an amount with the ``free-space'' command. This is only - used when talking to another instance of Taylor UUCP; if accepting - a file would not leave at least this many bytes free on the disk, - it will be refused. */ -#define DEFAULT_FREE_SPACE (50000) - -/* While a file is being received, Taylor UUCP will periodically check - to see if there is enough free space remaining on the disk. If - there is not enough space available on the disk (as determined by - DEFAULT_FREE_SPACE, above, or the ``free-space'' command for the - system) the communication will be aborted. The disk will be - checked each time FREE_SPACE_DELTA bytes are received. Lower - values of FREE_SPACE_DELTA are less likely to fill up the disk, but - will also waste more time checking the amount of free space. To - avoid checking the disk while the file is being received, set - FREE_SPACE_DELTA to 0. */ -#define FREE_SPACE_DELTA (10240) - -/* It is possible for an execute job to request to be executed using - sh(1), rather than execve(2). This is such a security risk, it is - being disabled by default; to allow such jobs, set the following - macro to 1. */ -#define ALLOW_SH_EXECUTION 0 - -/* If a command executed on behalf of a remote system takes a filename - as an argument, a security breach may be possible (note that on my - system neither of the default commands, rmail and rnews, take - filename arguments). If you set ALLOW_FILENAME_ARGUMENTS to 0, all - arguments to a command will be checked; if any argument - 1) starts with ../ - 2) contains the string /../ - 3) begins with a / but does not name a file that may be sent or - received (according to the specified ``remote-send'' and - ``remote-receive'') - the command will be rejected. By default, any argument is - permitted. */ -#define ALLOW_FILENAME_ARGUMENTS 1 - -/* If you set FSYNC_ON_CLOSE to 1, all output files will be forced out - to disk using the fsync system call when they are closed. This can - be useful if you can not afford to lose people's mail if the system - crashes. However, not all systems have the fsync call, and it is - always less efficient to use it. Note that some versions of SCO - Unix, and possibly other systems, make fsync a synonym for sync, - which is extremely inefficient. */ -#define FSYNC_ON_CLOSE 0 - -#if HAVE_TAYLOR_LOGGING - -/* The default log file when using HAVE_TAYLOR_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. */ -/* #define LOGFILE "/usr/spool/uucp/Log" */ -#define LOGFILE "/var/spool/uucp/Log" - -/* The default statistics file when using HAVE_TAYLOR_LOGGING. When - using HAVE_TAYLOR_CONFIG, this may be overridden by the - ``statfile'' command in the configuration file. */ -/* #define STATFILE "/usr/spool/uucp/Stats" */ -#define STATFILE "/var/spool/uucp/Stats" - -/* The default debugging file when using HAVE_TAYLOR_LOGGING. When - using HAVE_TAYLOR_CONFIG, this may be overridden by the - ``debugfile'' command in the configuration file. */ -/* #define DEBUGFILE "/usr/spool/uucp/Debug" */ -#define DEBUGFILE "/var/spool/uucp/Debug" - -#endif /* HAVE_TAYLOR_LOGGING */ - -#if HAVE_V2_LOGGING - -/* The default log file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. */ -#define LOGFILE "/usr/spool/uucp/LOGFILE" - -/* The default statistics file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile'' - command in the configuration file. */ -#define STATFILE "/usr/spool/uucp/SYSLOG" - -/* The default debugging file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile'' - command in the configuration file. */ -#define DEBUGFILE "/usr/spool/uucp/DEBUG" - -#endif /* HAVE_V2_LOGGING */ - -#if HAVE_HDB_LOGGING - -/* The default log file when using HAVE_HDB_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. The first %s in the string will - be replaced by the program name (e.g. uucico); the second %s will - be replaced by the system name (if there is no appropriate system, - "ANY" will be used). No other '%' character may appear in the - string. */ -#define LOGFILE "/usr/spool/uucp/.Log/%s/%s" - -/* The default statistics file when using HAVE_HDB_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile'' - command in the configuration file. */ -#define STATFILE "/usr/spool/uucp/.Admin/xferstats" - -/* The default debugging file when using HAVE_HDB_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile'' - command in the configuration file. */ -#define DEBUGFILE "/usr/spool/uucp/.Admin/audit.local" - -#endif /* HAVE_HDB_LOGGING */ diff --git a/gnu/libexec/uucp/common_sources/prot.c b/gnu/libexec/uucp/common_sources/prot.c deleted file mode 100644 index 6661c1fa7b1f..000000000000 --- a/gnu/libexec/uucp/common_sources/prot.c +++ /dev/null @@ -1,241 +0,0 @@ -/* prot.c - Protocol support routines to move commands and data around. - - Copyright (C) 1991, 1992, 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char prot_rcsid[] = "$FreeBSD$"; -#endif - -#include - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "conn.h" -#include "prot.h" - -/* Variables visible to the protocol-specific routines. */ - -/* Buffer to hold received data. */ -char abPrecbuf[CRECBUFLEN]; - -/* Index of start of data in abPrecbuf. */ -int iPrecstart; - -/* Index of end of data (first byte not included in data) in abPrecbuf. */ -int iPrecend; - -/* We want to output and input at the same time, if supported on this - machine. If we have something to send, we send it all while - accepting a large amount of data. Once we have sent everything we - look at whatever we have received. If data comes in faster than we - can send it, we may run out of buffer space. */ - -boolean -fsend_data (qconn, zsend, csend, fdoread) - struct sconnection *qconn; - const char *zsend; - size_t csend; - boolean fdoread; -{ - if (! fdoread) - return fconn_write (qconn, zsend, csend); - - while (csend > 0) - { - size_t crec, csent; - - if (iPrecend < iPrecstart) - crec = iPrecstart - iPrecend - 1; - else - { - crec = CRECBUFLEN - iPrecend; - if (iPrecstart == 0) - --crec; - } - - if (crec == 0) - return fconn_write (qconn, zsend, csend); - - csent = csend; - - if (! fconn_io (qconn, zsend, &csent, abPrecbuf + iPrecend, &crec)) - return FALSE; - - csend -= csent; - zsend += csent; - - iPrecend = (iPrecend + crec) % CRECBUFLEN; - } - - return TRUE; -} - -/* Read data from the other system when we have nothing to send. The - argument cneed is the amount of data the caller wants, and ctimeout - is the timeout in seconds. The function sets *pcrec to the amount - of data which was actually received, which may be less than cneed - if there isn't enough room in the receive buffer. If no data is - received before the timeout expires, *pcrec will be returned as 0. - If an error occurs, the function returns FALSE. If the freport - argument is FALSE, no error should be reported. */ - -boolean -freceive_data (qconn, cneed, pcrec, ctimeout, freport) - struct sconnection *qconn; - size_t cneed; - size_t *pcrec; - int ctimeout; - boolean freport; -{ - /* Set *pcrec to the maximum amount of data we can read. fconn_read - expects *pcrec to be the buffer size, and sets it to the amount - actually received. */ - if (iPrecend < iPrecstart) - *pcrec = iPrecstart - iPrecend - 1; - else - { - *pcrec = CRECBUFLEN - iPrecend; - if (iPrecstart == 0) - --(*pcrec); - } - -#if DEBUG > 0 - /* If we have no room in the buffer, we're in trouble. The - protocols must be written to ensure that this can't happen. */ - if (*pcrec == 0) - ulog (LOG_FATAL, "freceive_data: No room in buffer"); -#endif - - /* If we don't have room for all the data the caller wants, we - simply have to expect less. We'll get the rest later. */ - if (*pcrec < cneed) - cneed = *pcrec; - - if (! fconn_read (qconn, abPrecbuf + iPrecend, pcrec, cneed, ctimeout, - freport)) - return FALSE; - - iPrecend = (iPrecend + *pcrec) % CRECBUFLEN; - - return TRUE; -} - -/* Read a single character. Get it out of the receive buffer if it's - there, otherwise ask freceive_data for at least one character. - This is used because as a protocol is shutting down freceive_data - may read ahead and eat characters that should be read outside the - protocol routines. We call freceive_data rather than fconn_read - with an argument of 1 so that we can get all the available data in - a single system call. The ctimeout argument is the timeout in - seconds; the freport argument is FALSE if no error should be - reported. This returns a character, or -1 on timeout or -2 on - error. */ - -int -breceive_char (qconn, ctimeout, freport) - struct sconnection *qconn; - int ctimeout; - boolean freport; -{ - char b; - - if (iPrecstart == iPrecend) - { - size_t crec; - - if (! freceive_data (qconn, sizeof (char), &crec, ctimeout, freport)) - return -2; - if (crec == 0) - return -1; - } - - b = abPrecbuf[iPrecstart]; - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - return BUCHAR (b); -} - -/* Send mail about a file transfer. We send to the given mailing - address if there is one, otherwise to the user. */ - -boolean -fmail_transfer (fsuccess, zuser, zmail, zwhy, zfromfile, zfromsys, - ztofile, ztosys, zsaved) - boolean fsuccess; - const char *zuser; - const char *zmail; - const char *zwhy; - const char *zfromfile; - const char *zfromsys; - const char *ztofile; - const char *ztosys; - const char *zsaved; -{ - const char *zsendto; - const char *az[20]; - int i; - - if (zmail != NULL && *zmail != '\0') - zsendto = zmail; - else - zsendto = zuser; - - i = 0; - az[i++] = "The file\n\t"; - if (zfromsys != NULL) - { - az[i++] = zfromsys; - az[i++] = "!"; - } - az[i++] = zfromfile; - if (fsuccess) - az[i++] = "\nwas successfully transferred to\n\t"; - else - az[i++] = "\ncould not be transferred to\n\t"; - if (ztosys != NULL) - { - az[i++] = ztosys; - az[i++] = "!"; - } - az[i++] = ztofile; - az[i++] = "\nas requested by\n\t"; - az[i++] = zuser; - if (! fsuccess) - { - az[i++] = "\nfor the following reason:\n\t"; - az[i++] = zwhy; - az[i++] = "\n"; - } - if (zsaved != NULL) - { - az[i++] = zsaved; - az[i++] = "\n"; - } - - return fsysdep_mail (zsendto, - fsuccess ? "UUCP succeeded" : "UUCP failed", - i, az); -} diff --git a/gnu/libexec/uucp/common_sources/prot.h b/gnu/libexec/uucp/common_sources/prot.h deleted file mode 100644 index 11c3941c5c50..000000000000 --- a/gnu/libexec/uucp/common_sources/prot.h +++ /dev/null @@ -1,270 +0,0 @@ -/* prot.h - Protocol header file. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* We need the definition of uuconf_cmdtab to declare the protocol - parameter arrays. */ -#ifndef UUCONF_H -#include "uuconf.h" -#endif - -#if ANSI_C -/* These structures are used in prototypes but are not defined in this - header file. */ -struct sdaemon; -struct sconnection; -struct stransfer; -#endif - -/* The sprotocol structure holds information and functions for a specific - protocol (e.g. the 'g' protocol). */ - -struct sprotocol -{ - /* The name of the protocol (e.g. 'g'). */ - char bname; - /* Reliability requirements, an or of UUCONF_RELIABLE_xxx defines - from uuconf.h. */ - int ireliable; - /* The maximum number of channels this protocol can support. */ - int cchans; - /* Whether files may be reliably restarted using this protocol. */ - boolean frestart; - /* Protocol parameter commands. */ - struct uuconf_cmdtab *qcmds; - /* A routine to start the protocol. If *pzlog is set to be - non-NULL, it is an informative message to be logged; it should - then be passed to ubuffree. */ - boolean (*pfstart) P((struct sdaemon *qdaemon, char **pzlog)); - /* Shutdown the protocol. */ - boolean (*pfshutdown) P((struct sdaemon *qdaemon)); - /* Send a command to the other side. */ - boolean (*pfsendcmd) P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); - /* Get buffer to space to fill with data. This should set *pcdata - to the amount of data desired. */ - char *(*pzgetspace) P((struct sdaemon *qdaemon, size_t *pcdata)); - /* Send data to the other side. The argument z must be a return - value of pzgetspace. The ipos argument is the file position, and - is ignored by most protocols. */ - boolean (*pfsenddata) P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); - /* Wait for data to come in and call fgot_data with it until - fgot_data sets *pfexit. */ - boolean (*pfwait) P((struct sdaemon *qdaemon)); - /* Handle any file level actions that need to be taken. If a file - transfer is starting rather than ending, fstart is TRUE. If the - file is being sent rather than received, fsend is TRUE. If - fstart and fsend are both TRUE, cbytes holds the size of the - file. If *pfhandled is set to TRUE, then the protocol routine - has taken care of queueing up qtrans for the next action. */ - boolean (*pffile) P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); -}; - -/* Send data to the other system. If the fread argument is TRUE, this - will also receive data into the receive buffer abPrecbuf; fread is - passed as TRUE if the protocol expects data to be coming back, to - make sure the input buffer does not fill up. Returns FALSE on - error. */ -extern boolean fsend_data P((struct sconnection *qconn, - const char *zsend, size_t csend, - boolean fdoread)); - -/* Receive data from the other system when there is no data to send. - The cneed argument is the amount of data desired and the ctimeout - argument is the timeout in seconds. This will set *pcrec to the - amount of data received. It will return FALSE on error. If a - timeout occurs, it will return TRUE with *pcrec set to zero. */ -extern boolean freceive_data P((struct sconnection *qconn, size_t cneed, - size_t *pcrec, int ctimeout, - boolean freport)); - -/* Get one character from the remote system, going through the - procotol buffering. The ctimeout argument is the timeout in - seconds, and the freport argument is TRUE if errors should be - reported (when closing a connection it is pointless to report - errors). This returns a character or -1 on a timeout or -2 on an - error. */ -extern int breceive_char P((struct sconnection *qconn, - int ctimeout, boolean freport)); - -/* Compute a 32 bit CRC of a data buffer, given an initial CRC. */ -extern unsigned long icrc P((const char *z, size_t c, unsigned long ick)); - -/* The initial CRC value to use for a new buffer. */ -#if ANSI_C -#define ICRCINIT (0xffffffffUL) -#else -#define ICRCINIT ((unsigned long) 0xffffffffL) -#endif - -/* The size of the receive buffer. */ -#define CRECBUFLEN (16384) - -/* Buffer to hold received data. */ -extern char abPrecbuf[CRECBUFLEN]; - -/* Index of start of data in abPrecbuf. */ -extern int iPrecstart; - -/* Index of end of data (first byte not included in data) in abPrecbuf. */ -extern int iPrecend; - -/* There are a couple of variables and functions that are shared by - the 'i' and 'j' protocols (the 'j' protocol is just a wrapper - around the 'i' protocol). These belong in a separate header file, - protij.h, but I don't want to create one for just a couple of - things. */ - -/* An escape sequence of characters for the 'j' protocol to avoid - (protocol parameter ``avoid''). */ -extern const char *zJavoid_parameter; - -/* Timeout to use when sending the 'i' protocol SYNC packet (protocol - parameter ``sync-timeout''). */ -extern int cIsync_timeout; - -/* Shared startup routine for the 'i' and 'j' protocols. */ -extern boolean fijstart P((struct sdaemon *qdaemon, char **pzlog, - int imaxpacksize, - boolean (*pfsend) P((struct sconnection *qconn, - const char *zsend, - size_t csend, - boolean fdoread)), - boolean (*pfreceive) P((struct sconnection *qconn, - size_t cneed, - size_t *pcrec, - int ctimeout, - boolean freport)))); - -/* Prototypes for 'g' protocol functions. */ - -extern struct uuconf_cmdtab asGproto_params[]; -extern boolean fgstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fbiggstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fvstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fgshutdown P((struct sdaemon *qdaemon)); -extern boolean fgsendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zggetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean fgsenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean fgwait P((struct sdaemon *qdaemon)); - -/* Prototypes for 'f' protocol functions. */ - -extern struct uuconf_cmdtab asFproto_params[]; -extern boolean ffstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean ffshutdown P((struct sdaemon *qdaemon)); -extern boolean ffsendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zfgetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean ffsenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean ffwait P((struct sdaemon *qdaemon)); -extern boolean fffile P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); - -/* Prototypes for 't' protocol functions. */ - -extern struct uuconf_cmdtab asTproto_params[]; -extern boolean ftstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean ftshutdown P((struct sdaemon *qdaemon)); -extern boolean ftsendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *ztgetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean ftsenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean ftwait P((struct sdaemon *qdaemon)); -extern boolean ftfile P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); - -/* Prototypes for 'e' protocol functions. */ - -extern struct uuconf_cmdtab asEproto_params[]; -extern boolean festart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean feshutdown P((struct sdaemon *qdaemon)); -extern boolean fesendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zegetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean fesenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean fewait P((struct sdaemon *qdaemon)); -extern boolean fefile P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); - -/* Prototypes for 'i' protocol functions. */ - -extern struct uuconf_cmdtab asIproto_params[]; -extern boolean fistart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fishutdown P((struct sdaemon *qdaemon)); -extern boolean fisendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zigetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean fisenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean fiwait P((struct sdaemon *qdaemon)); - -/* Prototypes for 'j' protocol functions. The 'j' protocol mostly - uses the 'i' protocol functions, but it has a couple of functions - of its own. */ - -extern boolean fjstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fjshutdown P((struct sdaemon *qdaemon)); - -/* Prototypes for 'a' protocol functions (these use 'z' as the second - character because 'a' is a modified Zmodem protocol). */ - -extern struct uuconf_cmdtab asZproto_params[]; -extern boolean fzstart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fzshutdown P((struct sdaemon *qdaemon)); -extern boolean fzsendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zzgetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean fzsenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean fzwait P((struct sdaemon *qdaemon)); -extern boolean fzfile P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); - -/* Prototypes for 'y' protocol functions. */ - -extern struct uuconf_cmdtab asYproto_params[]; -extern boolean fystart P((struct sdaemon *qdaemon, char **pzlog)); -extern boolean fyshutdown P((struct sdaemon *qdaemon)); -extern boolean fysendcmd P((struct sdaemon *qdaemon, const char *z, - int ilocal, int iremote)); -extern char *zygetspace P((struct sdaemon *qdaemon, size_t *pcdata)); -extern boolean fysenddata P((struct sdaemon *qdaemon, char *z, size_t c, - int ilocal, int iremote, long ipos)); -extern boolean fywait P((struct sdaemon *qdaemon)); -extern boolean fyfile P((struct sdaemon *qdaemon, struct stransfer *qtrans, - boolean fstart, boolean fsend, long cbytes, - boolean *pfhandled)); diff --git a/gnu/libexec/uucp/common_sources/sysdep.h b/gnu/libexec/uucp/common_sources/sysdep.h deleted file mode 100644 index 8b7e279d80dc..000000000000 --- a/gnu/libexec/uucp/common_sources/sysdep.h +++ /dev/null @@ -1,563 +0,0 @@ -/* sysh.unx -*- C -*- - The header file for the UNIX system dependent routines. - - Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#ifndef SYSH_UNX_H - -#define SYSH_UNX_H - -#if ANSI_C -/* These structures are used in prototypes but are not defined in this - header file. */ -struct uuconf_system; -struct sconnection; -#endif - -/* SCO, SVR4 and Sequent lockfiles are basically just like HDB - lockfiles. */ -#if HAVE_SCO_LOCKFILES || HAVE_SVR4_LOCKFILES || HAVE_SEQUENT_LOCKFILES -#undef HAVE_HDB_LOCKFILES -#define HAVE_HDB_LOCKFILES 1 -#endif - -#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS != 1 - #error Terminal driver define not set or duplicated -#endif - -#if SPOOLDIR_V2 + SPOOLDIR_BSD42 + SPOOLDIR_BSD43 + SPOOLDIR_HDB + SPOOLDIR_ULTRIX + SPOOLDIR_SVR4 + SPOOLDIR_TAYLOR != 1 - #error Spool directory define not set or duplicated -#endif - -/* If setreuid is broken, don't use it. */ -#if HAVE_BROKEN_SETREUID -#undef HAVE_SETREUID -#define HAVE_SETREUID 0 -#endif - -/* Get some standard types from the configuration header file. */ -#ifdef PID_T -typedef PID_T pid_t; -#endif - -#ifdef UID_T -typedef UID_T uid_t; -#endif - -#ifdef GID_T -typedef GID_T gid_t; -#endif - -#ifdef OFF_T -typedef OFF_T off_t; -#endif - -/* On Unix, binary files are the same as text files. */ -#define BINREAD "r" -#define BINWRITE "w" - -/* If we have sigaction, we can force system calls to not be - restarted. */ -#if HAVE_SIGACTION -#undef HAVE_RESTARTABLE_SYSCALLS -#define HAVE_RESTARTABLE_SYSCALLS 0 -#endif - -/* If we have sigvec, and we have HAVE_SIGVEC_SV_FLAGS, and - SV_INTERRUPT is defined, we can force system calls to not be - restarted (signal.h is included by uucp.h before this point, so - SV_INTERRUPT will be defined by now if it it ever is). */ -#if HAVE_SIGVEC && HAVE_SIGVEC_SV_FLAGS -#ifdef SV_INTERRUPT -#undef HAVE_RESTARTABLE_SYSCALLS -#define HAVE_RESTARTABLE_SYSCALLS 0 -#endif -#endif - -/* If we were cross-configured, we will have a value of -1 for - HAVE_RESTARTABLE_SYSCALLS. In this case, we try to guess what the - correct value should be. Yuck. If we have sigvec, but neither of - the above cases applied (which we know because they would have - changed HAVE_RESTARTABLE_SYSCALLS) then we are probably on 4.2BSD - and system calls are automatically restarted. Otherwise, assume - that they are not. */ -#if HAVE_RESTARTABLE_SYSCALLS == -1 -#undef HAVE_RESTARTABLE_SYSCALLS -#if HAVE_SIGVEC -#define HAVE_RESTARTABLE_SYSCALLS 1 -#else -#define HAVE_RESTARTABLE_SYSCALLS 0 -#endif -#endif /* HAVE_RESTARTABLE_SYSCALLS == -1 */ - -/* We don't handle sigset in combination with restartable system - calls, so we check for it although this combination will never - happen. */ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && HAVE_SIGSET -#if HAVE_RESTARTABLE_SYSCALLS -#undef HAVE_SIGSET -#define HAVE_SIGSET 0 -#endif -#endif - -/* If we don't have restartable system calls, we can ignore - fsysdep_catch, usysdep_start_catch and usysdep_end_catch. - Otherwise fsysdep_catch has to do a setjmp. */ - -#if ! HAVE_RESTARTABLE_SYSCALLS - -#define fsysdep_catch() (TRUE) -#define usysdep_start_catch() -#define usysdep_end_catch() -#define CATCH_PROTECT - -#else /* HAVE_RESTARTABLE_SYSCALLS */ - -#if HAVE_SETRET && ! HAVE_SIGSETJMP -#include -#define setjmp setret -#define longjmp longret -#define jmp_buf ret_buf -#else /* ! HAVE_SETRET || HAVE_SIGSETJMP */ -#include -#if HAVE_SIGSETJMP -#undef setjmp -#undef longjmp -#undef jmp_buf -#define setjmp(s) sigsetjmp ((s), TRUE) -#define longjmp siglongjmp -#define jmp_buf sigjmp_buf -#endif /* HAVE_SIGSETJMP */ -#endif /* ! HAVE_SETRET || HAVE_SIGSETJMP */ - -extern volatile sig_atomic_t fSjmp; -extern volatile jmp_buf sSjmp_buf; - -#define fsysdep_catch() (setjmp (sSjmp_buf) == 0) - -#define usysdep_start_catch() (fSjmp = TRUE) - -#define usysdep_end_catch() (fSjmp = FALSE) - -#define CATCH_PROTECT volatile - -#endif /* HAVE_RESTARTABLE_SYSCALLS */ - -/* Get definitions for the terminal driver. */ - -#if HAVE_BSD_TTY -#include -struct sbsd_terminal -{ - struct sgttyb stty; - struct tchars stchars; - struct ltchars sltchars; -}; -typedef struct sbsd_terminal sterminal; -#define fgetterminfo(o, q) \ - (ioctl ((o), TIOCGETP, &(q)->stty) == 0 \ - && ioctl ((o), TIOCGETC, &(q)->stchars) == 0 \ - && ioctl ((o), TIOCGLTC, &(q)->sltchars) == 0) -#define fsetterminfo(o, q) \ - (ioctl ((o), TIOCSETN, &(q)->stty) == 0 \ - && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \ - && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0) -#define fsetterminfodrain(o, q) \ - (ioctl ((o), TIOCSETP, &(q)->stty) == 0 \ - && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \ - && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0) -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO -#include -typedef struct termio sterminal; -#define fgetterminfo(o, q) (ioctl ((o), TCGETA, (q)) == 0) -#define fsetterminfo(o, q) (ioctl ((o), TCSETA, (q)) == 0) -#define fsetterminfodrain(o, q) (ioctl ((o), TCSETAW, (q)) == 0) -#endif /* HAVE_SYSV_TERMIO */ - -#if HAVE_POSIX_TERMIOS -#include -typedef struct termios sterminal; -#define fgetterminfo(o, q) (tcgetattr ((o), (q)) == 0) -#define fsetterminfo(o, q) (tcsetattr ((o), TCSANOW, (q)) == 0) -#define fsetterminfodrain(o, q) (tcsetattr ((o), TCSADRAIN, (q)) == 0) - -/* On some systems it is not possible to include both - and in the same source files; I don't really know why. - On such systems, we pretend that we don't have . */ -#if ! HAVE_TERMIOS_AND_SYS_IOCTL_H -#undef HAVE_SYS_IOCTL_H -#define HAVE_SYS_IOCTL_H 0 -#endif - -#endif /* HAVE_POSIX_TERMIOS */ - -/* The root directory (this is needed by the system independent stuff - as the default for local-send). */ -#define ZROOTDIR "/" - -/* The name of the execution directory within the spool directory - (this is need by the system independent uuxqt.c). */ -#define XQTDIR ".Xqtdir" - -/* The name of the directory in which we preserve file transfers that - failed. */ -#define PRESERVEDIR ".Preserve" - -/* The name of the directory to which we move corrupt files. */ -#define CORRUPTDIR ".Corrupt" - -/* The name of the directory to which we move failed execution files. */ -#define FAILEDDIR ".Failed" - -/* The length of the sequence number used in a file name. */ -#define CSEQLEN (4) - -/* Get some standard definitions. Avoid including the files more than - once--some might have been included by uucp.h. */ -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif -#if ! USE_TYPES_H -#include -#endif -#include - -/* Get definitions for the file permission bits. */ - -#ifndef S_IRWXU -#define S_IRWXU 0700 -#endif -#ifndef S_IRUSR -#define S_IRUSR 0400 -#endif -#ifndef S_IWUSR -#define S_IWUSR 0200 -#endif -#ifndef S_IXUSR -#define S_IXUSR 0100 -#endif - -#ifndef S_IRWXG -#define S_IRWXG 0070 -#endif -#ifndef S_IRGRP -#define S_IRGRP 0040 -#endif -#ifndef S_IWGRP -#define S_IWGRP 0020 -#endif -#ifndef S_IXGRP -#define S_IXGRP 0010 -#endif - -#ifndef S_IRWXO -#define S_IRWXO 0007 -#endif -#ifndef S_IROTH -#define S_IROTH 0004 -#endif -#ifndef S_IWOTH -#define S_IWOTH 0002 -#endif -#ifndef S_IXOTH -#define S_IXOTH 0001 -#endif - -#if STAT_MACROS_BROKEN -#undef S_ISDIR -#endif - -#ifndef S_ISDIR -#ifdef S_IFDIR -#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR) -#else /* ! defined (S_IFDIR) */ -#define S_ISDIR(i) (((i) & 0170000) == 040000) -#endif /* ! defined (S_IFDIR) */ -#endif /* ! defined (S_ISDIR) */ - -/* We need the access macros. */ -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 -#endif /* ! defined (R_OK) */ - -/* We create files with these modes (should this be configurable?). */ -#define IPRIVATE_FILE_MODE (S_IRUSR | S_IWUSR) -#define IPUBLIC_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) - -/* We create directories with this mode (should this be configurable?). */ -#define IDIRECTORY_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) -#define IPUBLIC_DIRECTORY_MODE (S_IRWXU | S_IRWXG | S_IRWXO) - -#if ! HAVE_OPENDIR - -/* Define some structures to use if we don't have opendir, etc. These - will only work if we have the old Unix filesystem, with a 2 byte - inode and a 14 byte filename. */ - -#include - -struct dirent -{ - char d_name[DIRSIZ + 1]; -}; - -typedef struct -{ - int o; - struct dirent s; -} DIR; - -extern DIR *opendir P((const char *zdir)); -extern struct dirent *readdir P((DIR *)); -extern int closedir P((DIR *)); - -#endif /* ! HAVE_OPENDIR */ - -#if ! HAVE_FTW_H - -/* If there is no , define the ftw constants. */ - -#define FTW_F (0) -#define FTW_D (1) -#define FTW_DNR (2) -#define FTW_NS (3) - -#endif /* ! HAVE_FTW_H */ - -/* This structure holds the system dependent information we keep for a - connection. This is used by the TCP and TLI code. */ - -struct ssysdep_conn -{ - /* File descriptor. */ - int o; - /* File descriptor to read from (used by stdin and pipe port types). */ - int ord; - /* File descriptor to write to (used by stdin and pipe port types). */ - int owr; - /* Device name. */ - char *zdevice; - /* File status flags. */ - int iflags; - /* File status flags for write descriptor (-1 if not used). */ - int iwr_flags; - /* Hold the real descriptor when using a dialer device. */ - int ohold; - /* TRUE if this is a terminal and the remaining fields are valid. */ - boolean fterminal; - /* TRUE if this is a TLI descriptor. */ - boolean ftli; - /* Baud rate. */ - long ibaud; - /* Original terminal settings. */ - sterminal sorig; - /* Current terminal settings. */ - sterminal snew; - /* Process ID of currently executing pipe command, or parent process - of forked TCP or TLI server, or -1. */ - pid_t ipid; -#if HAVE_COHERENT_LOCKFILES - /* On Coherent we need to hold on to the real port name which will - be used to enable the port. Ick. */ - char *zenable; -#endif -}; - -/* These functions do I/O and chat scripts to a port. They are called - by the TCP and TLI routines. */ -extern boolean fsysdep_conn_read P((struct sconnection *qconn, - char *zbuf, size_t *pclen, - size_t cmin, int ctimeout, - boolean freport)); -extern boolean fsysdep_conn_write P((struct sconnection *qconn, - const char *zbuf, size_t clen)); -extern boolean fsysdep_conn_io P((struct sconnection *qconn, - const char *zwrite, size_t *pcwrite, - char *zread, size_t *pcread)); -extern boolean fsysdep_conn_chat P((struct sconnection *qconn, - char **pzprog)); - -/* Set a signal handler. */ -extern void usset_signal P((int isig, RETSIGTYPE (*pfn) P((int)), - boolean fforce, boolean *pfignored)); - -/* Default signal handler. This sets the appropriate element of the - afSignal array. If system calls are automatically restarted, it - may do a longjmp to an fsysdep_catch. */ -extern RETSIGTYPE ussignal P((int isig)); - -/* Try to fork, repeating several times. */ -extern pid_t ixsfork P((void)); - -/* Spawn a job. Returns the process ID of the spawned job or -1 on - error. The following macros may be passed in aidescs. */ - -/* Set descriptor to /dev/null. */ -#define SPAWN_NULL (-1) -/* Set element of aidescs to a pipe for caller to read from. */ -#define SPAWN_READ_PIPE (-2) -/* Set element of aidescs to a pipe for caller to write to. */ -#define SPAWN_WRITE_PIPE (-3) - -extern pid_t ixsspawn P((const char **pazargs, int *aidescs, - boolean fkeepuid, boolean fkeepenv, - const char *zchdir, boolean fnosigs, - boolean fshell, const char *zpath, - const char *zuu_machine, - const char *zuu_user)); - -/* Do a form of popen using ixsspawn. */ -extern FILE *espopen P((const char **pazargs, boolean frd, - pid_t *pipid)); - -/* Wait for a particular process to finish, returning the exit status. - The process ID should be pid_t, but we can't put that in a - prototype. */ -extern int ixswait P((unsigned long ipid, const char *zreport)); - -/* Read from a connection using two file descriptors. */ -extern boolean fsdouble_read P((struct sconnection *qconn, char *zbuf, - size_t *pclen, size_t cmin, int ctimeout, - boolean freport)); - -/* Write to a connection using two file descriptors. */ -extern boolean fsdouble_write P((struct sconnection *qconn, - const char *zbuf, size_t clen)); - -/* Run a chat program on a connection using two file descriptors. */ -extern boolean fsdouble_chat P((struct sconnection *qconn, - char **pzprog)); - -/* Find a spool file in the spool directory. For a local file, the - bgrade argument is the grade of the file. This is needed for - SPOOLDIR_SVR4. */ -extern char *zsfind_file P((const char *zsimple, const char *zsystem, - int bgrade)); - -/* Return the grade given a sequence number. */ -extern int bsgrade P((pointer pseq)); - -/* Lock a string. */ -extern boolean fsdo_lock P((const char *, boolean fspooldir, - boolean *pferr)); - -/* Unlock a string. */ -extern boolean fsdo_unlock P((const char *, boolean fspooldir)); - -/* Check access for a particular user name, or NULL to check access - for any user. */ -extern boolean fsuser_access P((const struct stat *, int imode, - const char *zuser)); - -/* Switch to the permissions of the invoking user. This sets the - argument to a value to pass to fsuucp_perms. */ -extern boolean fsuser_perms P((uid_t *)); - -/* Switch back to the permissions of the UUCP user ID. This should be - passed the value returned by fsuser_perms in its argument. */ -extern boolean fsuucp_perms P((long)); - -/* Stick two directories and a file name together. */ -extern char *zsappend3 P((const char *zdir1, const char *zdir2, - const char *zfile)); - -/* Stick three directories and a file name together. */ -extern char *zsappend4 P((const char *zdir1, const char *zdir2, - const char *zdir3, const char *zfile)); - -/* Get a temporary file name. */ -extern char *zstemp_file P((const struct uuconf_system *qsys)); - -/* Get a command file name. */ -extern char *zscmd_file P((const struct uuconf_system *qsys, int bgrade)); - -/* Get a jobid from a system, a file name, and a grade. */ -extern char *zsfile_to_jobid P((const struct uuconf_system *qsys, - const char *zfile, - int bgrade)); - -/* Get a file name from a jobid. This also returns the associated system - in *pzsystem and the grade in *pbgrade. */ -extern char *zsjobid_to_file P((const char *zid, char **pzsystem, - char *pbgrade)); - -/* See whether there is a spool directory for a system when using - SPOOLDIR_ULTRIX. */ -extern boolean fsultrix_has_spool P((const char *zsystem)); - -#if HAVE_COHERENT_LOCKFILES -/* Lock a coherent tty. */ -extern boolean lockttyexist P((const char *z)); -extern boolean fscoherent_disable_tty P((const char *zdevice, - char **pzenable)); -#endif - -/* Some replacements for standard Unix functions. */ - -#if ! HAVE_DUP2 -extern int dup2 P((int oold, int onew)); -#endif - -#if ! HAVE_FTW -extern int ftw P((const char *zdir, - int (*pfn) P((const char *zfile, - struct stat *qstat, - int iflag)), - int cdescriptors)); -#endif - -#if ! HAVE_GETCWD && ! HAVE_GETWD -extern char *getcwd P((char *zbuf, size_t cbuf)); -#endif - -#if ! HAVE_MKDIR -extern int mkdir P((const char *zdir, int imode)); -#endif - -#if ! HAVE_RENAME -extern int rename P((const char *zold, const char *znew)); -#endif - -#if ! HAVE_RMDIR -extern int rmdir P((const char *zdir)); -#endif - -/* The working directory from which the program was run (this is set - by usysdep_initialize if called with INIT_GETCWD). */ -extern char *zScwd; - -/* The spool directory name. */ -extern const char *zSspooldir; - -/* The lock directory name. */ -extern const char *zSlockdir; - -/* The local UUCP name (needed for some spool directory stuff). */ -extern const char *zSlocalname; - -#endif /* ! defined (SYSH_UNX_H) */ diff --git a/gnu/libexec/uucp/common_sources/system.h b/gnu/libexec/uucp/common_sources/system.h deleted file mode 100644 index 5fcc525f9841..000000000000 --- a/gnu/libexec/uucp/common_sources/system.h +++ /dev/null @@ -1,994 +0,0 @@ -/* system.h - Header file for system dependent stuff in the Taylor UUCP package. - This file is not itself system dependent. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#ifndef SYSTEM_H - -#define SYSTEM_H - -#if ANSI_C -/* These structures are used in prototypes but are not defined in this - header file. */ -struct tm; -struct uuconf_system; -struct uuconf_port; -struct sconnection; -struct sstatus; -struct scmd; -#endif - -/* Any function which returns an error should also report an error - message, unless otherwise indicated. - - Any function that returns a char *, rather than a const char *, is - returning a pointer to a buffer allocated by zbufalc which must be - freed using ubuffree, unless otherwise indicated. */ - -/* The maximum length of a remote system name. */ -extern size_t cSysdep_max_name_len; - -/* Initialize. If something goes wrong, this routine should just - exit. The flag argument is 0, or a combination of any of the - following flags. */ - -/* This program needs to know the current working directory. This is - used because on Unix it can be expensive to determine the current - working directory (some versions of getcwd fork a process), but in - most cases we don't need to know it. However, we are going to - chdir to the spool directory (unless INIT_CHDIR is set), so we have - to get the cwd now if we are ever going to get it. Both uucp and - uux use the function fsysdep_needs_cwd to determine whether they - will need the current working directory, and pass the argument to - usysdep_initialize appropriately. There's probably a cleaner way - to handle this, but this will suffice for now. */ -#define INIT_GETCWD (01) - -/* This program should not chdir to the spool directory. This may - only make sense on Unix. It is set by cu. */ -#define INIT_NOCHDIR (02) - -/* This program needs special access to the spool directories. That - means, on Unix, this program is normally installed setuid. */ -#define INIT_SUID (04) - -/* Do not close all open descriptors. This is not used by the UUCP - code, but it is used by other programs which share some of the - system dependent libraries. */ -#define INIT_NOCLOSE (010) - -extern void usysdep_initialize P((pointer puuconf, int iflags)); - -/* Exit the program. The fsuccess argument indicates whether to - return an indication of success or failure to the outer - environment. This routine should not return. */ -extern void usysdep_exit P((boolean fsuccess)); - -/* Called when a non-standard configuration file is being used, to - avoid handing out privileged access. If it returns FALSE, default - configuration file will be used. This is called before the - usysdep_initialize function is called. */ -extern boolean fsysdep_other_config P((const char *)); - -/* Detach from the controlling terminal. This probably only makes - sense on Unix. It is called by uucico to try to get the modem port - as a controlling terminal. It is also called by uucico before it - starts up uuxqt, so that uuxqt will be a complete daemon. */ -extern void usysdep_detach P((void)); - -/* Get the local node name if it is not specified in the configuration - files. Returns NULL on error; otherwise the return value should - point to a static buffer. */ -extern const char *zsysdep_localname P((void)); - -/* Get the login name. This is used when uucico is started up with no - arguments in slave mode, which causes it to assume that somebody - has logged in. It also used by uucp and uux for recording the user - name. This may not return NULL. The return value should point to - a static buffer. */ -extern const char *zsysdep_login_name P((void)); - -/* Set a signal handler for a signal. If the signal occurs, the - appropriate element of afSignal should be set to the signal number - (see the declaration of afSignal in uucp.h). This routine might be - able to just use signal, but Unix requires more complex handling. - This is called before usysdep_initialize. */ -extern void usysdep_signal P((int isig)); - -/* Catch a signal. This is actually defined as a macro in the system - dependent header file, and the prototype here just indicates how it - should be called. It is called before a routine which must exit if - a signal occurs, and is expected to set do a setjmp (which is why - it must be a macro). It is actually only called in one place in - the system independent code, before the call to read stdin in uux. - This is needed to handle 4.2 BSD restartable system calls, which - require a longjmp. On systems which don't need to do - setjmp/longjmp around system calls, this can be redefined in - sysdep.h to TRUE. It should return TRUE if the routine should - proceed, or FALSE if a signal occurred. After having this return - TRUE, usysdep_start_catch should be used to start catching the - signal; this basically tells the signal handler that it's OK to do - the longjmp, if fsysdep_catch did not already do so. */ -#ifndef fsysdep_catch -extern boolean fsysdep_catch P((void)); -#endif - -/* Start catching a signal. This is called after fsysdep_catch to - tell the signal handler to go ahead and do the longjmp. This may - be implemented as a macro in sysdep.h. */ -#ifndef usysdep_start_catch -extern void usysdep_start_catch P((void)); -#endif - -/* Stop catching a signal. This is called when it is no longer - necessary for fsysdep_catch to handle signals. This may be - implemented as a macro in sysdep.h. */ -#ifndef usysdep_end_catch -extern void usysdep_end_catch P((void)); -#endif - -/* Link two files. On Unix this should attempt the link. If it - succeeds it should return TRUE with *pfworked set to TRUE. If the - link fails because it must go across a device, it should return - TRUE with *pfworked set to FALSE. If the link fails for some other - reason, it should log an error message and return FALSE. On a - system which does not support links to files, this should just - return TRUE with *pfworked set to FALSE. */ -extern boolean fsysdep_link P((const char *zfrom, const char *zto, - boolean *pfworked)); - -/* Get the port name. This is used when uucico is started up in slave - mode to figure out which port was used to call in so that it can - determine any appropriate protocol parameters. This may return - NULL if the port cannot be determined, which will just mean that no - protocol parameters are applied. The name returned should be the - sort of name that would appear in the port file. This should set - *pftcp_port to TRUE if it can determine that the port is a TCP - connection rather than a normal serial port. The return value (if - not NULL) should point to a static buffer. */ -extern const char *zsysdep_port_name P((boolean *pftcp_port)); - -/* Expand a file name on the local system. On Unix, if the zfile - argument begins with ~user/ it goes in that users home directory, - and if it begins with ~/ it goes in the public directory (the - public directory is passed to this routine, since each system may - have its own public directory). Similar conventions may be - desirable on other systems. This should always return an absolute - path name, probably in the public directory. It should return NULL - on error; otherwise the return value should be allocated using - zbufcpy or zbufalc. If pfbadname is not NULL, then if the function - returns NULL *pfbadname should be set to TRUE if the error is just - that the file name is badly specified; *pfbadname should be set to - FALSE for some sort of internal error. */ -extern char *zsysdep_local_file P((const char *zname, - const char *zpubdir, - boolean *pfbadname)); - -/* Return whether a file name is in a directory, and check for read or - write access. This should check whether zfile is within zdir (or - is zdir itself). If it is not, it should return FALSE. If zfile - is in zdir, then fcheck indicates whether further checking should - be done. If fcheck is FALSE, no further checking is done. - Otherwise, if freadable is TRUE the user zuser should have search - access to all directories from zdir down to zfile and should have - read access on zfile itself (if zfile does not exist, or is not a - regular file, this function may return FALSE but does not have to). - If freadable is FALSE, the user zuser should have search access to - all directories from zdir down to zfile and should have write - access on zfile (which may be a directory, or may not actually - exist, which is acceptable). The zuser argument may be NULL, in - which case the check should be made for any user, not just zuser. - There is no way for this function to return error. */ -extern boolean fsysdep_in_directory P((const char *zfile, - const char *zdir, - boolean fcheck, - boolean freadable, - const char *zuser)); - -/* Return TRUE if a file exists, FALSE otherwise. There is no way to - return error. */ -extern boolean fsysdep_file_exists P((const char *zfile)); - -/* Start up a program. If the ffork argument is true, this should - spawn a new process and return. If the ffork argument is false, - this may either return or not. The three string arguments may be - catenated together to form the program to execute; I did it this - way to make it easy to call execl(2), and because I never needed - more than two arguments. The program will always be "uucico" or - "uuxqt". The return value should be TRUE on success, FALSE on - error. */ -extern boolean fsysdep_run P((boolean ffork, const char *zprogram, - const char *zarg1, const char *zarg2)); - -/* Send a mail message. This function will be passed an array of - strings. All necessary newlines are already included; the strings - should simply be concatenated together to form the mail message. - It should return FALSE on error, although the return value is often - ignored. */ -extern boolean fsysdep_mail P((const char *zto, const char *zsubject, - int cstrs, const char **paz)); - -/* Get the time in seconds since some epoch. The actual epoch is - unimportant, so long as the time values are consistent across - program executions and the value is never negative. If the - pimicros argument is not NULL, it should be set to the number of - microseconds (if this is not available, *pimicros should be set to - zero). */ -extern long ixsysdep_time P((long *pimicros)); - -/* Get the time in seconds and microseconds (millionths of a second) - since some epoch. The actual epoch is not important, and it may - change in between program invocations; this is provided because on - Unix the times function may be used. If microseconds can not be - determined, *pimicros can just be set to zero. */ -extern long ixsysdep_process_time P((long *pimicros)); - -/* Parse the value returned by ixsysdep_time into a struct tm. I - assume that this structure is defined in . This is - basically just localtime, except that the ANSI function takes a - time_t which may not be what is returned by ixsysdep_time. */ -extern void usysdep_localtime P((long itime, struct tm *q)); - -/* Sleep for a number of seconds. */ -extern void usysdep_sleep P((int cseconds)); - -/* Pause for half a second, or 1 second if subsecond sleeps are not - possible. */ -extern void usysdep_pause P((void)); - -/* Lock a remote system. This should return FALSE if the system is - already locked (no error should be reported). */ -extern boolean fsysdep_lock_system P((const struct uuconf_system *qsys)); - -/* Unlock a remote system. This should return FALSE on error - (although the return value is generally ignored). */ -extern boolean fsysdep_unlock_system P((const struct uuconf_system *qsys)); - -/* Get the conversation sequence number for a remote system, and - increment it for next time. This should return -1 on error. */ -extern long ixsysdep_get_sequence P((const struct uuconf_system *qsys)); - -/* Get the status of a remote system. This should return FALSE on - error. Otherwise it should set *qret to the status. If no status - information is available, this should set *qret to sensible values - and return TRUE. If pfnone is not NULL, then it should be set to - TRUE if no status information was available or FALSE otherwise. */ -extern boolean fsysdep_get_status P((const struct uuconf_system *qsys, - struct sstatus *qret, - boolean *pfnone)); - -/* Set the status of a remote system. This should return FALSE on - error. The system will be locked before this call is made. */ -extern boolean fsysdep_set_status P((const struct uuconf_system *qsys, - const struct sstatus *qset)); - -/* See whether a remote system is permitted to log in. This is just - to support the remote.unknown shell script for HDB. The zscript - argument is the script name, as return by uuconf_remote_unknown. - The zsystem argument is the name given by the remote system. If - the system is not permitted to log in, this function should log an - error and return FALSE. */ -extern boolean fsysdep_unknown_caller P((const char *zscript, - const char *zsystem)); - -/* Check whether there is work for a remote system. It should return - TRUE if there is work, FALSE otherwise; there is no way to indicate - an error. */ -extern boolean fsysdep_has_work P((const struct uuconf_system *qsys)); - -/* Initialize the work scan. This will be called before - fsysdep_get_work. The bgrade argument is the minimum grade of - execution files that should be considered (e.g. a bgrade of 'd' - will allow all grades from 'A' to 'Z' and 'a' to 'd'). This - function should return FALSE on error. */ -extern boolean fsysdep_get_work_init P((const struct uuconf_system *qsys, - int bgrade)); - -/* Get the next command to be executed for a remote system. The - bgrade argument will be the same as for fsysdep_get_work_init; - probably only one of these functions will use it, namely the - function for which it is more convenient. This should return FALSE - on error. The structure pointed to by qcmd should be filled in. - The strings may point into a static buffer; they will be copied out - if necessary. If there is no more work, this should set qcmd->bcmd - to 'H' and return TRUE. This should set qcmd->pseq to something - which can be passed to fsysdep_did_work to remove the job from the - queue when it has been completed. This may set qcmd->bcmd to 'P' - to represent a poll file; the main code will just pass the pseq - element of such a structure to fsysdep_did_work if the system is - called. */ -extern boolean fsysdep_get_work P((const struct uuconf_system *qsys, - int bgrade, struct scmd *qcmd)); - -/* Remove a job from the work queue. This must also remove the - temporary file used for a send command, if there is one. It should - return FALSE on error. */ -extern boolean fsysdep_did_work P((pointer pseq)); - -/* Save the temporary file for a send command. This function should - return a string that will be put into a mail message. On success - this string should say something like ``The file has been saved as - ...''. On failure it could say something like ``The file could not - be saved because ...''. If there is no temporary file, or for some - reason it's not appropriate to include a message, this function - should just return NULL. This function is used when a file send - fails for some reason, to make sure that we don't completely lost - the file. */ -extern const char *zsysdep_save_temp_file P((pointer pseq)); - -/* Save a file in a location used to hold corrupt files. This is - called if a bad execution file is found by uuxqt. This should - return the new name of the file (allocated by zbufalc), or NULL if - the move failed (in which the original file should remain). */ -extern char *zsysdep_save_corrupt_file P((const char *zfile)); - -/* Save a file in a location used to hold failed execution files. - This is called if a uuxqt execution fails. This should return the - new name of the file (allocated by zbufalc), or NULL if the move - failed (in which case the original file should remain). */ -extern char *zsysdep_save_failed_file P((const char *zfile)); - -/* Cleanup anything left over by fsysdep_get_work_init and - fsysdep_get_work. This may be called even though - fsysdep_get_work_init has not been. */ -extern void usysdep_get_work_free P((const struct uuconf_system *qsys)); - -/* Add a base name to a file if it is a directory. If zfile names a - directory, then return a string naming a file within the directory - with the base file name of zname. This should return NULL on - error. */ -extern char *zsysdep_add_base P((const char *zfile, - const char *zname)); - -/* Get a file name from the spool directory. This should return NULL - on error. The pseq argument is TRUE if the file was found from - searching the work directory; this is, unfortunately, needed to - support SVR4 spool directories. */ -extern char *zsysdep_spool_file_name P((const struct uuconf_system *qsys, - const char *zfile, - pointer pseq)); - -/* Make necessary directories. This should create all non-existent - directories for a file. If the fpublic argument is TRUE, anybody - should be permitted to create and remove files in the directory; - otherwise anybody can list the directory, but only the UUCP system - can create and remove files. It should return FALSE on error. */ -extern boolean fsysdep_make_dirs P((const char *zfile, boolean fpublic)); - -/* Create a stdio file, setting appropriate protection. If the - fpublic argument is TRUE, the file is made publically accessible; - otherwise it is treated as a private data file. If the fappend - argument is TRUE, the file is opened in append mode; otherwise any - previously existing file of the same name is removed. If the - fmkdirs argument is TRUE, then any necessary directories should - also be created. On a system in which file protections are - unimportant and the necessary directories exist, this may be - implemented as - - fopen (zfile, fappend ? "a" : "w"); - - */ -extern FILE *esysdep_fopen P((const char *zfile, boolean fpublic, - boolean fappend, boolean fmkdirs)); - -/* Open a file, using the access permission of the user who invoked - the program. The frd argument is TRUE if the file should be opened - for reading, and the fbinary argument is TRUE if the file should be - opened as a binary file (this is ignored on Unix, since there all - files are binary files). This returns an openfile_t, not a FILE *. - This is supposed to be able to open a file even if it can not be - read by the uucp user. This is not possible on some older Unix - systems. */ -extern openfile_t esysdep_user_fopen P((const char *zfile, - boolean frd, boolean fbinary)); - -/* Open a file to send to another system; the qsys argument is the - system the file is being sent to. If fcheck is TRUE, it should - make sure that the file is readable by zuser (if zuser is NULL the - file must be readable by anybody). This is to eliminate a window - between fsysdep_in_directory and esysdep_open_send. If an error - occurs, it should return EFILECLOSED. */ -extern openfile_t esysdep_open_send P((const struct uuconf_system *qsys, - const char *zname, - boolean fcheck, - const char *zuser)); - -/* Return a temporary file name to receive into. This file will be - opened by esysdep_open_receive. The qsys argument is the system - the file is coming from, the zto argument is the name the file will - have after it has been fully received, the ztemp argument, if it is - not NULL, is from the command sent by the remote system, and the - frestart argument is TRUE if the protocol and remote system permit - file transfers to be restarted. The return value must be freed - using ubuffree. The function should return NULL on error. */ -extern char *zsysdep_receive_temp P((const struct uuconf_system *qsys, - const char *zfile, - const char *ztemp, - boolean frestart)); - -/* Open a file to receive from another system. The zreceive argument - is the return value of zsysdep_receive_temp with the same qsys, - zfile and ztemp arguments. If the function can determine that this - file has already been partially received, it should set *pcrestart - to the number of bytes that have been received. If the file has - not been partially received, *pcrestart should be set to -1. - pcrestart will be passed in as NULL if file restart is not - supported by the protocol or the remote system. The function - should return EFILECLOSED on error. After the file is written, - fsysdep_move_file will be called to move the file to its final - destination, and to set the correct file mode. */ -extern openfile_t esysdep_open_receive P((const struct uuconf_system *qsys, - const char *zto, - const char *ztemp, - const char *zreceive, - long *pcrestart)); - -/* Move a file. This is used to move a received file to its final - location. The zto argument is the file to create. The zorig - argument is the name of the file to move. If fmkdirs is TRUE, then - any necessary directories are created; fpublic indicates whether - they should be publically writeable or not. If fcheck is TRUE, - this should make sure the directory is writeable by the user zuser - (if zuser is NULL, then it must be writeable by any user); this is - to avoid a window of vulnerability between fsysdep_in_directory and - fsysdep_move_file. This function should return FALSE on error, in - which case the zorig file should still exist. */ -extern boolean fsysdep_move_file P((const char *zorig, const char *zto, - boolean fmkdirs, boolean fpublic, - boolean fcheck, const char *zuser)); - -/* Change the mode of a file. The imode argument is a Unix mode. - This should return FALSE on error. */ -extern boolean fsysdep_change_mode P((const char *zfile, - unsigned int imode)); - -/* Truncate a file which we are receiving into. This may be done by - closing the original file, removing it and reopening it. This - should return FALSE on error. */ -extern openfile_t esysdep_truncate P((openfile_t e, const char *zname)); - -/* Sync a file to disk. If this fails it should log an error using - the zmsg parameter, and return FALSE. This is controlled by the - FSYNC_ON_CLOSE macro in policy.h. */ -extern boolean fsysdep_sync P((openfile_t e, const char *zmsg)); - -/* It is possible for the acknowledgement of a received file to be - lost. The sending system will then now know that the file was - correctly received, and will send it again. This can be a problem - particularly with protocols which support channels, since they may - send several small files in a single window, all of which may be - received correctly although the sending system never sees the - acknowledgement. If these files involve an execution, the - execution will happen twice, which will be bad. - - This function is called when a file is completely received. It is - supposed to try and remember the reception, in case the connection - is lost. It is passed the system, the file name to receive to, and - the temporary file name from the sending system. It should return - FALSE on error. */ -extern boolean fsysdep_remember_reception P((const struct uuconf_system *qsys, - const char *zto, - const char *ztemp)); - -/* This function is called to see if a file has already been received - successfully. It gets the same arguments as - fsysdep_remember_reception. It should return TRUE if the file was - already received, FALSE otherwise. There is no way to report - error. */ -extern boolean fsysdep_already_received P((const struct uuconf_system *qsys, - const char *zto, - const char *ztemp)); - -/* This function is called when it is no longer necessary to remember - that a file has been received. This will be called when the - protocol knows that the receive message has been acknowledged. It - gets the same arguments as fsysdep_remember_reception. it should - return FALSE on error. */ -extern boolean fsysdep_forget_reception P((const struct uuconf_system *qsys, - const char *zto, - const char *ztemp)); - -/* Start expanding a wildcarded file name. This should return FALSE - on error; otherwise subsequent calls to zsysdep_wildcard should - return file names. */ -extern boolean fsysdep_wildcard_start P((const char *zfile)); - -/* Get the next wildcard name. This should return NULL when there are - no more names to return. The return value should be freed using - ubuffree. The argument should be the same as that to - fsysdep_wildcard_start. There is no way to return error. */ -extern char *zsysdep_wildcard P((const char *zfile)); - -/* Finish getting wildcard names. This may be called before or after - zsysdep_wildcard has returned NULL. It should return FALSE on - error. */ -extern boolean fsysdep_wildcard_end P((void)); - -/* Prepare to execute a bunch of file transfer requests. This should - make an entry in the spool directory so that the next time uucico - is started up it will transfer these files. The bgrade argument - specifies the grade of the commands. The commands themselves are - in the pascmds array, which has ccmds entries. The function should - return NULL on error, or the jobid on success. The jobid is a - string that may be printed or passed to fsysdep_kill_job and - related functions, but is otherwise uninterpreted. */ -extern char *zsysdep_spool_commands P((const struct uuconf_system *qsys, - int bgrade, int ccmds, - const struct scmd *pascmds)); - -/* Get a file name to use for a data file to be copied to another - system. The ztname, zdname and zxname arguments will all either be - NULL or point to an array of CFILE_NAME_LEN characters in length. - The ztname array should be set to a temporary file name that could - be passed to zsysdep_spool_file_name to retrieve the return value - of this function; this will be appropriate for the temporary name - in a send request. The zdname array should be set to a data file - name that is appropriate for the spool directory of the other - system; this will be appropriate for the name of the destination - file in a send request of a data file for an execution of some - sort. The zxname array should be set to an execute file name that - is appropriate for the other system. The zlocalname argument is - the name of the local system as seen by the remote system, the - bgrade argument is the grade, and fxqt is TRUE if this file is - going to become an execution file. This should return NULL on - error. */ -#define CFILE_NAME_LEN (15) - -extern char *zsysdep_data_file_name P((const struct uuconf_system *qsys, - const char *zlocalname, - int bgrade, boolean fxqt, - char *ztname, char *zdname, - char *zxname)); - -/* Get a name for a local execute file. This is used by uux for a - local command with remote files. Returns NULL on error. */ -extern char *zsysdep_xqt_file_name P((void)); - -/* Beginning getting execute files. To get a list of execute files, - first fsysdep_get_xqt_init is called, then zsysdep_get_xqt is - called several times until it returns NULL, then finally - usysdep_get_xqt_free is called. If the zsystem argument is not - NULL, it is the name of a system for which execution files are - desired. */ -extern boolean fsysdep_get_xqt_init P((const char *zsystem)); - -/* Get the next execute file. This should return NULL when finished - (with *pferr set to FALSE). The zsystem argument should be the - same string as that passed to fsysdep_get_xqt_init. On an error - this should return NULL with *pferr set to TRUE. This should set - *pzsystem to the name of the system for which the execute file was - created; this is not guaranteed to match the zsystem argument--that - must be double checked by the caller. Both the return value and - *pzsystem should be freed using ubuffree. */ -extern char *zsysdep_get_xqt P((const char *zsystem, char **pzsystem, - boolean *pferr)); - -/* Clean up after getting execute files. The zsystem argument should - be the same string as that passed to fsysdep_get_xqt_init. */ -extern void usysdep_get_xqt_free P((const char *zsystem)); - -/* Get the absolute pathname of a command to execute. This is given - the legal list of commands (which may be the special case "ALL") - and the path. It must return an absolute pathname to the command. - If it gets an error it should set *pferr to TRUE and return NULL; - if the command is not found it should set *pferr to FALSE and - return NULL. */ -extern char *zsysdep_find_command P((const char *zcmd, char **pzcmds, - char **pzpath, boolean *pferr)); - -/* Expand file names for uuxqt. This exists because uuxqt on Unix has - to expand file names which begin with a ~. It does not want to - expand any other type of file name, and it turns a double ~ into a - single one without expanding. If this returns NULL, the file does - not need to be changed; otherwise it returns a zbufalc'ed string. - There is no way to report error. */ -extern char *zsysdep_xqt_local_file P((const struct uuconf_system *qsys, - const char *zfile)); - -#if ! ALLOW_FILENAME_ARGUMENTS -/* Check an argument to an execution command to make sure that it - doesn't refer to a file name that may not be accessed. This should - check the argument to see if it is a filename. If it is, it should - either reject it out of hand or it should call fin_directory_list - on the file with both qsys->zremote_receive and qsys->zremote_send. - If the file is rejected, it should log an error and return FALSE. - Otherwise it should return TRUE. */ -extern boolean fsysdep_xqt_check_file P((const struct uuconf_system *qsys, - const char *zfile)); -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - -/* Run an execute file. The arguments are: - - qsys -- system for which execute file was created - zuser -- user who requested execution - pazargs -- list of arguments to command (element 0 is command) - zfullcmd -- command and arguments stuck together in one string - zinput -- file name for standard input (may be NULL) - zoutput -- file name for standard output (may be NULL) - fshell -- if TRUE, use /bin/sh to execute file - ilock -- return value of ixsysdep_lock_uuxqt - pzerror -- set to name of standard error file - pftemp -- set to TRUE if error is temporary, FALSE otherwise - - If fshell is TRUE, the command should be executed with /bin/sh - (obviously, this can only really be done on Unix systems). If an - error occurs this should return FALSE and set *pftemp - appropriately. *pzerror should be freed using ubuffree. */ -extern boolean fsysdep_execute P((const struct uuconf_system *qsys, - const char *zuser, - const char **pazargs, - const char *zfullcmd, - const char *zinput, - const char *zoutput, - boolean fshell, - int ilock, - char **pzerror, - boolean *pftemp)); - -/* Lock for uuxqt execution. If the cmaxuuxqts argument is not zero, - this should make sure that no more than cmaxuuxqts uuxqt processes - are running at once. Also, only one uuxqt may execute a particular - command (specified by the -c option) at a time. If zcmd is not - NULL, it is a command that must be locked. This should return a - nonnegative number which will be passed to other routines, - including fsysdep_unlock_uuxqt, or -1 on error. */ -extern int ixsysdep_lock_uuxqt P((const char *zcmd, - int cmaxuuxqts)); - -/* Unlock a uuxqt process. This is passed the return value of - ixsysdep_lock_uuxqt, as well as the arguments passed to - ixsysdep_lock_uuxqt. It may return FALSE on error, but at present - the return value is ignored. */ -extern boolean fsysdep_unlock_uuxqt P((int iseq, const char *zcmd, - int cmaxuuxqts)); - -/* See whether a particular uuxqt command is locked. This should - return TRUE if the command is locked (because ixsysdep_lock_uuxqt - was called with it as an argument), FALSE otherwise. There is no - way to return error. */ -extern boolean fsysdep_uuxqt_locked P((const char *zcmd)); - -/* Lock an execute file in order to execute it. This should return - FALSE if the execute file is already locked. There is no way to - return error. */ -extern boolean fsysdep_lock_uuxqt_file P((const char *zfile)); - -/* Unlock an execute file. This should return FALSE on error. */ -extern boolean fsysdep_unlock_uuxqt_file P((const char *zfile)); - -/* Lock the execution directory. The ilock argument is the return - value of ixsysdep_lock_uuxqt. This should return FALSE if the - directory is already locked. There is no way to return error. */ -extern boolean fsysdep_lock_uuxqt_dir P((int ilock)); - -/* Remove all files in the execution directory, and unlock it. This - should return FALSE on error. */ -extern boolean fsysdep_unlock_uuxqt_dir P((int ilock)); - -/* Move files into or out of the execution directory. The code will - already have checked that all the files exist. The elements in the - pzfrom array will be complete filenames, and the elements in the - pzto array will be either NULL (in which case the file should not - be moved) or simple base names. If fto is TRUE, the files in - pzfrom should be moved to pzto; otherwise, the files in pzto should - be moved to pzfrom (this is used if a temporary failure occurs, in - which case the execution will be retried later). If pzinput and - *pzinput are not NULL, then it is the name of the standard input - file; if it is the same as any element of pzfrom, then *pzinput - should be set to the zbufcpy of the corresponding pzto value, if - any. */ -extern boolean fsysdep_move_uuxqt_files P((int cfiles, - const char *const *pzfrom, - const char *const *pzto, - boolean fto, int ilock, - char **pzinput)); - -/* Expand a file name on the local system, defaulting to the current - directory. This is just like zsysdep_local_file, except that - relative files are placed in the working directory the program - started in rather than in the public directory. This should return - NULL on error. */ -extern char *zsysdep_local_file_cwd P((const char *zname, - const char *zpubdir, - boolean *pfbadname)); - -/* Add the working directory to a file name. The named file is - actually on a remote system. If the file already has a directory, - it should not be changed. This should return NULL on error. */ -extern char *zsysdep_add_cwd P((const char *zfile)); - -/* See whether a file name will need the current working directory - when zsysdep_local_file_cwd or zsysdep_add_cwd is called on it. - This will be called before usysdep_initialize. It should just - check whether the argument is an absolute path. See the comment - above usysdep_initialize in this file for an explanation of why - things are done this way. */ -extern boolean fsysdep_needs_cwd P((const char *zfile)); - -/* Get the base name of a file. The file will be a local file name, - and this function should return the base file name, ideally in a - form which will make sense on most systems; it will be used if the - destination of a uucp is a directory. */ -extern char *zsysdep_base_name P((const char *zfile)); - -/* Return a filename within a directory. */ -extern char *zsysdep_in_dir P((const char *zdir, const char *zfile)); - -/* Get the mode of a file. This should return a Unix style file mode. - It should return 0 on error. */ -extern unsigned int ixsysdep_file_mode P((const char *zfile)); - -/* See whether the user has access to a file. This is called by uucp - and uux to prevent copying of a file which uucp can read but the - user cannot. If access is denied, this should log an error message - and return FALSE. */ -extern boolean fsysdep_access P((const char *zfile)); - -/* See whether the daemon has access to a file. This is called by - uucp and uux when a file is queued up for transfer without being - copied into the spool directory. It is merely an early error - check, as the daemon would of course discover the error itself when - it tried the transfer. If access would be denied, this should log - an error message and return FALSE. */ -extern boolean fsysdep_daemon_access P((const char *zfile)); - -/* Translate a destination from system!user to a place in the public - directory where uupick will get the file. On Unix this produces - system!~/receive/user/localname, and that's probably what it has to - produce on any other system as well. Returns NULL on a usage - error, or otherwise returns string allocated by zbufcpy. */ -extern char *zsysdep_uuto P((const char *zdest, - const char *zlocalname)); - -/* Return TRUE if a pathname exists and is a directory. */ -extern boolean fsysdep_directory P((const char *zpath)); - -/* Walk a directory tree. The zdir argument is the directory to walk. - The pufn argument is a function to call on each regular file in the - tree. The first argument to pufn should be the full filename; the - second argument to pufn should be the filename relative to zdir; - the third argument to pufn should be the pinfo argument to - usysdep_walk_tree. The usysdep_walk_tree function should return - FALSE on error. */ -extern boolean usysdep_walk_tree P((const char *zdir, - void (*pufn) P((const char *zfull, - const char *zrelative, - pointer pinfo)), - pointer pinfo)); - -/* Return the jobid of a work file, given the sequence value. On - error this should log an error and return NULL. The jobid is a - string which may be printed out and read in and passed to - fsysdep_kill_job, etc., but is not otherwise interpreted. */ -extern char *zsysdep_jobid P((const struct uuconf_system *qsys, - pointer pseq)); - -/* See whether the current user is privileged. Privileged users are - permitted to kill jobs submitted by another user, and they are - permitted to use the -u argument to uucico; other uses of this call - may be added later. This should return TRUE if permission is - granted, FALSE otherwise. */ -extern boolean fsysdep_privileged P((void)); - -/* Kill a job, given the jobid. This should remove all associated - files and in general eliminate the job completely. On error it - should log an error message and return FALSE. */ -extern boolean fsysdep_kill_job P((pointer puuconf, - const char *zjobid)); - -/* Rejuvenate a job, given the jobid. If possible, this should update - the time associated with the job such that it will not be - eliminated by uustat -K or similar programs that check the creation - time. This should affect the return value of ixsysdep_work_time. - On error it should log an error message and return FALSE. */ -extern boolean fsysdep_rejuvenate_job P((pointer puuconf, - const char *zjobid)); - -/* Get the time a job was queued, given the sequence number. There is - no way to indicate error. The return value must use the same epoch - as ixsysdep_time. */ -extern long ixsysdep_work_time P((const struct uuconf_system *qsys, - pointer pseq)); - -/* Get the time a file was created. This is called by uustat on - execution files. There is no way to indicate error. The return - value must use the same epoch as ixsysdep_time. */ -extern long ixsysdep_file_time P((const char *zfile)); - -/* Touch a file to make it appear as though it was created at the - current time. This is called by uustat on execution files. On - error this should log an error message and return FALSE. */ -extern boolean fsysdep_touch_file P((const char *zfile)); - -/* Get the size in bytes of a file. If this file does not exist, this - should not give an error message, but should return -1. If some - other error occurs, this should return -2. */ -extern long csysdep_size P((const char *zfile)); - -/* Return the amount of free space on the containing the given file - name (the file may or may not exist). If the amount of free space - cannot be determined, the function should return -1. */ -extern long csysdep_bytes_free P((const char *zfile)); - -/* Start getting status information for all systems with available - status information. There may be status information for unknown - systems, which is why this series of functions is used. The phold - argument is used to pass information around, to possibly avoid the - use of static variables. On error this should log an error and - return FALSE. */ -extern boolean fsysdep_all_status_init P((pointer *phold)); - -/* Get status information for the next system. This should return the - system name and fill in the qstat argument. The phold argument - will be that set by fsysdep_all_status_init. On error this should - log an error, set *pferr to TRUE, and return NULL. */ -extern char *zsysdep_all_status P((pointer phold, boolean *pferr, - struct sstatus *qstat)); - -/* Free up anything allocated by fsysdep_all_status_init and - zsysdep_all_status. The phold argument is that set by - fsysdep_all_status_init. */ -extern void usysdep_all_status_free P((pointer phold)); - -/* Display the process status of all processes holding lock files. - This is uustat -p. The return value is passed to usysdep_exit. */ -extern boolean fsysdep_lock_status P((void)); - -/* Return TRUE if the user has legitimate access to the port. This is - used by cu to control whether the user can open a port directly, - rather than merely being able to dial out on it. Opening a port - directly allows the modem to be reprogrammed. */ -extern boolean fsysdep_port_access P((struct uuconf_port *qport)); - -/* Return whether the given port could be named by the given line. On - Unix, the line argument would be something like "ttyd0", and this - function should return TRUE if the named port is "/dev/ttyd0". */ -extern boolean fsysdep_port_is_line P((struct uuconf_port *qport, - const char *zline)); - -/* Set the terminal into raw mode. In this mode no input characters - should be treated specially, and characters should be made - available as they are typed. The original terminal mode should be - saved, so that it can be restored by fsysdep_terminal_restore. If - flocalecho is TRUE, then local echoing should still be done; - otherwise echoing should be disabled. This function returns FALSE - on error. */ -extern boolean fsysdep_terminal_raw P((boolean flocalecho)); - -/* Restore the terminal back to the original setting, before - fsysdep_terminal_raw was called. Returns FALSE on error. */ -extern boolean fsysdep_terminal_restore P((void)); - -/* Read a line from the terminal. The fsysdep_terminal_raw function - will have been called. This should print the zprompt argument - (unless it is NULL) and return the line, allocated by zbufcpy, or - NULL on error. */ -extern char *zsysdep_terminal_line P((const char *zprompt)); - -/* Write a line to the terminal, ending with a newline. This is - basically just puts (zline, stdout), except that the terminal will - be in raw mode, so on ASCII Unix systems the line needs to end with - \r\n. */ -extern boolean fsysdep_terminal_puts P((const char *zline)); - -/* If faccept is TRUE, permit the user to generate signals from the - terminal. If faccept is FALSE, turn signals off again. After - fsysdep_terminal_raw is called, signals should be off. Return - FALSE on error. */ -extern boolean fsysdep_terminal_signals P((boolean faccept)); - -/* The cu program expects the system dependent code to handle the - details of copying data from the communications port to the - terminal. This should be set up by fsysdep_cu_init, and done while - fsysdep_cu is called. It is permissible to do it on a continual - basis (on Unix a subprocess handles it) so long as the copying can - be stopped by the fsysdep_cu_copy function. - - The fsysdep_cu_init function does any system dependent - initialization needed for this. */ -extern boolean fsysdep_cu_init P((struct sconnection *qconn)); - -/* Copy all data from the communications port to the terminal, and all - data from the terminal to the communications port. Keep this up - until the escape character *zCuvar_escape is seen. Set *pbcmd to - the character following the escape character; after the escape - character, zlocalname should be printed, possibly after a delay. - If two escape characters are entered in sequence, this function - should send a single escape character to the port, and not return. - Returns FALSE on error. */ -extern boolean fsysdep_cu P((struct sconnection *qconn, - char *pbcmd, - const char *zlocalname)); - -/* If fcopy is TRUE, start copying data from the communications port - to the terminal. If fcopy is FALSE, stop copying data. This - function may be called several times during a cu session. It - should return FALSE on error. */ -extern boolean fsysdep_cu_copy P((boolean fcopy)); - -/* Stop copying data from the communications port to the terminal, and - generally clean up after fsysdep_cu_init and fsysdep_cu. Returns - FALSE on error. */ -extern boolean fsysdep_cu_finish P((void)); - -/* Run a shell command. If zcmd is NULL, or *zcmd == '\0', just - start up a shell. The second argument is one of the following - values. This should return FALSE on error. */ -enum tshell_cmd -{ - /* Attach stdin and stdout to the terminal. */ - SHELL_NORMAL, - /* Attach stdout to the communications port, stdin to the terminal. */ - SHELL_STDOUT_TO_PORT, - /* Attach stdin to the communications port, stdout to the terminal. */ - SHELL_STDIN_FROM_PORT, - /* Attach both stdin and stdout to the communications port. */ - SHELL_STDIO_ON_PORT -}; - -extern boolean fsysdep_shell P((struct sconnection *qconn, - const char *zcmd, - enum tshell_cmd tcmd)); - -/* Change directory. If zdir is NULL, or *zdir == '\0', change to the - user's home directory. Return FALSE on error. */ -extern boolean fsysdep_chdir P((const char *zdir)); - -/* Suspend the current process. This is only expected to work on Unix - versions that support SIGTSTP. In general, people can just shell - out. */ -extern boolean fsysdep_suspend P((void)); - -/* Start getting files for uupick. The zsystem argument may be NULL - to get files from all systems, or it may specify a particular - system. The zpubdir argument is the public directory to use. This - returns FALSE on error. */ -extern boolean fsysdep_uupick_init P((const char *zsystem, - const char *zpubdir)); - -/* Get the next file for uupick. This returns the basic file name. - It sets *pzfull to the full name, and *pzfrom to the name of the - system which sent this file over; both should be freed using - ubuffree. *pzfull should be passed to ubuffree after it is no - longer needed. The zsystem and zpubdir arguments should be the - same as the arguments to fsysdep_uupick_init. This returns NULL - when all files been returned. */ -extern char *zsysdep_uupick P((const char *zsystem, const char *zpubdir, - char **pzfrom, char **pzfull)); - -/* Clean up after getting files for uupick. */ -extern boolean fsysdep_uupick_free P((const char *zsystem, - const char *zpubdir)); - -/* Translate a local file name for uupick. On Unix this is just like - zsysdep_local_file_cwd except that a file beginning with ~/ is - placed in the user's home directory rather than in the public - directory. */ -extern char *zsysdep_uupick_local_file P((const char *zfile, - boolean *pfbadname)); - -/* Remove a directory and all the files in it. */ -extern boolean fsysdep_rmdir P((const char *zdir)); - -#endif /* ! defined (SYSTEM_H) */ diff --git a/gnu/libexec/uucp/common_sources/uuconf.h b/gnu/libexec/uucp/common_sources/uuconf.h deleted file mode 100644 index 32f653d45a8d..000000000000 --- a/gnu/libexec/uucp/common_sources/uuconf.h +++ /dev/null @@ -1,1561 +0,0 @@ -/* uuconf.h - Header file for UUCP configuration routines. - - Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The use of an object file which uses material from this header - file, and from no other portion of the uuconf library, is - unrestricted, as described in paragraph 4 of section 5 of version 2 - of the GNU Library General Public License (this sentence is merely - informative, and does not modify the License in any way). - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* $FreeBSD$ */ - -#ifndef UUCONF_H - -#define UUCONF_H - -#include - -/* The macro UUCONF_ANSI_C may be used to override __STDC__. */ -#ifndef UUCONF_ANSI_C -#ifdef __STDC__ -#define UUCONF_ANSI_C 1 -#else /* ! defined (__STDC__) */ -#define UUCONF_ANSI_C 0 -#endif /* ! defined (__STDC__) */ -#endif /* ! defined (UUCONF_ANSI_C) */ - -#if UUCONF_ANSI_C -#define UUCONF_CONST const -typedef void *UUCONF_POINTER; -#include -typedef size_t UUCONF_SIZE_T; -#else -#define UUCONF_CONST -typedef char *UUCONF_POINTER; -typedef unsigned int UUCONF_SIZE_T; -#endif - -/* The field names of each of the following structures begin with - "uuconf_". This is to avoid any conflicts with user defined - macros. The first character following the "uuconf_" string - indicates the type of the field. - - z -- a string (char *) - c -- a count (normally int) - i -- an integer value (normally int) - f -- a boolean value (normally int) - b -- a single character value (char or int) - t -- an enum (enum XX) - s -- a structure (struct XX) - u -- a union (union XX) - q -- a pointer to a structure (struct XX *) - p -- a pointer to something other than a string - */ - -/* The information which is kept for a chat script. */ - -struct uuconf_chat -{ - /* The script itself. This is a NULL terminated list of expect/send - pairs. The first string is an expect string. A string starting - with a '-' indicates subsend string; the following strings which - start with '-' are subexpect/subsend strings. This field may be - NULL, in which case there is no chat script (but pzprogram may - hold a program to run). */ - char **uuconf_pzchat; - /* The chat program to run. This is a NULL terminated list of - arguments; element 0 if the program. May be NULL, in which case - there is no program. */ - char **uuconf_pzprogram; - /* The timeout in seconds to use for expect strings in the chat - script. */ - int uuconf_ctimeout; - /* The NULL terminated list of failure strings. If any of these - strings appear, the chat script is aborted. May be NULL, in - which case there are no failure strings. */ - char **uuconf_pzfail; - /* Non-zero if incoming characters should be stripped to seven bits - (by anding with 0x7f). */ - int uuconf_fstrip; -}; - -/* The information which is kept for a time specification. This is a - linked list of structures. Each element of the list represents a - span of time, giving a starting time and an ending time. The time - only depends on the day of the week, not on the day of the month or - of the year. The time is only specified down to the minute, not - down to the second or below. The list is sorted by starting time. - - The starting and ending time are expressed in minutes since the - beginning of the week, which is considered to be 12 midnight on - Sunday. Thus 60 is 1 am on Sunday, 1440 (== 60 * 24) is 12 - midnight on Monday, and the largest possible value is 10080 (== 60 - * 24 * 7) which is 12 midnight on the following Sunday. - - Each span of time has a value associated with it. This is the - lowest grade or the largest file size that may be transferred - during that time, depending on the source of the time span. When - time specifications overlap, the value used for the overlap is the - higher grade or the smaller file size. Thus specifying - ``call-timegrade z Any'' and ``call-timegrade Z Mo'' means that - only grade Z or higher may be sent on Monday, since Z is the higer - grade of the overlapping spans. The final array wil have no - overlaps. - - Each span also has a retry time associated with it. This permits - different retry times to be used at different times of day. The - retry time is only relevant if the span came from a ``time'' or - ``timegrade'' command for a system. */ - -struct uuconf_timespan -{ - /* Next element in list. */ - struct uuconf_timespan *uuconf_qnext; - /* Starting minute (-1 at the end of the array). */ - int uuconf_istart; - /* Ending minute. */ - int uuconf_iend; - /* Value for this span (lowest grade or largest file that may be - transferred at this time). */ - long uuconf_ival; - /* Retry time. */ - int uuconf_cretry; -}; - -/* The information which is kept for protocol parameters. Protocol - parameter information is stored as an array of the following - structures. */ - -struct uuconf_proto_param -{ - /* The name of the protocol to which this entry applies. This is - '\0' for the last element of the array. */ - int uuconf_bproto; - /* Specific entries for this protocol. This points to an array - ending in an element with a uuconf_cargs field of 0. */ - struct uuconf_proto_param_entry *uuconf_qentries; -}; - -/* Each particular protocol parameter entry is one of the following - structures. */ - -struct uuconf_proto_param_entry -{ - /* The number of arguments to the ``protocol-parameter'' command - (not counting ``protocol-parameter'' itself). This is 0 for the - last element of the array. */ - int uuconf_cargs; - /* The actual arguments to the ``protocol-parameter'' command; this - is an array with cargs entries. */ - char **uuconf_pzargs; -}; - -/* The information which is kept for a system. The zname and zalias - fields will be the same for all alternates. Every other fields is - specific to the particular alternate in which it appears (although - most will be the same for all alternates). */ - -struct uuconf_system -{ - /* The name of the system. */ - char *uuconf_zname; - /* A list of aliases for the system. This is a NULL terminated list - of strings. May be NULL, in which case there are no aliases. */ - char **uuconf_pzalias; - /* A linked list of alternate call in or call out information. Each - alternative way to call this system occupies an element of this - list. May be NULL, in which case there are no alternates. */ - struct uuconf_system *uuconf_qalternate; - /* The name for this particular alternate. May be NULL, in which - case this alternate does not have a name. */ - char *uuconf_zalternate; - /* If non-zero, this alternate may be used for calling out. */ - int uuconf_fcall; - /* If non-zero, this alternate may be used for accepting a call. */ - int uuconf_fcalled; - /* The times at which this system may be called. The ival field of - each uuconf_timespan structure is the lowest grade which may be - transferred at that time. The cretry field is the number of - minutes to wait before retrying the call, or 0 if it was not - specified. May be NULL, in which case the system may never be - called. */ - struct uuconf_timespan *uuconf_qtimegrade; - /* The times at which to request a particular grade of the system - when calling it, and the grades to request. The ival field of - each uuconf_timespan structure is the lowest grade which the - other system should transfer at that time. May be NULL, in which - case there are no grade restrictions. */ - struct uuconf_timespan *uuconf_qcalltimegrade; - /* The times at which to allow a particular grade of work to be - transferred to the system, when it calls in. The ival field of - each uuconf_timespan structure is the lowest grade which should - be transferred at that time. May be NULL, in which case there - are no grade restrictions. */ - struct uuconf_timespan *uuconf_qcalledtimegrade; - /* The maximum number of times to retry calling this system. If - this is 0, there is no limit. */ - int uuconf_cmax_retries; - /* The number of minutes to wait between successful calls to a - system. */ - int uuconf_csuccess_wait; - /* The size restrictions by time for local requests during a locally - placed call. The ival field of each uuconf_timespan structure is - the size in bytes of the largest file which may be transferred at - that time. May be NULL, in which case there are no size - restrictions. */ - struct uuconf_timespan *uuconf_qcall_local_size; - /* The size restrictions by time for remote requests during a - locally placed call. May be NULL. */ - struct uuconf_timespan *uuconf_qcall_remote_size; - /* The size restrictions by time for local requests during a - remotely placed call. May be NULL. */ - struct uuconf_timespan *uuconf_qcalled_local_size; - /* The size restrictions by time for remote requests during a - remotely placed call. May be NULL. */ - struct uuconf_timespan *uuconf_qcalled_remote_size; - /* Baud rate, or speed. Zero means any baud rate. If ihighbaud is - non-zero, this is the low baud rate of a range. */ - long uuconf_ibaud; - /* If non-zero, ibaud is the low baud rate of a range and ihighbaud - is the high baud rate. */ - long uuconf_ihighbaud; - /* Port name to use. May be NULL. If an HDB configuration file - contains a modem class (alphabetic characters preceeding the baud - rate), the class is appended to the port name. */ - char *uuconf_zport; - /* Specific port information, if the system entry includes port - information. May be NULL. */ - struct uuconf_port *uuconf_qport; - /* Phone number to call, or address to use for a TCP connection. - May be NULL, in which case a dialer script may not use \D or \T - for this system, and a TCP port will use the system name. */ - char *uuconf_zphone; - /* Chat script to use when logging in to the system. */ - struct uuconf_chat uuconf_schat; - /* Login name to use for \L in the login chat script. This should - normally be accessed via uuconf_callout. If it is "*", - uuconf_callout will look it up in the call out file. This may be - NULL, in which case the login script may not use \L. */ - char *uuconf_zcall_login; - /* Password to use for \P in the login chat script. This should - normally be accessed via uuconf_callout. If it is "*", - uuconf_callout will look it up in the call out file. This may be - NULL, in which case the login script may not use \P. */ - char *uuconf_zcall_password; - /* The login name this system must use when calling in. This may be - different for different alternates. This should only be examined - if uuconf_fcalled is TRUE. If this is NULL or "ANY" then - uuconf_validate must be called to make sure that whatever login - name was used is permitted for this machine. */ - char *uuconf_zcalled_login; - /* If non-zero, then when this system calls in the call should not - be allowed to proceed and the system should be called back. */ - int uuconf_fcallback; - /* If non-zero, then conversation sequence numbers should be used - with this system. */ - int uuconf_fsequence; - /* A list of protocols to use with this system. Each protocol has a - single character name. May be NULL, in which case any known - protocol may be used. */ - char *uuconf_zprotocols; - /* Array of protocol parameters. Ends in an entry with a - uuconf_bproto field of '\0'. May be NULL. */ - struct uuconf_proto_param *uuconf_qproto_params; - /* Chat script to run when called by this system. */ - struct uuconf_chat uuconf_scalled_chat; - /* Debugging level to set during a conversation. May be NULL. */ - char *uuconf_zdebug; - /* Maximum remote debugging level this system may request. May be - NULL. */ - char *uuconf_zmax_remote_debug; - /* Non-zero if the remote system may request us to send files from - the local system to the remote. */ - int uuconf_fsend_request; - /* Non-zero if the remote system may request us to receive files - from the remote system to the local. */ - int uuconf_frec_request; - /* Non-zero if local requests are permitted when calling this - system. */ - int uuconf_fcall_transfer; - /* Non-zero if local requests are permitted when this system calls - in. */ - int uuconf_fcalled_transfer; - /* NULL terminated list of directories from which files may be sent - by local request. */ - char **uuconf_pzlocal_send; - /* NULL terminated list of directories from which files may be sent - by remote request. */ - char **uuconf_pzremote_send; - /* NULL terminated list of directories into which files may be - received by local request. */ - char **uuconf_pzlocal_receive; - /* NULL terminated list of directories into which files may be - received by remote request. */ - char **uuconf_pzremote_receive; - /* Path to use for command execution. This is a NULL terminated - list of directories. */ - char **uuconf_pzpath; - /* NULL terminated List of commands that may be executed. */ - char **uuconf_pzcmds; - /* Amount of free space to leave when accepting a file from this - system, in bytes. */ - long uuconf_cfree_space; - /* NULL terminated list of systems that this system may forward - from. May be NULL if there are no systems from which files may - be forwarded. The list may include "ANY". */ - char **uuconf_pzforward_from; - /* NULL terminated list of systems that this system may forward to. - May be NULL if there are no systems to which files may be - forwarded. The list may include "ANY". */ - char **uuconf_pzforward_to; - /* The public directory to use for this sytem. */ - const char *uuconf_zpubdir; - /* The local name to use for this remote system. May be NULL if the - usual local name should be used. */ - char *uuconf_zlocalname; - /* Memory allocation block for the system. */ - UUCONF_POINTER uuconf_palloc; -}; - -/* Types of ports. */ - -enum uuconf_porttype -{ - /* Unknown port type. A port of this type should never be returned - by the uuconf functions. */ - UUCONF_PORTTYPE_UNKNOWN, - /* Read from standard input and write to standard output. Not - normally used. */ - UUCONF_PORTTYPE_STDIN, - /* A modem port. */ - UUCONF_PORTTYPE_MODEM, - /* A direct connect port. */ - UUCONF_PORTTYPE_DIRECT, - /* A TCP port. Not supported on all systems. */ - UUCONF_PORTTYPE_TCP, - /* A TLI port. Not supported on all systems. */ - UUCONF_PORTTYPE_TLI, - /* A pipe port. Not supported on all systems. */ - UUCONF_PORTTYPE_PIPE -}; - -/* Additional information for a stdin port (there is none). */ - -struct uuconf_stdin_port -{ - int uuconf_idummy; -}; - -/* Additional information for a modem port. */ - -struct uuconf_modem_port -{ - /* The device name. May be NULL, in which case the port name is - used instead. */ - char *uuconf_zdevice; - /* The device name to send the dialer chat script to. May be NULL, - in which case the chat script is sent to the usual device. */ - char *uuconf_zdial_device; - /* The default baud rate (speed). If zero, there is no default. */ - long uuconf_ibaud; - /* The low baud rate, if a range is used. If zero, a range is not - used and ihighbaud should be ignored. */ - long uuconf_ilowbaud; - /* The high baud rate, if ilowbaud is non-zero. */ - long uuconf_ihighbaud; - /* Non-zero if the port supports carrier detect. */ - int uuconf_fcarrier; - /* Non-zero if the port supports hardware flow control. */ - int uuconf_fhardflow; - /* A NULL terminated sequence of dialer/token pairs (element 0 is a - dialer name, element 1 is a token, etc.) May be NULL, in which - case qdialer should not be NULL. */ - char **uuconf_pzdialer; - /* Specific dialer information. Only used if pzdialer is NULL. */ - struct uuconf_dialer *uuconf_qdialer; -}; - -/* Additional information for a direct connect port. */ - -struct uuconf_direct_port -{ - /* The device name. May be NULL, in which case the port name is - used instead. */ - char *uuconf_zdevice; - /* The baud rate (speed). */ - long uuconf_ibaud; - /* Non-zero if the port uses carrier detect. */ - int uuconf_fcarrier; - /* Non-zero if the port supports hardware flow control. */ - int uuconf_fhardflow; -}; - -/* Additional information for a TCP port. */ - -struct uuconf_tcp_port -{ - /* The TCP port number to use. May be a name or a number. May be - NULL, in which case "uucp" is looked up using getservbyname. */ - char *uuconf_zport; - /* Address family to use for a TCP connection. */ - int uuconf_zfamily; - /* A NULL terminated sequence of dialer/token pairs (element 0 is a - dialer name, element 1 is a token, etc.) May be NULL. */ - char **uuconf_pzdialer; -}; - -/* Additional information for a TLI port. */ - -struct uuconf_tli_port -{ - /* Device name to open. May be NULL, in which case the port name is - used. */ - char *uuconf_zdevice; - /* Whether this port should be turned into a stream, permitting the - read and write calls instead of the t_rcv and t_send calls. */ - int uuconf_fstream; - /* A NULL terminated list of modules to push after making the - connection. May be NULL, in which case if fstream is non-zero, - then "tirdwr" is pushed onto the stream, and otherwise nothing is - pushed. */ - char **uuconf_pzpush; - /* A NULL terminated sequence of dialer/token pairs (element 0 is a - dialer name, element 1 is a token, etc.) May be NULL. If - element 0 is TLI or TLIS, element 1 is used as the address to - connect to; otherwise uuconf_zphone from the system information - is used. */ - char **uuconf_pzdialer; - /* Address to use when operating as a server. This may contain - escape sequences. */ - char *uuconf_zservaddr; -}; - -/* Additional information for a pipe port. */ - -struct uuconf_pipe_port -{ - /* The command and its arguments. */ - char **uuconf_pzcmd; -}; - -/* Information kept for a port. */ - -struct uuconf_port -{ - /* The name of the port. */ - char *uuconf_zname; - /* The type of the port. */ - enum uuconf_porttype uuconf_ttype; - /* The list of protocols supported by the port. The name of each - protocol is a single character. May be NULL, in which case any - protocol is permitted. */ - char *uuconf_zprotocols; - /* Array of protocol parameters. Ends in an entry with a - uuconf_bproto field of '\0'. May be NULL. */ - struct uuconf_proto_param *uuconf_qproto_params; - /* The set of reliability bits. */ - int uuconf_ireliable; - /* The lock file name to use. */ - char *uuconf_zlockname; - /* Memory allocation block for the port. */ - UUCONF_POINTER uuconf_palloc; - /* The type specific information. */ - union - { - struct uuconf_stdin_port uuconf_sstdin; - struct uuconf_modem_port uuconf_smodem; - struct uuconf_direct_port uuconf_sdirect; - struct uuconf_tcp_port uuconf_stcp; - struct uuconf_tli_port uuconf_stli; - struct uuconf_pipe_port uuconf_spipe; - } uuconf_u; -}; - -/* Information kept about a dialer. */ - -struct uuconf_dialer -{ - /* The name of the dialer. */ - char *uuconf_zname; - /* The chat script to use when dialing out. */ - struct uuconf_chat uuconf_schat; - /* The string to send when a `=' appears in the phone number. */ - char *uuconf_zdialtone; - /* The string to send when a `-' appears in the phone number. */ - char *uuconf_zpause; - /* Non-zero if the dialer supports carrier detect. */ - int uuconf_fcarrier; - /* The number of seconds to wait for carrier after the chat script - is complete. Only used if fcarrier is non-zero. Only supported - on some systems. */ - int uuconf_ccarrier_wait; - /* If non-zero, DTR should be toggled before dialing. Only - supported on some systems. */ - int uuconf_fdtr_toggle; - /* If non-zero, sleep for 1 second after toggling DTR. Ignored if - fdtr_toggle is zero. */ - int uuconf_fdtr_toggle_wait; - /* The chat script to use when a call is complete. */ - struct uuconf_chat uuconf_scomplete; - /* The chat script to use when a call is aborted. */ - struct uuconf_chat uuconf_sabort; - /* Array of protocol parameters. Ends in an entry with a - uuconf_bproto field of '\0'. May be NULL. */ - struct uuconf_proto_param *uuconf_qproto_params; - /* The set of reliability bits. */ - int uuconf_ireliable; - /* Memory allocation block for the dialer. */ - UUCONF_POINTER uuconf_palloc; -}; - -/* Reliability bits for the ireliable field of ports and dialers. - These bits are used to decide which protocol to run. A given - protocol will have a set of these bits, and each of them must be - turned on for the port before we will permit that protocol to be - used. This will be overridden by the zprotocols field. */ - -/* Whether a set of reliability bits is given. If this bit is not - set, then there is no reliability information. */ -#define UUCONF_RELIABLE_SPECIFIED (01) - -/* Set if the connection is eight bit transparent. */ -#define UUCONF_RELIABLE_EIGHT (02) - -/* Set if the connection is error-free. */ -#define UUCONF_RELIABLE_RELIABLE (04) - -/* Set if the connection is end-to-end reliable (e.g. TCP). */ -#define UUCONF_RELIABLE_ENDTOEND (010) - -/* Set if the connection is full-duplex; that is, no time consuming - line turnaround is required before sending data in the reverse - direction. If the connection is truly half-duplex, in the sense - that communication can only flow in one direction, UUCP can not be - used. */ -#define UUCONF_RELIABLE_FULLDUPLEX (020) - -/* UUCP grades range from 0 to 9, A to Z, a to z in order from highest - to lowest (work of higher grades is done before work of lower - grades). */ - -/* The highest grade. */ -#define UUCONF_GRADE_HIGH ('0') - -/* The lowest grade. */ -#define UUCONF_GRADE_LOW ('z') - -/* Whether a character is a legal grade (requires ). */ -#define UUCONF_GRADE_LEGAL(b) (isalnum (BUCHAR (b))) - -/* Return < 0 if the first grade should be done before the second - grade, == 0 if they are the same, or > 0 if the first grade should - be done after the second grade. On an ASCII system, this can just - be b1 - b2. */ -#define UUCONF_GRADE_CMP(b1, b2) (uuconf_grade_cmp ((b1), (b2))) - -/* Definitions for bits returned by uuconf_strip. */ -#define UUCONF_STRIP_LOGIN (01) -#define UUCONF_STRIP_PROTO (02) - -/* uuconf_runuuxqt returns either a positive number (the number of - execution files to receive between uuxqt invocations) or one of - these constant values. */ -#define UUCONF_RUNUUXQT_NEVER (0) -#define UUCONF_RUNUUXQT_ONCE (-1) -#define UUCONF_RUNUUXQT_PERCALL (-2) - -/* Most of the uuconf functions returns an error code. A value of - zero (UUCONF_SUCCESS) indicates success. */ - -/* If this bit is set in the returned error code, then the - uuconf_errno function may be used to obtain the errno value as set - by the function which caused the failure. */ -#define UUCONF_ERROR_ERRNO (0x100) - -/* If this bit is set in the returned error code, then the - uuconf_filename function may be used to get the name of a file - associated with the error. */ -#define UUCONF_ERROR_FILENAME (0x200) - -/* If this bit is set in the returned error code, then the - uuconf_lineno function may be used to get a line number associated - with the error; normally if this is set UUCONF_ERROR_FILENAME will - also be set. */ -#define UUCONF_ERROR_LINENO (0x400) - -/* There are two UUCONF_CMDTABRET bits that may be set in the return - value of uuconf_cmd_line or uuconf_cmd_args, described below. They - do not indicate an error, but instead give instructions to the - calling function, often uuconf_cmd_file. They may also be set in - the return value of a user function listed in a uuconf_cmdtab - table, in which case they will be honored by uuconf_cmd_file. */ - -/* This bit means that the memory occupied by the arguments passed to - the function should be preserved, and not overwritten or freed. It - refers only to the contents of the arguments; the contents of the - argv array itself may always be destroyed. If this bit is set in - the return value of uuconf_cmd_line or uuconf_cmd_args, it must be - honored. It will be honored by uuconf_cmd_file. This may be - combined with an error code or with UUCONF_CMDTABRET_EXIT, although - neither uuconf_cmd_file or uuconf_cmd_line will do so. */ -#define UUCONF_CMDTABRET_KEEP (0x800) - -/* This bit means that uuconf_cmd_file should exit, rather than go on - to read and process the next line. If uuconf_cmd_line or - uuconf_cmd_args encounter an error, the return value will have this - bit set along with the error code. A user function may set this - bit with or without an error; the return value of the user function - will be returned by uuconf_cmd_file, except that the - UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT bits will be - cleared. */ -#define UUCONF_CMDTABRET_EXIT (0x1000) - -/* This macro may be used to extract the specific error value. */ -#define UUCONF_ERROR_VALUE(i) ((i) & 0xff) - -/* UUCONF_ERROR_VALUE will return one of the following values. */ - -/* Function succeeded. */ -#define UUCONF_SUCCESS (0) -/* Named item not found. */ -#define UUCONF_NOT_FOUND (1) -/* A call to fopen failed. */ -#define UUCONF_FOPEN_FAILED (2) -/* A call to fseek failed. */ -#define UUCONF_FSEEK_FAILED (3) -/* A call to malloc or realloc failed. */ -#define UUCONF_MALLOC_FAILED (4) -/* Syntax error in file. */ -#define UUCONF_SYNTAX_ERROR (5) -/* Unknown command. */ -#define UUCONF_UNKNOWN_COMMAND (6) - -#if UUCONF_ANSI_C - -/* For each type of configuration file (Taylor, V2, HDB), there are - separate routines to read various sorts of information. There are - also generic routines, which call on the appropriate type specific - routines. The library can be compiled to read any desired - combination of the configuration file types. This affects only the - generic routines, as it determines which type specific routines - they call. Thus, on a system which, for example, does not have any - V2 configuration files, there is no need to include the overhead of - the code to parse the files and the time to look for them. - However, a program which specifically wants to be able to parse - them can call the V2 specific routines. - - The uuconf functions all take as an argument a pointer to uuconf - global information. This must be initialized by any the - initialization routines (the generic one and the three file type - specific ones) before any of the other uuconf functions may be - called. */ - -/* Initialize the configuration file reading routines. The ppglobal - argument should point to a generic pointer (a void *, or, on older - compilers, a char *) which will be initialized and may then be - passed to the other uuconf routines. The zprogram argument is the - name of the program for which files should be read. A NULL is - taken as "uucp", and reads the standard UUCP configuration files. - The only other common argument is "cu", but any string is - permitted. The zname argument is the name of the Taylor UUCP - config file; if it is NULL, the default config file will be read. - If not reading Taylor UUCP configuration information, the argument - is ignored. This function must be called before any of the other - uuconf functions. - - Note that if the zname argument is obtained from the user running - the program, the program should be careful to revoke any special - privileges it may have (e.g. on Unix call setuid (getuid ()) and - setgid (getgid ())). Otherwise various sorts of spoofing become - possible. */ -extern int uuconf_init (void **uuconf_ppglobal, - const char *uuconf_zprogram, - const char *uuconf_zname); - -/* Adjust the configuration file global pointer for a new thread. The - library is fully reentrant (with the exception of the function - uuconf_error_string, which calls strerror, which on some systems is - not reentrant), provided that each new thread that wishes to call - the library calls this function and uses the new global pointer - value. The ppglobal argument should be set to the address of the - global pointer set by any of the init functions; it will be - modified to become a new global pointer. */ -extern int uuconf_init_thread (void **uuconf_ppglobal); - -/* Get the names of all known systems. This sets sets *ppzsystems to - point to an array of system names. The list of names is NULL - terminated. The array is allocated using malloc, as is each - element of the array, and they may all be passed to free when they - are no longer needed. If the falias argument is 0, the list will - not include any aliases; otherwise, it will. */ -extern int uuconf_system_names (void *uuconf_pglobal, - char ***uuconf_ppzsystems, - int uuconf_falias); - -/* Get the information for the system zsystem. This sets the fields - in *qsys. This will work whether zsystem is the official name of - the system or merely an alias. */ -extern int uuconf_system_info (void *uuconf_pglobal, - const char *uuconf_zsystem, - struct uuconf_system *uuconf_qsys); - -/* Get information for an unknown (anonymous) system. The - uuconf_zname field of the returned system information will be NULL. - If no information is available for unknown systems, this will - return UUCONF_NOT_FOUND. This does not run the HDB remote.unknown - shell script. */ -extern int uuconf_system_unknown (void *uuconf_pglobal, - struct uuconf_system *uuconf_qsys); - -/* Get information for the local system. Normally the local system - name should first be looked up using uuconf_system_info. If that - returns UUCONF_NOT_FOUND, this function may be used to get an - appropriate set of defaults. The uuconf_zname field of the - returned system information may be NULL. */ -extern int uuconf_system_local (void *uuconf_pglobal, - struct uuconf_system *uuconf_qsys); - -/* Free the memory occupied by system information returned by - uuconf_system_info, uuconf_system_unknown, uuconf_system_local, or - any of the configuration file type specific routines described - below. After this is called, the contents of the structure shall - not be referred to. */ -extern int uuconf_system_free (void *uuconf_pglobal, - struct uuconf_system *uuconf_qsys); - -#ifdef __OPTIMIZE__ -#define uuconf_system_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#endif - -/* Find a matching port. This will consider each port in turn. - - If the zname argument is not NULL, the port's uuconf_zname field - must match it. - - If the ibaud argument is not zero and the ihighbaud argument is - zero, the port's baud rate, if defined, must be the same (if the - port has a range of baud rates, ibaud must be within the range). - If ibaud and ihighbaud are both not zero, the port's baud rate, if - defined, must be between ibaud and ihighbaud inclusive (if the port - has a range of baud rates, the ranges must intersect). If the port - has no baud rate, either because it is a type of port for which - baud rate is not defined (e.g. a TCP port) or because the - uuconf_ibaud field is 0, the ibaud and ihighbaud arguments are - ignored. - - If the pifn argument is not NULL, the port is passed to pifn, along - with the pinfo argument (which is otherwise ignored). If pifn - returns UUCONF_SUCCESS, the port matches. If pifn returns - UUCONF_NOT_FOUND, a new port is sought. Otherwise the return value - of pifn is returned from uuconf_find_port. The pifn function may - be used to further restrict the port, such as by modem class or - device name. It may also be used to lock the port, if appropriate; - in this case, if the lock fails, pifn may return UUCONF_NOT_FOUND - to force uuconf_find_port to continue searching for a port. - - If the port matches, the information is set into uuconf_qport, and - uuconf_find_port returns UUCONF_SUCCESS. */ -extern int uuconf_find_port (void *uuconf_pglobal, - const char *uuconf_zname, - long uuconf_ibaud, - long uuconf_ihighbaud, - int (*uuconf_pifn) (struct uuconf_port *, - void *uuconf_pinfo), - void *uuconf_pinfo, - struct uuconf_port *uuconf_qport); - -/* Free the memory occupied by system information returned by - uuconf_find_port (or any of the configuration file specific - routines described below). After this is called, the contents of - the structure shall not be referred to. */ -extern int uuconf_port_free (void *uuconf_pglobal, - struct uuconf_port *uuconf_qport); - -#ifdef __OPTIMIZE__ -#define uuconf_port_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#endif - -/* Get the names of all known dialers. This sets sets *ppzdialers to - point to an array of dialer names. The list of names is NULL - terminated. The array is allocated using malloc, as is each - element of the array, and they may all be passed to free when they - are no longer needed. */ -extern int uuconf_dialer_names (void *uuconf_pglobal, - char ***uuconf_ppzdialers); - -/* Get the information for the dialer zdialer. This sets the fields - in *qdialer. */ -extern int uuconf_dialer_info (void *uuconf_pglobal, - const char *uuconf_zdialer, - struct uuconf_dialer *uuconf_qdialer); - -/* Free the memory occupied by system information returned by - uuconf_dialer_info (or any of the configuration file specific - routines described below). After this is called, the contents of - the structure shall not be referred to. */ -extern int uuconf_dialer_free (void *uuconf_pglobal, - struct uuconf_dialer *uuconf_qsys); - -#ifdef __OPTIMIZE__ -#define uuconf_dialer_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#endif - -/* Get the local node name. If the node name is not specified - (because no ``nodename'' command appeared in the config file) this - will return UUCONF_NOT_FOUND, and some system dependent function - must be used to determine the node name. Otherwise it will return - a pointer to a constant string, which should not be freed. */ -extern int uuconf_localname (void *uuconf_pglobal, - const char **pzname); - -/* Get the local node name that should be used, given a login name. - This function will check for any special local name that may be - associated with the login name zlogin (as set by the ``myname'' - command in a Taylor configuration file, or the MYNAME field in a - Permissions entry). This will set *pzname to the node name. If no - node name can be determined, *pzname will be set to NULL and the - function will return UUCONF_NOT_FOUND; in this case some system - dependent function must be used to determine the node name. If the - function returns UUCONF_SUCCESS, *pzname will be point to an - malloced buffer. */ -extern int uuconf_login_localname (void *uuconf_pglobal, - const char *uuconf_zlogin, - char **pzname); - -/* Get the name of the UUCP spool directory. This will set *pzspool - to a constant string, which should not be freed. */ -extern int uuconf_spooldir (void *uuconf_pglobal, - const char **uuconf_pzspool); - -/* Get the name of the default UUCP public directory. This will set - *pzpub to a constant string, which should not be freed. Note that - particular systems may use a different public directory. */ -extern int uuconf_pubdir (void *uuconf_pglobal, - const char **uuconf_pzpub); - -/* Get the name of the UUCP lock directory. This will set *pzlock to - a constant string, which should not be freed. */ -extern int uuconf_lockdir (void *uuconf_pglobal, - const char **uuconf_pzlock); - -/* Get the name of the UUCP log file. This will set *pzlog to a - constant string, which should not be freed. */ -extern int uuconf_logfile (void *uuconf_pglobal, - const char **uuconf_pzlog); - -/* Get the name of the UUCP statistics file. This will set *pzstats - to a constant string, which should not be freed. */ -extern int uuconf_statsfile (void *uuconf_pglobal, - const char **uuconf_pzstats); - -/* Get the name of the UUCP debugging file. This will set *pzdebug to - a constant string, which should not be freed. */ -extern int uuconf_debugfile (void *uuconf_pglobal, - const char **uuconf_pzdebug); - -/* Get the default debugging level to use. This basically gets the - argument of the ``debug'' command from the Taylor UUCP config file. - It will set *pzdebug to a constant string, which should not be - freed. */ -extern int uuconf_debuglevel (void *uuconf_pglobal, - const char **uuconf_pzdebug); - -/* Get a combination of UUCONF_STRIP bits indicating what types of - global information should be stripped on input. */ -extern int uuconf_strip (void *uuconf_pglobal, - int *uuconf_pistrip); - -/* Get the maximum number of simultaneous uuxqt executions. This will - set *pcmaxuuxqt to the number. Zero indicates no maximum. */ -extern int uuconf_maxuuxqts (void *uuconf_pglobal, - int *uuconf_pcmaxuuxqt); - -/* Get the frequency with which to spawn a uuxqt process. This - returns an integer. A positive number is the number of execution - files that should be received between spawns. Other values are one - of the UUCONF_RUNUUXQT constants listed above. */ -extern int uuconf_runuuxqt (void *uuconf_pglobal, - int *uuconf_pirunuuxqt); - -/* Check a login name and password. This checks the Taylor UUCP - password file (not /etc/passwd). It will work even if - uuconf_taylor_init was not called. All comparisons are done via a - callback function. The first argument to the function will be zero - when comparing login names, non-zero when comparing passwords. The - second argument to the function will be the pinfo argument passed - to uuconf_callin. The third argument will be the login name or - password from the UUCP password file. The comparison function - should return non-zero for a match, or zero for a non-match. If - the login name is found and the password compares correctly, - uuconf_callin will return UUCONF_SUCCESS. If the login is not - found, or the password does not compare correctly, uuconf_callin - will return UUCONF_NOT_FOUND. Other errors are also possible. */ -extern int uuconf_callin (void *uuconf_pglobal, - int (*uuconf_cmp) (int, void *, const char *), - void *uuconf_pinfo); - -/* Get the callout login name and password for a system. This will - set both *pzlog and *pzpass to a string allocated by malloc, or to - NULL if the value is not found. If neither value is found, the - function will return UUCONF_NOT_FOUND. */ -extern int uuconf_callout (void *uuconf_pglobal, - const struct uuconf_system *uuconf_qsys, - char **uuconf_pzlog, - char **uuconf_pzpass); - -/* See if a login name is permitted for a system. This will return - UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is - invalid. This simply calls uuconf_taylor_validate or returns - UUCONF_SUCCESS, depending on the value of HAVE_TAYLOR_CONFIG. */ -extern int uuconf_validate (void *uuconf_pglobal, - const struct uuconf_system *uuconf_qsys, - const char *uuconf_zlogin); - -/* Get the name of the HDB remote.unknown shell script, if using - HAVE_HDB_CONFIG. This does not actually run the shell script. If - the function returns UUCONF_SUCCESS, the name will be in *pzname, - which will point to an malloced buffer. If it returns - UUCONF_NOT_FOUND, then there is no script to run. */ -extern int uuconf_remote_unknown (void *uuconf_pglobal, - char **pzname); - -/* Translate a dial code. This sets *pznum to an malloced string. - This will look up the entire zdial string in the dialcode file, so - for normal use the alphabetic prefix should be separated. */ -extern int uuconf_dialcode (void *uuconf_pglobal, - const char *uuconf_zdial, - char **uuconf_pznum); - -/* Compare two grades, returning < 0 if b1 should be executed before - b2, == 0 if they are the same, or > 0 if b1 should be executed - after b2. This can not fail, and does not return a standard uuconf - error code; it is normally called via the macro UUCONF_GRADE_CMP, - defined above. */ -extern int uuconf_grade_cmp (int uuconf_b1, int uuconf_b2); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_init (); -extern int uuconf_init_thread (); -extern int uuconf_system_names (); -extern int uuconf_system_info (); -extern int uuconf_system_unknown (); -extern int uuconf_system_local (); -extern int uuconf_system_free (); -extern int uuconf_find_port (); -extern int uuconf_port_free (); -extern int uuconf_dialer_names (); -extern int uuconf_dialer_info (); -extern int uuconf_dialer_free (); -extern int uuconf_localname (); -extern int uuconf_login_localname (); -extern int uuconf_spooldir (); -extern int uuconf_lockdir (); -extern int uuconf_pubdir (); -extern int uuconf_logfile (); -extern int uuconf_statsfile (); -extern int uuconf_debugfile (); -extern int uuconf_debuglevel (); -extern int uuconf_maxuuxqts (); -extern int uuconf_runuuxqt (); -extern int uuconf_callin (); -extern int uuconf_callout (); -extern int uuconf_remote_unknown (); -extern int uuconf_validate (); -extern int uuconf_grade_cmp (); - -#ifdef __OPTIMIZE__ -#define uuconf_system_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#define uuconf_port_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#define uuconf_dialer_free(qglob, q) \ - (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS) -#endif - -#endif /* ! UUCONF_ANSI_C */ - -#if UUCONF_ANSI_C - -/* Initialize the Taylor UUCP configuration file reading routines. - This must be called before calling any of the Taylor UUCP - configuration file specific routines. The ppglobal argument should - point to a generic pointer. Moreover, before calling this function - the pointer either must be set to NULL, or must have been passed to - one of the other uuconf init routines. The zprogram argument is - the name of the program for which files should be read. If NULL, - it is taken as "uucp", which means to read the standard UUCP files. - The zname argument is the name of the config file. If it is NULL, - the default config file will be used. - - Note that if the zname argument is obtained from the user running - the program, the program should be careful to revoke any special - privileges it may have (e.g. on Unix call setuid (getuid ()) and - setgid (getgid ())). Otherwise various sorts of spoofing become - possible. */ -extern int uuconf_taylor_init (void **uuconf_pglobal, - const char *uuconf_zprogram, - const char *uuconf_zname); - -/* Get the names of all systems listed in the Taylor UUCP - configuration files. This sets *ppzsystems to point to an array of - system names. The list of names is NULL terminated. The array is - allocated using malloc, as is each element of the array. If the - falias argument is 0, the list will not include any aliases; - otherwise, it will. */ -extern int uuconf_taylor_system_names (void *uuconf_pglobal, - char ***uuconf_ppzsystems, - int uuconf_falias); - -/* Get the information for system zsystem from the Taylor UUCP - configuration files. This will set *qsys. */ -extern int uuconf_taylor_system_info (void *uuconf_pglobal, - const char *uuconf_zsystem, - struct uuconf_system *uuconf_qsys); - -/* Get information for an unknown (anonymous) system. This returns - the values set by the ``unknown'' command in the main configuration - file. If the ``unknown'' command was not used, this will return - UUCONF_NOT_FOUND. */ -extern int uuconf_taylor_system_unknown (void *uuconf_pglobal, - struct uuconf_system *uuconf_qsys); - -/* Find a port from the Taylor UUCP configuration files. The - arguments and return values are identical to those of - uuconf_find_port. */ -extern int uuconf_taylor_find_port (void *uuconf_pglobal, - const char *uuconf_zname, - long uuconf_ibaud, - long uuconf_ihighbaud, - int (*uuconf_pifn) (struct uuconf_port *, - void *uuconf_pinfo), - void *uuconf_pinfo, - struct uuconf_port *uuconf_qport); - -/* Get the names of all dialers listed in the Taylor UUCP - configuration files. This sets *ppzdialers to point to an array of - dialer names. The list of names is NULL terminated. The array is - allocated using malloc, as is each element of the array. */ -extern int uuconf_taylor_dialer_names (void *uuconf_pglobal, - char ***uuconf_ppzdialers); - -/* Get the information for the dialer zdialer from the Taylor UUCP - configuration files. This sets the fields in *qdialer. */ -extern int uuconf_taylor_dialer_info (void *uuconf_pglobal, - const char *uuconf_zdialer, - struct uuconf_dialer *uuconf_qdialer); - -/* Get the local node name that should be used, given a login name, - considering only the ``myname'' command in the Taylor UUCP - configuration files. If the function returns UUCONF_SUCCESS, - *pzname will point to an malloced buffer. */ -extern int uuconf_taylor_login_localname (void *uuconf_pglobal, - const char *uuconf_zlogin, - char **pzname); - -/* Get the callout login name and password for a system from the - Taylor UUCP configuration files. This will set both *pzlog and - *pzpass to a string allocated by malloc, or to NULL if the value is - not found. If neither value is found, the function will return - UUCONF_NOT_FOUND. */ -extern int uuconf_taylor_callout (void *uuconf_pglobal, - const struct uuconf_system *uuconf_qsys, - char **uuconf_pzlog, - char **uuconf_pzpass); - -/* See if a login name is permitted for a system. This will return - UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is - invalid. This checks whether the login name appears in a - called-login command with a list of system which does not include - the system qsys. */ -extern int uuconf_taylor_validate (void *uuconf_pglobal, - const struct uuconf_system *uuconf_qsys, - const char *uuconf_zlogin); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_taylor_init (); -extern int uuconf_taylor_system_names (); -extern int uuconf_taylor_system_info (); -extern int uuconf_taylor_system_unknown (); -extern int uuconf_taylor_find_port (); -extern int uuconf_taylor_dialer_names (); -extern int uuconf_taylor_dialer_info (); -extern int uuconf_taylor_login_localname (); -extern int uuconf_taylor_callout (); -extern int uuconf_taylor_validate (); - -#endif /* ! UUCONF_ANSI_C */ - -#if UUCONF_ANSI_C - -/* Initialize the V2 configuration file reading routines. This must - be called before any of the other V2 routines are called. The - ppglobal argument should point to a generic pointer. Moreover, - before calling this function the pointer either must be set to - NULL, or must have been passed to one of the other uuconf init - routines. */ -extern int uuconf_v2_init (void **uuconf_ppglobal); - -/* Get the names of all systems listed in the V2 configuration files. - This sets *ppzsystems to point to an array of system names. The - list of names is NULL terminated. The array is allocated using - malloc, as is each element of the array. If the falias argument is - 0, the list will not include any aliases; otherwise, it will. */ -extern int uuconf_v2_system_names (void *uuconf_pglobal, - char ***uuconf_ppzsystems, - int uuconf_falias); - -/* Get the information for system zsystem from the V2 configuration - files. This will set *qsys. */ -extern int uuconf_v2_system_info (void *uuconf_pglobal, - const char *uuconf_zsystem, - struct uuconf_system *uuconf_qsys); - -/* Find a port from the V2 configuration files. The arguments and - return values are identical to those of uuconf_find_port. */ -extern int uuconf_v2_find_port (void *uuconf_pglobal, - const char *uuconf_zname, - long uuconf_ibaud, - long uuconf_ihighbaud, - int (*uuconf_pifn) (struct uuconf_port *, - void *uuconf_pinfo), - void *uuconf_pinfo, - struct uuconf_port *uuconf_qport); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_v2_init (); -extern int uuconf_v2_system_names (); -extern int uuconf_v2_system_info (); -extern int uuconf_v2_find_port (); - -#endif /* ! UUCONF_ANSI_C */ - -#if UUCONF_ANSI_C - -/* Initialize the HDB configuration file reading routines. This - should be called before any of the other HDB routines are called. - The ppglobal argument should point to a generic pointer. Moreover, - before calling this function the pointer either must be set to - NULL, or must have been passed to one of the other uuconf init - routines. The zprogram argument is used to match against a - "services" string in Sysfiles. A NULL or "uucp" argument is taken - as "uucico". */ -extern int uuconf_hdb_init (void **uuconf_ppglobal, - const char *uuconf_zprogram); - -/* Get the names of all systems listed in the HDB configuration files. - This sets *ppzsystems to point to an array of system names. The - list of names is NULL terminated. The array is allocated using - malloc, as is each element of the array. If the falias argument is - 0, the list will not include any aliases; otherwise, it will (an - alias is created by using the ALIAS= keyword in the Permissions - file). */ -extern int uuconf_hdb_system_names (void *uuconf_pglobal, - char ***uuconf_ppzsystems, - int uuconf_falias); - -/* Get the information for system zsystem from the HDB configuration - files. This will set *qsys. */ -extern int uuconf_hdb_system_info (void *uuconf_pglobal, - const char *uuconf_zsystem, - struct uuconf_system *uuconf_qsys); - - -/* Get information for an unknown (anonymous) system. If no - information is available for unknown systems, this will return - UUCONF_NOT_FOUND. This does not run the remote.unknown shell - script. */ -extern int uuconf_hdb_system_unknown (void *uuconf_pglobal, - struct uuconf_system *uuconf_qsys); - -/* Find a port from the HDB configuration files. The arguments and - return values are identical to those of uuconf_find_port. */ -extern int uuconf_hdb_find_port (void *uuconf_pglobal, - const char *uuconf_zname, - long uuconf_ibaud, - long uuconf_ihighbaud, - int (*uuconf_pifn) (struct uuconf_port *, - void *uuconf_pinfo), - void *uuconf_pinfo, - struct uuconf_port *uuconf_qport); - -/* Get the names of all dialers listed in the HDB configuration files. - This sets *ppzdialers to point to an array of dialer names. The - list of names is NULL terminated. The array is allocated using - malloc, as is each element of the array. */ -extern int uuconf_hdb_dialer_names (void *uuconf_pglobal, - char ***uuconf_ppzdialers); - -/* Get the information for the dialer zdialer from the HDB - configuration files. This sets the fields in *qdialer. */ -extern int uuconf_hdb_dialer_info (void *uuconf_pglobal, - const char *uuconf_zdialer, - struct uuconf_dialer *uuconf_qdialer); - -/* Get the local node name that should be used, given a login name, - considering only the MYNAME field in the HDB Permissions file. If - the function returns UUCONF_SUCCESS, *pzname will point to an - malloced buffer. */ -extern int uuconf_hdb_login_localname (void *uuconf_pglobal, - const char *uuconf_zlogin, - char **pzname); - -/* Get the name of the HDB remote.unknown shell script. This does not - actually run the shell script. If the function returns - UUCONF_SUCCESS, the name will be in *pzname, which will point to an - malloced buffer. */ -extern int uuconf_hdb_remote_unknown (void *uuconf_pglobal, - char **pzname); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_hdb_init (); -extern int uuconf_hdb_system_names (); -extern int uuconf_hdb_system_info (); -extern int uuconf_hdb_system_unknown (); -extern int uuconf_hdb_find_port (); -extern int uuconf_hdb_dialer_names (); -extern int uuconf_hdb_dialer_info (); -extern int uuconf_hdb_localname (); -extern int uuconf_hdb_remote_unknown (); - -#endif /* ! UUCONF_ANSI_C */ - -#if UUCONF_ANSI_C - -/* This function will set an appropriate error message into the buffer - zbuf, given a uuconf error code. The buffer will always be null - terminated, and will never be accessed beyond the length cbuf. - This function will return the number of characters needed for the - complete message, including the null byte. If this is less than - the cbytes argument, the buffer holds a truncated string. */ -extern int uuconf_error_string (void *uuconf_pglobal, int ierror, - char *zbuf, UUCONF_SIZE_T cbuf); - -/* If UUCONF_ERROR_ERRNO is set in a return value, this function may - be used to retrieve the errno value. This will be the value of - errno as set by the system function which failed. However, some - system functions, notably some stdio routines, may not set errno, - in which case the value will be meaningless. This function does - not return a uuconf error code, and it cannot fail. */ -extern int uuconf_error_errno (void *uuconf_pglobal); - -/* If UUCONF_ERROR_FILENAME is set in a return value, this function - may be used to retrieve the file name. This function does not - return a uuconf error code, and it cannot fail. The string that it - returns a pointer to is not guaranteed to remain allocated across - the next call to a uuconf function (other than one of the three - error retrieving functions). */ -extern const char *uuconf_error_filename (void *uuconf_pglobal); - -/* If UUCONF_ERROR_LINENO is set in a return value, this function may - be used to retrieve the line number. This function does not return - a uuconf error code, and it cannot fail. */ -extern int uuconf_error_lineno (void *uuconf_pglobal); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_error_string (); -extern int uuconf_error_errno (); -extern UUCONF_CONST char *uuconf_error_filename (); -extern int uuconf_error_lineno (); - -#endif /* ! UUCONF_ANSI_C */ - -/* The uuconf package also provides a few functions which can accept - commands and parcel them out according to a table. These are - publically visible, partially in the hopes that they will be - useful, but mostly because the rest of the Taylor UUCP package uses - them. */ - -/* The types of entries allowed in a command table (struct - uuconf_cmdtab). Each type defines how a particular command is - interpreted. Each type will either assign a value to a variable or - call a function. In all cases, a line of input is parsed into - separate fields, separated by whitespace; comments beginning with - '#' are discarded, except that a '#' preceeded by a backslash is - retained. The first field is taken as the command to execute, and - the remaining fields are its arguments. */ - -/* A boolean value. Used for a command which accepts a single - argument, which must begin with 'y', 'Y', 't', or 'T' for true (1) - or 'n', 'N', 'f', or 'F' for false (0). The corresponding variable - must be an int. */ -#define UUCONF_CMDTABTYPE_BOOLEAN (0x12) - -/* An integer value. Used for a command which accepts a single - argument, which must be an integer. The corresponding variable - must be an int. */ -#define UUCONF_CMDTABTYPE_INT (0x22) - -/* A long value. Used for a command which accepts a single value, - which must be an integer. The corresponding variable must be a - long. */ -#define UUCONF_CMDTABTYPE_LONG (0x32) - -/* A string value. Used for a command which accepts a string - argument. If there is no argument, the variable will be set to - point to a zero byte. Otherwise the variable will be set to point - to the string. The corresponding variable must be a char *. The - memory pointed to by the variable after it is set must not be - modified. */ -#define UUCONF_CMDTABTYPE_STRING (0x40) - -/* A full string value. Used for a command which accepts a series of - string arguments separated by whitespace. The corresponding - variable must be a char **. It will be set to an NULL terminated - array of the arguments. The memory occupied by the array itself, - and by the strings within it, must not be modified. */ -#define UUCONF_CMDTABTYPE_FULLSTRING (0x50) - -/* A function. If this command is encountered, the command and its - arguments are passed to the corresponding function. They are - passed as an array of strings, in which the first string is the - command itself, along with a count of strings. This value may be - or'red with a specific number of required arguments; - UUCONF_CMDTABTYPE_FN | 1 accepts no additional arguments besides - the command itself, UUCONF_CMDTABTYPE_FN | 2 accepts 1 argument, - etc. UUCONF_CMDTABTYPE_FN | 0, accepts any number of additional - arguments. */ -#define UUCONF_CMDTABTYPE_FN (0x60) - -/* A prefix function. The string in the table is a prefix; if a - command is encountered with the same prefix, the corresponding - function will be called as for UUCONF_CMDTABTYPE_FN. The number of - arguments may be or'red in as with UUCONF_CMDTABTYPE_FN. */ -#define UUCONF_CMDTABTYPE_PREFIX (0x70) - -/* This macro will return the particular type of a CMDTABTYPE. */ -#define UUCONF_TTYPE_CMDTABTYPE(i) ((i) & 0x70) - -/* This macro will return the required number of arguments of a - CMDTABTYPE. If it is zero, there is no restriction. */ -#define UUCONF_CARGS_CMDTABTYPE(i) ((i) & 0x0f) - -/* When a function is called via UUCONF_CMDTABTYPE_FN or - UUCONF_CMDTABTYPE_PREFIX, it may return any uuconf error code (see - above). However, it will normally return one of the following: - - UUCONF_CMDTABRET_CONTINUE: Take no special action. In particular, - the arguments passed to the function may be overwritten or freed. - - UUCONF_CMDTABRET_KEEP: The memory occupied by the arguments passed - to the function must be preserved. Continue processing commands. - - UUCONF_CMDTABRET_EXIT: If reading commands from a file, stop - processing. The arguments passed to the function may be - overwritten or freed. - - UUCONF_CMDTABRET_KEEP_AND_EXIT: Stop processing any file. The - memory occupied by the arguments passed to the function must be - preserved. - - These values are interpreted by uuconf_cmd_file. The - uuconf_cmd_line and uuconf_cmd_args functions may return - UUCONF_CMDTABRET_KEEP. It they get an error, they will return an - error code with UUCONF_CMDTABRET_EXIT set. Also, of course, they - may return any value that is returned by one of the user functions - in the uuconf_cmdtab table. */ - -/* UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT are defined above, - with the error codes. */ - -#define UUCONF_CMDTABRET_CONTINUE UUCONF_SUCCESS -#define UUCONF_CMDTABRET_KEEP_AND_EXIT \ - (UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT) - -/* When a function is called via CMDTABTYPE_FN or CMDTABTYPE_PREFIX, - it is passed five arguments. This is the type of a pointer to such - a function. The uuconf global information structure is passed in - for convenience in calling another uuconf function. The arguments - to the command are passed in (the command itself is the first - argument) along with a count and the value of the pvar field from - the uuconf_cmdtab structure in which the function pointer was - found. The pinfo argument to the function is taken from the - argument to uuconf_cmd_*. */ - -#if UUCONF_ANSI_C -typedef int (*uuconf_cmdtabfn) (void *uuconf_pglobal, - int uuconf_argc, - char **uuconf_argv, - void *uuconf_pvar, - void *uuconf_pinfo); -#else -typedef int (*uuconf_cmdtabfn) (); -#endif - -/* A table of commands is an array of the following structures. The - final element of the table should have uuconf_zcmd == NULL. */ - -struct uuconf_cmdtab -{ - /* Command name. */ - UUCONF_CONST char *uuconf_zcmd; - /* Command type (one of CMDTABTYPE_*). */ - int uuconf_itype; - /* If not CMDTABTYPE_FN or CMDTABTYPE_PREFIX, the address of the - associated variable. Otherwise, a pointer value to pass to the - function pifn. */ - UUCONF_POINTER uuconf_pvar; - /* The function to call if CMDTABTYPE_FN or CMDTABTYPE_PREFIX. */ - uuconf_cmdtabfn uuconf_pifn; -}; - -/* Bit flags to pass to uuconf_processcmds. */ - -/* If set, case is significant when checking commands. Normally case - is ignored. */ -#define UUCONF_CMDTABFLAG_CASE (0x1) - -/* If set, a backslash at the end of a line may be used to include the - next physical line in the logical line. */ -#define UUCONF_CMDTABFLAG_BACKSLASH (0x2) - -/* If set, the comment character (#) is treated as a normal character, - rather than as starting a comment. */ -#define UUCONF_CMDTABFLAG_NOCOMMENTS (0x4) - -#if UUCONF_ANSI_C - -/* Read commands from a file, look them up in a table, and take the - appropriate action. This continues reading lines from the file - until EOF, or until a function returns with UUCONF_CMDTABRET_EXIT - set, or until an error occurs. The qtab argument must point to a - table of struct uuconf_cmdtab; the last element in the table should - have uuconf_zcmd == NULL. When a UUCONF_CMDTABTYPE_FN or - UUCONF_CMDTABTYPE_PREFIX command is found, the pinfo argument will - be passed to the called function. If an a command is found that is - not in the table, then if pfiunknownfn is NULL the unknown command - is ignored; otherwise it is passed to pfiunknownfn, which should - return a uuconf return code which is handled as for any other - function (the pvar argument to pfiunknownfn will always be NULL). - The iflags argument is any combination of the above - UUCONF_CMDTABFLAG bits. The pblock argument may also be a memory - block, as returned by uuconf_malloc_block (described below), in - which case all memory preserved because of UUCONF_CMDTABRET_KEEP - will be added to the block so that it may be freed later; it may - also be NULL, in which case any such memory is permanently lost. - - This function initially sets the internal line number to 0, and - then increments it as each line is read. It is permitted for any - called function to use the uuconf_lineno function to obtain it. If - this function is called when not at the start of a file, the value - returned by uuconf_lineno (which is, in any case, only valid if an - error code with UUCONF_ERROR_LINENO set is returned) must be - adjusted by the caller. - - This returns a normal uuconf return value, as described above. */ -extern int uuconf_cmd_file (void *uuconf_pglobal, - FILE *uuconf_e, - const struct uuconf_cmdtab *uuconf_qtab, - void *uuconf_pinfo, - uuconf_cmdtabfn uuconf_pfiunknownfn, - int uuconf_iflags, - void *pblock); - -/* This utility function is just like uuconf_cmd_file, except that it - only operates on a single string. If a function is called via - qtab, its return value will be the return value of this function. - UUCONF_CMDTABFLAG_BACKSLASH is ignored in iflags. The string z is - modified in place. The return value may include the - UUCONF_CMDTABRET_KEEP and, on error, the UUCONF_CMDTABRET_EXIT - bits, which should be honored by the calling code. */ -extern int uuconf_cmd_line (void *uuconf_pglobal, - char *uuconf_z, - const struct uuconf_cmdtab *uuconf_qtab, - void *uuconf_pinfo, - uuconf_cmdtabfn uuconf_pfiunknownfn, - int uuconf_iflags, - void *pblock); - -/* This utility function is just like uuconf_cmd_line, except it is - given a list of already parsed arguments. */ -extern int uuconf_cmd_args (void *uuconf_pglobal, - int uuconf_cargs, - char **uuconf_pzargs, - const struct uuconf_cmdtab *uuconf_qtab, - void *uuconf_pinfo, - uuconf_cmdtabfn uuconf_pfiunknownfn, - int uuconf_iflags, - void *pblock); - -#else /* ! UUCONF_ANSI_C */ - -extern int uuconf_cmd_file (); -extern int uuconf_cmd_line (); -extern int uuconf_cmd_args (); - -#endif /* ! UUCONF_ANSI_C */ - -#if UUCONF_ANSI_C - -/* The uuconf_cmd_file function may allocate memory permanently, as - for setting a UUCONF_CMDTABTYPE_STRING value, in ways which are - difficult to free up. A memory block may be used to record all - allocated memory, so that it can all be freed up at once at some - later time. These functions do not take a uuconf global pointer, - and are independent of the rest of the uuconf library. */ - -/* Allocate a block of memory. If this returns NULL, then malloc - returned NULL, and errno is whatever malloc set it to. */ -extern void *uuconf_malloc_block (void); - -/* Allocate memory within a memory block. If this returns NULL, then - malloc returned NULL, and errno is whatever malloc set it to. */ -extern void *uuconf_malloc (void *uuconf_pblock, - UUCONF_SIZE_T uuconf_cbytes); - -/* Add a block returned by the generic malloc routine to a memory - block. This returns zero on success, non-zero on failure. If this - fails (returns non-zero), then malloc returned NULL, and errno is - whatever malloc set it to. */ -extern int uuconf_add_block (void *uuconf_pblock, void *uuconf_padd); - -/* Free a value returned by uuconf_malloc from a memory block. In the - current implementation, this will normally not do anything, but it - doesn't hurt. No errors can occur. */ -extern void uuconf_free (void *uuconf_pblock, void *uuconf_pfree); - -/* Free an entire memory block, including all values returned by - uuconf_malloc from it and all values added to it with - uuconf_add_block. No errors can occur. */ -extern void uuconf_free_block (void *uuconf_pblock); - -#else /* ! UUCONF_ANSI_C */ - -extern UUCONF_POINTER uuconf_malloc_block (); -extern UUCONF_POINTER uuconf_malloc (); -extern int uuconf_add_block (); -extern /* void */ uuconf_free (); -extern /* void */ uuconf_free_block (); - -#endif /* ! UUCONF_ANSI_C */ - -#endif /* ! defined (UUCONF_H) */ diff --git a/gnu/libexec/uucp/common_sources/uucp.h b/gnu/libexec/uucp/common_sources/uucp.h deleted file mode 100644 index 46369108f93a..000000000000 --- a/gnu/libexec/uucp/common_sources/uucp.h +++ /dev/null @@ -1,398 +0,0 @@ -/* uucp.h - Header file for the UUCP package. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* Get the system configuration parameters. */ -#include "config.h" -#include "policy.h" - -/* Get a definition for ANSI_C if we weren't given one. */ -#ifndef ANSI_C -#ifdef __STDC__ -#define ANSI_C 1 -#else /* ! defined (__STDC__) */ -#define ANSI_C 0 -#endif /* ! defined (__STDC__) */ -#endif /* ! defined (ANSI_C) */ - -/* Pass this definition into uuconf.h. */ -#define UUCONF_ANSI_C ANSI_C - -/* We always include some standard header files. We need - to define sig_atomic_t. */ -#include -#include -#if HAVE_STDDEF_H -#include -#endif - -/* On some systems we need to get sig_atomic_t or - size_t or time_t. */ -#if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && HAVE_SIG_ATOMIC_T_IN_TYPES_H -#define USE_TYPES_H 1 -#else -#if ! HAVE_SIZE_T_IN_STDDEF_H && HAVE_SIZE_T_IN_TYPES_H -#define USE_TYPES_H 1 -#else -#if ! HAVE_TIME_T_IN_TIME_H && HAVE_TIME_T_IN_TYPES_H -#define USE_TYPES_H 1 -#endif -#endif -#endif - -#ifndef USE_TYPES_H -#define USE_TYPES_H 0 -#endif - -#if USE_TYPES_H -#include -#endif - -/* Make sure we have sig_atomic_t. */ -#if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H -#ifndef SIG_ATOMIC_T -/* There is no portable definition for sig_atomic_t. */ -#define SIG_ATOMIC_T char -#endif /* ! defined (SIG_ATOMIC_T) */ -typedef SIG_ATOMIC_T sig_atomic_t; -#endif /* ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H && ! HAVE_SIG_ATOMIC_T_IN_TYPES_H */ - -/* Make sure we have size_t. */ -#if ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H -#ifndef SIZE_T -#define SIZE_T unsigned -#endif /* ! defined (SIZE_T) */ -typedef SIZE_T size_t; -#endif /* ! HAVE_SIZE_T_IN_STDDEF_H && ! HAVE_SIZE_T_IN_TYPES_H */ - -/* Make sure we have time_t. We use long as the default. We don't - bother to let conf.h override this, since on a system which doesn't - define time_t long must be correct. */ -#if ! HAVE_TIME_T_IN_TIME_H && ! HAVE_TIME_T_IN_TYPES_H -typedef long time_t; -#endif - -/* Set up some definitions for both ANSI C and Classic C. - - P() -- for function prototypes (e.g. extern int foo P((int)) ). - pointer -- for a generic pointer (i.e. void *). - constpointer -- for a generic pointer to constant data. - BUCHAR -- to convert a character to unsigned. */ -#if ANSI_C -#if ! HAVE_VOID || ! HAVE_UNSIGNED_CHAR || ! HAVE_PROTOTYPES - #error ANSI C compiler without void or unsigned char or prototypes -#endif -#define P(x) x -typedef void *pointer; -typedef const void *constpointer; -#define BUCHAR(b) ((unsigned char) (b)) -#else /* ! ANSI_C */ -/* Handle uses of volatile and void in Classic C. */ -#define volatile -#if ! HAVE_VOID -#define void int -#endif -#if HAVE_PROTOTYPES -#define P(x) x -#else -#define P(x) () -#endif -typedef char *pointer; -typedef const char *constpointer; -#if HAVE_UNSIGNED_CHAR -#define BUCHAR(b) ((unsigned char) (b)) -#else /* ! HAVE_UNSIGNED_CHAR */ -/* This should work on most systems, but not necessarily all. */ -#define BUCHAR(b) ((b) & 0xff) -#endif /* ! HAVE_UNSIGNED_CHAR */ -#endif /* ! ANSI_C */ - -/* Make sure we have a definition for offsetof. */ -#ifndef offsetof -#define offsetof(type, field) \ - ((size_t) ((char *) &(((type *) 0)->field) - (char *) (type *) 0)) -#endif - -/* Only use inline with gcc. */ -#ifndef __GNUC__ -#define __inline__ -#endif - -/* Get the string functions, which are used throughout the code. */ -#if HAVE_MEMORY_H -#include -#else -/* We really need a definition for memchr, and this should not - conflict with anything in . I hope. */ -extern pointer memchr (); -#endif - -#if HAVE_STRING_H -#include -#else /* ! HAVE_STRING_H */ -#if HAVE_STRINGS_H -#include -#else /* ! HAVE_STRINGS_H */ -extern char *strcpy (), *strncpy (), *strchr (), *strrchr (), *strtok (); -extern char *strcat (), *strerror (), *strstr (); -extern size_t strlen (), strspn (), strcspn (); -#if ! HAVE_MEMORY_H -extern pointer memcpy (), memchr (); -#endif /* ! HAVE_MEMORY_H */ -#endif /* ! HAVE_STRINGS_H */ -#endif /* ! HAVE_STRING_H */ - -/* Get what we need from . */ -#if HAVE_STDLIB_H -#include -#else /* ! HAVE_STDLIB_H */ -extern pointer malloc (), realloc (), bsearch (); -extern long strtol (); -extern unsigned long strtoul (); -extern char *getenv (); -#endif /* ! HAVE_STDLIB_H */ - -/* NeXT uses to declare a bunch of functions. */ -#if HAVE_LIBC_H -#include -#endif - -/* Make sure we have the EXIT_ macros. */ -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS (0) -#endif -#ifndef EXIT_FAILURE -#define EXIT_FAILURE (1) -#endif - -/* If we need to declare errno, do so. I don't want to always do - this, because some system might theoretically have a different - declaration for errno. On a POSIX system this is sure to work. */ -#if ! HAVE_ERRNO_DECLARATION -extern int errno; -#endif - -/* If the system has the socket call, guess that we can compile the - TCP code. */ -#define HAVE_TCP HAVE_SOCKET - -/* If the system has the t_open call, guess that we can compile the - TLI code. */ -#define HAVE_TLI HAVE_T_OPEN - -/* The boolean type holds boolean values. */ -typedef int boolean; -#undef TRUE -#undef FALSE -#define TRUE (1) -#define FALSE (0) - -/* The openfile_t type holds an open file. This depends on whether we - are using stdio or not. */ -#if USE_STDIO - -typedef FILE *openfile_t; -#define EFILECLOSED ((FILE *) NULL) -#define ffileisopen(e) ((e) != NULL) -#define ffileeof(e) feof (e) -#define cfileread(e, z, c) fread ((z), 1, (c), (e)) -#define cfilewrite(e, z, c) fwrite ((z), 1, (c), (e)) -#define ffileioerror(e, c) ferror (e) -#ifdef SEEK_SET -#define ffileseek(e, i) (fseek ((e), (long) (i), SEEK_SET) == 0) -#define ffilerewind(e) (fseek ((e), (long) 0, SEEK_SET) == 0) -#else -#define ffileseek(e, i) (fseek ((e), (long) (i), 0) == 0) -#define ffilerewind(e) (fseek ((e), (long) 0, 0) == 0) -#endif -#ifdef SEEK_END -#define ffileseekend(e) (fseek ((e), (long) 0, SEEK_END) == 0) -#else -#define ffileseekend(e) (fseek ((e), (long) 0, 2) == 0) -#endif -#define ffileclose(e) (fclose (e) == 0) - -#define fstdiosync(e, z) (fsysdep_sync (e, z)) - -#else /* ! USE_STDIO */ - -#if ! USE_TYPES_H -#undef USE_TYPES_H -#define USE_TYPES_H 1 -#include -#endif - -#if HAVE_UNISTD_H -#include -#endif - -#ifdef OFF_T -typedef OFF_T off_t; -#undef OFF_T -#endif - -typedef int openfile_t; -#define EFILECLOSED (-1) -#define ffileisopen(e) ((e) >= 0) -#define ffileeof(e) (FALSE) -#define cfileread(e, z, c) read ((e), (z), (c)) -#define cfilewrite(e, z, c) write ((e), (z), (c)) -#define ffileioerror(e, c) ((c) < 0) -#ifdef SEEK_SET -#define ffileseek(e, i) (lseek ((e), (off_t) i, SEEK_SET) >= 0) -#define ffilerewind(e) (lseek ((e), (off_t) 0, SEEK_SET) >= 0) -#else -#define ffileseek(e, i) (lseek ((e), (off_t) i, 0) >= 0) -#define ffilerewind(e) (lseek ((e), (off_t) 0, 0) >= 0) -#endif -#ifdef SEEK_END -#define ffileseekend(e) (lseek ((e), (off_t) 0, SEEK_END) >= 0) -#else -#define ffileseekend(e) (lseek ((e), (off_t) 0, 2) >= 0) -#endif -#define ffileclose(e) (close (e) >= 0) - -#define fstdiosync(e, z) (fsysdep_sync (fileno (e), z)) - -#endif /* ! USE_STDIO */ - -/* A prototype for main to avoid warnings from gcc 2.0 - -Wmissing-prototype option. */ -extern int main P((int argc, char **argv)); - -/* Some standard routines which we only define if they are not present - on the system we are compiling on. */ - -#if ! HAVE_GETLINE -/* Read a line from a file. */ -extern int getline P((char **pz, size_t *pc, FILE *e)); -#endif - -#if ! HAVE_REMOVE -/* Erase a file. */ -#undef remove -extern int remove P((const char *zfile)); -#endif - -#if ! HAVE_STRDUP -/* Copy a string into memory. */ -extern char *strdup P((const char *z)); -#endif - -#if ! HAVE_STRSTR -/* Look for one string within another. */ -extern char *strstr P((const char *zouter, const char *zinner)); -#endif - -#if ! HAVE_STRCASECMP -#if HAVE_STRICMP -#define strcasecmp stricmp -#else /* ! HAVE_STRICMP */ -/* Rename strcasecmp to avoid ANSI C name space. */ -#define strcasecmp xstrcasecmp -extern int strcasecmp P((const char *z1, const char *z2)); -#endif /* ! HAVE_STRICMP */ -#endif /* ! HAVE_STRCASECMP */ - -#if ! HAVE_STRNCASECMP -#if HAVE_STRNICMP -#define strncasecmp strnicmp -#else /* ! HAVE_STRNICMP */ -/* Rename strncasecmp to avoid ANSI C name space. */ -#define strncasecmp xstrncasecmp -extern int strncasecmp P((const char *z1, const char *z2, size_t clen)); -#endif /* ! HAVE_STRNICMP */ -#endif /* ! HAVE_STRNCASECMP */ - -#if ! HAVE_STRERROR -/* Get a string corresponding to an error message. */ -#undef strerror -extern char *strerror P((int ierr)); -#endif - -/* Get the appropriate definitions for memcmp, memcpy, memchr and - bzero. */ -#if ! HAVE_MEMCMP -#if HAVE_BCMP -#define memcmp(p1, p2, c) bcmp ((p1), (p2), (c)) -#else /* ! HAVE_BCMP */ -extern int memcmp P((constpointer p1, constpointer p2, size_t c)); -#endif /* ! HAVE_BCMP */ -#endif /* ! HAVE_MEMCMP */ - -#if ! HAVE_MEMCPY -#if HAVE_BCOPY -#define memcpy(pto, pfrom, c) bcopy ((pfrom), (pto), (c)) -#else /* ! HAVE_BCOPY */ -extern pointer memcpy P((pointer pto, constpointer pfrom, size_t c)); -#endif /* ! HAVE_BCOPY */ -#endif /* ! HAVE_MEMCPY */ - -#if ! HAVE_MEMCHR -extern pointer memchr P((constpointer p, int b, size_t c)); -#endif - -#if ! HAVE_BZERO -#if HAVE_MEMSET -#define bzero(p, c) memset ((p), 0, (c)) -#else /* ! HAVE_MEMSET */ -extern void bzero P((pointer p, int c)); -#endif /* ! HAVE_MEMSET */ -#endif /* ! HAVE_BZERO */ - -/* Look up a character in a string. */ -#if ! HAVE_STRCHR -#if HAVE_INDEX -#define strchr index -extern char *index (); -#else /* ! HAVE_INDEX */ -extern char *strchr P((const char *z, int b)); -#endif /* ! HAVE_INDEX */ -#endif /* ! HAVE_STRCHR */ - -#if ! HAVE_STRRCHR -#if HAVE_RINDEX -#define strrchr rindex -extern char *rindex (); -#else /* ! HAVE_RINDEX */ -extern char *strrchr P((const char *z, int b)); -#endif /* ! HAVE_RINDEX */ -#endif /* ! HAVE_STRRCHR */ - -/* Turn a string into a long integer. */ -#if ! HAVE_STRTOL -extern long strtol P((const char *, char **, int)); -#endif - -/* Turn a string into a long unsigned integer. */ -#if ! HAVE_STRTOUL -extern unsigned long strtoul P((const char *, char **, int)); -#endif - -/* Lookup a key in a sorted array. */ -#if ! HAVE_BSEARCH -extern pointer bsearch P((constpointer pkey, constpointer parray, - size_t celes, size_t cbytes, - int (*pficmp) P((constpointer, constpointer)))); -#endif diff --git a/gnu/libexec/uucp/common_sources/uudefs.h b/gnu/libexec/uucp/common_sources/uudefs.h deleted file mode 100644 index bf3d9f404acc..000000000000 --- a/gnu/libexec/uucp/common_sources/uudefs.h +++ /dev/null @@ -1,453 +0,0 @@ -/* uudefs.h - Miscellaneous definitions for the UUCP package. - - Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#if ANSI_C -/* These structures are used in prototypes but are not defined in this - header file. */ -struct uuconf_system; -struct uuconf_timespan; -#endif - -/* The tlog enumeration holds the different types of logging. */ -enum tlog -{ - /* Normal log entry. */ - LOG_NORMAL, - /* Error log entry. */ - LOG_ERROR, - /* Fatal log entry. */ - LOG_FATAL -#if DEBUG > 1 - , - /* Debugging log entry. */ - LOG_DEBUG, - /* Start debugging log entry. */ - LOG_DEBUG_START, - /* Continue debugging log entry. */ - LOG_DEBUG_CONTINUE, - /* End debugging log entry. */ - LOG_DEBUG_END -#endif -}; - -/* The tstatus_type enumeration holds the kinds of status information - we put in the status file. The order of entries here corresponds - to the order of entries in the azStatus array. */ -enum tstatus_type -{ - /* Conversation complete. */ - STATUS_COMPLETE, - /* Port unavailable. */ - STATUS_PORT_FAILED, - /* Dial failed. */ - STATUS_DIAL_FAILED, - /* Login failed. */ - STATUS_LOGIN_FAILED, - /* Handshake failed. */ - STATUS_HANDSHAKE_FAILED, - /* Failed after logging in. */ - STATUS_FAILED, - /* Talking to remote system. */ - STATUS_TALKING, - /* Wrong time to call. */ - STATUS_WRONG_TIME, - /* Number of status values. */ - STATUS_VALUES -}; - -/* An array to convert status entries to strings. If more status entries - are added, this array must be extended. */ -extern const char *azStatus[]; - -/* The sstatus structure holds the contents of a system status file. */ -struct sstatus -{ - /* Current status of conversation. */ - enum tstatus_type ttype; - /* Number of failed retries. */ - int cretries; - /* Time of last call in seconds since epoch (determined by - ixsysdep_time). */ - long ilast; - /* Number of seconds until a retry is permitted. */ - int cwait; - /* String in status file. Only used when reading status file, not - when writing. May be NULL. Should be freed with ubuffree. */ - char *zstring; -}; - -/* How long we have to wait for the next call, given the number of retries - we have already made. This should probably be configurable. */ -#define CRETRY_WAIT(c) ((c) * 10 * 60) - -/* The scmd structure holds a complete UUCP command. */ -struct scmd -{ - /* Command ('S' for send, 'R' for receive, 'X' for execute, 'E' for - simple execution, 'H' for hangup, 'Y' for hangup confirm, 'N' for - hangup deny). */ - char bcmd; - /* Grade of the command ('\0' if from remote system). */ - char bgrade; - /* Sequence handle for fsysdep_did_work. */ - pointer pseq; - /* File name to transfer from. */ - const char *zfrom; - /* File name to transfer to. */ - const char *zto; - /* User who requested transfer. */ - const char *zuser; - /* Options. */ - const char *zoptions; - /* Temporary file name ('S' and 'E'). */ - const char *ztemp; - /* Mode to give newly created file ('S' and 'E'). */ - unsigned int imode; - /* User to notify on remote system (optional; 'S' and 'E'). */ - const char *znotify; - /* File size (-1 if not supplied) ('S', 'E' and 'R'). */ - long cbytes; - /* Command to execute ('E'). */ - const char *zcmd; - /* Position to restart from ('R'). */ - long ipos; -}; - -#if DEBUG > 1 - -/* We allow independent control over several different types of - debugging output, using a bit string with individual bits dedicated - to particular debugging types. */ - -/* The bit string is stored in iDebug. */ -extern int iDebug; - -/* Debug abnormal events. */ -#define DEBUG_ABNORMAL (01) -/* Debug chat scripts. */ -#define DEBUG_CHAT (02) -/* Debug initial handshake. */ -#define DEBUG_HANDSHAKE (04) -/* Debug UUCP protocol. */ -#define DEBUG_UUCP_PROTO (010) -/* Debug protocols. */ -#define DEBUG_PROTO (020) -/* Debug port actions. */ -#define DEBUG_PORT (040) -/* Debug configuration files. */ -#define DEBUG_CONFIG (0100) -/* Debug spool directory actions. */ -#define DEBUG_SPOOLDIR (0200) -/* Debug executions. */ -#define DEBUG_EXECUTE (0400) -/* Debug incoming data. */ -#define DEBUG_INCOMING (01000) -/* Debug outgoing data. */ -#define DEBUG_OUTGOING (02000) - -/* Maximum possible value for iDebug. */ -#define DEBUG_MAX (03777) - -/* Intializer for array of debug names. The index of the name in the - array is the corresponding bit position in iDebug. We only check - for prefixes, so these names only need to be long enough to - distinguish each name from every other. The last entry must be - NULL. The string "all" is also recognized to turn on all - debugging. */ -#define DEBUG_NAMES \ - { "a", "ch", "h", "u", "pr", "po", "co", "s", "e", "i", "o", NULL } - -/* The prefix to use to turn off all debugging. */ -#define DEBUG_NONE "n" - -/* Check whether a particular type of debugging is being done. */ -#define FDEBUGGING(i) ((iDebug & (i)) != 0) - -/* These macros are used to output debugging information. I use - several different macros depending on the number of arguments - because no macro can take a variable number of arguments and I - don't want to use double parentheses. */ -#define DEBUG_MESSAGE0(i, z) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z)); } while (0) -#define DEBUG_MESSAGE1(i, z, a1) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1)); } while (0) -#define DEBUG_MESSAGE2(i, z, a1, a2) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1), (a2)); } while (0) -#define DEBUG_MESSAGE3(i, z, a1, a2, a3) \ - do \ - { \ - if (FDEBUGGING (i)) \ - ulog (LOG_DEBUG, (z), (a1), (a2), (a3)); \ - } \ - while (0) -#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) \ - do \ - { \ - if (FDEBUGGING (i)) \ - ulog (LOG_DEBUG, (z), (a1), (a2), (a3), (a4)); \ - } \ - while (0) - -#else /* DEBUG <= 1 */ - -/* If debugging information is not being compiled, provide versions of - the debugging macros which just disappear. */ -#define DEBUG_MESSAGE0(i, z) -#define DEBUG_MESSAGE1(i, z, a1) -#define DEBUG_MESSAGE2(i, z, a1, a2) -#define DEBUG_MESSAGE3(i, z, a1, a2, a3) -#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) - -#endif /* DEBUG <= 1 */ - -/* Functions. */ - -/* Given an unknown system name, return information for an unknown - system. If unknown systems are not permitted, this returns FALSE. - Otherwise, it translates the name as necessary for the spool - directory, and fills in *qsys. */ -extern boolean funknown_system P((pointer puuconf, const char *zsystem, - struct uuconf_system *qsys)); - -/* See whether a file belongs in the spool directory. */ -extern boolean fspool_file P((const char *zfile)); - -/* See if the current time matches a time span. If not, return FALSE. - Otherwise, return TRUE and set *pival and *pcretry to the values - from the matching element of the span. */ -extern boolean ftimespan_match P((const struct uuconf_timespan *qspan, - long *pival, int *pcretry)); - -/* Remove all occurrences of the local system name followed by an - exclamation point from the start of the argument. Return the - possibly shortened argument. */ -extern char *zremove_local_sys P((struct uuconf_system *qlocalsys, - char *z)); - -/* Determine the maximum size that may ever be transferred, given a - timesize span. If there are any time gaps larger than 1 hour not - described by the timesize span, this returns -1. Otherwise it - returns the largest size that may be transferred at some time. */ -extern long cmax_size_ever P((const struct uuconf_timespan *qtimesize)); - -/* Send mail about a file transfer. */ -extern boolean fmail_transfer P((boolean fok, const char *zuser, - const char *zmail, const char *zwhy, - const char *zfrom, const char *zfromsys, - const char *zto, const char *ztosys, - const char *zsaved)); - -/* See whether a file is in one of a list of directories. The zpubdir - argument is used to pass the directory names to zsysdep_local_file. - If fcheck is FALSE, this does not check accessibility. Otherwise, - if freadable is TRUE, the user zuser must have read access to the - file and all appropriate directories; if freadable is FALSE zuser - must have write access to the appropriate directories. The zuser - argument may be NULL, in which case all users must have the - appropriate access (this is used for a remote request). */ -extern boolean fin_directory_list P((const char *zfile, - char **pzdirs, - const char *zpubdir, - boolean fcheck, - boolean freadable, - const char *zuser)); - -/* Parse a command string. */ -extern boolean fparse_cmd P((char *zcmd, struct scmd *qcmd)); - -/* Make a log entry. */ -#ifdef __GNUC__ -#define GNUC_VERSION __GNUC__ -#else -#define GNUC_VERSION 0 -#endif - -#if ANSI_C && HAVE_VFPRINTF -extern void ulog P((enum tlog ttype, const char *zfmt, ...)) -#if GNUC_VERSION > 1 -#ifdef __printf0like - __printf0like (2, 3) -#else - __attribute__ ((format (printf, 2, 3))) -#endif -#endif - ; -#else -extern void ulog (); -#endif - -#undef GNUC_VERSION - -/* Report an error returned by one of the uuconf routines. */ -extern void ulog_uuconf P((enum tlog ttype, pointer puuconf, - int iuuconf)); - -/* Set the function to call if a fatal error occurs. */ -extern void ulog_fatal_fn P((void (*pfn) P((void)))); - -/* If ffile is TRUE, send log entries to the log file rather than to - stderr. */ -extern void ulog_to_file P((pointer puuconf, boolean ffile)); - -/* Set the ID number used by the logging functions. */ -extern void ulog_id P((int iid)); - -/* Set the system name used by the logging functions. */ -extern void ulog_system P((const char *zsystem)); - -/* Set the system and user name used by the logging functions. */ -extern void ulog_user P((const char *zuser)); - -/* Set the device name used by the logging functions. */ -extern void ulog_device P((const char *zdevice)); - -/* Close the log file. */ -extern void ulog_close P((void)); - -/* Make an entry in the statistics file. */ -extern void ustats P((boolean fsucceeded, const char *zuser, - const char *zsystem, boolean fsent, - long cbytes, long csecs, long cmicros, - boolean fcaller)); - -/* Close the statistics file. */ -extern void ustats_close P((void)); - -#if DEBUG > 1 -/* A debugging routine to output a buffer. This outputs zhdr, the - buffer length clen, and the contents of the buffer in quotation - marks. */ -extern void udebug_buffer P((const char *zhdr, const char *zbuf, - size_t clen)); - -/* A debugging routine to make a readable version of a character. - This takes a buffer at least 5 bytes long, and returns the length - of the string it put into it (not counting the null byte). */ -extern size_t cdebug_char P((char *z, int ichar)); - -/* Parse a debugging option string. This can either be a number or a - comma separated list of debugging names. This returns a value for - iDebug. */ -extern int idebug_parse P((const char *)); - -#endif /* DEBUG <= 1 */ - -/* Copy one file to another. */ -extern boolean fcopy_file P((const char *zfrom, const char *zto, - boolean fpublic, boolean fmkdirs, - boolean fsignals)); - -/* Copy an open file to another. */ -extern boolean fcopy_open_file P((openfile_t efrom, const char *zto, - boolean fpublic, boolean fmkdirs, - boolean fsignals)); - -/* Translate escape sequences in a buffer, leaving the result in the - same buffer and returning the length. */ -extern size_t cescape P((char *zbuf)); - -/* Get a buffer to hold a string of a given size. The buffer should - be freed with ubuffree. */ -extern char *zbufalc P((size_t csize)); - -/* Call zbufalc to allocate a buffer and copy a string into it. */ -extern char *zbufcpy P((const char *z)); - -/* Free up a buffer returned by zbufalc or zbufcpy. */ -extern void ubuffree P((char *z)); - -/* Allocate memory without fail. */ -extern pointer xmalloc P((size_t)); - -/* Realloc memory without fail. */ -extern pointer xrealloc P((pointer, size_t)); - -/* Free memory (accepts NULL pointers, which some libraries erroneously - do not). */ -extern void xfree P((pointer)); - -/* Global variables. */ - -/* The name of the program being run. Set from argv[0]. */ -extern const char *zProgram; - -/* When a signal occurs, the signal handlers sets the appropriate - element of the arrays afSignal and afLog_signal to TRUE. The - afSignal array is used to check whether a signal occurred. The - afLog_signal array tells ulog to log the signal; ulog will clear - the element after logging it, which means that if a signal comes in - at just the right moment it will not be logged. It will always be - recorded in afSignal, though. At the moment we handle 5 signals: - SIGHUP, SIGINT, SIGQUIT, SIGTERM and SIGPIPE (the Unix code also - handles SIGALRM). If we want to handle more, the afSignal array - must be extended; I see little point to handling any of the other - ANSI C or POSIX signals, as they are either unlikely to occur - (SIGABRT, SIGUSR1) or nearly impossible to handle cleanly (SIGILL, - SIGSEGV). SIGHUP is only logged if fLog_sighup is TRUE. */ -#define INDEXSIG_SIGHUP (0) -#define INDEXSIG_SIGINT (1) -#define INDEXSIG_SIGQUIT (2) -#define INDEXSIG_SIGTERM (3) -#define INDEXSIG_SIGPIPE (4) -#define INDEXSIG_COUNT (5) - -extern volatile sig_atomic_t afSignal[INDEXSIG_COUNT]; -extern volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT]; -extern boolean fLog_sighup; - -/* The names of the signals to use in error messages, as an - initializer for an array. */ -#define INDEXSIG_NAMES \ - { "hangup", "interrupt", "quit", "termination", "SIGPIPE" } - -/* Check to see whether we've received a signal. It would be nice if - we could use a single variable for this, but we sometimes want to - clear our knowledge of a signal and that would cause race - conditions (clearing a single element of the array is not a race - assuming that we don't care about a particular signal, even if it - occurs after we've examined the array). */ -#define FGOT_SIGNAL() \ - (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGINT] \ - || afSignal[INDEXSIG_SIGQUIT] || afSignal[INDEXSIG_SIGTERM] \ - || afSignal[INDEXSIG_SIGPIPE]) - -/* If we get a SIGINT in uucico, we continue the current communication - session but don't start any new ones. This macros checks for any - signal other than SIGINT, which means we should get out - immediately. */ -#define FGOT_QUIT_SIGNAL() \ - (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGQUIT] \ - || afSignal[INDEXSIG_SIGTERM] || afSignal[INDEXSIG_SIGPIPE]) - -/* Device name to log. This is set by fconn_open. It may be NULL. */ -extern char *zLdevice; - -/* If not NULL, ulog calls this function before outputting anything. - This is used to support cu. */ -extern void (*pfLstart) P((void)); - -/* If not NULL, ulog calls this function after outputting everything. - This is used to support cu. */ -extern void (*pfLend) P((void)); diff --git a/gnu/libexec/uucp/cu/Makefile b/gnu/libexec/uucp/cu/Makefile deleted file mode 100644 index 2503fc68a3da..000000000000 --- a/gnu/libexec/uucp/cu/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Makefile for cu -# $FreeBSD$ - -PROG= cu -SRCS= cu.c prot.c log.c chat.c conn.c copy.c -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -BINDIR= $(bindir) -BINOWN= $(owner) -BINGRP= dialer -BINMODE= 6555 -INSTALLFLAGS= -fschg - -.include - -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/cu/cu.1 b/gnu/libexec/uucp/cu/cu.1 deleted file mode 100644 index f3e5fe043ba2..000000000000 --- a/gnu/libexec/uucp/cu/cu.1 +++ /dev/null @@ -1,311 +0,0 @@ -.\" $Id: cu.1,v 1.9 1995/08/02 00:16:58 ian Rel $ -.\" $FreeBSD$ -.TH cu 1 "Taylor UUCP 1.06" -.SH NAME -cu \- Call up another system -.SH SYNOPSIS -.B cu -[ options ] [ system | phone | "dir" ] -.SH DESCRIPTION -The -.I cu -command is used to call up another system and act as a dial in -terminal. It can also do simple file transfers with no error -checking. - -.I cu -takes a single argument, besides the options. If the argument is the -string "dir" cu will make a direct connection to the port. This may -only be used by users with write access to the port, as it permits -reprogramming the modem. - -Otherwise, if the argument begins with a digit, it is taken to be a -phone number to call. Otherwise, it is taken to be the name of a -system to call. The -.B \-z -or -.B \-\-system -option may be used to name a system beginning with a digit, and the -.B \-c -or -.B \-\-phone -option may be used to name a phone number that does not begin with a -digit. - -.I cu -locates a port to use in the UUCP configuration files. If a simple -system name is given, it will select a port appropriate for that -system. The -.B \-p, \-\-port, \-l, \-\-line, \-s -and -.B \-\-speed -options may be used to control the port selection. - -When a connection is made to the remote system, -.I cu -forks into two processes. One reads from the port and writes to the -terminal, while the other reads from the terminal and writes to the -port. - -.I cu -provides several commands that may be used during the conversation. -The commands all begin with an escape character, initially -.B ~ -(tilde). The escape character is only recognized at the beginning of -a line. To send an escape character to the remote system at the start -of a line, it must be entered twice. All commands are either a single -character or a word beginning with -.B % -(percent sign). - -.I cu -recognizes the following commands: - -.TP 5 -.B ~. -Terminate the conversation. -.TP 5 -.B ~! command -Run command in a shell. If command is empty, starts up a shell. -.TP 5 -.B ~$ command -Run command, sending the standard output to the remote system. -.TP 5 -.B ~| command -Run command, taking the standard input from the remote system. -.TP 5 -.B ~+ command -Run command, taking the standard input from the remote system and -sending the standard output to the remote system. -.TP 5 -.B ~#, ~%break -Send a break signal, if possible. -.TP 5 -.B ~c directory, ~%cd directory -Change the local directory. -.TP 5 -.B ~> file -Send a file to the remote system. This just dumps the file over the -communication line. It is assumed that the remote system is expecting -it. -.TP 5 -.B ~< -Receive a file from the remote system. This prompts for the local -file name and for the remote command to execute to begin the file -transfer. It continues accepting data until the contents of the -.B eofread -variable are seen. -.TP 5 -.B ~p from to, ~%put from to -Send a file to a remote Unix system. This runs the appropriate -commands on the remote system. -.TP 5 -.B ~t from to, ~%take from to -Retrieve a file from a remote Unix system. This runs the appropriate -commands on the remote system. -.TP 5 -.B ~s variable value -Set a -.I cu -variable to the given value. If value is not given, the variable is -set to -.B true. -.TP 5 -.B ~! variable -Set a -.I cu -variable to -.B false. -.TP 5 -.B ~z -Suspend the cu session. This is only supported on some systems. On -systems for which ^Z may be used to suspend a job, -.B ~^Z -will also suspend the session. -.TP 5 -.B ~%nostop -Turn off XON/XOFF handling. -.TP 5 -.B ~%stop -Turn on XON/XOFF handling. -.TP 5 -.B ~v -List all the variables and their values. -.TP 5 -.B ~? -List all commands. - -.I cu -also supports several variables. They may be listed with the -.B ~v -command, and set with the -.B ~s -or -.B ~! -commands. - -.TP 5 -.B escape -The escape character. Initially -.B ~ -(tilde). -.TP 5 -.B delay -If this variable is true, -.I cu -will delay for a second after recognizing the escape character before -printing the name of the local system. The default is true. -.TP 5 -.B eol -The list of characters which are considered to finish a line. The -escape character is only recognized after one of these is seen. The -default is carriage return, ^U, ^C, ^O, ^D, ^S, ^Q, ^R. -.TP 5 -.B binary -Whether to transfer binary data when sending a file. If this is -false, then newlines in the file being sent are converted to carriage -returns. The default is false. -.TP 5 -.B binary-prefix -A string used before sending a binary character in a file transfer, if -the -.B binary -variable is true. The default is ^V. -.TP 5 -.B echo-check -Whether to check file transfers by examining what the remote system -echoes back. This probably doesn't work very well. The default is -false. -.TP 5 -.B echonl -The character to look for after sending each line in a file. The -default is carriage return. -.TP 5 -.B timeout -The timeout to use, in seconds, when looking for a character, either -when doing echo checking or when looking for the -.B echonl -character. The default is 30. -.TP 5 -.B kill -The character to use delete a line if the echo check fails. The -default is ^U. -.TP 5 -.B resend -The number of times to resend a line if the echo check continues to -fail. The default is 10. -.TP 5 -.B eofwrite -The string to write after sending a file with the -.B ~> -command. The default is ^D. -.TP 5 -.B eofread -The string to look for when receiving a file with the -.B ~< -command. The default is $, which is intended to be a typical shell -prompt. -.TP 5 -.B verbose -Whether to print accumulated information during a file transfer. The -default is true. -.SH OPTIONS -The following options may be given to -.I cu. -.TP 5 -.B \-e, \-\-parity=even -Use even parity. -.TP 5 -.B \-o, \-\-parity=odd -Use odd parity. -.TP 5 -.B \-\-parity=none -Use no parity. No parity is also used if both -.B \-e -and -.B \-o -are given. -.TP 5 -.B \-h, \-\-halfduplex -Echo characters locally (half-duplex mode). -.TP 5 -.B \-\-nostop -Turn off XON/XOFF handling (it is on by default). -.TP 5 -.B \-E char, \-\-escape char -Set the escape character. Initially -.B ~ -(tilde). To eliminate the escape character, use -.B -E ''. -.TP 5 -.B \-z system, \-\-system system -The system to call. -.TP 5 -.B \-c phone-number, \-\-phone phone-number -The phone number to call. -.TP 5 -.B \-p port, \-\-port port -Name the port to use. -.TP 5 -.B \-a port -Equivalent to -.B \-\-port port. -.TP 5 -.B \-l line, \-\-line line -Name the line to use by giving a device name. This may be used to -dial out on ports that are not listed in the UUCP configuration files. -Write access to the device is required. -.TP 5 -.B \-s speed, \-\-speed speed -The speed (baud rate) to use. -.TP 5 -.B \-# -Where # is a number, equivalent to -.B \-\-speed #. -.TP 5 -.B \-n, \-\-prompt -Prompt for the phone number to use. -.TP 5 -.B \-d -Enter debugging mode. Equivalent to -.B \-\-debug all. -.TP 5 -.B \-x type, \-\-debug type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. Only abnormal, chat, -handshake, port, config, incoming and outgoing are meaningful for -.I cu. - -Multiple types may be given, separated by commas, and the -.B \-\-debug -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. -.B \-\-debug all -may be used to turn on all debugging options. -.TP 5 -.B \-I file, \-\-config file -Set configuration file to use. This option may not be available, -depending upon how -.I cu -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH BUGS -This program does not work very well. -.SH FILES -The file name may be changed at compilation time, so this is only an -approximation. - -.br -/etc/uucp/config - Configuration file. -.SH AUTHOR -Ian Lance Taylor - diff --git a/gnu/libexec/uucp/cu/cu.c b/gnu/libexec/uucp/cu/cu.c deleted file mode 100644 index 3b41df3a28ac..000000000000 --- a/gnu/libexec/uucp/cu/cu.c +++ /dev/null @@ -1,2186 +0,0 @@ -/* cu.c - Call up a remote system. - - Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char cu_rcsid[] = "$FreeBSD$"; -#endif - -#include "cu.h" -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "prot.h" -#include "system.h" -#include "sysdep.h" -#include "getopt.h" - -#include -#include -#include - -/* Here are the user settable variables. The user is permitted to - change these while running the program, using ~s. */ - -/* The escape character used to introduce a special command. The - escape character is the first character of this string. */ -const char *zCuvar_escape = "~"; - -/* Whether to delay for a second before printing the host name after - seeing an escape character. */ -boolean fCuvar_delay = TRUE; - -/* The input characters which finish a line. The escape character is - only recognized following one of these characters. The default is - carriage return, ^U, ^C, ^O, ^D, ^S, ^Q, ^R, which I got from the - Ultrix /etc/remote file. */ -const char *zCuvar_eol = "\r\025\003\017\004\023\021\022"; - -/* Whether to transfer binary data (nonprintable characters other than - newline and tab) when sending a file. If this is FALSE, then - newline is changed to carriage return. */ -boolean fCuvar_binary = FALSE; - -/* A prefix string to use before sending a binary character from a - file; this is only used if fCuvar_binary is TRUE. The default is - ^V. */ -const char *zCuvar_binary_prefix = "\026"; - -/* Whether to check for echoes of characters sent when sending a file. - This is ignored if fCuvar_binary is TRUE. */ -boolean fCuvar_echocheck = FALSE; - -/* A character to look for after each newline is sent when sending a - file. The character is the first character in this string, except - that a '\0' means that no echo check is done. */ -const char *zCuvar_echonl = "\r"; - -/* The timeout to use when looking for an character. */ -int cCuvar_timeout = 30; - -/* The character to use to kill a line if an echo check fails. The - first character in this string is sent. The default is ^U. */ -const char *zCuvar_kill = "\025"; - -/* The number of times to try resending a line if the echo check keeps - failing. */ -int cCuvar_resend = 10; - -/* The string to send at the end of a file sent with ~>. The default - is ^D. */ -const char *zCuvar_eofwrite = "\004"; - -/* The string to look for to finish a file received with ~<. For tip - this is a collection of single characters, but I don't want to do - that because it means that there are characters which cannot be - received. The default is a guess at a typical shell prompt. */ -const char *zCuvar_eofread = "$"; - -/* Whether to provide verbose information when sending or receiving a - file. */ -boolean fCuvar_verbose = TRUE; - -/* The table used to give a value to a variable, and to print all the - variable values. */ - -static const struct uuconf_cmdtab asCuvars[] = -{ - { "escape", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_escape, NULL }, - { "delay", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_delay, NULL }, - { "eol", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eol, NULL }, - { "binary", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_binary, NULL }, - { "binary-prefix", UUCONF_CMDTABTYPE_STRING, - (pointer) &zCuvar_binary_prefix, NULL }, - { "echocheck", UUCONF_CMDTABTYPE_BOOLEAN, - (pointer) &fCuvar_echocheck, NULL }, - { "echonl", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_echonl, NULL }, - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cCuvar_timeout, NULL }, - { "kill", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_kill, NULL }, - { "resend", UUCONF_CMDTABTYPE_INT, (pointer) &cCuvar_resend, NULL }, - { "eofwrite", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eofwrite, NULL }, - { "eofread", UUCONF_CMDTABTYPE_STRING, (pointer) &zCuvar_eofread, NULL }, - { "verbose", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fCuvar_verbose, NULL }, - { NULL, 0, NULL, NULL} -}; - -/* The string printed at the initial connect. */ -#if ANSI_C -#define ZCONNMSG "\aConnected." -#else -#define ZCONNMSG "Connected." -#endif - -/* The string printed when disconnecting. */ -#if ANSI_C -#define ZDISMSG "\aDisconnected." -#else -#define ZDISMSG "Disconnected." -#endif - -/* Local variables. */ - -/* The string we print when the user is once again connected to the - port after transferring a file or taking some other action. */ -static const char abCuconnected[] -#if ANSI_C - = "\a[connected]"; -#else - = "[connected]"; -#endif - -/* Global uuconf pointer. */ -static pointer pCuuuconf; - -/* Connection. */ -static struct sconnection *qCuconn; - -/* Whether to close the connection. */ -static boolean fCuclose_conn; - -/* Dialer used to dial out. */ -static struct uuconf_dialer *qCudialer; - -/* Whether we need to restore the terminal. */ -static boolean fCurestore_terminal; - -/* Whether we are doing local echoing. */ -static boolean fCulocalecho; - -/* Whether we need to call fsysdep_cu_finish. */ -static boolean fCustarted; - -/* Whether ZCONNMSG has been printed yet. */ -static boolean fCuconnprinted = FALSE; - -/* A structure used to pass information to icuport_lock. */ -struct sconninfo -{ - boolean fmatched; - boolean flocked; - struct sconnection *qconn; - const char *zline; -}; - -/* Local functions. */ - -static void ucuusage P((void)); -static void ucuhelp P((void)); -static void ucuabort P((void)); -static void uculog_start P((void)); -static void uculog_end P((void)); -static int icuport_lock P((struct uuconf_port *qport, pointer pinfo)); -static boolean fcudo_cmd P((pointer puuconf, struct sconnection *qconn, - int bcmd)); -static boolean fcuset_var P((pointer puuconf, char *zline)); -static int icuunrecogvar P((pointer puuconf, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int icuunrecogfn P((pointer puuconf, int argc, char **argv, - pointer pvar, pointer pinfo)); -static void uculist_vars P((void)); -static void uculist_fns P((const char *zescape)); -static boolean fcudo_subcmd P((pointer puuconf, struct sconnection *qconn, - char *zline)); -static boolean fcusend_buf P((struct sconnection *qconn, const char *zbuf, - size_t cbuf)); - -#define ucuputs(zline) \ - do { if (! fsysdep_terminal_puts (zline)) ucuabort (); } while (0) - -/* Long getopt options. */ -static const struct option asCulongopts[] = -{ - { "phone", required_argument, NULL, 'c' }, - { "escape", required_argument, NULL, 'E' }, - { "parity", required_argument, NULL, 2 }, - { "halfduplex", no_argument, NULL, 'h' }, - { "prompt", no_argument, NULL, 'n' }, - { "line", required_argument, NULL, 'l' }, - { "port", required_argument, NULL, 'p' }, - { "speed", required_argument, NULL, 's' }, - { "baud", required_argument, NULL, 's' }, - { "mapcr", no_argument, NULL, 't' }, - { "nostop", no_argument, NULL, 3 }, - { "system", required_argument, NULL, 'z' }, - { "config", required_argument, NULL, 'I' }, - { "debug", required_argument, NULL, 'x' }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 1 }, - { NULL, 0, NULL, 0 } -}; - -int -main (argc, argv) - int argc; - char **argv; -{ - /* -c: phone number. */ - char *zphone = NULL; - /* -e: even parity. */ - boolean feven = FALSE; - /* -l: line. */ - char *zline = NULL; - /* -n: prompt for phone number. */ - boolean fprompt = FALSE; - /* -o: odd parity. */ - boolean fodd = FALSE; - /* -p: port name. */ - const char *zport = NULL; - /* -s: speed. */ - long ibaud = 0L; - /* -t: map cr to crlf. */ - boolean fmapcr = FALSE; - /* -z: system. */ - const char *zsystem = NULL; - /* --nostop: turn off XON/XOFF. */ - enum txonxoffsetting txonxoff = XONXOFF_ON; - /* -I: configuration file name. */ - const char *zconfig = NULL; - int iopt; - pointer puuconf; - int iuuconf; - const char *zlocalname; - int i; - struct uuconf_system ssys; - const struct uuconf_system *qsys = NULL; - boolean flooped; - struct uuconf_port sport; - struct sconnection sconn; - struct sconninfo sinfo; - long ihighbaud; - struct uuconf_dialer sdialer; - struct uuconf_dialer *qdialer; - char bcmd; - - zProgram = argv[0]; - - /* We want to accept -# as a speed. It's easiest to look through - the arguments, replace -# with -s#, and let getopt handle it. */ - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-' - && isdigit (BUCHAR (argv[i][1]))) - { - size_t clen; - char *z; - - clen = strlen (argv[i]); - z = zbufalc (clen + 2); - z[0] = '-'; - z[1] = 's'; - memcpy (z + 2, argv[i] + 1, clen); - argv[i] = z; - } - } - - while ((iopt = getopt_long (argc, argv, "a:c:deE:hnI:l:op:s:tvx:z:", - asCulongopts, (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'c': - /* Phone number. */ - zphone = optarg; - break; - - case 'd': - /* Set debugging level to maximum. */ -#if DEBUG > 1 - iDebug = DEBUG_MAX; -#endif - break; - - case 'e': - /* Even parity. */ - feven = TRUE; - break; - - case 'E': - /* Escape character. */ - zCuvar_escape = optarg; - break; - - case 'h': - /* Local echo. */ - fCulocalecho = TRUE; - break; - - case 'n': - /* Prompt for phone number. */ - fprompt = TRUE; - break; - - case 'l': - /* Line name. */ - zline = optarg; - break; - - case 'o': - /* Odd parity. */ - fodd = TRUE; - break; - - case 'p': - case 'a': - /* Port name (-a is for compatibility). */ - zport = optarg; - break; - - case 's': - /* Speed. */ - ibaud = strtol (optarg, (char **) NULL, 10); - break; - - case 't': - /* Map cr to crlf. */ - fmapcr = TRUE; - break; - - case 'z': - /* System name. */ - zsystem = optarg; - break; - - case 'I': - /* Configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - fprintf - (stderr, - "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 2: - /* --parity. */ - if (strncmp (optarg, "even", strlen (optarg)) == 0) - feven = TRUE; - else if (strncmp (optarg, "odd", strlen (optarg)) == 0) - fodd = TRUE; - else if (strncmp (optarg, "none", strlen (optarg)) == 0) - { - feven = TRUE; - fodd = TRUE; - } - else - { - fprintf (stderr, "%s: --parity requires even, odd or none\n", - zProgram); - ucuusage (); - } - break; - - case 3: - /* --nostop. */ - txonxoff = XONXOFF_OFF; - break; - - case 1: - /* --help. */ - ucuhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - ucuusage (); - /*NOTREACHED*/ - } - } - - /* There can be one more argument, which is either a system name, a - phone number, or "dir". We decide which it is based on the first - character. To call a UUCP system whose name begins with a digit, - or one which is named "dir", you must use -z. */ - if (optind != argc) - { - if (optind != argc - 1 - || zsystem != NULL - || zphone != NULL) - { - fprintf (stderr, "%s: too many arguments\n", zProgram); - ucuusage (); - } - if (strcmp (argv[optind], "dir") != 0) - { - if (isdigit (BUCHAR (argv[optind][0]))) - zphone = argv[optind]; - else - zsystem = argv[optind]; - } - } - - /* If the user doesn't give a system, port, line or speed, then - there's no basis on which to select a port. */ - if (zsystem == NULL - && zport == NULL - && zline == NULL - && ibaud == 0L) - { - fprintf (stderr, "%s: must specify system, line, port or speed\n", - zProgram); - ucuusage (); - } - - if (fprompt) - { - size_t cphone; - - printf ("Phone number: "); - (void) fflush (stdout); - zphone = NULL; - cphone = 0; - if (getline (&zphone, &cphone, stdin) <= 0 - || *zphone == '\0') - { - fprintf (stderr, "%s: no phone number entered\n", zProgram); - exit (EXIT_FAILURE); - } - } - - iuuconf = uuconf_init (&puuconf, "cu", zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - pCuuuconf = puuconf; - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - usysdep_initialize (puuconf, INIT_NOCHDIR | INIT_SUID); - - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - exit (EXIT_FAILURE); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - ulog_fatal_fn (ucuabort); - pfLstart = uculog_start; - pfLend = uculog_end; - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - if (zsystem != NULL) - { - iuuconf = uuconf_system_info (puuconf, zsystem, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - ulog (LOG_FATAL, "%s: System not found", zsystem); - } - qsys = &ssys; - } - - /* This loop is used if a system is specified. It loops over the - various alternates until it finds one for which the dial - succeeds. This is an ugly spaghetti construction, and it should - be broken up into different functions someday. */ - flooped = FALSE; - while (TRUE) - { - enum tparitysetting tparity; - enum tstripsetting tstrip; - long iusebaud; - - /* The uuconf_find_port function only selects directly on a port - name and a speed. To select based on the line name, we use a - function. If we can't find any defined port, and the user - specified a line name but did not specify a port name or a - system or a phone number, then we fake a direct port with - that line name (we don't fake a port if a system or phone - number were given because if we fake a port we have no way to - place a call; perhaps we should automatically look up a - particular dialer). This permits users to say cu -lttyd0 - without having to put ttyd0 in the ports file, provided they - have read and write access to the port. */ - sinfo.fmatched = FALSE; - sinfo.flocked = FALSE; - sinfo.qconn = &sconn; - sinfo.zline = zline; - if (zport != NULL || zline != NULL || ibaud != 0L) - { - iuuconf = uuconf_find_port (puuconf, zport, ibaud, 0L, - icuport_lock, (pointer) &sinfo, - &sport); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - { - if (sinfo.flocked) - { - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - } - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - } - if (zline == NULL - || zport != NULL - || zphone != NULL - || qsys != NULL) - { - if (sinfo.fmatched) - ulog (LOG_FATAL, "All matching ports in use"); - else - ulog (LOG_FATAL, "No matching ports"); - } - - sport.uuconf_zname = zline; - sport.uuconf_ttype = UUCONF_PORTTYPE_DIRECT; - sport.uuconf_zprotocols = NULL; - sport.uuconf_qproto_params = NULL; - sport.uuconf_ireliable = 0; - sport.uuconf_zlockname = NULL; - sport.uuconf_palloc = NULL; - sport.uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL; - sport.uuconf_u.uuconf_sdirect.uuconf_ibaud = ibaud; - - if (! fconn_init (&sport, &sconn, UUCONF_PORTTYPE_UNKNOWN)) - ucuabort (); - - if (! fconn_lock (&sconn, FALSE)) - ulog (LOG_FATAL, "%s: Line in use", zline); - - qCuconn = &sconn; - - /* Check user access after locking the port, because on - some systems shared lines affect the ownership and - permissions. In such a case ``Line in use'' is more - clear than ``Permission denied.'' */ - if (! fsysdep_port_access (&sport)) - ulog (LOG_FATAL, "%s: Permission denied", zline); - } - iusebaud = ibaud; - ihighbaud = 0L; - } - else - { - for (; qsys != NULL; qsys = qsys->uuconf_qalternate) - { - if (! qsys->uuconf_fcall) - continue; - if (qsys->uuconf_qport != NULL) - { - if (fconn_init (qsys->uuconf_qport, &sconn, - UUCONF_PORTTYPE_UNKNOWN)) - { - if (fconn_lock (&sconn, FALSE)) - { - qCuconn = &sconn; - break; - } - uconn_free (&sconn); - } - } - else - { - sinfo.fmatched = FALSE; - sinfo.flocked = FALSE; - sinfo.qconn = &sconn; - iuuconf = uuconf_find_port (puuconf, qsys->uuconf_zport, - qsys->uuconf_ibaud, - qsys->uuconf_ihighbaud, - icuport_lock, - (pointer) &sinfo, - &sport); - if (iuuconf == UUCONF_SUCCESS) - break; - if (iuuconf != UUCONF_NOT_FOUND) - { - if (sinfo.flocked) - { - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - } - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - } - } - } - - if (qsys == NULL) - { - const char *zrem; - - if (flooped) - zrem = "remaining "; - else - zrem = ""; - if (sinfo.fmatched) - ulog (LOG_FATAL, "%s: All %smatching ports in use", - zsystem, zrem); - else - ulog (LOG_FATAL, "%s: No %smatching ports", zsystem, zrem); - } - - iusebaud = qsys->uuconf_ibaud; - ihighbaud = qsys->uuconf_ihighbaud; - } - - /* Here we have locked a connection to use. */ - if (! fconn_open (&sconn, iusebaud, ihighbaud, FALSE)) - ucuabort (); - - fCuclose_conn = TRUE; - - if (FGOT_SIGNAL ()) - ucuabort (); - - /* Set up the connection. */ - if (fodd && feven) - { - tparity = PARITYSETTING_NONE; - tstrip = STRIPSETTING_SEVENBITS; - } - else if (fodd) - { - tparity = PARITYSETTING_ODD; - tstrip = STRIPSETTING_SEVENBITS; - } - else if (feven) - { - tparity = PARITYSETTING_EVEN; - tstrip = STRIPSETTING_SEVENBITS; - } - else - { - tparity = PARITYSETTING_DEFAULT; - tstrip = STRIPSETTING_DEFAULT; - } - - if (! fconn_set (&sconn, tparity, tstrip, txonxoff)) - ucuabort (); - - if (qsys != NULL) - zphone = qsys->uuconf_zphone; - - if (qsys != NULL || zphone != NULL) - { - enum tdialerfound tdialer; - - if (! fconn_dial (&sconn, puuconf, qsys, zphone, &sdialer, - &tdialer)) - { - if (zport != NULL - || zline != NULL - || ibaud != 0L - || qsys == NULL) - ucuabort (); - - qsys = qsys->uuconf_qalternate; - if (qsys == NULL) - ulog (LOG_FATAL, "%s: No remaining alternates", zsystem); - - fCuclose_conn = FALSE; - (void) fconn_close (&sconn, pCuuuconf, qCudialer, FALSE); - qCuconn = NULL; - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - - /* Loop around and try another alternate. */ - flooped = TRUE; - continue; - } - if (tdialer == DIALERFOUND_FALSE) - qdialer = NULL; - else - qdialer = &sdialer; - } - else - { - /* If no system or phone number was specified, we connect - directly to the modem. We only permit this if the user - has access to the port, since it permits various - shenanigans such as reprogramming the automatic - callbacks. */ - if (! fsysdep_port_access (sconn.qport)) - ulog (LOG_FATAL, "Access to port denied"); - qdialer = NULL; - if (! fconn_carrier (&sconn, FALSE)) - ulog (LOG_FATAL, "Can't turn off carrier"); - } - - break; - } - - qCudialer = qdialer; - - if (FGOT_SIGNAL ()) - ucuabort (); - - /* Here we have connected, and can start the main cu protocol. The - program spends most of its time in system dependent code, and - only comes out when a special command is received from the - terminal. */ - printf ("%s\n", ZCONNMSG); - fCuconnprinted = TRUE; - - if (! fsysdep_terminal_raw (fCulocalecho)) - ucuabort (); - - fCurestore_terminal = TRUE; - - if (! fsysdep_cu_init (&sconn)) - ucuabort (); - - fCustarted = TRUE; - - while (fsysdep_cu (&sconn, &bcmd, zlocalname)) - if (! fcudo_cmd (puuconf, &sconn, bcmd)) - break; - - fCustarted = FALSE; - if (! fsysdep_cu_finish ()) - ucuabort (); - - fCurestore_terminal = FALSE; - (void) fsysdep_terminal_restore (); - - (void) fconn_close (&sconn, puuconf, qdialer, TRUE); - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - - if (fCuconnprinted) - printf ("\n%s\n", ZDISMSG); - - ulog_close (); - - usysdep_exit (TRUE); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ucuusage () -{ - fprintf (stderr, "Usage: %s [options] [system or phone-number]\n", - zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void -ucuhelp () -{ - fprintf (stderr, - "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - fprintf (stderr, - "Usage: %s [options] [system or phone-number]\n", zProgram); - fprintf (stderr, - " -a,-p,--port port: Use named port\n"); - fprintf (stderr, - " -l,--line line: Use named device (e.g. tty0)\n"); - fprintf (stderr, - " -s,--speed,--baud speed, -#: Use given speed\n"); - fprintf (stderr, - " -c,--phone phone: Phone number to call\n"); - fprintf (stderr, - " -z,--system system: System to call\n"); - fprintf (stderr, - " -e: Set even parity\n"); - fprintf (stderr, - " -o: Set odd parity\n"); - fprintf (stderr, - " --parity={odd,even}: Set parity\n"); - fprintf (stderr, - " -E,--escape char: Set escape character\n"); - fprintf (stderr, - " -h,--halfduplex: Echo locally\n"); - fprintf (stderr, - " --nostop: Turn off XON/XOFF handling\n"); - fprintf (stderr, - " -t,--mapcr: Map carriage return to carriage return/linefeed\n"); - fprintf (stderr, - " -n,--prompt: Prompt for phone number\n"); - fprintf (stderr, - " -d: Set maximum debugging level\n"); - fprintf (stderr, - " -x,--debug debug: Set debugging type\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - fprintf (stderr, - " -v,--version: Print version and exit\n"); - fprintf (stderr, - " --help: Print help and exit\n"); -} - -/* This function is called when a fatal error occurs. */ - -static void -ucuabort () -{ - if (fCustarted) - { - fCustarted = FALSE; - (void) fsysdep_cu_finish (); - } - - if (fCurestore_terminal) - { - fCurestore_terminal = FALSE; - (void) fsysdep_terminal_restore (); - } - - if (qCuconn != NULL) - { - struct sconnection *qconn; - - if (fCuclose_conn) - { - fCuclose_conn = FALSE; - (void) fconn_close (qCuconn, pCuuuconf, qCudialer, FALSE); - } - qconn = qCuconn; - qCuconn = NULL; - (void) fconn_unlock (qconn); - uconn_free (qconn); - } - - ulog_close (); - - if (fCuconnprinted) - printf ("\n%s\n", ZDISMSG); - - usysdep_exit (FALSE); -} - -/* This variable is just used to communicate between uculog_start and - uculog_end. */ -static boolean fCulog_restore; - -/* This function is called by ulog before it output anything. We use - it to restore the terminal, if necessary. ulog is only called for - errors or debugging in cu, so it's not too costly to do this. If - we didn't do it, then at least on Unix each line would leave the - cursor in the same column rather than wrapping back to the start, - since CRMOD will not be on. */ - -static void -uculog_start () -{ - if (! fCurestore_terminal) - fCulog_restore = FALSE; - else - { - fCulog_restore = TRUE; - fCurestore_terminal = FALSE; - if (! fsysdep_terminal_restore ()) - ucuabort (); - } -} - -/* This function is called by ulog after everything is output. It - sets the terminal back, if necessary. */ - -static void -uculog_end () -{ - if (fCulog_restore) - { - if (! fsysdep_terminal_raw (fCulocalecho)) - ucuabort (); - fCurestore_terminal = TRUE; - } -} - -/* Check to see if this port has the desired line, to handle the -l - option. If it does, or if no line was specified, set up a - connection and lock it. */ - -static int -icuport_lock (qport, pinfo) - struct uuconf_port *qport; - pointer pinfo; -{ - struct sconninfo *q = (struct sconninfo *) pinfo; - - if (q->zline != NULL - && ! fsysdep_port_is_line (qport, q->zline)) - return UUCONF_NOT_FOUND; - - q->fmatched = TRUE; - - if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN)) - return UUCONF_NOT_FOUND; - else if (! fconn_lock (q->qconn, FALSE)) - { - uconn_free (q->qconn); - return UUCONF_NOT_FOUND; - } - else - { - qCuconn = q->qconn; - q->flocked = TRUE; - return UUCONF_SUCCESS; - } -} - -/* Execute a cu escape command. Return TRUE if the connection should - continue, or FALSE if the connection should be terminated. */ - -static boolean -fcudo_cmd (puuconf, qconn, bcmd) - pointer puuconf; - struct sconnection *qconn; - int bcmd; -{ - char *zline; - char *z; - char abescape[5]; - boolean fret; - size_t clen; - char abbuf[100]; - - /* Some commands take a string up to the next newline character. */ - switch (bcmd) - { - default: - zline = NULL; - break; - case '!': - case '$': - case '|': - case '+': - case '%': - case 'c': - case '>': - case '<': - case 'p': - case 't': - case 's': - { - zline = zsysdep_terminal_line ((const char *) NULL); - if (zline == NULL) - ucuabort (); - zline[strcspn (zline, "\n")] = '\0'; - } - break; - } - - switch (bcmd) - { - default: - if (! isprint (*zCuvar_escape)) - sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape)); - else - { - abescape[0] = *zCuvar_escape; - abescape[1] = '\0'; - } - sprintf (abbuf, "[Unrecognized. Use %s%s to send %s]", - abescape, abescape, abescape); - ucuputs (abbuf); - return TRUE; - - case '.': - /* Hangup. */ - return FALSE; - - case '!': - case '$': - case '|': - case '+': - /* Shell out. */ - if (! fsysdep_cu_copy (FALSE) - || ! fsysdep_terminal_restore ()) - ucuabort (); - fCurestore_terminal = FALSE; - { - enum tshell_cmd t; - - switch (bcmd) - { - default: - case '!': t = SHELL_NORMAL; break; - case '$': t = SHELL_STDOUT_TO_PORT; break; - case '|': t = SHELL_STDIN_FROM_PORT; break; - case '+': t = SHELL_STDIO_ON_PORT; break; - } - - (void) fsysdep_shell (qconn, zline, t); - } - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_raw (fCulocalecho)) - ucuabort (); - fCurestore_terminal = TRUE; - ubuffree (zline); - return TRUE; - - case '%': - fret = fcudo_subcmd (puuconf, qconn, zline); - ubuffree (zline); - return fret; - - case '#': - if (! fconn_break (qconn)) - ucuabort (); - return TRUE; - - case 'c': - (void) fsysdep_chdir (zline); - ubuffree (zline); - return TRUE; - - case '>': - case '<': - case 'p': - case 't': - clen = strlen (zline); - z = zbufalc (clen + 3); - z[0] = bcmd; - z[1] = ' '; - memcpy (z + 2, zline, clen + 1); - ubuffree (zline); - fret = fcudo_subcmd (puuconf, qconn, z); - ubuffree (z); - return fret; - - case 'z': - if (! fsysdep_cu_copy (FALSE) - || ! fsysdep_terminal_restore ()) - ucuabort (); - fCurestore_terminal = FALSE; - if (! fsysdep_suspend ()) - ucuabort (); - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_raw (fCulocalecho)) - ucuabort (); - fCurestore_terminal = TRUE; - return TRUE; - - case 's': - fret = fcuset_var (puuconf, zline); - ubuffree (zline); - return fret; - - case 'v': - uculist_vars (); - return TRUE; - - case '?': - if (! isprint (*zCuvar_escape)) - sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape)); - else - { - abescape[0] = *zCuvar_escape; - abescape[1] = '\0'; - } - ucuputs (""); - ucuputs ("[Escape sequences]"); - sprintf (abbuf, - "[%s. hangup] [%s!CMD run shell]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s$CMD stdout to remote] [%s|CMD stdin from remote]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s+CMD stdin and stdout to remote]", - abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s# send break] [%scDIR change directory]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s> send file] [%s< receive file]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%spFROM TO send to Unix] [%stFROM TO receive from Unix]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%ssVAR VAL set variable] [%ssVAR set boolean]", - abescape, abescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%ss!VAR unset boolean] [%sv list variables]", - abescape, abescape); - ucuputs (abbuf); -#ifdef SIGTSTP - sprintf (abbuf, - "[%sz suspend]", - abescape); - ucuputs (abbuf); -#endif - uculist_fns (abescape); - return TRUE; - } -} - -/* List ~% functions. */ - -static void -uculist_fns (zescape) - const char *zescape; -{ - char abbuf[100]; - - sprintf (abbuf, - "[%s%%break send break] [%s%%cd DIR change directory]", - zescape, zescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s%%put FROM TO send file] [%s%%take FROM TO receive file]", - zescape, zescape); - ucuputs (abbuf); - sprintf (abbuf, - "[%s%%nostop no XON/XOFF] [%s%%stop use XON/XOFF]", - zescape, zescape); - ucuputs (abbuf); -} - -/* Set a variable. */ - -static boolean -fcuset_var (puuconf, zline) - pointer puuconf; - char *zline; -{ - char *zvar, *zval; - char *azargs[2]; - int iuuconf; - - zvar = strtok (zline, "= \t"); - if (zvar == NULL) - { - ucuputs (abCuconnected); - return TRUE; - } - - zval = strtok ((char *) NULL, " \t"); - - if (zval == NULL) - { - azargs[0] = zvar; - if (azargs[0][0] != '!') - azargs[1] = zbufcpy ("t"); - else - { - ++azargs[0]; - azargs[1] = zbufcpy ("f"); - } - } - else - { - azargs[0] = zvar; - azargs[1] = zbufcpy (zval); - } - - iuuconf = uuconf_cmd_args (puuconf, 2, azargs, asCuvars, - (pointer) NULL, icuunrecogvar, 0, - (pointer) NULL); - - if ((iuuconf & UUCONF_CMDTABRET_KEEP) == 0) - ubuffree (azargs[1]); - - if ((iuuconf &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - - return TRUE; -} - -/* Warn about an unknown variable. */ - -/*ARGSUSED*/ -static int -icuunrecogvar (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - char abescape[5]; - - if (! isprint (*zCuvar_escape)) - sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape)); - else - { - abescape[0] = *zCuvar_escape; - abescape[1] = '\0'; - } - ulog (LOG_ERROR, "%s: unknown variable (%sv lists variables)", - argv[0], abescape); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* List all the variables with their values. */ - -static void -uculist_vars () -{ - const struct uuconf_cmdtab *q; - char abbuf[100]; - - ucuputs (""); - for (q = asCuvars; q->uuconf_zcmd != NULL; q++) - { - switch (UUCONF_TTYPE_CMDTABTYPE (q->uuconf_itype)) - { - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_BOOLEAN): - if (*(boolean *) q->uuconf_pvar) - sprintf (abbuf, "%s true", q->uuconf_zcmd); - else - sprintf (abbuf, "%s false", q->uuconf_zcmd); - break; - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_INT): - sprintf (abbuf, "%s %d", q->uuconf_zcmd, *(int *) q->uuconf_pvar); - break; - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_LONG): - sprintf (abbuf, "%s %ld", q->uuconf_zcmd, - *(long *) q->uuconf_pvar); - break; - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_STRING): - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FULLSTRING): - { - const char *z; - char abchar[5]; - size_t clen; - - sprintf (abbuf, "%s ", q->uuconf_zcmd); - clen = strlen (abbuf); - for (z = *(const char **) q->uuconf_pvar; *z != '\0'; z++) - { - int cchar; - - if (! isprint (*z)) - { - sprintf (abchar, "\\%03o", BUCHAR (*z)); - cchar = 4; - } - else - { - abchar[0] = *z; - abchar[1] = '\0'; - cchar = 1; - } - if (clen + cchar < sizeof (abbuf)) - strcat (abbuf, abchar); - clen += cchar; - } - } - break; - - default: - sprintf (abbuf, "%s [unprintable type]", q->uuconf_zcmd); - break; - } - - ucuputs (abbuf); - } -} - -/* Subcommands. These are commands that begin with ~%. */ - -/* This variable is only used so that we can pass a non-NULL address - in pvar. It is never assigned to or examined. */ - -static char bCutype; - -/* The command table for the subcommands. */ - -static int icubreak P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int icudebug P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int icuchdir P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int icuput P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int icutake P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int icunostop P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); - -static const struct uuconf_cmdtab asCucmds[] = -{ - { "break", UUCONF_CMDTABTYPE_FN | 1, NULL, icubreak }, - { "b", UUCONF_CMDTABTYPE_FN | 1, NULL, icubreak }, - { "cd", UUCONF_CMDTABTYPE_FN | 0, NULL, icuchdir }, - { "d", UUCONF_CMDTABTYPE_FN | 1, NULL, icudebug }, - { "put", UUCONF_CMDTABTYPE_FN | 0, NULL, icuput }, - { "take", UUCONF_CMDTABTYPE_FN | 0, NULL, icutake }, - { "nostop", UUCONF_CMDTABTYPE_FN | 1, NULL, icunostop }, - { "stop", UUCONF_CMDTABTYPE_FN | 1, &bCutype, icunostop }, - { ">", UUCONF_CMDTABTYPE_FN | 0, &bCutype, icuput }, - { "<", UUCONF_CMDTABTYPE_FN | 0, &bCutype, icutake }, - { "p", UUCONF_CMDTABTYPE_FN | 0, NULL, icuput }, - { "t", UUCONF_CMDTABTYPE_FN | 0, NULL, icutake }, - { NULL, 0, NULL, NULL } -}; - -/* Do a subcommand. This is called by commands beginning with ~%. */ - -static boolean -fcudo_subcmd (puuconf, qconn, zline) - pointer puuconf; - struct sconnection *qconn; - char *zline; -{ - char *azargs[3]; - int iarg; - int iuuconf; - - for (iarg = 0; iarg < 3; iarg++) - { - azargs[iarg] = strtok (iarg == 0 ? zline : (char *) NULL, " \t\n"); - if (azargs[iarg] == NULL) - break; - } - - if (iarg == 0) - { - ucuputs (abCuconnected); - return TRUE; - } - - iuuconf = uuconf_cmd_args (puuconf, iarg, azargs, asCucmds, - (pointer) qconn, icuunrecogfn, - 0, (pointer) NULL); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - - return TRUE; -} - -/* Warn about an unknown function. */ - -/*ARGSUSED*/ -static int -icuunrecogfn (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - char abescape[5]; - - if (! isprint (*zCuvar_escape)) - sprintf (abescape, "\\%03o", BUCHAR (*zCuvar_escape)); - else - { - abescape[0] = *zCuvar_escape; - abescape[1] = '\0'; - } - if (argv[0][0] == '?') - uculist_fns (abescape); - else - ulog (LOG_ERROR, "%s: unknown (%s%%? lists choices)", - argv[0], abescape); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Send a break. */ - -/*ARGSUSED*/ -static int -icubreak (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sconnection *qconn = (struct sconnection *) pinfo; - - if (! fconn_break (qconn)) - ucuabort (); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Change directories. */ - -/*ARGSUSED*/ -static int -icuchdir (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - const char *zarg; - - if (argc <= 1) - zarg = NULL; - else - zarg = argv[1]; - (void) fsysdep_chdir (zarg); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Toggle debugging. */ - -/*ARGSUSED*/ -static int -icudebug (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ -#if DEBUG > 1 - if (iDebug != 0) - iDebug = 0; - else - iDebug = DEBUG_MAX; -#else - ucuputs ("[compiled without debugging]"); -#endif - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Control whether the port does xon/xoff handshaking. If pvar is not - NULL, this is "stop"; otherwise it is "nostop". */ - -/*ARGSUSED*/ -static int -icunostop (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sconnection *qconn = (struct sconnection *) pinfo; - - if (! fconn_set (qconn, PARITYSETTING_DEFAULT, STRIPSETTING_DEFAULT, - pvar == NULL ? XONXOFF_OFF : XONXOFF_ON)) - ucuabort (); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Send a file to the remote system. The first argument is the file - to send. If that argument is not present, it is prompted for. The - second argument is to file name to use on the remote system. If - that argument is not present, the basename of the local filename is - used. If pvar is not NULL, then this is ~>, which is used to send - a command to a non-Unix system. We treat is the same as ~%put, - except that we assume the user has already entered the appropriate - command (for ~%put, we force ``cat >to'' to the other side). */ - -/*ARGSUSED*/ -static int -icuput (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sconnection *qconn = (struct sconnection *) pinfo; - char *zfrom; - char *zto = NULL; - char *zalc; - openfile_t e; - int cline; - char *zbuf; - size_t cbuf; - - if (argc > 1) - zfrom = zbufcpy (argv[1]); - else - { - zfrom = zsysdep_terminal_line ("File to send: "); - if (zfrom == NULL) - ucuabort (); - zfrom[strcspn (zfrom, " \t\n")] = '\0'; - - if (*zfrom == '\0') - { - ubuffree (zfrom); - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; - } - } - - if (pvar == NULL) - { - if (argc > 2) - zto = zbufcpy (argv[2]); - else - { - char *zbase; - char *zprompt; - - zbase = zsysdep_base_name (zfrom); - if (zbase == NULL) - ucuabort (); - - zprompt = zbufalc (sizeof "Remote file name []: " + - strlen (zbase)); - sprintf (zprompt, "Remote file name [%s]: ", zbase); - zto = zsysdep_terminal_line (zprompt); - ubuffree (zprompt); - if (zto == NULL) - ucuabort (); - - zto[strcspn (zto, " \t\n")] = '\0'; - if (*zto != '\0') - ubuffree (zbase); - else - { - ubuffree (zto); - zto = zbase; - } - } - } - - e = esysdep_user_fopen (zfrom, TRUE, fCuvar_binary); - if (! ffileisopen (e)) - { - const char *zerrstr; - - if (pvar == NULL) - ubuffree (zto); - zerrstr = strerror (errno); - zalc = zbufalc (strlen (zfrom) + sizeof ": " + strlen (zerrstr)); - sprintf (zalc, "%s: %s", zfrom, zerrstr); - ubuffree (zfrom); - ucuputs (zalc); - ubuffree (zalc); - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; - } - - ubuffree (zfrom); - - /* Tell the system dependent layer to stop copying data from the - port to the terminal. We want to read the echoes ourself. Also - permit the local user to generate signals. */ - if (! fsysdep_cu_copy (FALSE) - || ! fsysdep_terminal_signals (TRUE)) - ucuabort (); - - /* If pvar is NULL, then we are sending a file to a Unix system. We - send over the command "cat > TO" to prepare it to receive. If - pvar is not NULL, the user is assumed to have set up whatever - action was needed to receive the file. */ - if (pvar == NULL) - { - boolean fret; - - zalc = zbufalc (sizeof "cat > \n" + strlen (zto)); - sprintf (zalc, "cat > %s\n", zto); - ubuffree (zto); - fret = fcusend_buf (qconn, zalc, strlen (zalc)); - ubuffree (zalc); - if (! fret) - { - (void) ffileclose (e); - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_signals (FALSE)) - ucuabort (); - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; - } - } - - cline = 0; - - zbuf = NULL; - cbuf = 0; - - while (TRUE) - { - char abbuf[512]; - size_t c; - -#if USE_STDIO - if (fCuvar_binary) -#endif - { - if (ffileeof (e)) - break; - c = cfileread (e, abbuf, sizeof abbuf); - if (ffileioerror (e, c)) - { - ucuputs ("[file read error]"); - break; - } - if (c == 0) - break; - zbuf = abbuf; - } -#if USE_STDIO - else - { - if (getline (&zbuf, &cbuf, e) <= 0) - { - xfree ((pointer) zbuf); - break; - } - c = strlen (zbuf); - } -#endif - - if (fCuvar_verbose) - { - ++cline; - printf ("%d ", cline); - (void) fflush (stdout); - } - - if (! fcusend_buf (qconn, zbuf, c)) - { - if (! fCuvar_binary) - xfree ((pointer) zbuf); - (void) fclose (e); - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_signals (FALSE)) - ucuabort (); - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; - } - } - - (void) ffileclose (e); - - if (pvar == NULL) - { - char beof; - - beof = '\004'; - if (! fconn_write (qconn, &beof, 1)) - ucuabort (); - } - else - { - if (*zCuvar_eofwrite != '\0') - { - if (! fconn_write (qconn, zCuvar_eofwrite, - strlen (zCuvar_eofwrite))) - ucuabort (); - } - } - - if (fCuvar_verbose) - ucuputs (""); - - ucuputs ("[file transfer complete]"); - - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_signals (FALSE)) - ucuabort (); - - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Get a file from the remote side. This is ~%take, or ~t, or ~<. - The first two are assumed to be taking the file from a Unix system, - so we force the command "cat FROM; echo */ - -/*ARGSUSED*/ -static int -icutake (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sconnection *qconn = (struct sconnection *) pinfo; - const char *zeof; - char *zfrom, *zto, *zcmd; - char *zalc; - openfile_t e; - char bcr; - size_t ceoflen; - char *zlook = NULL; - size_t ceofhave; - boolean ferr; - - if (argc > 1) - zfrom = zbufcpy (argv[1]); - else - { - zfrom = zsysdep_terminal_line ("Remote file to retreive: "); - if (zfrom == NULL) - ucuabort (); - zfrom[strcspn (zfrom, " \t\n")] = '\0'; - if (*zfrom == '\0') - { - ubuffree (zfrom); - ucuputs (abCuconnected); - return UUCONF_CMDTABRET_CONTINUE; - } - } - - if (argc > 2) - zto = zbufcpy (argv[2]); - else - { - char *zbase; - char *zprompt; - - zbase = zsysdep_base_name (zfrom); - if (zbase == NULL) - ucuabort (); - - zprompt = zbufalc (sizeof "Local file name []: " + strlen (zbase)); - sprintf (zprompt, "Local file name [%s]: ", zbase); - zto = zsysdep_terminal_line (zprompt); - ubuffree (zprompt); - if (zto == NULL) - ucuabort (); - - zto[strcspn (zto, " \t\n")] = '\0'; - if (*zto != '\0') - ubuffree (zbase); - else - { - ubuffree (zto); - zto = zbase; - } - } - - if (pvar != NULL) - { - zcmd = zsysdep_terminal_line ("Remote command to execute: "); - if (zcmd == NULL) - ucuabort (); - zcmd[strcspn (zcmd, "\n")] = '\0'; - zeof = zCuvar_eofread; - } - else - { - zcmd = zbufalc (sizeof "cat ; echo; echo ////cuend////" - + strlen (zfrom)); - sprintf (zcmd, "cat %s; echo; echo ////cuend////", zfrom); - zeof = "\n////cuend////\n"; - } - - ubuffree (zfrom); - - e = esysdep_user_fopen (zto, FALSE, fCuvar_binary); - if (! ffileisopen (e)) - { - const char *zerrstr; - - ubuffree (zcmd); - zerrstr = strerror (errno); - zalc = zbufalc (strlen (zto) + sizeof ": " + strlen (zerrstr)); - sprintf (zalc, "%s: %s\n", zto, zerrstr); - ucuputs (zalc); - ubuffree (zalc); - ucuputs (abCuconnected); - ubuffree (zto); - return UUCONF_CMDTABRET_CONTINUE; - } - - if (! fsysdep_cu_copy (FALSE) - || ! fsysdep_terminal_signals (TRUE)) - ucuabort (); - - if (! fconn_write (qconn, zcmd, strlen (zcmd))) - ucuabort (); - bcr = '\r'; - if (! fconn_write (qconn, &bcr, 1)) - ucuabort (); - - ubuffree (zcmd); - - /* Eliminated any previously echoed data to avoid confusion. */ - iPrecstart = 0; - iPrecend = 0; - - /* If we're dealing with a Unix system, we can reliably discard the - command. Otherwise, the command will probably wind up in the - file; too bad. */ - if (pvar == NULL) - { - int b; - - while ((b = breceive_char (qconn, cCuvar_timeout, TRUE)) != '\n') - { - if (b == -2) - ucuabort (); - if (b < 0) - { - ucuputs ("[timed out waiting for newline]"); - ucuputs (abCuconnected); - ubuffree (zto); - return UUCONF_CMDTABRET_CONTINUE; - } - } - } - - ceoflen = strlen (zeof); - zlook = zbufalc (ceoflen); - ceofhave = 0; - ferr = FALSE; - - while (TRUE) - { - int b; - - if (FGOT_SIGNAL ()) - { - /* Make sure the signal is logged. */ - ulog (LOG_ERROR, (const char *) NULL); - ucuputs ("[file receive aborted]"); - /* Reset the SIGINT flag so that it does not confuse us in - the future. */ - afSignal[INDEXSIG_SIGINT] = FALSE; - break; - } - - b = breceive_char (qconn, cCuvar_timeout, TRUE); - if (b == -2) - ucuabort (); - if (b < 0) - { - if (ceofhave > 0) - (void) fwrite (zlook, sizeof (char), ceofhave, e); - ucuputs ("[timed out]"); - break; - } - - if (b == '\r' && ! fCuvar_binary) - continue; - - if (ceoflen == 0) - { - if (cfilewrite (e, &b, 1) != 1) - { - ferr = TRUE; - break; - } - } - else - { - zlook[ceofhave] = b; - ++ceofhave; - if (ceofhave == ceoflen) - { - size_t cmove; - char *zmove; - - if (memcmp (zeof, zlook, ceoflen) == 0) - { - ucuputs ("[file transfer complete]"); - break; - } - - if (cfilewrite (e, zlook, 1) != 1) - { - ferr = TRUE; - break; - } - - zmove = zlook; - for (cmove = ceoflen - 1, zmove = zlook; - cmove > 0; - cmove--, zmove++) - zmove[0] = zmove[1]; - - --ceofhave; - } - } - } - - ubuffree (zlook); - - if (! fsysdep_sync (e, zto)) - { - (void) ffileclose (e); - ferr = TRUE; - } - else - { - if (! ffileclose (e)) - ferr = TRUE; - } - if (ferr) - ucuputs ("[file write error]"); - - if (! fsysdep_cu_copy (TRUE) - || ! fsysdep_terminal_signals (FALSE)) - ucuabort (); - - ucuputs (abCuconnected); - - ubuffree (zto); - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Send a buffer to the remote system. If fCuvar_binary is FALSE, - each buffer passed in will be a single line; in this case we can - check the echoed characters and kill the line if they do not match. - This returns FALSE if an echo check fails. If a port error - occurrs, it calls ucuabort. */ - -static boolean -fcusend_buf (qconn, zbufarg, cbufarg) - struct sconnection *qconn; - const char *zbufarg; - size_t cbufarg; -{ - const char *zbuf; - size_t cbuf; - int ctries; - size_t cbplen; - char *zsendbuf; - - zbuf = zbufarg; - cbuf = cbufarg; - ctries = 0; - - if (fCuvar_binary) - cbplen = strlen (zCuvar_binary_prefix); - else - cbplen = 1; - zsendbuf = zbufalc (64 * (cbplen + 1)); - - /* Loop while we still have characters to send. The value of cbuf - will be reset to cbufarg if an echo failure occurs while sending - a line in non-binary mode. */ - while (cbuf > 0) - { - int csend; - char *zput; - const char *zget; - boolean fnl; - int i; - - if (FGOT_SIGNAL ()) - { - /* Make sure the signal is logged. */ - ubuffree (zsendbuf); - ulog (LOG_ERROR, (const char *) NULL); - ucuputs ("[file send aborted]"); - /* Reset the SIGINT flag so that it does not confuse us in - the future. */ - afSignal[INDEXSIG_SIGINT] = FALSE; - return FALSE; - } - - /* Discard anything we've read from the port up to now, to avoid - confusing the echo checking. */ - iPrecstart = 0; - iPrecend = 0; - - /* Send all characters up to a newline before actually sending - the newline. This makes it easier to handle the special - newline echo checking. Send up to 64 characters at a time - before doing echo checking. */ - if (*zbuf == '\n') - csend = 1; - else - { - const char *znl; - - znl = memchr (zbuf, '\n', cbuf); - if (znl == NULL) - csend = cbuf; - else - csend = znl - zbuf; - if (csend > 64) - csend = 64; - } - - /* Translate this part of the buffer. If we are not in binary - mode, we translate \n to \r, and ignore any nonprintable - characters. */ - zput = zsendbuf; - fnl = FALSE; - for (i = 0, zget = zbuf; i < csend; i++, zget++) - { - if (isprint (*zget) - || *zget == '\t') - *zput++ = *zget; - else if (*zget == '\n') - { - if (fCuvar_binary) - *zput++ = '\n'; - else - *zput++ = '\r'; - fnl = TRUE; - } - else if (fCuvar_binary) - { - strcpy (zput, zCuvar_binary_prefix); - zput += cbplen; - *zput++ = *zget; - } - } - - zbuf += csend; - cbuf -= csend; - - if (zput == zsendbuf) - continue; - - /* Send the data over the port. */ - if (! fsend_data (qconn, zsendbuf, (size_t) (zput - zsendbuf), TRUE)) - ucuabort (); - - /* We do echo checking if requested, unless we are in binary - mode. Echo checking of a newline is different from checking - of normal characters; when we send a newline we look for - *zCuvar_echonl. */ - if ((fCuvar_echocheck && ! fCuvar_binary) - || (fnl && *zCuvar_echonl != '\0')) - { - long iend; - - iend = ixsysdep_time ((long *) NULL) + (long) cCuvar_timeout; - for (zget = zsendbuf; zget < zput; zget++) - { - int bread; - int bwant; - - if (fCuvar_binary ? *zget == '\n' : *zget == '\r') - { - bwant = *zCuvar_echonl; - if (bwant == '\0') - continue; - } - else - { - if (! fCuvar_echocheck || ! isprint (*zget)) - continue; - bwant = *zget; - } - - do - { - if (FGOT_SIGNAL ()) - { - /* Make sure the signal is logged. */ - ubuffree (zsendbuf); - ulog (LOG_ERROR, (const char *) NULL); - ucuputs ("[file send aborted]"); - /* Reset the SIGINT flag so that it does not - confuse us in the future. */ - afSignal[INDEXSIG_SIGINT] = FALSE; - return FALSE; - } - - bread = breceive_char (qconn, - iend - ixsysdep_time ((long *) NULL), - TRUE); - if (bread < 0) - { - if (bread == -2) - ucuabort (); - - /* If we timed out, and we're not in binary - mode, we kill the line and try sending it - again from the beginning. */ - if (! fCuvar_binary && *zCuvar_kill != '\0') - { - ++ctries; - if (ctries < cCuvar_resend) - { - if (fCuvar_verbose) - { - printf ("R "); - (void) fflush (stdout); - } - if (! fsend_data (qconn, zCuvar_kill, 1, - TRUE)) - ucuabort (); - zbuf = zbufarg; - cbuf = cbufarg; - break; - } - } - ubuffree (zsendbuf); - ucuputs ("[timed out looking for echo]"); - return FALSE; - } - } - while (bread != *zget); - - if (bread < 0) - break; - } - } - } - - ubuffree (zsendbuf); - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/Makefile b/gnu/libexec/uucp/libunix/Makefile deleted file mode 100644 index a5d506fc0191..000000000000 --- a/gnu/libexec/uucp/libunix/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# This subdirectory contains Unix specific support functions. -# $FreeBSD$ - -LIB= unix -SRCS= basnam.c cusub.c efopen.c epopen.c init.c isdir.c isfork.c \ - iswait.c lock.c loctim.c mail.c mkdirs.c pause.c pipe.c \ - portnm.c proctm.c serial.c signal.c sindir.c sleep.c spawn.c \ - sync.c tcp.c time.c ufopen.c uid.c -CFLAGS+= -I$(.CURDIR)/../common_sources \ - -DOWNER=\"$(owner)\" -DSBINDIR=\"$(libxdir)\" - -NOMAN= noman -NOPROFILE= noprofile - -install: - -.include diff --git a/gnu/libexec/uucp/libunix/basnam.c b/gnu/libexec/uucp/libunix/basnam.c deleted file mode 100644 index c61fcaa8de61..000000000000 --- a/gnu/libexec/uucp/libunix/basnam.c +++ /dev/null @@ -1,22 +0,0 @@ -/* basnam.c - Get the base name of a file. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* Get the base name of a file name. */ - -char * -zsysdep_base_name (zfile) - const char *zfile; -{ - const char *z; - - z = strrchr (zfile, '/'); - if (z != NULL) - return zbufcpy (z + 1); - return zbufcpy (zfile); -} diff --git a/gnu/libexec/uucp/libunix/cusub.c b/gnu/libexec/uucp/libunix/cusub.c deleted file mode 100644 index 67cd363b3656..000000000000 --- a/gnu/libexec/uucp/libunix/cusub.c +++ /dev/null @@ -1,1215 +0,0 @@ -/* cusub.c - System dependent routines for cu. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char cusub_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" -#include "cu.h" -#include "conn.h" -#include "prot.h" - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -/* Get definitions for both O_NONBLOCK and O_NDELAY. */ -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else /* ! defined (FNDELAY) */ -#define O_NDELAY 0 -#endif /* ! defined (FNDELAY) */ -#endif /* ! defined (O_NDELAY) */ - -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else /* ! defined (FNBLOCK) */ -#define O_NONBLOCK 0 -#endif /* ! defined (FNBLOCK) */ -#endif /* ! defined (O_NONBLOCK) */ - -#include -#include - -/* 4.2 systems don't define SIGUSR2. This should work for them. On - systems which are missing SIGUSR1, or SIGURG, you must find two - signals which you can safely use. */ -#ifndef SIGUSR2 -#define SIGUSR2 SIGURG -#endif - -/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */ -#ifndef EAGAIN -#ifndef EWOULDBLOCK -#define EAGAIN (-1) -#define EWOULDBLOCK (-1) -#else /* defined (EWOULDBLOCK) */ -#define EAGAIN EWOULDBLOCK -#endif /* defined (EWOULDBLOCK) */ -#else /* defined (EAGAIN) */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif /* ! defined (EWOULDBLOCK) */ -#endif /* defined (EAGAIN) */ - -#ifndef ENODATA -#define ENODATA EAGAIN -#endif - -/* Local variables. */ - -/* The EOF character, as set by fsysdep_terminal_raw. */ -static char bSeof; - -/* The SUSP character, as set by fsysdep_terminal_raw. */ -static char bStstp; - -/* Local functions. */ - -static const char *zsport_line P((const struct uuconf_port *qport)); -static void uscu_child P((struct sconnection *qconn, int opipe)); -static RETSIGTYPE uscu_child_handler P((int isig)); -static RETSIGTYPE uscu_alarm P((int isig)); -static int cscu_escape P((char *pbcmd, const char *zlocalname)); -static RETSIGTYPE uscu_alarm_kill P((int isig)); - -/* Return the device name for a port, or NULL if none. */ - -static const char * -zsport_line (qport) - const struct uuconf_port *qport; -{ - const char *zline; - - if (qport == NULL) - return NULL; - - switch (qport->uuconf_ttype) - { - default: - case UUCONF_PORTTYPE_STDIN: - return NULL; - case UUCONF_PORTTYPE_MODEM: - zline = qport->uuconf_u.uuconf_smodem.uuconf_zdevice; - break; - case UUCONF_PORTTYPE_DIRECT: - zline = qport->uuconf_u.uuconf_sdirect.uuconf_zdevice; - break; - case UUCONF_PORTTYPE_TCP: - case UUCONF_PORTTYPE_TLI: - case UUCONF_PORTTYPE_PIPE: - return NULL; - } - - if (zline == NULL) - zline = qport->uuconf_zname; - return zline; -} - -/* Check whether the user has legitimate access to a port. */ - -boolean -fsysdep_port_access (qport) - struct uuconf_port *qport; -{ - const char *zline; - char *zfree; - boolean fret; - - zline = zsport_line (qport); - if (zline == NULL) - return TRUE; - - zfree = NULL; - if (*zline != '/') - { - zfree = zbufalc (sizeof _PATH_DEV + strlen (zline)); - sprintf (zfree, "%s%s", _PATH_DEV, zline); - zline = zfree; - } - - fret = access (zline, R_OK | W_OK) == 0; - ubuffree (zfree); - return fret; -} - -/* Return whether the given port is named by the given line. */ - -boolean -fsysdep_port_is_line (qport, zline) - struct uuconf_port *qport; - const char *zline; -{ - const char *zpline; - char *zfree1, *zfree2; - boolean fret; - - zpline = zsport_line (qport); - if (zpline == NULL) - return FALSE; - - if (strcmp (zline, zpline) == 0) - return TRUE; - - zfree1 = NULL; - zfree2 = NULL; - if (*zline != '/') - { - zfree1 = zbufalc (sizeof _PATH_DEV + strlen (zline)); - sprintf (zfree1, "%s%s", _PATH_DEV, zline); - zline = zfree1; - } - if (*zpline != '/') - { - zfree2 = zbufalc (sizeof _PATH_DEV + strlen (zpline)); - sprintf (zfree2, "%s%s", _PATH_DEV, zpline); - zpline = zfree2; - } - - fret = strcmp (zline, zpline) == 0; - ubuffree (zfree1); - ubuffree (zfree2); - return fret; -} - -/* The cu program wants the system dependent layer to handle the - details of copying data from the communications port to the - terminal. This copying need only be done while executing - fsysdep_cu. On Unix, however, we set up a subprocess to do it all - the time. This subprocess must be controllable via the - fsysdep_cu_copy function. - - We keep a pipe open to the subprocess. When we want it to stop we - send it a signal, and then wait for it to write a byte to us over - the pipe. */ - -/* The subprocess pid. */ -static volatile pid_t iSchild; - -/* The pipe from the subprocess. */ -static int oSpipe; - -/* When we tell the child to stop, it sends this. */ -#define CHILD_STOPPED ('S') - -/* When we tell the child to start, it sends this. */ -#define CHILD_STARTED ('G') - -/* Initialize the subprocess, and have it start copying data. */ - -boolean -fsysdep_cu_init (qconn) - struct sconnection *qconn; -{ - int ai[2]; - - /* Write out anything we may have buffered up during the chat - script. We do this before forking the child only to make it easy - to move the child into a separate executable. */ - while (iPrecend != iPrecstart) - { - char *z; - int c; - - z = abPrecbuf + iPrecstart; - if (iPrecend > iPrecstart) - c = iPrecend - iPrecstart; - else - c = CRECBUFLEN - iPrecstart; - - iPrecstart = (iPrecstart + c) % CRECBUFLEN; - - while (c > 0) - { - int cwrote; - - cwrote = write (1, z, c); - if (cwrote <= 0) - { - if (cwrote < 0) - ulog (LOG_ERROR, "write: %s", strerror (errno)); - else - ulog (LOG_ERROR, "Line disconnected"); - return FALSE; - } - c -= cwrote; - z += cwrote; - } - } - - if (pipe (ai) < 0) - { - ulog (LOG_ERROR, "pipe: %s", strerror (errno)); - return FALSE; - } - - iSchild = ixsfork (); - if (iSchild < 0) - { - ulog (LOG_ERROR, "fork: %s", strerror (errno)); - return FALSE; - } - - if (iSchild == 0) - { - (void) close (ai[0]); - uscu_child (qconn, ai[1]); - /*NOTREACHED*/ - } - - (void) close (ai[1]); - - oSpipe = ai[0]; - - return TRUE; -} - -/* Copy all data from the terminal to the communications port. If we - see an escape character following a newline character, read the - next character and return it. */ - -boolean -fsysdep_cu (qconn, pbcmd, zlocalname) - struct sconnection *qconn; - char *pbcmd; - const char *zlocalname; -{ - boolean fstart; - char b; - int c; - - fstart = TRUE; - - while (TRUE) - { - if (fsysdep_catch ()) - usysdep_start_catch (); - else - { - ulog (LOG_ERROR, (const char *) NULL); - return FALSE; - } - - c = read (0, &b, 1); - - usysdep_end_catch (); - - if (c <= 0) - break; - - if (fstart && b == *zCuvar_escape && b != '\0') - { - c = cscu_escape (pbcmd, zlocalname); - if (c <= 0) - break; - if (*pbcmd != b) - { - write (1, pbcmd, 1); - - /* For Unix, we let the eof character be the same as - '.', and we let the suspend character (if any) be the - same as 'z'. */ - if (*pbcmd == bSeof) - *pbcmd = '.'; - if (*pbcmd == bStstp) - *pbcmd = 'z'; - return TRUE; - } - } - if (! fconn_write (qconn, &b, (size_t) 1)) - return FALSE; - fstart = strchr (zCuvar_eol, b) != NULL; - } - - if (c < 0) - { - if (errno != EINTR) - ulog (LOG_ERROR, "read: %s", strerror (errno)); - else - ulog (LOG_ERROR, (const char *) NULL); - return FALSE; - } - - /* I'm not sure what's best in this case. */ - ulog (LOG_ERROR, "End of file on terminal"); - return FALSE; -} - -/* A SIGALRM handler that sets fScu_alarm and optionally longjmps. */ - -volatile sig_atomic_t fScu_alarm; - -static RETSIGTYPE -uscu_alarm (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, uscu_alarm); -#endif - - fScu_alarm = TRUE; - -#if HAVE_RESTARTABLE_SYSCALLS - if (fSjmp) - longjmp (sSjmp_buf, 1); -#endif -} - -/* We've just seen an escape character. We print the host name, - optionally after a 1 second delay. We read the next character from - the terminal and return it. The 1 second delay on the host name is - mostly to be fancy; it lets ~~ look smoother. */ - -static int -cscu_escape (pbcmd, zlocalname) - char *pbcmd; - const char *zlocalname; -{ - CATCH_PROTECT int c; - - write (1, zCuvar_escape, 1); - - fScu_alarm = FALSE; - usset_signal (SIGALRM, uscu_alarm, TRUE, (boolean *) NULL); - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - alarm (1); - } - - c = 0; - - while (TRUE) - { - if (fScu_alarm) - { - char b; - - fScu_alarm = FALSE; - b = '['; - write (1, &b, 1); - write (1, zlocalname, strlen (zlocalname)); - b = ']'; - write (1, &b, 1); - } - - if (c <= 0) - c = read (0, pbcmd, 1); - if (c >= 0 || errno != EINTR) - { - usysdep_end_catch (); - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - return c; - } - } -} - -/* A SIGALRM handler which does nothing but send a signal to the child - process and schedule another alarm. POSIX.1 permits kill and alarm - from a signal handler. The reference to static data may or may not - be permissible. */ - -static volatile sig_atomic_t iSsend_sig; - -static RETSIGTYPE -uscu_alarm_kill (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, uscu_alarm_kill); -#endif - - (void) kill (iSchild, iSsend_sig); - - alarm (1); -} - -/* Start or stop copying data from the communications port to the - terminal. We send a signal to the child process to tell it what to - do. Unfortunately, there are race conditions in the child, so we - keep sending it a signal once a second until it responds. We send - SIGUSR1 to make it start copying, and SIGUSR2 to make it stop. */ - -boolean -fsysdep_cu_copy (fcopy) - boolean fcopy; -{ - int ierr; - int c; - - usset_signal (SIGALRM, uscu_alarm_kill, TRUE, (boolean *) NULL); - if (fcopy) - iSsend_sig = SIGUSR1; - else - iSsend_sig = SIGUSR2; - - uscu_alarm_kill (SIGALRM); - - alarm (1); - - while (TRUE) - { - char b; - - c = read (oSpipe, &b, 1); - -#if DEBUG > 1 - if (c > 0) - DEBUG_MESSAGE1 (DEBUG_INCOMING, - "fsysdep_cu_copy: Got '%d'", b); -#endif - - if ((c < 0 && errno != EINTR) - || c == 0 - || (c > 0 && b == (fcopy ? CHILD_STARTED : CHILD_STOPPED))) - break; - - /* If none of the above conditions were true, then we either got - an EINTR error, in which case we probably timed out and the - SIGALRM handler resent the signal, or we read the wrong - character, in which case we will just read again from the - pipe. */ - } - - ierr = errno; - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - - if (c > 0) - return TRUE; - - if (c == 0) - ulog (LOG_ERROR, "EOF on child pipe"); - else - ulog (LOG_ERROR, "read: %s", strerror (ierr)); - - return FALSE; -} - -/* Shut down cu by killing the child process. */ - -boolean -fsysdep_cu_finish () -{ - (void) close (oSpipe); - - /* We hit the child with SIGTERM, give it two seconds to die, and - then send a SIGKILL. */ - if (kill (iSchild, SIGTERM) < 0) - { - /* Don't give an error if the child has already died. */ - if (errno != ESRCH) - ulog (LOG_ERROR, "kill: %s", strerror (errno)); - } - - usset_signal (SIGALRM, uscu_alarm_kill, TRUE, (boolean *) NULL); - iSsend_sig = SIGKILL; - alarm (2); - - (void) ixswait ((unsigned long) iSchild, "child"); - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - - return TRUE; -} - -/* Code for the child process. */ - -/* This signal handler just records the signal. In this case we only - care about which signal we received most recently. */ - -static volatile sig_atomic_t iSchild_sig; - -static RETSIGTYPE -uscu_child_handler (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, uscu_child_handler); -#endif - - iSchild_sig = isig; - -#if HAVE_RESTARTABLE_SYSCALLS - if (fSjmp) - longjmp (sSjmp_buf, 1); -#endif /* HAVE_RESTARTABLE_SYSCALLS */ -} - -/* The child process. This copies the port to the terminal, except - when it is stopped by a signal. It would be reasonable to write a - separate program for this, probably passing it the port on stdin. - This would reduce the memory requirements, since we wouldn't need a - second process holding all the configuration stuff, and also let it - work reasonably on 680x0 versions of MINIX. */ - -static void -uscu_child (qconn, opipe) - struct sconnection *qconn; - int opipe; -{ - CATCH_PROTECT int oport; - CATCH_PROTECT boolean fstopped, fgot; - CATCH_PROTECT int cwrite; - CATCH_PROTECT char abbuf[1024]; - - fgot = FALSE; - - /* It would be nice if we could just use fsysdep_conn_read, but that - will log signals that we don't want logged. There should be a - generic way to extract the file descriptor from the port. */ - if (qconn->qport == NULL) - oport = 0; - else - { - switch (qconn->qport->uuconf_ttype) - { -#if DEBUG > 0 - default: - ulog (LOG_FATAL, "uscu_child: Can't happen"); - oport = -1; - break; -#endif - case UUCONF_PORTTYPE_PIPE: - /* A read of 0 on a pipe always means EOF (see below). */ - fgot = TRUE; - /* Fall through. */ - case UUCONF_PORTTYPE_STDIN: - oport = ((struct ssysdep_conn *) qconn->psysdep)->ord; - break; - case UUCONF_PORTTYPE_MODEM: - case UUCONF_PORTTYPE_DIRECT: - case UUCONF_PORTTYPE_TCP: - case UUCONF_PORTTYPE_TLI: - oport = ((struct ssysdep_conn *) qconn->psysdep)->o; - break; - } - } - - /* Force the descriptor into blocking mode. */ - (void) fcntl (oport, F_SETFL, - fcntl (oport, F_GETFL, 0) &~ (O_NDELAY | O_NONBLOCK)); - - usset_signal (SIGUSR1, uscu_child_handler, TRUE, (boolean *) NULL); - usset_signal (SIGUSR2, uscu_child_handler, TRUE, (boolean *) NULL); - usset_signal (SIGINT, SIG_IGN, TRUE, (boolean *) NULL); - usset_signal (SIGQUIT, SIG_IGN, TRUE, (boolean *) NULL); - usset_signal (SIGPIPE, SIG_DFL, TRUE, (boolean *) NULL); - usset_signal (SIGTERM, uscu_child_handler, TRUE, (boolean *) NULL); - - fstopped = FALSE; - iSchild_sig = 0; - cwrite = 0; - - if (fsysdep_catch ()) - usysdep_start_catch (); - - while (TRUE) - { - int isig; - int c; - - /* There is a race condition here between checking the signal - and receiving a new and possibly different one. This is - solved by having the parent resend the signal until it gets a - response. */ - isig = iSchild_sig; - iSchild_sig = 0; - if (isig != 0) - { - char b; - - if (isig == SIGTERM) - exit (EXIT_SUCCESS); - - if (isig == SIGUSR1) - { - fstopped = FALSE; - b = CHILD_STARTED; - } - else - { - fstopped = TRUE; - b = CHILD_STOPPED; - cwrite = 0; - } - - c = write (opipe, &b, 1); - - /* Apparently on some systems we can get EAGAIN here. */ - if (c < 0 && - (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA)) - c = 0; - - if (c <= 0) - { - /* Should we give an error message here? */ - (void) kill (getppid (), SIGHUP); - exit (EXIT_FAILURE); - } - } - - if (fstopped) - pause (); - else if (cwrite > 0) - { - char *zbuf; - - zbuf = abbuf; - while (cwrite > 0) - { - c = write (1, zbuf, cwrite); - - /* Apparently on some systems we can get EAGAIN here. */ - if (c < 0 && - (errno == EAGAIN - || errno == EWOULDBLOCK - || errno == ENODATA)) - c = 0; - - if (c < 0 && errno == EINTR) - break; - if (c <= 0) - { - /* Should we give an error message here? */ - (void) kill (getppid (), SIGHUP); - exit (EXIT_FAILURE); - } - cwrite -= c; - zbuf += c; - } - } - else - { - /* On some systems apparently read will return 0 until - something has been written to the port. We therefore - accept a 0 return until after we have managed to read - something. Setting errno to 0 apparently avoids a - problem on Coherent. */ - errno = 0; - c = read (oport, abbuf, sizeof abbuf); - - /* Apparently on some systems we can get EAGAIN here. */ - if (c < 0 && - (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA)) - c = 0; - - if ((c == 0 && fgot) - || (c < 0 && errno != EINTR)) - { - /* This can be a normal way to exit, depending on just - how the connection is dropped. */ - (void) kill (getppid (), SIGHUP); - exit (EXIT_SUCCESS); - } - if (c > 0) - { - fgot = TRUE; - cwrite = c; - } - } - } -} - -/* Terminal control routines. */ - -/* Whether file descriptor 0 is attached to a terminal or not. */ -static boolean fSterm; - -/* Whether we are doing local echoing. */ -static boolean fSlocalecho; - -/* The original state of the terminal. */ -static sterminal sSterm_orig; - -/* The new state of the terminal. */ -static sterminal sSterm_new; - -#if ! HAVE_BSD_TTY -#ifdef SIGTSTP -/* Whether SIGTSTP is being ignored. */ -static boolean fStstp_ignored; -#endif -#endif - -/* Set the terminal into raw mode. */ - -boolean -fsysdep_terminal_raw (flocalecho) - boolean flocalecho; -{ - fSlocalecho = flocalecho; - - /* This defaults may be overriden below. */ - bSeof = '\004'; - bStstp = '\032'; - - if (! fgetterminfo (0, &sSterm_orig)) - { - fSterm = FALSE; - return TRUE; - } - - fSterm = TRUE; - - sSterm_new = sSterm_orig; - -#if HAVE_BSD_TTY - - /* We use CBREAK mode rather than RAW mode, because RAW mode turns - off all output processing, which we don't want to do. This means - that we have to disable the interrupt characters, which we do by - setting them to -1. */ - bSeof = sSterm_orig.stchars.t_eofc; - - sSterm_new.stchars.t_intrc = -1; - sSterm_new.stchars.t_quitc = -1; - sSterm_new.stchars.t_startc = -1; - sSterm_new.stchars.t_stopc = -1; - sSterm_new.stchars.t_eofc = -1; - sSterm_new.stchars.t_brkc = -1; - - bStstp = sSterm_orig.sltchars.t_suspc; - - sSterm_new.sltchars.t_suspc = -1; - sSterm_new.sltchars.t_dsuspc = -1; - sSterm_new.sltchars.t_rprntc = -1; - sSterm_new.sltchars.t_flushc = -1; - sSterm_new.sltchars.t_werasc = -1; - sSterm_new.sltchars.t_lnextc = -1; - - if (! flocalecho) - { - sSterm_new.stty.sg_flags |= (CBREAK | ANYP); - sSterm_new.stty.sg_flags &=~ (ECHO | CRMOD | TANDEM); - } - else - { - sSterm_new.stty.sg_flags |= (CBREAK | ANYP | ECHO); - sSterm_new.stty.sg_flags &=~ (CRMOD | TANDEM); - } - -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO - - bSeof = sSterm_new.c_cc[VEOF]; - if (! flocalecho) - sSterm_new.c_lflag &=~ (ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHONL); - else - sSterm_new.c_lflag &=~ (ICANON | ISIG); - sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY); - sSterm_new.c_oflag &=~ (OPOST); - sSterm_new.c_cc[VMIN] = 1; - sSterm_new.c_cc[VTIME] = 0; - -#endif /* HAVE_SYSV_TERMIO */ - -#if HAVE_POSIX_TERMIOS - - bSeof = sSterm_new.c_cc[VEOF]; - bStstp = sSterm_new.c_cc[VSUSP]; - if (! flocalecho) - sSterm_new.c_lflag &=~ - (ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHOK | ECHONL); - else - sSterm_new.c_lflag &=~ (ICANON | IEXTEN | ISIG); - sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF); - sSterm_new.c_oflag &=~ (OPOST); - sSterm_new.c_cc[VMIN] = 1; - sSterm_new.c_cc[VTIME] = 0; - -#endif /* HAVE_POSIX_TERMIOS */ - - if (! fsetterminfo (0, &sSterm_new)) - { - ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Restore the terminal to its original setting. */ - -boolean -fsysdep_terminal_restore () -{ - if (! fSterm) - return TRUE; - - if (! fsetterminfo (0, &sSterm_orig)) - { - ulog (LOG_ERROR, "Can't restore terminal: %s", strerror (errno)); - return FALSE; - } - return TRUE; -} - -/* Read a line from the terminal. This will be called after - fsysdep_terminal_raw has been called. */ - -char * -zsysdep_terminal_line (zprompt) - const char *zprompt; -{ - CATCH_PROTECT size_t cbuf = 0; - CATCH_PROTECT char *zbuf = NULL; - CATCH_PROTECT size_t cgot = 0; - - if (zprompt != NULL && *zprompt != '\0') - (void) write (1, zprompt, strlen (zprompt)); - - /* Forgot about any previous SIGINT or SIGQUIT signals we may have - received. We don't worry about the race condition here, since we - can't get these signals from the terminal at the moment and it's - not too likely that somebody else will be sending them to us. */ - afSignal[INDEXSIG_SIGINT] = 0; - afSignal[INDEXSIG_SIGQUIT] = 0; - - if (! fsysdep_terminal_restore ()) - return NULL; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - cbuf = 0; - zbuf = NULL; - cgot = 0; - } - - while (TRUE) - { - char b; - int c; - - if (afSignal[INDEXSIG_SIGINT] - || afSignal[INDEXSIG_SIGQUIT]) - { - usysdep_end_catch (); - /* Make sure the signal is logged. */ - ulog (LOG_ERROR, (const char *) NULL); - /* Return an empty string. */ - cgot = 0; - break; - } - - /* There's a race here between checking the signals and calling - read. It just means that the user will have to hit ^C more - than once. */ - - c = read (0, &b, 1); - if (c < 0) - { - if (errno == EINTR) - continue; - usysdep_end_catch (); - ulog (LOG_ERROR, "read: %s", strerror (errno)); - (void) fsysdep_terminal_raw (fSlocalecho); - return NULL; - } - if (c == 0) - { - /* I'm not quite sure what to do here. */ - usysdep_end_catch (); - ulog (LOG_ERROR, "EOF on terminal"); - (void) fsysdep_terminal_raw (fSlocalecho); - return NULL; - } - - if (cgot >= cbuf) - { - char *znew; - - cbuf += 64; - znew = zbufalc (cbuf); - if (zbuf != NULL) - { - memcpy (znew, zbuf, cgot); - ubuffree (zbuf); - } - zbuf = znew; - } - - zbuf[cgot] = b; - - ++cgot; - - if (b == '\n') - { - usysdep_end_catch (); - break; - } - } - - if (cgot >= cbuf) - { - char *znew; - - ++cbuf; - znew = zbufalc (cbuf); - if (zbuf != NULL) - { - memcpy (znew, zbuf, cgot); - ubuffree (zbuf); - } - zbuf = znew; - } - - zbuf[cgot] = '\0'; - - if (! fsysdep_terminal_raw (fSlocalecho)) - return NULL; - - return zbuf; -} - -/* Write a line to the terminal with a trailing newline. */ - -boolean -fsysdep_terminal_puts (zline) - const char *zline; -{ - char *zalc, *zprint; - size_t clen; - - if (zline == NULL) - { - zalc = zbufalc (2); - clen = 0; - } - else - { - clen = strlen (zline); - zalc = zbufalc (clen + 2); - memcpy (zalc, zline, clen); - } - - if (fSterm) - { - zalc[clen] = '\r'; - ++clen; - } - zalc[clen] = '\n'; - ++clen; - - zprint = zalc; - while (clen > 0) - { - int c; - - c = write (1, zprint, clen); - if (c <= 0) - { - ubuffree (zalc); - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - clen -= c; - zprint += c; - } - - ubuffree (zalc); - - return TRUE; -} - -/* Allow or disallow signals from the terminal. */ - -boolean -fsysdep_terminal_signals (faccept) - boolean faccept; -{ -#if HAVE_BSD_TTY - - if (faccept) - { - sSterm_new.stchars.t_intrc = sSterm_orig.stchars.t_intrc; - sSterm_new.stchars.t_quitc = sSterm_orig.stchars.t_quitc; - } - else - { - sSterm_new.stchars.t_intrc = -1; - sSterm_new.stchars.t_quitc = -1; - } - -#else /* ! HAVE_BSD_TTY */ - - if (faccept) - sSterm_new.c_lflag |= ISIG; - else - sSterm_new.c_lflag &=~ ISIG; - -#ifdef SIGTSTP - /* We only want to get SIGINT and SIGQUIT, not SIGTSTP. This - function will be called with faccept TRUE before it is called - with faccept FALSE, so fStstp_ignored will be correctly - initialized. */ - if (faccept) - usset_signal (SIGTSTP, SIG_IGN, FALSE, &fStstp_ignored); - else if (! fStstp_ignored) - usset_signal (SIGTSTP, SIG_DFL, TRUE, (boolean *) NULL); -#endif - -#endif /* ! HAVE_BSD_TTY */ - - if (! fsetterminfo (0, &sSterm_new)) - { - ulog (LOG_ERROR, "Can't set terminal: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Start up a command, or possibly just a shell. Optionally attach - stdin or stdout to the port. We attach directly to the port, - rather than copying the data ourselves. */ - -boolean -fsysdep_shell (qconn, zcmd, tcmd) - struct sconnection *qconn; - const char *zcmd; - enum tshell_cmd tcmd; -{ - const char *azargs[4]; - int oread, owrite; - int aidescs[3]; - pid_t ipid; - - if (tcmd != SHELL_NORMAL) - azargs[0] = "/bin/sh"; - else - { - azargs[0] = getenv ("SHELL"); - if (azargs[0] == NULL) - azargs[0] = "/bin/sh"; - } - if (zcmd == NULL || *zcmd == '\0') - azargs[1] = NULL; - else - { - azargs[1] = "-c"; - azargs[2] = zcmd; - azargs[3] = NULL; - } - - if (qconn->qport == NULL) - { - oread = 0; - owrite = 1; - } - else - { - switch (qconn->qport->uuconf_ttype) - { - default: - oread = owrite = -1; - break; - case UUCONF_PORTTYPE_STDIN: - case UUCONF_PORTTYPE_PIPE: - oread = ((struct ssysdep_conn *) qconn->psysdep)->ord; - owrite = ((struct ssysdep_conn *) qconn->psysdep)->owr; - break; - case UUCONF_PORTTYPE_MODEM: - case UUCONF_PORTTYPE_DIRECT: - case UUCONF_PORTTYPE_TCP: - case UUCONF_PORTTYPE_TLI: - oread = owrite = ((struct ssysdep_conn *) qconn->psysdep)->o; - break; - } - } - - aidescs[0] = 0; - aidescs[1] = 1; - aidescs[2] = 2; - - if (tcmd == SHELL_STDIN_FROM_PORT || tcmd == SHELL_STDIO_ON_PORT) - aidescs[0] = oread; - if (tcmd == SHELL_STDOUT_TO_PORT || tcmd == SHELL_STDIO_ON_PORT) - aidescs[1] = owrite; - - ipid = ixsspawn (azargs, aidescs, FALSE, TRUE, (const char *) NULL, - FALSE, FALSE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn (/bin/sh): %s", strerror (errno)); - return FALSE; - } - - return ixswait ((unsigned long) ipid, "shell") == 0; -} - -/* Change directories. */ - -boolean -fsysdep_chdir (zdir) - const char *zdir; -{ - if (zdir == NULL || *zdir == '\0') - { - zdir = getenv ("HOME"); - if (zdir == NULL) - { - ulog (LOG_ERROR, "HOME not defined"); - return FALSE; - } - } - if (chdir (zdir) < 0) - { - ulog (LOG_ERROR, "chdir (%s): %s", zdir, strerror (errno)); - return FALSE; - } - return TRUE; -} - -/* Suspend the current process. */ - -boolean -fsysdep_suspend () -{ -#ifndef SIGTSTP - return fsysdep_terminal_puts ("[process suspension not supported]"); -#else - return kill (getpid (), SIGTSTP) == 0; -#endif -} diff --git a/gnu/libexec/uucp/libunix/efopen.c b/gnu/libexec/uucp/libunix/efopen.c deleted file mode 100644 index 7e360b616876..000000000000 --- a/gnu/libexec/uucp/libunix/efopen.c +++ /dev/null @@ -1,132 +0,0 @@ -/* efopen.c - Open a stdio file with appropriate permissions. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_APPEND -#ifdef FAPPEND -#define O_APPEND FAPPEND -#endif -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -FILE * -esysdep_fopen (zfile, fpublic, fappend, fmkdirs) - const char *zfile; - boolean fpublic; - boolean fappend; - boolean fmkdirs; -{ - int imode; - int o; - FILE *e; - - if (fpublic) - imode = IPUBLIC_FILE_MODE; - else - imode = IPRIVATE_FILE_MODE; - - if (! fappend) - o = creat ((char *) zfile, imode); - else - { -#ifdef O_CREAT - o = open ((char *) zfile, - O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY, - imode); -#else - o = open ((char *) zfile, O_WRONLY | O_NOCTTY); - if (o < 0 && errno == ENOENT) - o = creat ((char *) zfile, imode); -#endif /* ! defined (O_CREAT) */ - } - - if (o < 0) - { - if (errno == ENOENT && fmkdirs) - { - if (! fsysdep_make_dirs (zfile, fpublic)) - return NULL; - if (! fappend) - o = creat ((char *) zfile, imode); - else - { -#ifdef O_CREAT - o = open ((char *) zfile, - O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY, - imode); -#else - o = creat ((char *) zfile, imode); -#endif - } - } - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); - return NULL; - } - } - -#ifndef O_CREAT -#ifdef O_APPEND - if (fappend) - { - if (fcntl (o, F_SETFL, O_APPEND) < 0) - { - ulog (LOG_ERROR, "fcntl (%s, O_APPEND): %s", zfile, - strerror (errno)); - (void) close (o); - return NULL; - } - } -#endif /* defined (O_APPEND) */ -#endif /* ! defined (O_CREAT) */ - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (%s, FD_CLOEXEC): %s", zfile, - strerror (errno)); - (void) close (o); - return NULL; - } - - if (fappend) - e = fdopen (o, (char *) "a"); - else - e = fdopen (o, (char *) "w"); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen: %s", strerror (errno)); - (void) close (o); - } - - return e; -} diff --git a/gnu/libexec/uucp/libunix/epopen.c b/gnu/libexec/uucp/libunix/epopen.c deleted file mode 100644 index 1873c5c73bc2..000000000000 --- a/gnu/libexec/uucp/libunix/epopen.c +++ /dev/null @@ -1,85 +0,0 @@ -/* epopen.c - A version of popen that goes through ixsspawn. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "sysdep.h" - -#include - -/* A version of popen that goes through ixsspawn. This actually takes - an array of arguments rather than a string, and takes a boolean - read/write value rather than a string. It sets *pipid to the - process ID of the child. */ - -FILE * -espopen (pazargs, frd, pipid) - const char **pazargs; - boolean frd; - pid_t *pipid; -{ - int aidescs[3]; - pid_t ipid; - FILE *eret; - - if (frd) - { - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_READ_PIPE; - } - else - { - aidescs[0] = SPAWN_WRITE_PIPE; - aidescs[1] = SPAWN_NULL; - } - aidescs[2] = SPAWN_NULL; - - ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, - (const char *) NULL, FALSE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - return NULL; - - if (frd) - eret = fdopen (aidescs[1], (char *) "r"); - else - eret = fdopen (aidescs[0], (char *) "w"); - if (eret == NULL) - { - int ierr; - - ierr = errno; - (void) close (frd ? aidescs[1] : aidescs[0]); - (void) kill (ipid, SIGKILL); - (void) ixswait ((unsigned long) ipid, (const char *) NULL); - errno = ierr; - return NULL; - } - - *pipid = ipid; - - return eret; -} diff --git a/gnu/libexec/uucp/libunix/init.c b/gnu/libexec/uucp/libunix/init.c deleted file mode 100644 index fade17c32458..000000000000 --- a/gnu/libexec/uucp/libunix/init.c +++ /dev/null @@ -1,401 +0,0 @@ -/* init.c - Initialize the system dependent routines. - - Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* $FreeBSD$ */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" - -#include -#include -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#if ! HAVE_GETHOSTNAME && HAVE_UNAME -#include -#endif - -/* Use getcwd in preference to getwd; if we have neither, we will be - using a getcwd replacement. */ -#if HAVE_GETCWD -#undef HAVE_GETWD -#define HAVE_GETWD 0 -#else /* ! HAVE_GETCWD */ -#if ! HAVE_GETWD -#undef HAVE_GETCWD -#define HAVE_GETCWD 1 -#endif /* ! HAVE_GETWD */ -#endif /* ! HAVE_GETCWD */ - -#if HAVE_GETWD -/* Get a value for MAXPATHLEN. */ -#if HAVE_SYS_PARAMS_H -#include -#endif - -#if HAVE_LIMITS_H -#include -#endif - -#ifndef MAXPATHLEN -#ifdef PATH_MAX -#define MAXPATHLEN PATH_MAX -#else /* ! defined (PATH_MAX) */ -#define MAXPATHLEN 1024 -#endif /* ! defined (PATH_MAX) */ -#endif /* ! defined (MAXPATHLEN) */ -#endif /* HAVE_GETWD */ - -/* External functions. */ -#ifndef getlogin -extern char *getlogin (); -#endif -#if GETPWNAM_DECLARATION_OK -#ifndef getpwnam -extern struct passwd *getpwnam (); -#endif -#endif -#if GETPWUID_DECLARATION_OK -#ifndef getpwuid -extern struct passwd *getpwuid (); -#endif -#endif -#if HAVE_GETCWD -#ifndef getcwd -extern char *getcwd (); -#endif -#endif -#if HAVE_GETWD -#ifndef getwd -extern char *getwd (); -#endif -#endif -#if HAVE_SYSCONF -#ifndef sysconf -extern long sysconf (); -#endif -#endif - -/* Initialize the system dependent routines. We will probably be running - suid to uucp, so we make sure that nothing is obviously wrong. We - save the login name since we will be losing the real uid. */ -static char *zSlogin; - -/* The UUCP spool directory. */ -const char *zSspooldir; - -/* The UUCP lock directory. */ -const char *zSlockdir; - -/* The local UUCP name. */ -const char *zSlocalname; - -/* We save the current directory since we will do a chdir to the - spool directory. */ -char *zScwd; - -/* The maximum length of a system name is controlled by the type of spool - directory we use. */ -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX -size_t cSysdep_max_name_len = 7; -#endif -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 -size_t cSysdep_max_name_len = 14; -#endif -#if SPOOLDIR_TAYLOR -#if HAVE_LONG_FILE_NAMES -size_t cSysdep_max_name_len = 255; -#else /* ! HAVE_LONG_FILE_NAMES */ -size_t cSysdep_max_name_len = 14; -#endif /* ! HAVE_LONG_FILE_NAMES */ -#endif /* SPOOLDIR_TAYLOR */ - -/* Initialize the system dependent routines. */ - -void -usysdep_initialize (puuconf,iflags) - pointer puuconf; - int iflags; -{ - int iuuconf; - char *z; - struct passwd *q; - - ulog_id (getpid ()); - - if ((iflags & INIT_NOCLOSE) == 0) - { - int cdescs; - int o; - - /* Close everything but stdin, stdout and stderr. */ -#if HAVE_GETDTABLESIZE - cdescs = getdtablesize (); -#else -#if HAVE_SYSCONF - cdescs = sysconf (_SC_OPEN_MAX); -#else -#ifdef OPEN_MAX - cdescs = OPEN_MAX; -#else -#ifdef NOFILE - cdescs = NOFILE; -#else - cdescs = 20; -#endif /* ! defined (NOFILE) */ -#endif /* ! defined (OPEN_MAX) */ -#endif /* ! HAVE_SYSCONF */ -#endif /* ! HAVE_GETDTABLESIZE */ - - for (o = 3; o < cdescs; o++) - (void) close (o); - } - - /* Make sure stdin, stdout and stderr are open. */ - if (fcntl (0, F_GETFD, 0) < 0 - && open ((char *) _PATH_DEVNULL, O_RDONLY, 0) != 0) - exit (EXIT_FAILURE); - if (fcntl (1, F_GETFD, 0) < 0 - && open ((char *) _PATH_DEVNULL, O_WRONLY, 0) != 1) - exit (EXIT_FAILURE); - if (fcntl (2, F_GETFD, 0) < 0 - && open ((char *) _PATH_DEVNULL, O_WRONLY, 0) != 2) - exit (EXIT_FAILURE); - - iuuconf = uuconf_spooldir (puuconf, &zSspooldir); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - iuuconf = uuconf_lockdir (puuconf, &zSlockdir); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - iuuconf = uuconf_localname (puuconf, &zSlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { -#if HAVE_GETHOSTNAME - char ab[256]; - - if (gethostname (ab, sizeof ab - 1) < 0) - ulog (LOG_FATAL, "gethostname: %s", strerror (errno)); - ab[sizeof ab - 1] = '\0'; - ab[strcspn (ab, ".")] = '\0'; - zSlocalname = zbufcpy (ab); -#else /* ! HAVE_GETHOSTNAME */ -#if HAVE_UNAME - struct utsname s; - - if (uname (&s) < 0) - ulog (LOG_FATAL, "uname: %s", strerror (errno)); - zSlocalname = zbufcpy (s.nodename); -#else /* ! HAVE_UNAME */ - ulog (LOG_FATAL, "Don't know how to get local node name"); -#endif /* ! HAVE_UNAME */ -#endif /* ! HAVE_GETHOSTNAME */ - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - /* We always set our file modes to exactly what we want. */ - umask (0); - - /* Get the login name, making sure that it matches the uid. Many - systems truncate the getlogin return value to 8 characters, but - keep the full name in the password file, so we prefer the name in - the password file. */ - z = getenv ("LOGNAME"); - if (z == NULL) - z = getenv ("USER"); - if (z == NULL) - z = getlogin (); - if (z == NULL) - q = NULL; - else - { - q = getpwnam (z); - if (q != NULL) - z = q->pw_name; - } - if (q == NULL || q->pw_uid != getuid ()) - { - q = getpwuid (getuid ()); - if (q == NULL) - z = NULL; - else - z = q->pw_name; - } - if (z != NULL) - zSlogin = zbufcpy (z); - - /* On some old systems, an suid program run by root is started with - an euid of 0. If this happens, we look up the uid we should have - and set ourselves to it manually. This means that on such a - system root will not be able to uucp or uux files that are not - readable by uucp. */ - if ((iflags & INIT_SUID) != 0 - && geteuid () == 0) - { - q = getpwnam (OWNER); - if (q != NULL) - setuid (q->pw_uid); - } - - if ((iflags & INIT_GETCWD) != 0) - { - const char *zenv; - struct stat senv, sdot; - - /* Get the current working directory. We have to get it now, - since we're about to do a chdir. We use PWD if it's defined - and if it really names the working directory, since if it's - not the same as whatever getcwd returns it's probably more - appropriate. */ - zenv = getenv ("PWD"); - if (zenv != NULL - && stat ((char *) zenv, &senv) == 0 - && stat ((char *) ".", &sdot) == 0 - && senv.st_ino == sdot.st_ino - && senv.st_dev == sdot.st_dev) - zScwd = zbufcpy (zenv); - else - { - -#if HAVE_GETCWD - { - size_t c; - - c = 128; - while (TRUE) - { - zScwd = (char *) xmalloc (c); - if (getcwd (zScwd, c) != NULL) - break; - xfree ((pointer) zScwd); - zScwd = NULL; - if (errno != ERANGE) - break; - c <<= 1; - } - } -#endif /* HAVE_GETCWD */ - -#if HAVE_GETWD - zScwd = (char *) xmalloc (MAXPATHLEN); - if (getwd (zScwd) == NULL) - { - xfree ((pointer) zScwd); - zScwd = NULL; - } -#endif /* HAVE_GETWD */ - - if (zScwd != NULL) - zScwd = (char *) xrealloc ((pointer) zScwd, - strlen (zScwd) + 1); - } - } - - if ((iflags & INIT_NOCHDIR) == 0) - { - /* Connect to the spool directory, and create it if it doesn't - exist. */ - if (chdir (zSspooldir) < 0) - { - if (errno == ENOENT - && mkdir ((char *) zSspooldir, IDIRECTORY_MODE) < 0) - ulog (LOG_FATAL, "mkdir (%s): %s", zSspooldir, - strerror (errno)); - if (chdir (zSspooldir) < 0) - ulog (LOG_FATAL, "chdir (%s): %s", zSspooldir, - strerror (errno)); - } - } -} - -/* Exit the program. */ - -void -usysdep_exit (fsuccess) - boolean fsuccess; -{ - exit (fsuccess ? EXIT_SUCCESS : EXIT_FAILURE); -} - -/* This is called when a non-standard configuration file is used, to - make sure the program doesn't hand out privileged file access. - This means that to test non-standard configuration files, you - should be logged in as uucp. This is called before - usysdep_initialize. It ensures that someone can't simply use an - alternate configuration file to steal UUCP transfers from other - systems. This will still permit people to set up their own - configuration file and pretend to be whatever system they choose. - The only real security is to use a high level of protection on the - modem ports. */ - -/*ARGSUSED*/ -boolean fsysdep_other_config (z) - const char *z; -{ - (void) setuid (getuid ()); - (void) setgid (getgid ()); - return TRUE; -} - -/* Get the node name to use if it was not specified in the configuration - file. */ - -const char * -zsysdep_localname () -{ - return zSlocalname; -} - -/* Get the login name. We actually get the login name in - usysdep_initialize, because after that we may switch away from the - real uid. */ - -const char * -zsysdep_login_name () -{ - if (zSlogin == NULL) - ulog (LOG_FATAL, "Can't get login name"); - return zSlogin; -} diff --git a/gnu/libexec/uucp/libunix/isdir.c b/gnu/libexec/uucp/libunix/isdir.c deleted file mode 100644 index fc95e5275a82..000000000000 --- a/gnu/libexec/uucp/libunix/isdir.c +++ /dev/null @@ -1,18 +0,0 @@ -/* isdir.c - See whether a file exists and is a directory. */ - -#include "uucp.h" - -#include "system.h" -#include "sysdep.h" - -boolean -fsysdep_directory (z) - const char *z; -{ - struct stat s; - - if (stat ((char *) z, &s) < 0) - return FALSE; - return S_ISDIR (s.st_mode); -} diff --git a/gnu/libexec/uucp/libunix/isfork.c b/gnu/libexec/uucp/libunix/isfork.c deleted file mode 100644 index f067d07552cd..000000000000 --- a/gnu/libexec/uucp/libunix/isfork.c +++ /dev/null @@ -1,25 +0,0 @@ -/* isfork.c - Retry fork several times before giving up. */ - -#include "uucp.h" - -#include "sysdep.h" - -#include - -pid_t -ixsfork () -{ - int i; - pid_t iret; - - for (i = 0; i < 10; i++) - { - iret = fork (); - if (iret >= 0 || errno != EAGAIN) - return iret; - sleep (5); - } - - return iret; -} diff --git a/gnu/libexec/uucp/libunix/iswait.c b/gnu/libexec/uucp/libunix/iswait.c deleted file mode 100644 index d13db6ebeba1..000000000000 --- a/gnu/libexec/uucp/libunix/iswait.c +++ /dev/null @@ -1,159 +0,0 @@ -/* iswait.c - Wait for a process to finish. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -#include - -#if HAVE_SYS_WAIT_H -#include -#endif - -/* We use a typedef wait_status for wait (waitpid, wait4) to put - results into. We define the POSIX examination functions we need if - they are not already defined (if they aren't defined, I assume that - we have a standard wait status). */ - -#if HAVE_UNION_WAIT -typedef union wait wait_status; -#ifndef WIFEXITED -#define WIFEXITED(u) ((u).w_termsig == 0) -#endif -#ifndef WEXITSTATUS -#define WEXITSTATUS(u) ((u).w_retcode) -#endif -#ifndef WTERMSIG -#define WTERMSIG(u) ((u).w_termsig) -#endif -#else /* ! HAVE_UNION_WAIT */ -typedef int wait_status; -#ifndef WIFEXITED -#define WIFEXITED(i) (((i) & 0xff) == 0) -#endif -#ifndef WEXITSTATUS -#define WEXITSTATUS(i) (((i) >> 8) & 0xff) -#endif -#ifndef WTERMSIG -#define WTERMSIG(i) ((i) & 0x7f) -#endif -#endif /* ! HAVE_UNION_WAIT */ - -/* Wait for a particular process to finish. The ipid argument should - be pid_t, but then we couldn't have a prototype. If the zreport - argument is not NULL, then a wait error will be logged, and if the - exit status is non-zero it will be logged with zreport as the - header of the log message. If the zreport argument is NULL, no - errors will be logged. This function returns the exit status if - the process exited normally, or -1 on error or if the process was - killed by a signal (I don't just always return the exit status - because then the calling code would have to prepared to handle - union wait status vs. int status, and none of the callers care - which signal killed the program anyhow). - - This functions keeps waiting until the process finished, even if it - is interrupted by a signal. I think this is right for all uses. - The controversial one would be when called from uuxqt to wait for a - requested process. Hitting uuxqt with SIGKILL will approximate the - actions taken if we return from here with an error anyhow. If we - do get a signal, we call ulog with a NULL argument to get it in the - log file at about the right time. */ - -int -ixswait (ipid, zreport) - unsigned long ipid; - const char *zreport; -{ - wait_status istat; - -#if HAVE_WAITPID - while (waitpid ((pid_t) ipid, (pointer) &istat, 0) < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "waitpid: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } -#else /* ! HAVE_WAITPID */ -#if HAVE_WAIT4 - while (wait4 ((pid_t) ipid, (pointer) &istat, 0, - (struct rusage *) NULL) < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "wait4: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } -#else /* ! HAVE_WAIT4 */ - pid_t igot; - - /* We could theoretically get the wrong child here if we're in some - kind of weird pipeline, so we don't give any error messages for - it. */ - while ((igot = wait ((pointer) &istat)) != (pid_t) ipid) - { - if (igot < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "wait: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } - } -#endif /* ! HAVE_WAIT4 */ -#endif /* ! HAVE_WAITPID */ - - DEBUG_MESSAGE2 (DEBUG_EXECUTE, "%s %d", - WIFEXITED (istat) ? "Exit status" : "Signal", - WIFEXITED (istat) ? WEXITSTATUS (istat) : WTERMSIG (istat)); - - if (WIFEXITED (istat) && WEXITSTATUS (istat) == 0) - return 0; - - if (zreport != NULL) - { - if (! WIFEXITED (istat)) - ulog (LOG_ERROR, "%s: Got signal %d", zreport, WTERMSIG (istat)); - else - ulog (LOG_ERROR, "%s: Exit status %d", zreport, - WEXITSTATUS (istat)); - } - - if (WIFEXITED (istat)) - return WEXITSTATUS (istat); - else - return -1; -} diff --git a/gnu/libexec/uucp/libunix/lock.c b/gnu/libexec/uucp/libunix/lock.c deleted file mode 100644 index 9740e862c1a8..000000000000 --- a/gnu/libexec/uucp/libunix/lock.c +++ /dev/null @@ -1,690 +0,0 @@ -/* lock.c - Lock and unlock a file name. - - Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char lock_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#if TM_IN_SYS_TIME -#include -#else -#include -#endif - -#if HAVE_QNX_LOCKFILES -#include -#include -#include -#include -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef localtime -extern struct tm *localtime (); -#endif - -#if HAVE_QNX_LOCKFILES -static boolean fsqnx_stale P((unsigned long ipid, unsigned long inme, - unsigned long inid, boolean *pferr)); -#endif - -/* Lock something. If the fspooldir argument is TRUE, the argument is - a file name relative to the spool directory; otherwise the argument - is a simple file name which should be created in the system lock - directory (under HDB this is /etc/locks). */ - -boolean -fsdo_lock (zlock, fspooldir, pferr) - const char *zlock; - boolean fspooldir; - boolean *pferr; -{ - char *zfree; - const char *zpath, *zslash; - size_t cslash; - pid_t ime; - char *ztempfile; - char abtempfile[sizeof "TMP12345678901234567890"]; - int o; -#if HAVE_QNX_LOCKFILES - nid_t inme; - char ab[23]; - char *zend; -#else -#if HAVE_V2_LOCKFILES - int i; -#else - char ab[12]; -#endif -#endif - int cwrote; - const char *zerr; - boolean fret; - - if (pferr != NULL) - *pferr = TRUE; - - if (fspooldir) - { - zfree = NULL; - zpath = zlock; - } - else - { - zfree = zsysdep_in_dir (zSlockdir, zlock); - zpath = zfree; - } - - ime = getpid (); -#if HAVE_QNX_LOCKFILES - inme = getnid (); -#endif - - /* We do the actual lock by creating a file and then linking it to - the final file name we want. This avoids race conditions due to - one process checking the file before we have finished writing it, - and also works even if we are somehow running as root. - - First, create the file in the right directory (we must create the - file in the same directory since otherwise we might attempt a - cross-device link). */ - zslash = strrchr (zpath, '/'); - if (zslash == NULL) - cslash = 0; - else - cslash = zslash - zpath + 1; - -#if HAVE_QNX_LOCKFILES - sprintf (abtempfile, "TMP%010lx%010lx", (unsigned long) ime, - (unsigned long) inme); -#else - sprintf (abtempfile, "TMP%010lx", (unsigned long) ime); -#endif - ztempfile = zbufalc (cslash + sizeof abtempfile); - memcpy (ztempfile, zpath, cslash); - memcpy (ztempfile + cslash, abtempfile, sizeof abtempfile); - - o = creat (ztempfile, IPUBLIC_FILE_MODE); - if (o < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (ztempfile, FALSE)) - { - ubuffree (zfree); - ubuffree (ztempfile); - return FALSE; - } - o = creat (ztempfile, IPUBLIC_FILE_MODE); - } - if (o < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", ztempfile, strerror (errno)); - ubuffree (zfree); - ubuffree (ztempfile); - return FALSE; - } - } - -#if HAVE_QNX_LOCKFILES - sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inme); - cwrote = write (o, ab, strlen (ab)); -#else -#if HAVE_V2_LOCKFILES - i = (int) ime; - cwrote = write (o, &i, sizeof i); -#else - sprintf (ab, "%10ld\n", (long) ime); - cwrote = write (o, ab, strlen (ab)); -#endif -#endif - - zerr = NULL; - if (cwrote < 0) - zerr = "write"; - if (close (o) < 0) - zerr = "close"; - if (zerr != NULL) - { - ulog (LOG_ERROR, "%s (%s): %s", zerr, ztempfile, strerror (errno)); - (void) remove (ztempfile); - ubuffree (zfree); - ubuffree (ztempfile); - return FALSE; - } - - /* Now try to link the file we just created to the lock file that we - want. If it fails, try reading the existing file to make sure - the process that created it still exists. We do this in a loop - to make it easy to retry if the old locking process no longer - exists. */ - fret = TRUE; - if (pferr != NULL) - *pferr = FALSE; - o = -1; - zerr = NULL; - - while (link (ztempfile, zpath) != 0) - { - int cgot; - pid_t ipid; - boolean freadonly; - struct stat st; - char abtime[sizeof "1991-12-31 12:00:00"]; -#if HAVE_QNX_LOCKFILES - nid_t inid; -#endif - - fret = FALSE; - - if (errno != EEXIST) - { - ulog (LOG_ERROR, "link (%s, %s): %s", ztempfile, zpath, - strerror (errno)); - if (pferr != NULL) - *pferr = TRUE; - break; - } - - freadonly = FALSE; - o = open ((char *) zpath, O_RDWR | O_NOCTTY, 0); - if (o < 0) - { - if (errno == EACCES) - { - freadonly = TRUE; - o = open ((char *) zpath, O_RDONLY, 0); - } - if (o < 0) - { - if (errno == ENOENT) - { - /* The file was presumably removed between the link - and the open. Try the link again. */ - fret = TRUE; - continue; - } - zerr = "open"; - break; - } - } - - /* The race starts here. See below for a discussion. */ - -#if HAVE_V2_LOCKFILES - cgot = read (o, &i, sizeof i); -#else - cgot = read (o, ab, sizeof ab - 1); -#endif - - if (cgot < 0) - { - zerr = "read"; - break; - } - -#if DEBUG > 0 -#if HAVE_V2_LOCKFILES - { - char ab[10]; - - if (read (o, ab, sizeof ab) > 4 - && isdigit (BUCHAR (ab[0]))) - ulog (LOG_ERROR, - "Lock file %s may be HDB format; check LOCKFILES in policy.h", - zpath); - } -#else - if (cgot == 4) - ulog (LOG_ERROR, - "Lock file %s may be V2 format; check LOCKFILES in policy.h", - zpath); -#endif -#endif /* DEBUG > 0 */ - -#if HAVE_QNX_LOCKFILES - ab[cgot] = '\0'; - ipid = (pid_t) strtol (ab, &zend, 10); - inid = (nid_t) strtol (zend, (char **) NULL, 10); -#else -#if HAVE_V2_LOCKFILES - ipid = (pid_t) i; -#else - ab[cgot] = '\0'; - ipid = (pid_t) strtol (ab, (char **) NULL, 10); -#endif -#endif - - /* On NFS, the link might have actually succeeded even though we - got a failure return. This can happen if the original - acknowledgement was lost or delayed and the operation was - retried. In this case the pid will be our own. This - introduces a rather improbable race condition: if a stale - lock was left with our process ID in it, and another process - just did the kill, below, but has not yet changed the lock - file to hold its own process ID, we could start up and make - it all the way to here and think we have the lock. I'm not - going to worry about this possibility. */ - if (ipid == ime) - { -#if HAVE_QNX_LOCKFILES - if (inid == inme) -#endif - { - fret = TRUE; - break; - } - } - - /* If the lock file is empty (cgot == 0), we assume that it is - stale. This can happen if the system crashed after the lock - file was created but before the process ID was written out. */ - if (cgot > 0) - { -#if HAVE_QNX_LOCKFILES - if (! fsqnx_stale ((unsigned long) ipid, (unsigned long) inme, - (unsigned long) inid, pferr)) - break; -#else - /* If the process still exists, we will get EPERM rather - than ESRCH. We then return FALSE to indicate that we - cannot make the lock. */ - if (kill (ipid, 0) == 0 || errno == EPERM) - break; -#endif - } - - if (fstat (o, &st) < 0) - strcpy (abtime, "unknown"); - else - { - time_t itm; - struct tm *q; - - itm = (time_t) st.st_mtime; - q = localtime (&itm); - sprintf (abtime, "%04d-%02d-%02d %02d:%02d:%02d", - q->tm_year + 1900, q->tm_mon + 1, q->tm_mday, q->tm_hour, - q->tm_min, q->tm_sec); - } - -#if HAVE_QNX_LOCKFILES - ulog (LOG_ERROR, - "Stale lock %s held by process %ld on node %ld created %s", - zpath, (long) ipid, (long) inid, abtime); -#else - ulog (LOG_ERROR, "Stale lock %s held by process %ld created %s", - zpath, (long) ipid, abtime); -#endif - - /* This is a stale lock, created by a process that no longer - exists. - - Now we could remove the file (and, if the file mode disallows - writing, that's what we have to do), but we try to avoid - doing so since it causes a race condition. If we remove the - file, and are interrupted any time after we do the read until - we do the remove, another process could get in, open the - file, find that it was a stale lock, remove the file and - create a new one. When we regained control we would remove - the file the other process just created. - - These files are being generated partially for the benefit of - cu, and it would be nice to avoid the race however cu avoids - it, so that the programs remain compatible. Unfortunately, - nobody seems to know how cu avoids the race, or even if it - tries to avoid it at all. - - There are a few ways to avoid the race. We could use kernel - locking primitives, but they may not be available. We could - link to a special file name, but if that file were left lying - around then no stale lock could ever be broken (Henry Spencer - would think this was a good thing). - - Instead I've implemented the following procedure: seek to the - start of the file, write our pid into it, sleep for five - seconds, and then make sure our pid is still there. Anybody - who checks the file while we're asleep will find our pid - there and fail the lock. The only race will come from - another process which has done the read by the time we do our - write. That process will then have five seconds to do its - own write. When we wake up, we'll notice that our pid is no - longer in the file, and retry the lock from the beginning. - - This relies on the atomicity of write(2). If it possible for - the writes of two processes to be interleaved, the two - processes could livelock. POSIX unfortunately leaves this - case explicitly undefined; however, given that the write is - of less than a disk block, it's difficult to imagine an - interleave occurring. - - Note that this is still a race. If it takes the second - process more than five seconds to do the kill, the lseek, and - the write, both processes will think they have the lock. - Perhaps the length of time to sleep should be configurable. - Even better, perhaps I should add a configuration option to - use a permanent lock file, which eliminates any race and - forces the installer to be aware of the existence of the - permanent lock file. - - We stat the file after the sleep, to make sure some other - program hasn't deleted it for us. */ - if (freadonly) - { - (void) close (o); - o = -1; - (void) remove (zpath); - fret = TRUE; - continue; - } - - if (lseek (o, (off_t) 0, SEEK_SET) != 0) - { - zerr = "lseek"; - break; - } - -#if HAVE_QNX_LOCKFILES - sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inme); - cwrote = write (o, ab, strlen (ab)); -#else -#if HAVE_V2_LOCKFILES - i = (int) ime; - cwrote = write (o, &i, sizeof i); -#else - sprintf (ab, "%10ld\n", (long) ime); - cwrote = write (o, ab, strlen (ab)); -#endif -#endif - - if (cwrote < 0) - { - zerr = "write"; - break; - } - - (void) sleep (5); - - if (lseek (o, (off_t) 0, SEEK_SET) != 0) - { - zerr = "lseek"; - break; - } - -#if HAVE_V2_LOCKFILES - cgot = read (o, &i, sizeof i); -#else - cgot = read (o, ab, sizeof ab - 1); -#endif - - if (cgot < 0) - { - zerr = "read"; - break; - } - -#if HAVE_QNX_LOCKFILES - ab[cgot] = '\0'; - ipid = (pid_t) strtol (ab, &zend, 10); - inid = (nid_t) strtol (zend, (char **) NULL, 10); -#else -#if HAVE_V2_LOCKFILES - ipid = (pid_t) i; -#else - ab[cgot] = '\0'; - ipid = (pid_t) strtol (ab, (char **) NULL, 10); -#endif -#endif - - if (ipid == ime) - { -#if HAVE_QNX_LOCKFILES - if (inid == inme) -#endif - { - struct stat sfile, sdescriptor; - - /* It looks like we have the lock. Do the final stat - check. */ - if (stat ((char *) zpath, &sfile) < 0) - { - if (errno != ENOENT) - { - zerr = "stat"; - break; - } - /* Loop around and try again. */ - } - else - { - if (fstat (o, &sdescriptor) < 0) - { - zerr = "fstat"; - break; - } - - if (sfile.st_ino == sdescriptor.st_ino - && sfile.st_dev == sdescriptor.st_dev) - { - /* Close the file before assuming we've - succeeded to pick up any trailing errors. */ - if (close (o) < 0) - { - zerr = "close"; - break; - } - - o = -1; - - /* We have the lock. */ - fret = TRUE; - break; - } - } - } - } - - /* Loop around and try the lock again. We keep doing this until - the lock file holds a pid that exists. */ - (void) close (o); - o = -1; - fret = TRUE; - } - - if (zerr != NULL) - { - ulog (LOG_ERROR, "%s (%s): %s", zerr, zpath, strerror (errno)); - if (pferr != NULL) - *pferr = TRUE; - } - - if (o >= 0) - (void) close (o); - - ubuffree (zfree); - - /* It would be nice if we could leave the temporary file around for - future calls, but considering that we create lock files in - various different directories it's probably more trouble than - it's worth. */ - if (remove (ztempfile) != 0) - ulog (LOG_ERROR, "remove (%s): %s", ztempfile, strerror (errno)); - - ubuffree (ztempfile); - - return fret; -} - -/* Unlock something. The fspooldir argument is as in fsdo_lock. */ - -boolean -fsdo_unlock (zlock, fspooldir) - const char *zlock; - boolean fspooldir; -{ - char *zfree; - const char *zpath; - - if (fspooldir) - { - zfree = NULL; - zpath = zlock; - } - else - { - zfree = zsysdep_in_dir (zSlockdir, zlock); - zpath = zfree; - } - - if (remove (zpath) == 0 - || errno == ENOENT) - { - ubuffree (zfree); - return TRUE; - } - else - { - ulog (LOG_ERROR, "remove (%s): %s", zpath, strerror (errno)); - ubuffree (zfree); - return FALSE; - } -} - -#if HAVE_QNX_LOCKFILES - -/* Return TRUE if the lock is stale. */ - -static boolean -fsqnx_stale (ipid, inme, inid, pferr) - unsigned long ipid; - unsigned long inme; - unsigned long inid; - boolean *pferr; -{ - /* A virtual process ID. This virtual process ID, which will exist - on the local node, will represent the process ID of the process - manager process (Proc) on the remote node. */ - pid_t ivid; - /* The return value of the qnx_psinfo function. This is either a - process ID which might or might not be the same as the process - being looked for, or -1 to indicate no process found. */ - pid_t ifound_pid; - /* This holds the actual result of qnx_psinfo. We will ignore - almost all the fields since we're just checking for existence. */ - struct _psinfo spsdata; - - /* Establish connection with a remote process manager if necessary. */ - if (inid != inme) - { - ivid = qnx_vc_attach (inid /* remote node ID */, - PROC_PID /* pid of process manager */, - 1000 /* initial buffer size */, - 0 /* flags */); - if (ivid < 0) - { - ulog (LOG_ERROR, "qnx_vc_attach (%lu, PROC_PID): %s", - inid, strerror (errno)); - if (pferr != NULL) - *pferr = TRUE; - return FALSE; - } - } - else - { - /* Use the local pid of the local process manager. */ - ivid = PROC_PID; - } - - /* Request the process information. */ - ifound_pid = qnx_psinfo (ivid /* process manager handling request */, - ipid /* get info on this process */, - &spsdata /* put info in this struct */, - 0 /* unused */, - (struct _seginfo *) NULL /* unused */); - - /* Deallocate the virtual connection before continuing. */ - { - int isaved_errno = errno; - if (qnx_vc_detach (ivid) < 0) - ulog (LOG_ERROR, "qnx_vd_detach (%ld): %s", (long) ivid, - strerror (errno)); - errno = isaved_errno; - } - - /* If the returned pid matches then the process still holds the lock. */ - if ((ifound_pid == ipid) && (spsdata.pid == ipid)) - return FALSE; - - /* If the returned pid is positive and doesn't match, then the - process doesn't exist and the lock is stale. Continue. */ - - /* If the returned pid is negative (-1) and errno is EINVAL (or ESRCH - in older versions of QNX), then the process doesn't exist and the - lock is stale. Continue. */ - - /* Check for impossible errors. */ - if ((ifound_pid < 0) && (errno != ESRCH) && (errno != EINVAL)) - { - ulog (LOG_ERROR, "qnx_psinfo (%ld, %ld): %s", (long) ivid, - (long) ipid, strerror (errno)); - /* Since we don't know what the hell this means, and we don't - want our system to freeze, we treat this case as a stale - lock. Continue on. */ - } - - return TRUE; -} - -#endif /* HAVE_QNX_LOCKFILES */ diff --git a/gnu/libexec/uucp/libunix/loctim.c b/gnu/libexec/uucp/libunix/loctim.c deleted file mode 100644 index 7f1f87aa671c..000000000000 --- a/gnu/libexec/uucp/libunix/loctim.c +++ /dev/null @@ -1,27 +0,0 @@ -/* loctim.c - Turn a time epoch into a struct tm. This is trivial on Unix. */ - -#include "uucp.h" - -#if TM_IN_SYS_TIME -#include -#else -#include -#endif - -#include "system.h" - -#ifndef localtime -extern struct tm *localtime (); -#endif - -void -usysdep_localtime (itime, q) - long itime; - struct tm *q; -{ - time_t i; - - i = (time_t) itime; - *q = *localtime (&i); -} diff --git a/gnu/libexec/uucp/libunix/mail.c b/gnu/libexec/uucp/libunix/mail.c deleted file mode 100644 index 634a59370342..000000000000 --- a/gnu/libexec/uucp/libunix/mail.c +++ /dev/null @@ -1,121 +0,0 @@ -/* mail.c - Send mail to a user. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -#if HAVE_TIME_H -#include -#endif - -#ifndef ctime -extern char *ctime (); -#endif - -/* Mail a message to a user. */ - -boolean -fsysdep_mail (zto, zsubject, cstrs, paz) - const char *zto; - const char *zsubject; - int cstrs; - const char **paz; -{ - char **pazargs; - char *zcopy, *ztok; - size_t cargs, iarg; - FILE *e; - pid_t ipid; - time_t itime; - int i; - - /* Parse MAIL_PROGRAM into an array of arguments. */ - zcopy = zbufcpy (MAIL_PROGRAM); - - cargs = 0; - for (ztok = strtok (zcopy, " \t"); - ztok != NULL; - ztok = strtok ((char *) NULL, " \t")) - ++cargs; - - pazargs = (char **) xmalloc ((cargs + 4) * sizeof (char *)); - - memcpy (zcopy, MAIL_PROGRAM, sizeof MAIL_PROGRAM); - for (ztok = strtok (zcopy, " \t"), iarg = 0; - ztok != NULL; - ztok = strtok ((char *) NULL, " \t"), ++iarg) - pazargs[iarg] = ztok; - -#if ! MAIL_PROGRAM_SUBJECT_BODY - pazargs[iarg++] = (char *) "-s"; - pazargs[iarg++] = (char *) zsubject; -#endif - -#if ! MAIL_PROGRAM_TO_BODY - pazargs[iarg++] = (char *) zto; -#endif - - pazargs[iarg] = NULL; - - e = espopen ((const char **) pazargs, FALSE, &ipid); - - ubuffree (zcopy); - xfree ((pointer) pazargs); - - if (e == NULL) - { - ulog (LOG_ERROR, "espopen (%s): %s", MAIL_PROGRAM, - strerror (errno)); - return FALSE; - } - -#if MAIL_PROGRAM_TO_BODY - fprintf (e, "To: %s\n", zto); -#endif -#if MAIL_PROGRAM_SUBJECT_BODY - fprintf (e, "Subject: %s\n", zsubject); -#endif - -#if MAIL_PROGRAM_TO_BODY || MAIL_PROGRAM_SUBJECT_BODY - fprintf (e, "\n"); -#endif - - (void) time (&itime); - /* Remember that ctime includes a \n, so this skips a line. */ - fprintf (e, "Message from UUCP on %s %s\n", zSlocalname, - ctime (&itime)); - - for (i = 0; i < cstrs; i++) - fputs (paz[i], e); - - (void) fclose (e); - - return ixswait ((unsigned long) ipid, MAIL_PROGRAM) == 0; -} diff --git a/gnu/libexec/uucp/libunix/mkdirs.c b/gnu/libexec/uucp/libunix/mkdirs.c deleted file mode 100644 index df4f98707f9f..000000000000 --- a/gnu/libexec/uucp/libunix/mkdirs.c +++ /dev/null @@ -1,57 +0,0 @@ -/* mkdirs.c - Create any directories needed for a file name. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -boolean -fsysdep_make_dirs (zfile, fpublic) - const char *zfile; - boolean fpublic; -{ - char *zcopy, *z; - int imode; - - zcopy = zbufcpy (zfile); - - if (fpublic) - imode = IPUBLIC_DIRECTORY_MODE; - else - imode = IDIRECTORY_MODE; - - for (z = zcopy; *z != '\0'; z++) - { - if (*z == '/' && z != zcopy) - { - /* Some versions of uuto will send a double slash. Some - systems will fail to create a directory ending in a - slash. */ - if (z[-1] == '/') - continue; - *z = '\0'; - if (mkdir (zcopy, imode) != 0 - && errno != EEXIST - && errno != EISDIR -#ifdef EROFS - && errno != EROFS -#endif - && (errno != EACCES || ! fsysdep_directory (zcopy))) - { - ulog (LOG_ERROR, "mkdir (%s): %s", zcopy, - strerror (errno)); - ubuffree (zcopy); - return FALSE; - } - *z = '/'; - } - } - - ubuffree (zcopy); - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/pause.c b/gnu/libexec/uucp/libunix/pause.c deleted file mode 100644 index 8b2b698ba0dc..000000000000 --- a/gnu/libexec/uucp/libunix/pause.c +++ /dev/null @@ -1,101 +0,0 @@ -/* pause.c - Pause for half a second. */ - -#include "uucp.h" - -#include "sysdep.h" -#include "system.h" - -/* Pick a timing routine to use. I somewhat arbitrarily picked usleep - above napms above poll above select above nap. The nap function is - last because on different systems the argument has different - meanings. */ -#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL || HAVE_SELECT -#undef HAVE_NAP -#define HAVE_NAP 0 -#endif - -#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL -#undef HAVE_SELECT -#define HAVE_SELECT 0 -#endif - -#if HAVE_USLEEP || HAVE_NAPMS -#undef HAVE_POLL -#define HAVE_POLL 0 -#endif - -#if HAVE_USLEEP -#undef HAVE_NAPMS -#define HAVE_NAPMS 0 -#endif - -#if HAVE_SELECT -#if HAVE_SYS_TIME_H -#include -#endif -#if HAVE_SYS_SELECT_H -#include -#endif -#endif - -#if HAVE_POLL -#if HAVE_STROPTS_H -#include -#endif -#if HAVE_POLL_H -#include -#endif -#if ! HAVE_STROPTS_H && ! HAVE_POLL_H -/* We need a definition for struct pollfd, although it doesn't matter - what it contains. */ -struct pollfd -{ - int idummy; -}; -#endif /* ! HAVE_STROPTS_H && ! HAVE_POLL_H */ -#endif /* HAVE_POLL */ - -#if HAVE_TIME_H -#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME -#include -#endif -#endif - -void -usysdep_pause () -{ -#if HAVE_NAPMS - napms (500); -#endif /* HAVE_NAPMS */ -#if HAVE_NAP -#if HAVE_HUNDREDTHS_NAP - nap (50L); -#else - nap (500L); -#endif /* ! HAVE_HUNDREDTHS_NAP */ -#endif /* HAVE_NAP */ -#if HAVE_USLEEP - usleep (500 * (long) 1000); -#endif /* HAVE_USLEEP */ -#if HAVE_POLL - struct pollfd sdummy; - - /* We need to pass an unused pollfd structure because poll checks - the address before checking the number of elements. */ - memset (&sdummy, 0, sizeof sdummy); - poll (&sdummy, 0, 500); -#endif /* HAVE_POLL */ -#if HAVE_SELECT - struct timeval s; - - s.tv_sec = 0; - s.tv_usec = 500 * (long) 1000; - select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s); -#endif /* HAVE_SELECT */ -#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP -#if ! HAVE_SELECT && ! HAVE_POLL - sleep (1); -#endif /* ! HAVE_SELECT && ! HAVE_POLL */ -#endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */ -} diff --git a/gnu/libexec/uucp/libunix/pipe.c b/gnu/libexec/uucp/libunix/pipe.c deleted file mode 100644 index ad1ff01c9aa0..000000000000 --- a/gnu/libexec/uucp/libunix/pipe.c +++ /dev/null @@ -1,294 +0,0 @@ -/* pipe.c - The pipe port communication routines for Unix. - Contributed by Marc Boucher . - - Copyright (C) 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char pipe_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "conn.h" -#include "sysdep.h" - -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -/* Local functions. */ - -static void uspipe_free P((struct sconnection *qconn)); -static boolean fspipe_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean fspipe_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean fspipe_dial P((struct sconnection *qconn, pointer puuconf, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialer)); - -/* The command table for standard input ports. */ - -static const struct sconncmds spipecmds = -{ - uspipe_free, - NULL, /* pflock */ - NULL, /* pfunlock */ - fspipe_open, - fspipe_close, - fspipe_dial, - fsdouble_read, - fsdouble_write, - fsysdep_conn_io, - NULL, /* pfbreak */ - NULL, /* pfset */ - NULL, /* pfcarrier */ - fsdouble_chat, - NULL /* pibaud */ -}; - -/* Initialize a pipe connection. */ - -boolean -fsysdep_pipe_init (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn)); - q->o = -1; - q->ord = -1; - q->owr = -1; - q->zdevice = NULL; - q->iflags = -1; - q->iwr_flags = -1; - q->fterminal = FALSE; - q->ftli = FALSE; - q->ibaud = 0; - q->ipid = -1; - qconn->psysdep = (pointer) q; - qconn->qcmds = &spipecmds; - return TRUE; -} - -static void -uspipe_free (qconn) - struct sconnection *qconn; -{ - xfree (qconn->psysdep); -} - -/* Open a pipe port. */ - -/*ARGSUSED*/ -static boolean -fspipe_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - /* We don't do incoming waits on pipes. */ - if (fwait) - return FALSE; - - return TRUE; -} - -/* Close a pipe port. */ - -/*ARGSUSED*/ -static boolean -fspipe_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - struct ssysdep_conn *qsysdep; - boolean fret; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - fret = TRUE; - - /* Close our sides of the pipe. */ - if (qsysdep->ord >= 0 && close (qsysdep->ord) < 0) - { - ulog (LOG_ERROR, "fspipe_close: close read fd: %s", strerror (errno)); - fret = FALSE; - } - if (qsysdep->owr != qsysdep->ord - && qsysdep->owr >= 0 - && close (qsysdep->owr) < 0) - { - ulog (LOG_ERROR, "fspipe_close: close write fd: %s", strerror (errno)); - fret = FALSE; - } - qsysdep->ord = -1; - qsysdep->owr = -1; - - /* Kill dangling child process. */ - if (qsysdep->ipid >= 0) - { - if (kill (qsysdep->ipid, SIGHUP) == 0) - usysdep_sleep (2); -#ifdef SIGPIPE - if (kill (qsysdep->ipid, SIGPIPE) == 0) - usysdep_sleep (2); -#endif - if (kill (qsysdep->ipid, SIGKILL) < 0 && errno == EPERM) - { - ulog (LOG_ERROR, "fspipe_close: Cannot kill child pid %lu: %s", - (unsigned long) qsysdep->ipid, strerror (errno)); - fret = FALSE; - } - else - (void) ixswait ((unsigned long) qsysdep->ipid, (const char *) NULL); - } - qsysdep->ipid = -1; - return fret; -} - -/* Dial out on a pipe port, so to speak: launch connection program - under us. The code alternates q->o between q->ord and q->owr as - appropriate. It is always q->ord before any call to fsblock. */ - -/*ARGSUSED*/ -static boolean -fspipe_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialer; -{ - struct ssysdep_conn *q; - int aidescs[3]; - const char **pzprog; - - q = (struct ssysdep_conn *) qconn->psysdep; - - *ptdialer = DIALERFOUND_FALSE; - - pzprog = (const char **) qconn->qport->uuconf_u.uuconf_spipe.uuconf_pzcmd; - - if (pzprog == NULL) - { - ulog (LOG_ERROR, "No command for pipe connection"); - return FALSE; - } - - aidescs[0] = SPAWN_WRITE_PIPE; - aidescs[1] = SPAWN_READ_PIPE; - aidescs[2] = SPAWN_NULL; - - /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the - responsibility of security on the connection program. */ - q->ipid = ixsspawn (pzprog, aidescs, TRUE, TRUE, (const char *) NULL, - FALSE, TRUE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - if (q->ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno)); - return FALSE; - } - - q->owr = aidescs[0]; - q->ord = aidescs[1]; - q->o = q->ord; - - q->iflags = fcntl (q->ord, F_GETFL, 0); - q->iwr_flags = fcntl (q->owr, F_GETFL, 0); - if (q->iflags < 0 || q->iwr_flags < 0) - { - ulog (LOG_ERROR, "fspipe_dial: fcntl: %s", strerror (errno)); - (void) fspipe_close (qconn, puuconf, qdialer, FALSE); - return FALSE; - } - - return TRUE; -} - -#if 0 - -/* Marc Boucher's contributed code used an alarm to avoid waiting too - long when closing the pipe. However, I believe that it is not - possible for the kernel to sleep when closing a pipe; it is only - possible when closing a device. Therefore, I have removed the - code, but am preserving it in case I am wrong. To reenable it, the - two calls to close in fspipe_close should be changed to call - fspipe_alarmclose. */ - -static RETSIGTYPE -usalarm (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, usalarm); -#endif - -#if HAVE_RESTARTABLE_SYSCALLS - longjmp (sSjmp_buf, 1); -#endif -} - -static int -fspipe_alarmclose (fd) - int fd; -{ - int iret = -1; - int ierrno = 0; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (30); - - iret = close (fd); - ierrno = errno; - } - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - errno = ierrno; - return iret; -} - -#endif /* 0 */ diff --git a/gnu/libexec/uucp/libunix/portnm.c b/gnu/libexec/uucp/libunix/portnm.c deleted file mode 100644 index 11f124792709..000000000000 --- a/gnu/libexec/uucp/libunix/portnm.c +++ /dev/null @@ -1,54 +0,0 @@ -/* portnm.c - Get the port name of stdin. */ - -/* $FreeBSD$ */ - -#include "uucp.h" - -#include "sysdep.h" -#include "system.h" - -#if HAVE_TCP -#if HAVE_SYS_TYPES_TCP_H -#include -#endif -#include -#endif -#include - -#ifndef ttyname -extern char *ttyname (); -#endif - -/* Get the port name of standard input. I assume that Unix systems - generally support ttyname. If they don't, this function can just - return NULL. It uses getsockname to see whether standard input is - a TCP connection. */ - -const char * -zsysdep_port_name (ftcp_port) - boolean *ftcp_port; -{ - const char *z; - - *ftcp_port = FALSE; - -#if HAVE_TCP - { - size_t clen; - struct sockaddr s; - - clen = sizeof (struct sockaddr); - if (getsockname (0, &s, &clen) == 0) - *ftcp_port = TRUE; - } -#endif /* HAVE_TCP */ - - z = ttyname (0); - if (z == NULL) - return NULL; - if (strncmp (z, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) - return z + sizeof _PATH_DEV - 1; - else - return z; -} diff --git a/gnu/libexec/uucp/libunix/proctm.c b/gnu/libexec/uucp/libunix/proctm.c deleted file mode 100644 index 912b11bfed40..000000000000 --- a/gnu/libexec/uucp/libunix/proctm.c +++ /dev/null @@ -1,197 +0,0 @@ -/* proctm.c - Get the time spent in the process. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "sysdep.h" -#include "system.h" - -#if HAVE_SYS_PARAM_H -#include -#endif - -#if HAVE_LIMITS_H -#include -#endif - -/* Prefer gettimeofday to ftime to times. */ - -#if HAVE_GETTIMEOFDAY || HAVE_FTIME -#undef HAVE_TIMES -#define HAVE_TIMES 0 -#endif - -#if HAVE_GETTIMEOFDAY -#undef HAVE_FTIME -#define HAVE_FTIME 0 -#endif - -#if HAVE_TIME_H && (TIME_WITH_SYS_TIME || ! HAVE_GETTIMEOFDAY) -#include -#endif - -#if HAVE_GETTIMEOFDAY -#include -#endif - -#if HAVE_FTIME -#include -#endif - -#if HAVE_TIMES - -#if HAVE_SYS_TIMES_H -#include -#endif - -#if TIMES_DECLARATION_OK -/* We use a macro to protect this because times really returns clock_t - and on some systems, such as Ultrix 4.0, clock_t is int. We don't - leave it out entirely because on some systems, such as System III, - the declaration is necessary for correct compilation. */ -#ifndef times -extern long times (); -#endif -#endif /* TIMES_DECLARATION_OK */ - -#ifdef _SC_CLK_TCK -#define HAVE_SC_CLK_TCK 1 -#else -#define HAVE_SC_CLK_TCK 0 -#endif - -/* TIMES_TICK may have been set in policy.h, or we may be able to get - it using sysconf. If neither is the case, try to find a useful - definition from the system header files. */ -#if TIMES_TICK == 0 && (! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK) -#ifdef CLK_TCK -#undef TIMES_TICK -#define TIMES_TICK CLK_TCK -#else /* ! defined (CLK_TCK) */ -#ifdef HZ -#undef TIMES_TICK -#define TIMES_TICK HZ -#endif /* defined (HZ) */ -#endif /* ! defined (CLK_TCK) */ -#endif /* TIMES_TICK == 0 && (! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK) */ - -#endif /* HAVE_TIMES */ - -#ifndef time -extern time_t time (); -#endif -#if HAVE_SYSCONF -#ifndef sysconf -extern long sysconf (); -#endif -#endif - -/* Get the time in seconds and microseconds; this need only work - within the process when called from the system independent code. - It is also called by ixsysdep_time. */ - -long -ixsysdep_process_time (pimicros) - long *pimicros; -{ -#if HAVE_GETTIMEOFDAY - struct timeval stime; - struct timezone stz; - - (void) gettimeofday (&stime, &stz); - if (pimicros != NULL) - *pimicros = (long) stime.tv_usec; - return (long) stime.tv_sec; -#endif /* HAVE_GETTIMEOFDAY */ - -#if HAVE_FTIME - static boolean fbad; - - if (! fbad) - { - struct timeb stime; - static struct timeb slast; - - (void) ftime (&stime); - - /* On some systems, such as SCO 3.2.2, ftime can go backwards in - time. If we detect this, we switch to using time. */ - if (slast.time != 0 - && (stime.time < slast.time - || (stime.time == slast.time && - stime.millitm < slast.millitm))) - fbad = TRUE; - else - { - slast = stime; - if (pimicros != NULL) - *pimicros = (long) stime.millitm * (long) 1000; - return (long) stime.time; - } - } - - if (pimicros != NULL) - *pimicros = 0; - return (long) time ((time_t *) NULL); -#endif /* HAVE_FTIME */ - -#if HAVE_TIMES - struct tms s; - long i; - static int itick; - - if (itick == 0) - { -#if TIMES_TICK == 0 -#if HAVE_SYSCONF && HAVE_SC_CLK_TCK - itick = (int) sysconf (_SC_CLK_TCK); -#else /* ! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK */ - const char *z; - - z = getenv ("HZ"); - if (z != NULL) - itick = (int) strtol (z, (char **) NULL, 10); - - /* If we really couldn't get anything, just use 60. */ - if (itick == 0) - itick = 60; -#endif /* ! HAVE_SYSCONF || ! HAVE_SC_CLK_TCK */ -#else /* TIMES_TICK != 0 */ - itick = TIMES_TICK; -#endif /* TIMES_TICK == 0 */ - } - - i = (long) times (&s); - if (pimicros != NULL) - *pimicros = (i % (long) itick) * ((long) 1000000 / (long) itick); - return i / (long) itick; -#endif /* HAVE_TIMES */ - -#if ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES - if (pimicros != NULL) - *pimicros = 0; - return (long) time ((time_t *) NULL); -#endif /* ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES */ -} diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c deleted file mode 100644 index 4b8472731719..000000000000 --- a/gnu/libexec/uucp/libunix/serial.c +++ /dev/null @@ -1,3403 +0,0 @@ -/* serial.c - The serial port communication routines for Unix. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char serial_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "conn.h" -#include "sysdep.h" - -#include -#include -#include - -#if HAVE_SYS_PARAM_H -#include -#endif - -#if HAVE_LIMITS_H -#include -#endif - -#if HAVE_TLI -#if HAVE_TIUSER_H -#include -#else /* ! HAVE_TIUSER_H */ -#if HAVE_XTI_H -#include -#endif /* HAVE_XTI_H */ -#endif /* ! HAVE_TIUSER_H */ -#endif /* HAVE_TLI */ - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#if HAVE_SYS_IOCTL_H || HAVE_TXADDCD -#include -#endif - -#if HAVE_SELECT -#if HAVE_SYS_TIME_H -#include -#endif -#if HAVE_SYS_SELECT_H -#include -#endif -#endif - -#if HAVE_TIME_H -#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME -#include -#endif -#endif - -#if HAVE_STRIP_BUG && HAVE_BSD_TTY -#include -#endif - -#if HAVE_SVR4_LOCKFILES -/* Get the right definitions for major and minor. */ -#if MAJOR_IN_MKDEV -#include -#endif /* MAJOR_IN_MKDEV */ -#if MAJOR_IN_SYSMACROS -#include -#endif /* MAJOR_IN_SYSMACROS */ -#if ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS -#ifndef major -#define major(i) (((i) >> 8) & 0xff) -#endif -#ifndef minor -#define minor(i) ((i) & 0xff) -#endif -#endif /* ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS */ -#endif /* HAVE_SVR4_LOCKFILES */ - -#if HAVE_DEV_INFO -#include -#endif - -/* Get definitions for both O_NONBLOCK and O_NDELAY. */ -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else /* ! defined (FNDELAY) */ -#define O_NDELAY 0 -#endif /* ! defined (FNDELAY) */ -#endif /* ! defined (O_NDELAY) */ - -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else /* ! defined (FNBLOCK) */ -#define O_NONBLOCK 0 -#endif /* ! defined (FNBLOCK) */ -#endif /* ! defined (O_NONBLOCK) */ - -#if O_NDELAY == 0 && O_NONBLOCK == 0 - #error No way to do nonblocking I/O -#endif - -/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */ -#ifndef EAGAIN -#ifndef EWOULDBLOCK -#define EAGAIN (-1) -#define EWOULDBLOCK (-1) -#else /* defined (EWOULDBLOCK) */ -#define EAGAIN EWOULDBLOCK -#endif /* defined (EWOULDBLOCK) */ -#else /* defined (EAGAIN) */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif /* ! defined (EWOULDBLOCK) */ -#endif /* defined (EAGAIN) */ - -#ifndef ENODATA -#define ENODATA EAGAIN -#endif - -/* Make sure we have a definition for MAX_INPUT. */ -#ifndef MAX_INPUT -#define MAX_INPUT (256) -#endif - -/* If we have the TIOCSINUSE ioctl call, we use it to lock a terminal. - Otherwise, if we have the TIOCEXCL ioctl call, we have to open the - terminal before we know that it is unlocked. */ -#ifdef TIOCSINUSE -#define HAVE_TIOCSINUSE 1 -#else -#ifdef TIOCEXCL -#define HAVE_TIOCEXCL 1 -#endif -#endif - -#if HAVE_TLI -extern int t_errno; -extern char *t_errlist[]; -extern int t_nerr; -#endif - -/* Determine bits to clear for the various terminal control fields for - HAVE_SYSV_TERMIO and HAVE_POSIX_TERMIOS. */ - -/* These fields are defined on some systems, and I am told that it - does not hurt to clear them, and it sometimes helps. */ -#ifndef IMAXBEL -#define IMAXBEL 0 -#endif - -#ifndef PENDIN -#define PENDIN 0 -#endif - -#if HAVE_SYSV_TERMIO -#define ICLEAR_IFLAG (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK \ - | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC \ - | IXON | IXANY | IXOFF | IMAXBEL) -#define ICLEAR_OFLAG (OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET \ - | OFILL | OFDEL | NLDLY | CRDLY | TABDLY | BSDLY \ - | VTDLY | FFDLY) -#define ICLEAR_CFLAG (CBAUD | CSIZE | PARENB | PARODD) -#define ISET_CFLAG (CS8 | CREAD | HUPCL) -#define ICLEAR_LFLAG (ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK \ - | ECHONL | NOFLSH | PENDIN) -#endif -#if HAVE_POSIX_TERMIOS -#define ICLEAR_IFLAG (BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR \ - | INLCR | INPCK | ISTRIP | IXOFF | IXON \ - | PARMRK | IMAXBEL) -#define ICLEAR_OFLAG (OPOST) -#define ICLEAR_CFLAG (CSIZE | PARENB | PARODD) -#define ISET_CFLAG (CS8 | CREAD | HUPCL) -#define ICLEAR_LFLAG (ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN \ - | ISIG | NOFLSH | TOSTOP | PENDIN) -#endif - -enum tclocal_setting -{ - SET_CLOCAL, - CLEAR_CLOCAL, - IGNORE_CLOCAL -}; - -/* Local functions. */ - -static RETSIGTYPE usalarm P((int isig)); -static boolean fsserial_init P((struct sconnection *qconn, - const struct sconncmds *qcmds, - const char *zdevice)); -static void usserial_free P((struct sconnection *qconn)); -static boolean fsserial_lockfile P((boolean flok, - const struct sconnection *)); -static boolean fsserial_lock P((struct sconnection *qconn, - boolean fin)); -static boolean fsserial_unlock P((struct sconnection *qconn)); -static boolean fsserial_open P((struct sconnection *qconn, long ibaud, - boolean fwait, enum tclocal_setting tlocal)); -static boolean fsstdin_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean fsmodem_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean fsdirect_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean fsblock P((struct ssysdep_conn *q, boolean fblock)); -static boolean fsserial_close P((struct ssysdep_conn *q)); -static boolean fsstdin_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean fsmodem_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean fsdirect_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean fsserial_break P((struct sconnection *qconn)); -static boolean fsstdin_break P((struct sconnection *qconn)); -static boolean fsserial_set P((struct sconnection *qconn, - enum tparitysetting tparity, - enum tstripsetting tstrip, - enum txonxoffsetting txonxoff)); -static boolean fsstdin_set P((struct sconnection *qconn, - enum tparitysetting tparity, - enum tstripsetting tstrip, - enum txonxoffsetting txonxoff)); -static boolean fsmodem_carrier P((struct sconnection *qconn, - boolean fcarrier)); -static boolean fsserial_hardflow P((struct sconnection *qconn, - boolean fhardflow)); -static boolean fsrun_chat P((int oread, int owrite, char **pzprog)); -static long isserial_baud P((struct sconnection *qconn)); - -/* The command table for standard input ports. */ - -static const struct sconncmds sstdincmds = -{ - usserial_free, - NULL, /* pflock */ - NULL, /* pfunlock */ - fsstdin_open, - fsstdin_close, - NULL, /* pfdial */ - fsdouble_read, - fsdouble_write, - fsysdep_conn_io, - fsstdin_break, - fsstdin_set, - NULL, /* pfcarrier */ - fsdouble_chat, - isserial_baud -}; - -/* The command table for modem ports. */ - -static const struct sconncmds smodemcmds = -{ - usserial_free, - fsserial_lock, - fsserial_unlock, - fsmodem_open, - fsmodem_close, - fmodem_dial, - fsysdep_conn_read, - fsysdep_conn_write, - fsysdep_conn_io, - fsserial_break, - fsserial_set, - fsmodem_carrier, - fsysdep_conn_chat, - isserial_baud -}; - -/* The command table for direct ports. */ - -static const struct sconncmds sdirectcmds = -{ - usserial_free, - fsserial_lock, - fsserial_unlock, - fsdirect_open, - fsdirect_close, - NULL, /* pfdial */ - fsysdep_conn_read, - fsysdep_conn_write, - fsysdep_conn_io, - fsserial_break, - fsserial_set, - NULL, /* pfcarrier */ - fsysdep_conn_chat, - isserial_baud -}; - -/* If the system will let us set both O_NDELAY and O_NONBLOCK, we do - so. This is because some ancient drivers on some systems appear to - look for one but not the other. Some other systems will give an - EINVAL error if we attempt to set both, so we use a static global - to hold the value we want to set. If we get EINVAL, we change the - global and try again (if some system gives an error other than - EINVAL, the code will have to be modified). */ -static int iSunblock = O_NDELAY | O_NONBLOCK; - -/* This code handles SIGALRM. See the discussion above - fsysdep_conn_read. Normally we ignore SIGALRM, but the handler - will temporarily be set to this function, which should set fSalarm - and then either longjmp or schedule another SIGALRM. fSalarm is - never referred to outside of this file, but we don't make it static - to try to fool compilers which don't understand volatile. */ - -volatile sig_atomic_t fSalarm; - -static RETSIGTYPE -usalarm (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, usalarm); -#endif - - fSalarm = TRUE; - -#if HAVE_RESTARTABLE_SYSCALLS - longjmp (sSjmp_buf, 1); -#else - alarm (1); -#endif -} - -/* We need a simple routine to block SIGINT, SIGQUIT, SIGTERM and - SIGPIPE and another to restore the original state. When these - functions are called (in fsysdep_modem_close) SIGHUP is being - ignored. The routines are isblocksigs, which returns a value of - type HELD_SIG_MASK and usunblocksigs which takes a single argument - of type HELD_SIG_MASK. */ - -#if HAVE_SIGPROCMASK - -/* Use the POSIX sigprocmask call. */ - -#define HELD_SIG_MASK sigset_t - -static sigset_t isblocksigs P((void)); - -static sigset_t -isblocksigs () -{ - sigset_t sblock, sold; - - /* These expressions need an extra set of parentheses to avoid a bug - in SCO 3.2.2. */ - (void) (sigemptyset (&sblock)); - (void) (sigaddset (&sblock, SIGINT)); - (void) (sigaddset (&sblock, SIGQUIT)); - (void) (sigaddset (&sblock, SIGTERM)); - (void) (sigaddset (&sblock, SIGPIPE)); - - (void) sigprocmask (SIG_BLOCK, &sblock, &sold); - return sold; -} - -#define usunblocksigs(s) \ - ((void) sigprocmask (SIG_SETMASK, &(s), (sigset_t *) NULL)) - -#else /* ! HAVE_SIGPROCMASK */ -#if HAVE_SIGBLOCK - -/* Use the BSD sigblock and sigsetmask calls. */ - -#define HELD_SIG_MASK int - -#ifndef sigmask -#define sigmask(i) (1 << ((i) - 1)) -#endif - -#define isblocksigs() \ - sigblock (sigmask (SIGINT) | sigmask (SIGQUIT) \ - | sigmask (SIGTERM) | sigmask (SIGPIPE)) - -#define usunblocksigs(i) ((void) sigsetmask (i)) - -#else /* ! HAVE_SIGBLOCK */ - -#if HAVE_SIGHOLD - -/* Use the SVR3 sighold and sigrelse calls. */ - -#define HELD_SIG_MASK int - -static int isblocksigs P((void)); - -static int -isblocksigs () -{ - sighold (SIGINT); - sighold (SIGQUIT); - sighold (SIGTERM); - sighold (SIGPIPE); - return 0; -} - -static void usunblocksigs P((int)); - -/*ARGSUSED*/ -static void -usunblocksigs (i) - int i; -{ - sigrelse (SIGINT); - sigrelse (SIGQUIT); - sigrelse (SIGTERM); - sigrelse (SIGPIPE); -} - -#else /* ! HAVE_SIGHOLD */ - -/* We have no way to block signals. This system will suffer from a - race condition in fsysdep_modem_close. */ - -#define HELD_SIG_MASK int - -#define isblocksigs() 0 - -#define usunblocksigs(i) - -#endif /* ! HAVE_SIGHOLD */ -#endif /* ! HAVE_SIGBLOCK */ -#endif /* ! HAVE_SIGPROCMASK */ - -/* Initialize a connection for use on a serial port. */ - -static boolean -fsserial_init (qconn, qcmds, zdevice) - struct sconnection *qconn; - const struct sconncmds *qcmds; - const char *zdevice; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn)); - if (zdevice == NULL - && qconn->qport != NULL - && qconn->qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN) - zdevice = qconn->qport->uuconf_zname; - if (zdevice == NULL) - q->zdevice = NULL; - else if (*zdevice == '/') - q->zdevice = zbufcpy (zdevice); - else - { - size_t clen; - - clen = strlen (zdevice); - q->zdevice = zbufalc (sizeof _PATH_DEV + clen); - memcpy (q->zdevice, _PATH_DEV, sizeof _PATH_DEV - 1); - memcpy (q->zdevice + sizeof _PATH_DEV - 1, zdevice, clen); - q->zdevice[sizeof _PATH_DEV + clen - 1] = '\0'; - } - q->o = -1; - q->ord = -1; - q->owr = -1; - q->ftli = FALSE; - qconn->psysdep = (pointer) q; - qconn->qcmds = qcmds; - return TRUE; -} - -/* Initialize a connection for use on standard input. */ - -boolean -fsysdep_stdin_init (qconn) - struct sconnection *qconn; -{ - /* chmod /dev/tty to prevent other users from writing messages to - it. This is essentially `mesg n'. */ - (void) chmod (_PATH_TTY, S_IRUSR | S_IWUSR); - return fsserial_init (qconn, &sstdincmds, (const char *) NULL); -} - -/* Initialize a connection for use on a modem port. */ - -boolean -fsysdep_modem_init (qconn) - struct sconnection *qconn; -{ - return fsserial_init (qconn, &smodemcmds, - qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdevice); -} - -/* Initialize a connection for use on a direct port. */ - -boolean -fsysdep_direct_init (qconn) - struct sconnection *qconn; -{ - return fsserial_init (qconn, &sdirectcmds, - qconn->qport->uuconf_u.uuconf_sdirect.uuconf_zdevice); -} - -/* Free up a serial port. */ - -static void -usserial_free (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - ubuffree (qsysdep->zdevice); - xfree ((pointer) qsysdep); - qconn->psysdep = NULL; -} - -#if HAVE_SEQUENT_LOCKFILES -#define LCK_TEMPLATE "LCK..tty" -#else -#define LCK_TEMPLATE "LCK.." -#endif - -/* This routine is used for both locking and unlocking. It is the - only routine which knows how to translate a device name into the - name of a lock file. If it can't figure out a name, it does - nothing and returns TRUE. */ - -static boolean -fsserial_lockfile (flok, qconn) - boolean flok; - const struct sconnection *qconn; -{ - struct ssysdep_conn *qsysdep; - const char *z; - char *zalc; - boolean fret; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - if (qconn->qport == NULL) - z = NULL; - else - z = qconn->qport->uuconf_zlockname; - zalc = NULL; - if (z == NULL) - { -#if HAVE_QNX_LOCKFILES - { - nid_t idevice_nid; - char abdevice_nid[13]; /* length of long, a period, and a NUL */ - size_t cdevice_nid; - const char *zbase; - size_t clen; - - /* If the node ID is explicitly specified as part of the - pathname to the device, use that. Otherwise, presume the - device is local to the current node. */ - if (qsysdep->zdevice[0] == '/' && qsysdep->zdevice[1] == '/') - idevice_nid = (nid_t) strtol (qsysdep->zdevice + 2, - (char **) NULL, 10); - else - idevice_nid = getnid (); - - sprintf (abdevice_nid, "%ld.", (long) idevice_nid); - cdevice_nid = strlen (abdevice_nid); - - zbase = strrchr (qsysdep->zdevice, '/') + 1; - clen = strlen (zbase); - - zalc = zbufalc (sizeof LCK_TEMPLATE + cdevice_nid + clen); - - memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1); - memcpy (zalc + sizeof LCK_TEMPLATE - 1, abdevice_nid, cdevice_nid); - memcpy (zalc + sizeof LCK_TEMPLATE - 1 + cdevice_nid, - zbase, clen + 1); - - z = zalc; - } -#else /* ! HAVE_QNX_LOCKFILES */ -#if ! HAVE_SVR4_LOCKFILES - { - const char *zbase; - size_t clen; - - zbase = strrchr (qsysdep->zdevice, '/') + 1; - clen = strlen (zbase); - zalc = zbufalc (sizeof LCK_TEMPLATE + clen); - memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1); - memcpy (zalc + sizeof LCK_TEMPLATE - 1, zbase, clen + 1); -#if HAVE_SCO_LOCKFILES - { - char *zl; - - for (zl = zalc + sizeof LCK_TEMPLATE - 1; *zl != '\0'; zl++) - if (isupper (*zl)) - *zl = tolower (*zl); - } -#endif - z = zalc; - } -#else /* HAVE_SVR4_LOCKFILES */ - { - struct stat s; - - if (stat (qsysdep->zdevice, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", qsysdep->zdevice, - strerror (errno)); - return FALSE; - } - zalc = zbufalc (sizeof "LK.1234567890.1234567890.1234567890"); - sprintf (zalc, "LK.%03d.%03d.%03d", major (s.st_dev), - major (s.st_rdev), minor (s.st_rdev)); - z = zalc; - } -#endif /* HAVE_SVR4_LOCKFILES */ -#endif /* ! HAVE_QNX_LOCKFILES */ - } - - if (flok) - fret = fsdo_lock (z, FALSE, (boolean *) NULL); - else - fret = fsdo_unlock (z, FALSE); - -#if HAVE_COHERENT_LOCKFILES - if (fret) - { - if (flok) - { - if (lockttyexist (z + sizeof LCK_TEMPLATE - 1)) - { - ulog (LOG_NORMAL, "%s: port already locked", - z + sizeof LCK_TEMPLATE - 1); - fret = FALSE; - } - else - fret = fscoherent_disable_tty (z + sizeof LCK_TEMPLATE - 1, - &qsysdep->zenable); - } - else - { - fret = TRUE; - if (qsysdep->zenable != NULL) - { - const char *azargs[3]; - int aidescs[3]; - pid_t ipid; - - azargs[0] = "/etc/enable"; - azargs[1] = qsysdep->zenable; - azargs[2] = NULL; - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, - (const char *) NULL, TRUE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn (/etc/enable %s): %s", - qsysdep->zenable, strerror (errno)); - fret = FALSE; - } - else - { - if (ixswait ((unsigned long) ipid, (const char *) NULL) - == 0) - fret = TRUE; - else - fret = FALSE; - } - ubuffree (qsysdep->zenable); - qsysdep->zenable = NULL; - } - } - } -#endif /* HAVE_COHERENT_LOCKFILES */ - - ubuffree (zalc); - return fret; -} - -/* If we can mark a modem line in use, then when we lock a port we - must open it and mark it in use. We can't wait until the actual - open because we can't fail out if it is locked then. */ - -static boolean -fsserial_lock (qconn, fin) - struct sconnection *qconn; - boolean fin; -{ - if (! fsserial_lockfile (TRUE, qconn)) - return FALSE; - -#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL || HAVE_DEV_INFO - /* Open the line and try to mark it in use. */ - { - struct ssysdep_conn *qsysdep; - int iflag; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - if (fin) - iflag = 0; - else - iflag = iSunblock; - - qsysdep->o = open (qsysdep->zdevice, O_RDWR | iflag); - if (qsysdep->o < 0) - { -#if O_NONBLOCK != 0 - if (! fin && iSunblock != O_NONBLOCK && errno == EINVAL) - { - iSunblock = O_NONBLOCK; - qsysdep->o = open (qsysdep->zdevice, - O_RDWR | O_NONBLOCK); - } -#endif - if (qsysdep->o < 0) - { - if (errno != EBUSY) - ulog (LOG_ERROR, "open (%s): %s", qsysdep->zdevice, - strerror (errno)); - (void) fsserial_lockfile (FALSE, qconn); - return FALSE; - } - } - -#if HAVE_TIOCSINUSE - /* If we can't mark it in use, return FALSE to indicate that the - lock failed. */ - if (ioctl (qsysdep->o, TIOCSINUSE, 0) < 0) - { - if (errno != EALREADY) - ulog (LOG_ERROR, "ioctl (TIOCSINUSE): %s", strerror (errno)); -#ifdef TIOCNOTTY - (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL); -#endif - (void) close (qsysdep->o); - qsysdep->o = -1; - (void) fsserial_lockfile (FALSE, qconn); - return FALSE; - } -#endif - -#if HAVE_DEV_INFO - /* QNX programs "lock" a serial port by simply opening it and - checking if some other program also has the port open. If the - count of openers is greater than one, the program presumes the - port is "locked" and backs off. This isn't really "locking" of - course, but it pretty much seems to work. This can result in - dropping incoming connections if an outgoing connection is - started at exactly the same time. It would probably be better - to stop using the lock files at all for this case, but that - would involve more complex changes to the code, and I'm afraid - I would break something. -- Joe Wells */ - { - struct _dev_info_entry sdevinfo; - - if (dev_info (qsysdep->o, &sdevinfo) == -1) - { - ulog (LOG_ERROR, "dev_info: %s", strerror (errno)); - sdevinfo.open_count = 2; /* force presumption of "locked" */ - } - if (sdevinfo.open_count != 1) - { -#ifdef TIOCNOTTY - (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL); -#endif /* TIOCNOTTY */ - (void) close (qsysdep->o); - qsysdep->o = -1; - (void) fsserial_lockfile (FALSE, qconn); - return FALSE; - } - } -#endif /* HAVE_DEV_INFO */ - - if (fcntl (qsysdep->o, F_SETFD, - fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); -#ifdef TIOCNOTTY - (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL); -#endif - (void) close (qsysdep->o); - qsysdep->o = -1; - (void) fsserial_lockfile (FALSE, qconn); - return FALSE; - } - } -#endif /* HAVE_TIOCSINUSE || HAVE_TIOCEXCL */ - - return TRUE; -} - -/* Unlock a modem or direct port. */ - -static boolean -fsserial_unlock (qconn) - struct sconnection *qconn; -{ - boolean fret; - struct ssysdep_conn *qsysdep; - - fret = TRUE; - - /* The file may have been opened by fsserial_lock, so close it here - if necessary. */ - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - if (qsysdep->o >= 0) - { -#ifdef TIOCNOTTY - (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL); -#endif - if (close (qsysdep->o) < 0) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - fret = FALSE; - } - qsysdep->o = -1; - } - - if (! fsserial_lockfile (FALSE, qconn)) - fret = FALSE; - - return fret; -} - -/* A table to map baud rates into index numbers. */ - -#if HAVE_POSIX_TERMIOS -typedef speed_t baud_code; -#else -typedef int baud_code; -#endif - -static struct sbaud_table -{ - baud_code icode; - long ibaud; -} asSbaud_table[] = -{ - { B50, 50 }, - { B75, 75 }, - { B110, 110 }, - { B134, 134 }, - { B150, 150 }, - { B200, 200 }, - { B300, 300 }, - { B600, 600 }, - { B1200, 1200 }, - { B1800, 1800 }, - { B2400, 2400 }, - { B4800, 4800 }, - { B9600, 9600 }, - { B28800, 28800 }, -#ifdef B19200 - { B19200, 19200 }, -#else /* ! defined (B19200) */ -#ifdef EXTA - { EXTA, 19200 }, -#endif /* EXTA */ -#endif /* ! defined (B19200) */ -#ifdef B38400 - { B38400, 38400 }, -#else /* ! defined (B38400) */ -#ifdef EXTB - { EXTB, 38400 }, -#endif /* EXTB */ -#endif /* ! defined (B38400) */ -#ifdef B57600 - { B57600, 57600 }, -#endif -#ifdef B76800 - { B76800, 76800 }, -#endif -#ifdef B115200 - { B115200, 115200 }, -#endif -#ifdef B230400 - { B230400, 230400 }, -#endif - { B0, 0 } -}; - -#define CBAUD_TABLE (sizeof asSbaud_table / sizeof asSbaud_table[0]) - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS -/* Hold the MIN value for the terminal to avoid setting it - unnecessarily. */ -static int cSmin; -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - -/* Open a serial line. This sets the terminal settings. We begin in - seven bit mode and let the protocol change if necessary. If fwait - is FALSE we open the terminal in non-blocking mode. If flocal is - TRUE we set CLOCAL on the terminal when using termio[s]; this is - supposedly required on some versions of BSD/386. */ - -static boolean -fsserial_open (qconn, ibaud, fwait, tlocal) - struct sconnection *qconn; - long ibaud; - boolean fwait; - enum tclocal_setting tlocal; -{ - struct ssysdep_conn *q; - baud_code ib; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (q->zdevice != NULL) - { -#if LOG_DEVICE_PREFIX - ulog_device (q->zdevice); -#else - const char *z; - - if (strncmp (q->zdevice, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) - z = q->zdevice + sizeof _PATH_DEV - 1; - else - z = q->zdevice; - ulog_device (z); -#endif - } - else - { - const char *zport; - boolean fdummy; - -#if DEBUG > 0 - if (qconn->qport != NULL && - qconn->qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN) - ulog (LOG_FATAL, "fsserial_open: Can't happen"); -#endif - zport = zsysdep_port_name (&fdummy); - if (zport != NULL) - ulog_device (zport); - } - - ib = B0; - if (ibaud != 0) - { - int i; - - for (i = 0; i < CBAUD_TABLE; i++) - if (asSbaud_table[i].ibaud == ibaud) - break; - if (i >= CBAUD_TABLE) - { - ulog (LOG_ERROR, "Unsupported baud rate %ld", ibaud); - return FALSE; - } - ib = asSbaud_table[i].icode; - } - - /* The port may have already been opened by the locking routine. */ - if (q->o < 0) - { - int iflag; - - if (fwait) - iflag = 0; - else - iflag = iSunblock; - - q->o = open (q->zdevice, O_RDWR | iflag); - if (q->o < 0) - { -#if O_NONBLOCK != 0 - if (! fwait && iSunblock != O_NONBLOCK && errno == EINVAL) - { - iSunblock = O_NONBLOCK; - q->o = open (q->zdevice, O_RDWR | O_NONBLOCK); - } -#endif - if (q->o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", q->zdevice, - strerror (errno)); - return FALSE; - } - } - - if (fcntl (q->o, F_SETFD, fcntl (q->o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - return FALSE; - } - } - - /* Get the port flags, and make sure the ports are blocking. */ - - q->iflags = fcntl (q->o, F_GETFL, 0); - if (q->iflags < 0) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - return FALSE; - } - q->iwr_flags = -1; - - if (! fgetterminfo (q->o, &q->sorig)) - { - q->fterminal = FALSE; - return TRUE; - } - - q->fterminal = TRUE; - - q->snew = q->sorig; - -#if HAVE_BSD_TTY - - q->snew.stty.sg_flags = RAW | ANYP; - if (ibaud == 0) - ib = q->snew.stty.sg_ospeed; - else - { - q->snew.stty.sg_ispeed = ib; - q->snew.stty.sg_ospeed = ib; - } - - /* We don't want to receive any interrupt characters. */ - q->snew.stchars.t_intrc = -1; - q->snew.stchars.t_quitc = -1; - q->snew.stchars.t_eofc = -1; - q->snew.stchars.t_brkc = -1; - q->snew.sltchars.t_suspc = -1; - q->snew.sltchars.t_rprntc = -1; - q->snew.sltchars.t_dsuspc = -1; - q->snew.sltchars.t_flushc = -1; - q->snew.sltchars.t_werasc = -1; - q->snew.sltchars.t_lnextc = -1; - -#ifdef NTTYDISC - /* We want to use the ``new'' terminal driver so that we can use the - local mode bits to control XON/XOFF. */ - { - int iparam; - - if (ioctl (q->o, TIOCGETD, &iparam) >= 0 - && iparam != NTTYDISC) - { - iparam = NTTYDISC; - (void) ioctl (q->o, TIOCSETD, &iparam); - } - } -#endif - -#ifdef TIOCHPCL - /* When the file is closed, hang up the line. This is a safety - measure in case the program crashes. */ - (void) ioctl (q->o, TIOCHPCL, 0); -#endif - -#ifdef TIOCFLUSH - { - int iparam; - - /* Flush pending input. */ -#ifdef FREAD - iparam = FREAD; -#else - iparam = 0; -#endif - (void) ioctl (q->o, TIOCFLUSH, &iparam); - } -#endif /* TIOCFLUSH */ - -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO - - if (ibaud == 0) - ib = q->snew.c_cflag & CBAUD; - - q->snew.c_iflag &=~ ICLEAR_IFLAG; - q->snew.c_oflag &=~ ICLEAR_OFLAG; - q->snew.c_cflag &=~ ICLEAR_CFLAG; - q->snew.c_cflag |= ib | ISET_CFLAG; - q->snew.c_lflag &=~ ICLEAR_LFLAG; - cSmin = 1; - q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 1; - -#ifdef TCFLSH - /* Flush pending input. */ - (void) ioctl (q->o, TCFLSH, 0); -#endif - -#endif /* HAVE_SYSV_TERMIO */ - -#if HAVE_POSIX_TERMIOS - - if (ibaud == 0) - ib = cfgetospeed (&q->snew); - - q->snew.c_iflag &=~ ICLEAR_IFLAG; - q->snew.c_oflag &=~ ICLEAR_OFLAG; - q->snew.c_cflag &=~ ICLEAR_CFLAG; - q->snew.c_cflag |= ISET_CFLAG; - q->snew.c_lflag &=~ ICLEAR_LFLAG; - cSmin = 1; - q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 1; - - (void) cfsetospeed (&q->snew, ib); - (void) cfsetispeed (&q->snew, ib); - - /* Flush pending input. */ - (void) tcflush (q->o, TCIFLUSH); - -#endif /* HAVE_POSIX_TERMIOS */ - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - switch (tlocal) - { - case SET_CLOCAL: - q->snew.c_cflag |= CLOCAL; - break; - case CLEAR_CLOCAL: - q->snew.c_cflag &=~ CLOCAL; - break; - case IGNORE_CLOCAL: - break; - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno)); - return FALSE; - } - -#ifdef TIOCSCTTY - /* On BSD 4.4, make it our controlling terminal. */ - (void) ioctl (q->o, TIOCSCTTY, 0); -#endif - - if (ibaud != 0) - q->ibaud = ibaud; - else - { - int i; - - q->ibaud = (long) 1200; - for (i = 0; i < CBAUD_TABLE; i++) - { - if (asSbaud_table[i].icode == ib) - { - q->ibaud = asSbaud_table[i].ibaud; - break; - } - } - - DEBUG_MESSAGE1 (DEBUG_PORT, - "fsserial_open: Baud rate is %ld", q->ibaud); - } - - return TRUE; -} - -/* Open a standard input port. The code alternates q->o between - q->ord and q->owr as appropriate. It is always q->ord before any - call to fsblock. */ - -static boolean -fsstdin_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) qconn->psysdep; - q->ord = 0; - q->owr = 1; - - q->o = q->ord; - if (! fsserial_open (qconn, ibaud, fwait, IGNORE_CLOCAL)) - return FALSE; - q->iwr_flags = fcntl (q->owr, F_GETFL, 0); - if (q->iwr_flags < 0) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - return FALSE; - } - return TRUE; -} - -/* Open a modem port. */ - -static boolean -fsmodem_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - struct uuconf_modem_port *qm; - - qm = &qconn->qport->uuconf_u.uuconf_smodem; - if (ibaud == (long) 0) - ibaud = qm->uuconf_ibaud; - - if (! fsserial_open (qconn, ibaud, fwait, - fwait ? CLEAR_CLOCAL : SET_CLOCAL)) - return FALSE; - - /* If we are waiting for carrier, then turn on hardware flow - control. We don't turn on hardware flow control when dialing - out, because some modems don't assert the necessary signals until - they see carrier. Instead, we turn on hardware flow control in - fsmodem_carrier. */ - if (fwait - && ! fsserial_hardflow (qconn, qm->uuconf_fhardflow)) - return FALSE; - - return TRUE; -} - -/* Open a direct port. */ - -static boolean -fsdirect_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - struct uuconf_direct_port *qd; - - qd = &qconn->qport->uuconf_u.uuconf_sdirect; - if (ibaud == (long) 0) - ibaud = qd->uuconf_ibaud; - if (! fsserial_open (qconn, ibaud, fwait, - qd->uuconf_fcarrier ? CLEAR_CLOCAL : SET_CLOCAL)) - return FALSE; - - /* Always turn on hardware flow control for a direct port when it is - opened. There is no other sensible time to turn it on. */ - return fsserial_hardflow (qconn, qd->uuconf_fhardflow); -} - -/* Change the blocking status of the port. We keep track of the - current blocking status to avoid calling fcntl unnecessarily; fcntl - turns out to be surprisingly expensive, at least on Ultrix. */ - -static boolean -fsblock (qs, fblock) - struct ssysdep_conn *qs; - boolean fblock; -{ - int iwant; - int isys; - - if (fblock) - iwant = qs->iflags &~ (O_NDELAY | O_NONBLOCK); - else - iwant = qs->iflags | iSunblock; - - if (iwant == qs->iflags) - return TRUE; - - isys = fcntl (qs->o, F_SETFL, iwant); - if (isys < 0) - { -#if O_NONBLOCK != 0 - if (! fblock && iSunblock != O_NONBLOCK && errno == EINVAL) - { - iSunblock = O_NONBLOCK; - iwant = qs->iflags | O_NONBLOCK; - isys = fcntl (qs->o, F_SETFL, iwant); - } -#endif - if (isys < 0) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - return FALSE; - } - } - - qs->iflags = iwant; - - if (qs->iwr_flags >= 0 && qs->ord != qs->owr) - { - if (fblock) - iwant = qs->iwr_flags &~ (O_NDELAY | O_NONBLOCK); - else - iwant = qs->iwr_flags | iSunblock; - - if (fcntl (qs->owr, F_SETFL, iwant) < 0) - { - /* We don't bother to fix up iSunblock here, since we - succeeded above. */ - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - return FALSE; - } - - qs->iwr_flags = iwant; - } - - return TRUE; -} - -/* Close a serial port. */ - -static boolean -fsserial_close (q) - struct ssysdep_conn *q; -{ - if (q->o >= 0) - { - /* Use a 30 second timeout to avoid hanging while draining - output. */ - if (q->fterminal) - { - fSalarm = FALSE; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (30); - - (void) fsetterminfodrain (q->o, &q->sorig); - } - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - /* If we timed out, use the non draining call. Hopefully - this can't hang. */ - if (fSalarm) - (void) fsetterminfo (q->o, &q->sorig); - } - -#ifdef TIOCNOTTY - /* We don't want this as our controlling terminal any more, so - get rid of it. This is necessary because we don't want to - open /dev/tty, since that can confuse the serial port locking - on some computers. */ - (void) ioctl (q->o, TIOCNOTTY, (char *) NULL); -#endif - - (void) close (q->o); - q->o = -1; - - /* Sleep to give the terminal a chance to settle, in case we are - about to call out again. */ - sleep (2); - } - - return TRUE; -} - -/* Close a stdin port. */ - -/*ARGSUSED*/ -static boolean -fsstdin_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - (void) close (qsysdep->owr); - (void) close (2); - qsysdep->o = qsysdep->ord; - return fsserial_close (qsysdep); -} - -/* Close a modem port. */ - -static boolean -fsmodem_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - struct ssysdep_conn *qsysdep; - boolean fret; - struct uuconf_dialer sdialer; - const struct uuconf_chat *qchat; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - fret = TRUE; - - /* Figure out the dialer so that we can run the complete or abort - chat scripts. */ - if (qdialer == NULL) - { - if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL) - { - const char *zdialer; - int iuuconf; - - zdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0]; - iuuconf = uuconf_dialer_info (puuconf, zdialer, &sdialer); - if (iuuconf == UUCONF_SUCCESS) - qdialer = &sdialer; - else - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - } - } - else - qdialer = qconn->qport->uuconf_u.uuconf_smodem.uuconf_qdialer; - } - - /* Get the complete or abort chat script to use. */ - qchat = NULL; - if (qdialer != NULL) - { - if (fsuccess) - qchat = &qdialer->uuconf_scomplete; - else - qchat = &qdialer->uuconf_sabort; - } - - if (qchat != NULL - && (qchat->uuconf_pzprogram != NULL - || qchat->uuconf_pzchat != NULL)) - { - boolean fsighup_ignored; - HELD_SIG_MASK smask; - int i; - sig_atomic_t afhold[INDEXSIG_COUNT]; - - /* We're no longer interested in carrier. */ - (void) fsmodem_carrier (qconn, FALSE); - - /* The port I/O routines check whether any signal has been - received, and abort if one has. While we are closing down - the modem, we don't care if we received a signal in the past, - but we do care if we receive a new signal (otherwise it would - be difficult to kill a uucico which was closing down a - modem). We never care if we get SIGHUP at this point. So we - turn off SIGHUP, remember what signals we've already seen, - and clear our notion of what signals we've seen. We have to - block the signals while we remember and clear the array, - since we might otherwise miss a signal which occurred between - the copy and the clear (old systems can't block signals; they - will just have to suffer the race). */ - usset_signal (SIGHUP, SIG_IGN, FALSE, &fsighup_ignored); - smask = isblocksigs (); - for (i = 0; i < INDEXSIG_COUNT; i++) - { - afhold[i] = afSignal[i]; - afSignal[i] = FALSE; - } - usunblocksigs (smask); - - if (! fchat (qconn, puuconf, qchat, (const struct uuconf_system *) NULL, - (const struct uuconf_dialer *) NULL, (const char *) NULL, - FALSE, qconn->qport->uuconf_zname, - qsysdep->ibaud)) - fret = FALSE; - - /* Restore the old signal array and the SIGHUP handler. It is - not necessary to block signals here, since all we are doing - is exactly what the signal handler itself would do if the - signal occurred. */ - for (i = 0; i < INDEXSIG_COUNT; i++) - if (afhold[i]) - afSignal[i] = TRUE; - if (! fsighup_ignored) - usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL); - } - - if (qdialer != NULL - && qdialer == &sdialer) - (void) uuconf_dialer_free (puuconf, &sdialer); - -#if ! HAVE_RESET_BUG - /* Reset the terminal to make sure we drop DTR. It should be - dropped when we close the descriptor, but that doesn't seem to - happen on some systems. Use a 30 second timeout to avoid hanging - while draining output. */ - if (qsysdep->fterminal) - { -#if HAVE_BSD_TTY - qsysdep->snew.stty.sg_ispeed = B0; - qsysdep->snew.stty.sg_ospeed = B0; -#endif -#if HAVE_SYSV_TERMIO - qsysdep->snew.c_cflag = (qsysdep->snew.c_cflag &~ CBAUD) | B0; -#endif -#if HAVE_POSIX_TERMIOS - (void) cfsetospeed (&qsysdep->snew, B0); -#endif - - fSalarm = FALSE; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (30); - - (void) fsetterminfodrain (qsysdep->o, &qsysdep->snew); - } - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - /* Let the port settle. */ - sleep (2); - } -#endif /* ! HAVE_RESET_BUG */ - - if (! fsserial_close (qsysdep)) - fret = FALSE; - - return fret; -} - -/* Close a direct port. */ - -/*ARGSUSED*/ -static boolean -fsdirect_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - return fsserial_close ((struct ssysdep_conn *) qconn->psysdep); -} - -/* Begin dialing out on a modem port. This opens the dialer device if - there is one. */ - -boolean -fsysdep_modem_begin_dial (qconn, qdial) - struct sconnection *qconn; - struct uuconf_dialer *qdial; -{ - struct ssysdep_conn *qsysdep; - const char *z; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - -#ifdef TIOCMODEM - /* If we can tell the modem to obey modem control, do so. */ - { - int iperm; - - iperm = 0; - (void) ioctl (qsysdep->o, TIOCMODEM, &iperm); - } -#endif /* TIOCMODEM */ - - /* If we supposed to toggle DTR, do so. */ - - if (qdial->uuconf_fdtr_toggle) - { -#ifdef TIOCCDTR - (void) ioctl (qsysdep->o, TIOCCDTR, 0); - sleep (2); - (void) ioctl (qsysdep->o, TIOCSDTR, 0); -#else /* ! defined (TIOCCDTR) */ - if (qsysdep->fterminal) - { - sterminal sbaud; - - sbaud = qsysdep->snew; - -#if HAVE_BSD_TTY - sbaud.stty.sg_ispeed = B0; - sbaud.stty.sg_ospeed = B0; -#endif -#if HAVE_SYSV_TERMIO - sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0; -#endif -#if HAVE_POSIX_TERMIOS - (void) cfsetospeed (&sbaud, B0); -#endif - - (void) fsetterminfodrain (qsysdep->o, &sbaud); - sleep (2); - (void) fsetterminfo (qsysdep->o, &qsysdep->snew); - } -#endif /* ! defined (TIOCCDTR) */ - - if (qdial->uuconf_fdtr_toggle_wait) - sleep (2); - } - - if (! fsmodem_carrier (qconn, FALSE)) - return FALSE; - - /* Open the dial device if there is one. */ - z = qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdial_device; - if (z != NULL) - { - char *zfree; - int o; - - qsysdep->ohold = qsysdep->o; - - zfree = NULL; - if (*z != '/') - { - zfree = zbufalc (sizeof _PATH_DEV + strlen (z)); - sprintf (zfree, "%s%s", _PATH_DEV, z); - z = zfree; - } - - o = open ((char *) z, O_RDWR | O_NOCTTY); - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", z, strerror (errno)); - ubuffree (zfree); - return FALSE; - } - ubuffree (zfree); - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) close (o); - return FALSE; - } - - qsysdep->o = o; - } - - return TRUE; -} - -/* Tell the port to require or not require carrier. On BSD this uses - TIOCCAR and TIOCNCAR, which I assume are generally supported (it - can also use the LNOMDM bit supported by IS68K Unix). On System V - it resets or sets CLOCAL. We only require carrier if the port - supports it. This will only be called with fcarrier TRUE if the - dialer supports carrier. */ - -static boolean -fsmodem_carrier (qconn, fcarrier) - struct sconnection *qconn; - boolean fcarrier; -{ - register struct ssysdep_conn *q; - struct uuconf_modem_port *qm; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (! q->fterminal) - return TRUE; - - qm = &qconn->qport->uuconf_u.uuconf_smodem; - if (fcarrier) - { - if (qm->uuconf_fcarrier) - { -#ifdef TIOCCAR - /* Tell the modem to pay attention to carrier. */ - if (ioctl (q->o, TIOCCAR, 0) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCCAR): %s", strerror (errno)); - return FALSE; - } -#endif /* TIOCCAR */ - -#if HAVE_BSD_TTY -#ifdef LNOMDM - /* IS68K Unix uses a local LNOMDM bit. */ - { - int iparam; - - iparam = LNOMDM; - if (ioctl (q->o, TIOCLBIC, &iparam) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s", - strerror (errno)); - return FALSE; - } - } -#endif /* LNOMDM */ -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* Put the modem into nonlocal mode. */ - q->snew.c_cflag &=~ CLOCAL; - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't clear CLOCAL: %s", strerror (errno)); - return FALSE; - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - } - - /* Turn on hardware flow control after turning on carrier. We - don't do it until now because some modems don't assert the - right signals until they see carrier. */ - if (! fsserial_hardflow (qconn, qm->uuconf_fhardflow)) - return FALSE; - } - else - { - /* Turn off any hardware flow control before turning off - carrier. */ - if (! fsserial_hardflow (qconn, FALSE)) - return FALSE; - -#ifdef TIOCNCAR - /* Tell the modem to ignore carrier. */ - if (ioctl (q->o, TIOCNCAR, 0) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCNCAR): %s", strerror (errno)); - return FALSE; - } -#endif /* TIOCNCAR */ - -#if HAVE_BSD_TTY -#ifdef LNOMDM - /* IS68K Unix uses a local LNOMDM bit. */ - { - int iparam; - - iparam = LNOMDM; - if (ioctl (q->o, TIOCLBIS, &iparam) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCLBIS, LNOMDM): %s", - strerror (errno)); - return FALSE; - } - } -#endif /* LNOMDM */ -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* Put the modem into local mode (ignore carrier) to start the chat - script. */ - q->snew.c_cflag |= CLOCAL; - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't set CLOCAL: %s", strerror (errno)); - return FALSE; - } - -#if HAVE_CLOCAL_BUG - /* On SCO and AT&T UNIX PC you have to reopen the port. */ - { - int onew; - - onew = open (q->zdevice, O_RDWR); - if (onew < 0) - { - ulog (LOG_ERROR, "open (%s): %s", q->zdevice, strerror (errno)); - return FALSE; - } - - if (fcntl (onew, F_SETFD, - fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) close (onew); - return FALSE; - } - - (void) close (q->o); - q->o = onew; - } -#endif /* HAVE_CLOCAL_BUG */ - -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - } - - return TRUE; -} - -/* Tell the port to use hardware flow control. There is no standard - mechanism for controlling this. This implementation supports - CRTSCTS on SunOS, RTS/CTSFLOW on 386(ish) unix, CTSCD on the 3b1, - CCTS_OFLOW/CRTS_IFLOW on BSDI, TXADDCD/TXDELCD on AIX, and IRTS on - NCR Tower. If you know how to do it on other systems, please - implement it and send me the patches. */ - -static boolean -fsserial_hardflow (qconn, fhardflow) - struct sconnection *qconn; - boolean fhardflow; -{ - register struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (! q->fterminal) - return TRUE; - - /* Don't do anything if we don't know what to do. */ -#if HAVE_BSD_TTY -#define HAVE_HARDFLOW 0 -#endif -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS -#if ! HAVE_TXADDCD -#ifndef CRTSFL -#ifndef CRTSCTS -#ifndef CTSCD -#ifndef CCTS_OFLOW -#ifndef IRTS -#define HAVE_HARDFLOW 0 -#endif -#endif -#endif -#endif -#endif -#endif -#endif - -#ifndef HAVE_HARDFLOW -#define HAVE_HARDFLOW 1 -#endif - -#if HAVE_HARDFLOW - if (fhardflow) - { -#if HAVE_TXADDCD - /* The return value does not reliably indicate whether this - actually succeeded. */ - (void) ioctl (q->o, TXADDCD, "rts"); -#else /* ! HAVE_TXADDCD */ -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS -#ifdef CRTSFL - q->snew.c_cflag |= CRTSFL; - q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW); -#endif /* defined (CRTSFL) */ -#ifdef CRTSCTS - q->snew.c_cflag |= CRTSCTS; -#endif /* defined (CRTSCTS) */ -#ifdef CTSCD - q->snew.c_cflag |= CTSCD; -#endif /* defined (CTSCD) */ -#ifdef CCTS_OFLOW - q->snew.c_cflag |= CCTS_OFLOW | CRTS_IFLOW; -#endif -#ifdef IRTS - q->snew.c_iflag |= IRTS; -#endif -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't enable hardware flow control: %s", - strerror (errno)); - return FALSE; - } -#endif /* ! HAVE_TXADDCD */ - } - else - { -#if HAVE_TXADDCD - /* The return value does not reliably indicate whether this - actually succeeded. */ - (void) ioctl (q->o, TXDELCD, "rts"); -#else /* ! HAVE_TXADDCD */ -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS -#ifdef CRTSFL - q->snew.c_cflag &=~ CRTSFL; - q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW); -#endif /* defined (CRTSFL) */ -#ifdef CRTSCTS - q->snew.c_cflag &=~ CRTSCTS; -#endif /* defined (CRTSCTS) */ -#ifdef CTSCD - q->snew.c_cflag &=~ CTSCD; -#endif /* defined (CTSCD) */ -#ifdef CCTS_OFLOW - q->snew.c_cflag &=~ (CCTS_OFLOW | CRTS_IFLOW); -#endif -#ifdef IRTS - q->snew.c_iflag &=~ IRTS; -#endif -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't disable hardware flow control: %s", - strerror (errno)); - return FALSE; - } -#endif /* ! HAVE_TXADDCD */ - } -#endif /* HAVE_HARDFLOW */ - - return TRUE; -} - -/* Finish dialing out on a modem by closing any dialer device and waiting - for carrier. */ - -boolean -fsysdep_modem_end_dial (qconn, qdial) - struct sconnection *qconn; - struct uuconf_dialer *qdial; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL) - { - (void) close (q->o); - q->o = q->ohold; - } - - if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_fcarrier - && qdial->uuconf_fcarrier) - { - /* Tell the port that we need carrier. */ - if (! fsmodem_carrier (qconn, TRUE)) - return FALSE; - -#ifdef TIOCWONLINE - - /* We know how to wait for carrier, so do so. */ - - /* If we already got a signal, just quit now. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* This bit of code handles signals just like fsysdep_conn_read - does. See that function for a longer explanation. */ - - /* Use fsysdep_catch to handle a longjmp from the signal - handler. */ - - fSalarm = FALSE; - - if (fsysdep_catch ()) - { - /* Start catching SIGALRM; normally we ignore it. */ - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (qdial->uuconf_ccarrier_wait); - - /* We really don't care if we get an error, since that will - probably just mean that TIOCWONLINE isn't supported in - which case there's nothing we can do anyhow. If we get - SIGINT we want to keep waiting for carrier, because - SIGINT just means don't start any new sessions. We don't - handle SIGINT correctly if we do a longjmp in the signal - handler; too bad. */ - while (ioctl (q->o, TIOCWONLINE, 0) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL () || fSalarm) - break; - } - } - - /* Turn off the pending SIGALRM and ignore SIGALARM again. */ - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - /* If we got a random signal, just return FALSE. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* If we timed out, give an error. */ - if (fSalarm) - { - ulog (LOG_ERROR, "Timed out waiting for carrier"); - return FALSE; - } - -#else /* ! defined (TIOCWONLINE) */ - - /* Try to open the port again without using O_NDELAY. In - principle, the open should delay until carrier is available. - This may not work on some systems, so we just ignore any - errors. */ - { - int onew; - - onew = open (q->zdevice, O_RDWR); - if (onew >= 0) - { - boolean fbad; - int iflags; - - fbad = FALSE; - - if (fcntl (onew, F_SETFD, - fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0) - fbad = TRUE; - - if (! fbad) - { - iflags = fcntl (onew, F_GETFL, 0); - if (iflags < 0 - || ! fsetterminfo (onew, &q->snew)) - fbad = TRUE; - } - - if (fbad) - (void) close (onew); - else - { - (void) close (q->o); - q->o = onew; - q->iflags = iflags; -#if HAVE_TIOCSINUSE - (void) ioctl (onew, TIOCSINUSE, 0); -#endif - } - } - } - -#endif /* ! defined (TIOCWONLINE) */ - } - - return TRUE; -} - -/* Read data from a connection, with a timeout. This routine handles - all types of connections, including TLI. - - This function should return when we have read cmin characters or - the timeout has occurred. We have to work a bit to get Unix to do - this efficiently on a terminal. The simple implementation - schedules a SIGALRM signal and then calls read; if there is a - single character available, the call to read will return - immediately, so there must be a loop which terminates when the - SIGALRM is delivered or the correct number of characters has been - read. This can be very inefficient with a fast CPU or a low baud - rate (or both!), since each call to read may return only one or two - characters. - - Under POSIX or System V, we can specify a minimum number of - characters to read, so there is no serious trouble. - - Under BSD, we figure out how many characters we have left to read, - how long it will take for them to arrive at the current baud rate, - and sleep that long. - - Doing this with a timeout and avoiding all possible race conditions - get very hairy, though. Basically, we're going to schedule a - SIGALRM for when the timeout expires. I don't really want to do a - longjmp in the SIGALRM handler, though, because that may lose data. - Therefore, I have the signal handler set a variable. However, this - means that there will be a span of time between the time the code - checks the variable and the time it calls the read system call; if - the SIGALRM occurs during that time, the read might hang forever. - To avoid this, the SIGALRM handler not only sets a global variable, - it also schedules another SIGALRM for one second in the future - (POSIX specifies that a signal handler is permitted to safely call - alarm). To avoid getting a continual sequence of SIGALRM - interrupts, we change the signal handler to ignore SIGALRM when - we're about to exit the function. This means that every time we - execute fsysdep_conn_read we make at least five system calls. It's - the best I've been able to come up with, though. - - When fsysdep_conn_read finishes, there will be no SIGALRM scheduled - and SIGALRM will be ignored. */ - -boolean -fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) - struct sconnection *qconn; - char *zbuf; - size_t *pclen; - size_t cmin; - int ctimeout; - boolean freport; -{ - CATCH_PROTECT size_t cwant; - boolean fret; - register struct ssysdep_conn * const q - = (struct ssysdep_conn *) qconn->psysdep; - int cwouldblock; - - cwant = *pclen; - *pclen = 0; - - /* Guard against a bad timeout. We return TRUE when a timeout - expires. It is possible to get a negative timeout here because - the calling code does not check user supplied timeouts for - plausibility. */ - if (ctimeout <= 0) - return TRUE; - - /* We want to do a blocking read. */ - if (! fsblock (q, TRUE)) - return FALSE; - - fSalarm = FALSE; - - /* We're going to set up an alarm signal to last for the entire - read. If the read system call cannot be interrupted, the signal - handler will do a longjmp causing fsysdep_catch (a macro) to - return FALSE. We handle that here. If read can be interrupted, - fsysdep_catch will be defined to TRUE. */ - if (fsysdep_catch ()) - { - /* Prepare to catch SIGALRM and schedule the signal. */ - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - alarm (ctimeout); - } - else - { - /* We caught a signal. We don't actually have to do anything, - as all the appropriate checks are made at the start of the - following loop. */ - } - - fret = FALSE; - - cwouldblock = 0; - while (TRUE) - { - int cgot; - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* If we can tell the terminal not to return until we have a - certain number of characters, do so. */ - if (q->fterminal) - { - int csetmin; - - /* I'm not that confident about setting MIN to values larger - than 127, although up to 255 would probably work. */ - if (cmin < 127) - csetmin = cmin; - else - csetmin = 127; - - if (csetmin != cSmin) - { - q->snew.c_cc[VMIN] = csetmin; - while (! fsetterminfo (q->o, &q->snew)) - { - if (errno != EINTR - || FGOT_QUIT_SIGNAL ()) - { - int ierr; - - /* We turn off the signal before reporting the - error to minimize any problems with - interrupted system calls. */ - ierr = errno; - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - ulog (LOG_ERROR, "Can't set MIN for terminal: %s", - strerror (ierr)); - return FALSE; - } - - if (fSalarm) - { - ulog (LOG_ERROR, - "Timed out when setting MIN to %d; retrying", - csetmin); - fSalarm = FALSE; - alarm (ctimeout); - } - } - cSmin = csetmin; - } - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - - /* If we've received a signal, get out now. */ - if (FGOT_QUIT_SIGNAL ()) - break; - - /* If we've already gotten a SIGALRM, get out with whatever - we've accumulated. */ - if (fSalarm) - { - fret = TRUE; - break; - } - - /* Right here is the race condition which we avoid by having the - SIGALRM handler schedule another SIGALRM. */ -#if HAVE_TLI - if (q->ftli) - { - int iflags; - - cgot = t_rcv (q->o, zbuf, cwant, &iflags); - if (cgot < 0 && t_errno != TSYSERR) - { - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - - if (freport) - ulog (LOG_ERROR, "t_rcv: %s", - (t_errno >= 0 && t_errno < t_nerr - ? t_errlist[t_errno] - : "unknown TLI error")); - - return FALSE; - } - } - else -#endif - cgot = read (q->o, zbuf, cwant); - - /* If the read returned an error, check for signals. */ - if (cgot < 0) - { - if (errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - } - if (fSalarm) - { - fret = TRUE; - break; - } - if (FGOT_QUIT_SIGNAL ()) - break; - } - - /* If read returned an error, get out. We just ignore EINTR - here, since it must be from some signal we don't care about. - If the read returned 0 then the line must have been hung up - (normally we would have received SIGHUP, but we can't count - on that). We turn off the signals before calling ulog to - reduce problems with interrupted system calls. */ - if (cgot > 0) - cwouldblock = 0; - else - { - if (cgot < 0 && errno == EINTR) - cgot = 0; - else if (cgot < 0 - && (errno == EAGAIN || errno == EWOULDBLOCK) - && cwouldblock < 2) - { - /* Incomprehensibly, on some systems the read will - return EWOULDBLOCK even though the descriptor has - been set to blocking mode. We permit the read call - to do this twice in a row, and then error out. We - don't want to permit an arbitrary number of - EWOULDBLOCK errors, since that could hang us up - indefinitely. */ - ++cwouldblock; - cgot = 0; - } - else - { - int ierr; - - ierr = errno; - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - - if (freport) - { - if (cgot == 0) - ulog (LOG_ERROR, "Line disconnected"); - else - ulog (LOG_ERROR, "read: %s", strerror (ierr)); - } - - return FALSE; - } - } - - cwant -= cgot; - if (cgot >= cmin) - cmin = 0; - else - cmin -= cgot; - zbuf += cgot; - *pclen += cgot; - - /* If we have enough data, get out now. */ - if (cmin == 0) - { - fret = TRUE; - break; - } - -#if HAVE_BSD_TTY - /* We still want more data, so sleep long enough for the rest of - it to arrive. We don't this for System V or POSIX because - setting MIN is good enough (we can't sleep longer than it - takes to get MAX_INPUT characters anyhow). - - The baud rate is approximately 10 times the number of - characters which will arrive in one second, so the number of - milliseconds to sleep == - characters * (milliseconds / character) == - characters * (1000 * (seconds / character)) == - characters * (1000 * (1 / (baud / 10))) == - characters * (10000 / baud) - - We arbitrarily reduce the sleep amount by 10 milliseconds to - attempt to account for the amount of time it takes to set up - the sleep. This is how long it takes to get half a character - at 19200 baud. We then don't bother to sleep for less than - 10 milliseconds. We don't sleep if the read was interrupted. - - We use select to sleep. It would be easy to use poll as - well, but it's unlikely that any system with BSD ttys would - have poll but not select. Using select avoids hassles with - the pending SIGALRM; if it hits the select will be - interrupted, and otherwise the select will not affect it. */ - -#if ! HAVE_SELECT - #error This code requires select; feel free to extend it -#endif - - if (q->fterminal && cmin > 1 && cgot > 0) - { - int csleepchars; - int isleep; - - /* We don't try to read all the way up to MAX_INPUT, - since that might drop a character. */ - if (cmin <= MAX_INPUT - 10) - csleepchars = cmin; - else - csleepchars = MAX_INPUT - 10; - - isleep = (int) (((long) csleepchars * 10000L) / (q->ibaud? q->ibaud: (long)1200)); - isleep -= 10; - - if (isleep > 10) - { - struct timeval s; - - s.tv_sec = isleep / 1000; - s.tv_usec = (isleep % 1000) * 1000; - - /* Some versions of select take a pointer to an int, - while some take a pointer to an fd_set. I just cast - the arguments to a generic pointer, and assume that - any machine which distinguishes int * from fd_set * - (I would be amazed if there are any such machines) - have an appropriate prototype somewhere or other. */ - (void) select (0, (pointer) NULL, (pointer) NULL, - (pointer) NULL, &s); - - /* Here either the select finished sleeping or we got a - SIGALRM. If the latter occurred, fSalarm was set to - TRUE; it will be checked at the top of the loop. */ - } - } -#endif /* HAVE_BSD_TTY */ - } - - /* Turn off the pending SIGALRM and return. */ - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - - return fret; -} - -/* Read from a port with separate read/write file descriptors. */ - -boolean -fsdouble_read (qconn, zbuf, pclen, cmin, ctimeout, freport) - struct sconnection *qconn; - char *zbuf; - size_t *pclen; - size_t cmin; - int ctimeout; - boolean freport; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = qsysdep->ord; - return fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport); -} - -/* Write data to a connection. This routine handles all types of - connections, including TLI. */ - -boolean -fsysdep_conn_write (qconn, zwrite, cwrite) - struct sconnection *qconn; - const char *zwrite; - size_t cwrite; -{ - struct ssysdep_conn *q; - int czero; - - q = (struct ssysdep_conn *) qconn->psysdep; - - /* We want blocking writes here. */ - if (! fsblock (q, TRUE)) - return FALSE; - - czero = 0; - - while (cwrite > 0) - { - int cdid; - - /* Loop until we don't get an interrupt. */ - while (TRUE) - { - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - -#if HAVE_TLI - if (q->ftli) - { - cdid = t_snd (q->o, (char *) zwrite, cwrite, 0); - if (cdid < 0 && t_errno != TSYSERR) - { - ulog (LOG_ERROR, "t_snd: %s", - (t_errno >= 0 && t_errno < t_nerr - ? t_errlist[t_errno] - : "unknown TLI error")); - return FALSE; - } - } - else -#endif - cdid = write (q->o, zwrite, cwrite); - - if (cdid >= 0) - break; - if (errno != EINTR) - break; - - /* We were interrupted by a signal. Log it. */ - ulog (LOG_ERROR, (const char *) NULL); - } - - if (cdid < 0) - { - if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - cdid = 0; - } - - if (cdid == 0) - { - /* On some systems write will return 0 if carrier is lost. - If we fail to write anything ten times in a row, we - assume that this has happened. This is hacked in like - this because there seems to be no reliable way to tell - exactly why the write returned 0. */ - ++czero; - if (czero >= 10) - { - ulog (LOG_ERROR, "Line disconnected"); - return FALSE; - } - } - else - { - czero = 0; - - cwrite -= cdid; - zwrite += cdid; - } - } - - return TRUE; -} - -/* Write to a port with separate read/write file descriptors. */ - -boolean -fsdouble_write (qconn, zwrite, cwrite) - struct sconnection *qconn; - const char *zwrite; - size_t cwrite; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = qsysdep->ord; - if (! fsblock (qsysdep, TRUE)) - return FALSE; - qsysdep->o = qsysdep->owr; - return fsysdep_conn_write (qconn, zwrite, cwrite); -} - -/* The fsysdep_conn_io routine is supposed to both read and write data - until it has either filled its read buffer or written out all the - data it was given. This lets us write out large packets without - losing incoming data. It handles all types of connections, - including TLI. */ - -boolean -fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) - struct sconnection *qconn; - const char *zwrite; - size_t *pcwrite; - char *zread; - size_t *pcread; -{ - struct ssysdep_conn *q; - size_t cwrite, cread; - int czero; - - q = (struct ssysdep_conn *) qconn->psysdep; - - cwrite = *pcwrite; - *pcwrite = 0; - cread = *pcread; - *pcread = 0; - - czero = 0; - - while (TRUE) - { - int cgot, cdid; - size_t cdo; - - /* This used to always use nonblocking writes, but it turns out - that some systems don't support them on terminals. - - The current algorithm is: - loop: - unblocked read - if read buffer full, return - if nothing to write, return - if HAVE_UNBLOCKED_WRITES - write all data - else - write up to SINGLE_WRITE bytes - if all data written, return - if no data written - if select works - select on the write descriptor with a ten second timeout - else - blocked write of one byte with a ten second alarm - - This algorithm should work whether the system supports - unblocked writes on terminals or not. If the system supports - unblocked writes but HAVE_UNBLOCKED_WRITES is 0, then it will - call write more often than it needs to. If the system does - not support unblocked writes but HAVE_UNBLOCKED_WRITES is 1, - then the write may hang so long that incoming data is lost. - This is actually possible at high baud rates on any system - when a blocking write is done; there is no solution, except - hardware handshaking. - - If we were not able to write any data, then we need to block - until we can write something. The code used to simply do a - blocking write. However, that fails when a bidirectional - protocol is permitted to push out enough bytes to fill the - entire pipe between the two communicating uucico processes. - They can both block on writing, because neither is reading. - - In this case, we use select. We could select on both the - read and write descriptor, but on some systems that would - lead to calling read on each byte, which would be very - inefficient. Instead, we select only on the write - descriptor. After the select succeeds or times out, we retry - the read. - - Of course, some systems don't have select, and on some - systems that have it it doesn't work on terminal devices. If - we can't use select, then we do a blocked write of a single - byte after setting an alarm. We only write a single byte to - avoid any confusion as to whether or not the byte was - actually written. */ - - /* If we are running on standard input, we switch the file - descriptors by hand. */ - if (q->ord >= 0) - q->o = q->ord; - - /* Do an unblocked read. */ - if (! fsblock (q, FALSE)) - return FALSE; - - /* Loop until we get something (error or data) other than an - acceptable EINTR. */ - while (TRUE) - { - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - -#if HAVE_TLI - if (q->ftli) - { - int iflags; - - cgot = t_rcv (q->o, zread, cread, &iflags); - if (cgot < 0) - { - if (t_errno == TNODATA) - errno = EAGAIN; - else if (t_errno != TSYSERR) - { - ulog (LOG_ERROR, "t_rcv: %s", - (t_errno >= 0 && t_errno < t_nerr - ? t_errlist[t_errno] - : "unknown TLI error")); - return FALSE; - } - } - } - else -#endif - cgot = read (q->o, zread, cread); - - if (cgot >= 0) - break; - if (errno != EINTR) - break; - - /* We got interrupted by a signal. Log it. */ - ulog (LOG_ERROR, (const char *) NULL); - } - - if (cgot < 0) - { - if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA) - { - ulog (LOG_ERROR, "read: %s", strerror (errno)); - return FALSE; - } - cgot = 0; - } - - cread -= cgot; - zread += cgot; - *pcread += cgot; - - /* If we've filled the read buffer, or we have nothing left to - write, return out. */ - if (cread == 0 || cwrite == 0) - return TRUE; - - /* The port is currently unblocked. Do a write. */ - cdo = cwrite; - -#if ! HAVE_UNBLOCKED_WRITES - if (q->fterminal && cdo > SINGLE_WRITE) - cdo = SINGLE_WRITE; -#endif - - if (q->owr >= 0) - q->o = q->owr; - - /* Loop until we get something besides EINTR. */ - while (TRUE) - { - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - -#if HAVE_TLI - if (q->ftli) - { - cdid = t_snd (q->o, (char *) zwrite, cdo, 0); - if (cdid < 0) - { - if (t_errno == TFLOW) - errno = EAGAIN; - else if (t_errno != TSYSERR) - { - ulog (LOG_ERROR, "t_snd: %s", - (t_errno >= 0 && t_errno < t_nerr - ? t_errlist[t_errno] - : "unknown TLI error")); - return FALSE; - } - } - } - else -#endif - cdid = write (q->o, zwrite, cdo); - - if (cdid >= 0) - break; - if (errno != EINTR) - break; - - /* We got interrupted by a signal. Log it. */ - ulog (LOG_ERROR, (const char *) NULL); - } - - if (cdid < 0) - { - if (errno != EAGAIN && errno != EWOULDBLOCK && errno != ENODATA) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - cdid = 0; - } - - if (cdid > 0) - { - /* We wrote some data. If we wrote everything, return out. - Otherwise loop around and do another read. */ - cwrite -= cdid; - zwrite += cdid; - *pcwrite += cdid; - - if (cwrite == 0) - return TRUE; - - czero = 0; - } - else - { -#if HAVE_SELECT - struct timeval stime; - int imask; - int c; - - /* We didn't write any data. Call select. We use a timeout - long enough for 1024 bytes to be sent. - secs/kbyte == (1024 bytes/kbyte * 10 bits/byte) / baud bits/sec - usecs/kbyte == (((1024 bytes/kbyte * 1000000 usecs/sec) - / baud bits/sec) - * 10 bits/byte) - */ - stime.tv_sec = (long) 10240 / (q->ibaud? q->ibaud: (long)1200); - stime.tv_usec = ((((long) 1024000000 / (q->ibaud? q->ibaud: (long)1200)) * (long) 10) - % (long) 1000000); - - imask = 1 << q->o; - if (imask == 0) - ulog (LOG_FATAL, "fsysdep_conn_io: File descriptors too large"); - - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - DEBUG_MESSAGE0 (DEBUG_PORT, "fsysdep_conn_io: Calling select"); - - /* We don't bother to loop on EINTR. If we get a signal, we - just loop around and try the read and write again. */ - c = select (q->o + 1, (pointer) NULL, (pointer) &imask, - (pointer) NULL, &stime); - if (c < 0 && errno == EINTR) - { - /* We got interrupted by a signal. Log it. */ - ulog (LOG_ERROR, (const char *) NULL); - } - else if (c >= 0) - { - /* The select either discovered that we could write - something, or it timed out. Either way, we go around - the main read/write loop again. */ - } - else -#endif /* HAVE_SELECT */ - { - int ierr; - - /* Either the select failed for some reason other than - EINTR, or the system does not support select at all. - Fall back on a timed write. We don't worry about why - the select might have failed, we just assume that it - will not succeed on this descriptor. */ - -#if HAVE_RESTARTABLE_SYSCALLS - /* If HAVE_RESTARTABLE_SYSCALLS, then receiving an alarm - signal in the middle of a write will not cause the - write to return EINTR, and the only way to interrupt - the write is to longjmp out of it (see sysh.unx). - That is unreliable, because it means that we won't - know whether the byte was actually written or not. - However, I believe that the only system on which we - need to do this longjmp is BSD 4.2, and that system - supports select, so we should never execute this - case. */ - ulog (LOG_FATAL, "fsysdep_conn_io: Unsupported case; see code"); -#endif - - if (q->ord >= 0) - q->o = q->ord; - - if (! fsblock (q, TRUE)) - return FALSE; - - DEBUG_MESSAGE0 (DEBUG_PORT, "fsysdep_conn_io: Blocking write"); - - if (q->owr >= 0) - q->o = q->owr; - - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* Start up an alarm to interrupt the write. Note that - we don't need to use the catch stuff, since we know - that HAVE_RESTARTABLE_SYSCALLS is 0. */ - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - alarm ((int) ((long) 10240 / (q->ibaud? q->ibaud: (long)1200)) + 1); - - /* There is a race condition here: on a severely loaded - system, we could get the alarm before we start the - write call. This would not be a disaster; often the - write will succeed anyhow. */ -#if HAVE_TLI - if (q->ftli) - { - cdid = t_snd (q->o, (char *) zwrite, 1, 0); - if (cdid < 0 && t_errno != TSYSERR) - { - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - ulog (LOG_ERROR, "t_snd: %s", - (t_errno >= 0 && t_errno < t_nerr - ? t_errlist[t_errno] - : "unknown TLI error")); - return FALSE; - } - } - else -#endif - cdid = write (q->o, zwrite, 1); - - ierr = errno; - - /* Note that we don't really care whether the write - finished because the byte was written out or whether - it finished because the alarm was triggered. Either - way, we are going to loop around and try another - read. */ - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - - if (cdid < 0) - { - if (ierr == EINTR) - { - /* We got interrupted by a signal. Log it. */ - ulog (LOG_ERROR, (const char *) NULL); - } - else - { - ulog (LOG_ERROR, "write: %s", strerror (ierr)); - return FALSE; - } - } - else if (cdid == 0) - { - /* On some systems write will return 0 if carrier is - lost. If we fail to write anything ten times in - a row, we assume that this has happened. This is - hacked in like this because there seems to be no - reliable way to tell exactly why the write - returned 0. */ - ++czero; - if (czero >= 10) - { - ulog (LOG_ERROR, "Line disconnected"); - return FALSE; - } - } - else - { - cwrite -= cdid; - zwrite += cdid; - *pcwrite += cdid; - czero = 0; - } - } - } - } -} - -/* Send a break character to a serial port. */ - -static boolean -fsserial_break (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) qconn->psysdep; - -#if HAVE_BSD_TTY - (void) ioctl (q->o, TIOCSBRK, 0); - sleep (2); - (void) ioctl (q->o, TIOCCBRK, 0); - return TRUE; -#endif /* HAVE_BSD_TTY */ -#if HAVE_SYSV_TERMIO - (void) ioctl (q->o, TCSBRK, 0); - return TRUE; -#endif /* HAVE_SYSV_TERMIO */ -#if HAVE_POSIX_TERMIOS - return tcsendbreak (q->o, 0) == 0; -#endif /* HAVE_POSIX_TERMIOS */ -} - -/* Send a break character to a stdin port. */ - -static boolean -fsstdin_break (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = qsysdep->owr; - return fsserial_break (qconn); -} - -/* Change the setting of a serial port. */ - -/*ARGSUSED*/ -static boolean -fsserial_set (qconn, tparity, tstrip, txonxoff) - struct sconnection *qconn; - enum tparitysetting tparity; - enum tstripsetting tstrip; - enum txonxoffsetting txonxoff; -{ - register struct ssysdep_conn *q; - boolean fchanged, fdo; - int iset = 0; - int iclear = 0; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (! q->fterminal) - return TRUE; - - fchanged = FALSE; - - /* Set the parity for output characters. */ - -#if HAVE_BSD_TTY - - /* This will also cause parity detection on input characters. */ - - fdo = FALSE; - switch (tparity) - { - case PARITYSETTING_DEFAULT: - break; - case PARITYSETTING_NONE: -#if HAVE_PARITY_BUG - /* The Sony NEWS mishandles this for some reason. */ - iset = 0; - iclear = ANYP; -#else - iset = ANYP; - iclear = 0; -#endif - fdo = TRUE; - break; - case PARITYSETTING_EVEN: - iset = EVENP; - iclear = ODDP; - fdo = TRUE; - break; - case PARITYSETTING_ODD: - iset = ODDP; - iclear = EVENP; - fdo = TRUE; - break; - case PARITYSETTING_MARK: - case PARITYSETTING_SPACE: - /* Not supported. */ - break; - } - - if (fdo) - { - if ((q->snew.stty.sg_flags & iset) != iset - || (q->snew.stty.sg_flags & iclear) != 0) - { - q->snew.stty.sg_flags |= iset; - q->snew.stty.sg_flags &=~ iclear; - fchanged = TRUE; - } - } - -#else /* ! HAVE_BSD_TTY */ - - fdo = FALSE; - switch (tparity) - { - case PARITYSETTING_DEFAULT: - break; - case PARITYSETTING_NONE: - iset = CS8; - iclear = PARENB | PARODD | (CSIZE &~ CS8); - fdo = TRUE; - break; - case PARITYSETTING_EVEN: - iset = PARENB | CS7; - iclear = PARODD | (CSIZE &~ CS7); - fdo = TRUE; - break; - case PARITYSETTING_ODD: - iset = PARENB | PARODD | CS7; - iclear = CSIZE &~ CS7; - fdo = TRUE; - break; - case PARITYSETTING_MARK: - case PARITYSETTING_SPACE: - /* Not supported. */ - break; - } - - if (fdo) - { - if ((q->snew.c_cflag & iset) != iset - || (q->snew.c_cflag & iclear) != 0) - { - q->snew.c_cflag |= iset; - q->snew.c_cflag &=~ iclear; - fchanged = TRUE; - } - } - -#endif /* ! HAVE_BSD_TTY */ - - /* Set whether input characters are stripped to seven bits. */ - -#if HAVE_BSD_TTY - -#ifdef LPASS8 - { - int i; - - i = LPASS8; - if (tstrip == STRIPSETTING_EIGHTBITS) - { - i = LPASS8; - (void) ioctl (q->o, TIOCLBIS, &i); - } - else if (tstrip == STRIPSETTING_SEVENBITS) - { - i = LPASS8; - (void) ioctl (q->o, TIOCLBIC, &i); - } - } -#endif - -#else /* ! HAVE_BSD_TTY */ - - fdo = FALSE; - switch (tstrip) - { - case STRIPSETTING_DEFAULT: - break; - case STRIPSETTING_EIGHTBITS: - iset = 0; - iclear = ISTRIP; - fdo = TRUE; - break; - case STRIPSETTING_SEVENBITS: - iset = ISTRIP; - iclear = 0; - fdo = TRUE; - break; - } - - if (fdo) - { - if ((q->snew.c_iflag & iset) != iset - || (q->snew.c_iflag & iclear) != 0) - { - q->snew.c_iflag |= iset; - q->snew.c_iflag &=~ iclear; - fchanged = TRUE; - } - } - -#endif /* ! HAVE_BSD_TTY */ - - /* Set XON/XOFF handshaking. */ - -#if HAVE_BSD_TTY - - fdo = FALSE; - switch (txonxoff) - { - case XONXOFF_DEFAULT: - break; - case XONXOFF_OFF: - iset = RAW; - iclear = TANDEM | CBREAK; - fdo = TRUE; - break; - case XONXOFF_ON: - iset = CBREAK | TANDEM; - iclear = RAW; - fdo = TRUE; - break; - } - - if (fdo) - { - if ((q->snew.stty.sg_flags & iset) != iset - || (q->snew.stty.sg_flags & iclear) != 0) - { - q->snew.stty.sg_flags |= iset; - q->snew.stty.sg_flags &=~ iclear; - fchanged = TRUE; - } - } - -#else /* ! HAVE_BSD_TTY */ - - fdo = FALSE; - switch (txonxoff) - { - case XONXOFF_DEFAULT: - break; - case XONXOFF_OFF: - iset = 0; - iclear = IXON | IXOFF; - fdo = TRUE; - break; - case XONXOFF_ON: -#ifdef CRTSCTS -#if HAVE_POSIX_TERMIOS - /* This is system dependent, but I haven't figured out a good - way around it yet. If we are doing hardware flow control, we - don't send XON/XOFF characters but we do recognize them. */ - if ((q->snew.c_cflag & CRTSCTS) != 0) - { - iset = IXON; - iclear = IXOFF; - fdo = TRUE; - break; - } -#endif /* HAVE_POSIX_TERMIOS */ -#endif /* defined (CRTSCTS) */ -#ifdef CRTSFL - if ((q->snew.c_cflag & CRTSFL) != 0) - { - iset = IXON; - iclear = IXOFF; - /* SCO says we cant have CRTSFL **and** RTSFLOW/CTSFLOW */ -#ifdef RTSFLOW - iclear |= RTSFLOW; -#endif -#ifdef CTSFLOW - iclear |= CTSFLOW; -#endif - fdo = TRUE; - break; - } -#endif /* defined(CRTSFL) */ - iset = IXON | IXOFF; - iclear = 0; - fdo = TRUE; - break; - } - - if (fdo) - { - if ((q->snew.c_iflag & iset) != iset - || (q->snew.c_iflag & iclear) != 0) - { - q->snew.c_iflag |= iset; - q->snew.c_iflag &=~ iclear; - fchanged = TRUE; - } - } - -#endif /* ! HAVE_BSD_TTY */ - - if (fchanged) - { - if (! fsetterminfodrain (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't change terminal settings: %s", - strerror (errno)); - return FALSE; - } - } - -#if HAVE_BSD_TTY - if (txonxoff == XONXOFF_ON - && (q->snew.stty.sg_flags & ANYP) == ANYP) - { - int i; - - /* At least on Ultrix, we seem to have to set LLITOUT and - LPASS8. This shouldn't foul things up anywhere else. As far - as I can tell, this has to be done after setting the terminal - into cbreak mode, not before. */ -#ifndef LLITOUT -#define LLITOUT 0 -#endif -#ifndef LPASS8 -#define LPASS8 0 -#endif -#ifndef LAUTOFLOW -#define LAUTOFLOW 0 -#endif - i = LLITOUT | LPASS8 | LAUTOFLOW; - (void) ioctl (q->o, TIOCLBIS, &i); - -#if HAVE_STRIP_BUG - /* Ultrix 4.0 has a peculiar problem: setting CBREAK always - causes input characters to be stripped. I hope this does not - apply to other BSD systems. It is possible to work around - this by using the termio call. I wish this sort of stuff was - not necessary!!! */ - { - struct termio s; - - if (ioctl (q->o, TCGETA, &s) >= 0) - { - s.c_iflag &=~ ISTRIP; - (void) ioctl (q->o, TCSETA, &s); - } - } -#endif /* HAVE_STRIP_BUG */ - } -#endif /* HAVE_BSD_TTY */ - - return TRUE; -} - -/* Change settings of a stdin port. */ - -static boolean -fsstdin_set (qconn, tparity, tstrip, txonxoff) - struct sconnection *qconn; - enum tparitysetting tparity; - enum tstripsetting tstrip; - enum txonxoffsetting txonxoff; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = qsysdep->ord; - return fsserial_set (qconn, tparity, tstrip, txonxoff); -} - -/* Run a chat program. */ - -static boolean -fsrun_chat (oread, owrite, pzprog) - int oread; - int owrite; - char **pzprog; -{ - int aidescs[3]; - FILE *e; - pid_t ipid; - char *z; - size_t c; - - aidescs[0] = oread; - aidescs[1] = owrite; - aidescs[2] = SPAWN_READ_PIPE; - - /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the - responsibility of maintaing security on the chat program. */ - ipid = ixsspawn ((const char **) pzprog, aidescs, TRUE, TRUE, - (const char *) NULL, FALSE, TRUE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno)); - return FALSE; - } - - e = fdopen (aidescs[2], (char *) "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen: %s", strerror (errno)); - (void) close (aidescs[2]); - (void) kill (ipid, SIGKILL); - (void) ixswait ((unsigned long) ipid, (const char *) NULL); - return FALSE; - } - - /* The FILE e now is attached to stderr of the program. Forward - every line the program outputs to the log file. */ - z = NULL; - c = 0; - while (getline (&z, &c, e) > 0) - { - size_t clen; - - clen = strlen (z); - if (z[clen - 1] == '\n') - z[clen - 1] = '\0'; - if (*z != '\0') - ulog (LOG_NORMAL, "chat: %s", z); - } - - xfree ((pointer) z); - (void) fclose (e); - - return ixswait ((unsigned long) ipid, "Chat program") == 0; -} - -/* Run a chat program on a port using separate read/write file - descriptors. */ - -boolean -fsdouble_chat (qconn, pzprog) - struct sconnection *qconn; - char **pzprog; -{ - struct ssysdep_conn *qsysdep; - boolean fret; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - fret = fsrun_chat (qsysdep->ord, qsysdep->owr, pzprog); - if (qsysdep->fterminal) - (void) fgetterminfo (qsysdep->ord, &qsysdep->snew); - return fret; -} - -/* Run a chat program on any general type of connection. */ - -boolean -fsysdep_conn_chat (qconn, pzprog) - struct sconnection *qconn; - char **pzprog; -{ - struct ssysdep_conn *qsysdep; - boolean fret; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - fret = fsrun_chat (qsysdep->o, qsysdep->o, pzprog); - if (qsysdep->fterminal) - (void) fgetterminfo (qsysdep->o, &qsysdep->snew); - return fret; -} - -/* Return baud rate of a serial port. */ - -static long -isserial_baud (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - return qsysdep->ibaud; -} diff --git a/gnu/libexec/uucp/libunix/signal.c b/gnu/libexec/uucp/libunix/signal.c deleted file mode 100644 index 6aa899b26dbf..000000000000 --- a/gnu/libexec/uucp/libunix/signal.c +++ /dev/null @@ -1,208 +0,0 @@ -/* signal.c - Signal handling routines. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -/* Signal handling routines. When we catch a signal, we want to set - the appropriate elements of afSignal and afLog_signal to TRUE. If - we are on a system which restarts system calls, we may also want to - longjmp out. On a system which does not restart system calls, - these signal handling routines are well-defined by ANSI C. */ - -#if HAVE_RESTARTABLE_SYSCALLS -volatile sig_atomic_t fSjmp; -volatile jmp_buf sSjmp_buf; -#endif /* HAVE_RESTARTABLE_SYSCALLS */ - -/* Some systems, such as SunOS, have a SA_INTERRUPT bit that must be - set in the sigaction structure to force system calls to be - interrupted. */ -#ifndef SA_INTERRUPT -#define SA_INTERRUPT 0 -#endif - -/* The SVR3 sigset function can be called just like signal, unless - system calls are restarted which is extremely unlikely; we prevent - this case in sysh.unx. */ -#if HAVE_SIGSET && ! HAVE_SIGACTION && ! HAVE_SIGVEC -#define signal sigset -#endif - -/* The sigvec structure changed from 4.2BSD to 4.3BSD. These macros - make the 4.3 code backward compatible. */ -#ifndef SV_INTERRUPT -#define SV_INTERRUPT 0 -#endif -#if ! HAVE_SIGVEC_SV_FLAGS -#define sv_flags sv_onstack -#endif - -/* Catch a signal. Reinstall the signal handler if necessary, set the - appropriate variables, and do a longjmp if necessary. */ - -RETSIGTYPE -ussignal (isig) - int isig; -{ - int iindex; - -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, ussignal); -#endif - - switch (isig) - { - default: iindex = INDEXSIG_SIGHUP; break; -#ifdef SIGINT - case SIGINT: iindex = INDEXSIG_SIGINT; break; -#endif -#ifdef SIGQUIT - case SIGQUIT: iindex = INDEXSIG_SIGQUIT; break; -#endif -#ifdef SIGTERM - case SIGTERM: iindex = INDEXSIG_SIGTERM; break; -#endif -#ifdef SIGPIPE - case SIGPIPE: iindex = INDEXSIG_SIGPIPE; break; -#endif - } - - afSignal[iindex] = TRUE; - afLog_signal[iindex] = TRUE; - -#if HAVE_RESTARTABLE_SYSCALLS - if (fSjmp) - longjmp (sSjmp_buf, 1); -#endif /* HAVE_RESTARTABLE_SYSCALLS */ -} - -/* Prepare to catch a signal. This is basically the ANSI C routine - signal, but it uses sigaction or sigvec instead if they are - available. If fforce is FALSE, we do not set the signal if it is - currently being ignored. If pfignored is not NULL and fforce is - FALSE, then *pfignored will be set to TRUE if the signal was - previously being ignored (if fforce is TRUE the value returned in - *pfignored is meaningless). If we can't change the signal handler - we give a fatal error. */ - -void -usset_signal (isig, pfn, fforce, pfignored) - int isig; - RETSIGTYPE (*pfn) P((int)); - boolean fforce; - boolean *pfignored; -{ -#if HAVE_SIGACTION - - struct sigaction s; - - if (! fforce) - { - (void) (sigemptyset (&s.sa_mask)); - if (sigaction (isig, (struct sigaction *) NULL, &s) != 0) - ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno)); - - if (s.sa_handler == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - s.sa_handler = pfn; - (void) (sigemptyset (&s.sa_mask)); - s.sa_flags = SA_INTERRUPT; - - if (sigaction (isig, &s, (struct sigaction *) NULL) != 0) - ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno)); - -#else /* ! HAVE_SIGACTION */ -#if HAVE_SIGVEC - - struct sigvec s; - - if (! fforce) - { - if (sigvec (isig, (struct sigvec *) NULL, &s) != 0) - ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno)); - - if (s.sv_handler == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - s.sv_handler = pfn; - s.sv_mask = 0; - s.sv_flags = SV_INTERRUPT; - - if (sigvec (isig, &s, (struct sigvec *) NULL) != 0) - ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno)); - -#else /* ! HAVE_SIGVEC */ - - if (! fforce) - { - if (signal (isig, SIG_IGN) == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - (void) signal (isig, pfn); - -#endif /* ! HAVE_SIGVEC */ -#endif /* ! HAVE_SIGACTION */ -} - -/* The routine called by the system independent code, which always - uses the same signal handler. */ - -void -usysdep_signal (isig) - int isig; -{ - usset_signal (isig, ussignal, FALSE, (boolean *) NULL); -} diff --git a/gnu/libexec/uucp/libunix/sindir.c b/gnu/libexec/uucp/libunix/sindir.c deleted file mode 100644 index 7c9da50045ff..000000000000 --- a/gnu/libexec/uucp/libunix/sindir.c +++ /dev/null @@ -1,29 +0,0 @@ -/* sindir.c - Stick a directory and file name together. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -char * -zsysdep_in_dir (zdir, zfile) - const char *zdir; - const char *zfile; -{ - size_t cdir, cfile; - char *zret; - - cdir = strlen (zdir); - cfile = strlen (zfile); - zret = zbufalc (cdir + cfile + 2); - if (cdir == 1 && *zdir == '/') - cdir = 0; - else - memcpy (zret, zdir, cdir); - memcpy (zret + cdir + 1, zfile, cfile); - zret[cdir] = '/'; - zret[cdir + cfile + 1] = '\0'; - return zret; -} diff --git a/gnu/libexec/uucp/libunix/sleep.c b/gnu/libexec/uucp/libunix/sleep.c deleted file mode 100644 index 910c9292e198..000000000000 --- a/gnu/libexec/uucp/libunix/sleep.c +++ /dev/null @@ -1,26 +0,0 @@ -/* sleep.c - Sleep for a number of seconds. */ - -#include "uucp.h" - -#include "sysdep.h" -#include "system.h" - -void -usysdep_sleep (c) - int c; -{ -#if HAVE_NAPMS || HAVE_NAP || HAVE_USLEEP || HAVE_SELECT || HAVE_POLL - int i; - - /* In this case, usysdep_pause is accurate. */ - for (i = 2 * c; i > 0; i--) - usysdep_pause (); -#else - /* On some system sleep (1) may not sleep at all. Avoid this sort - of problem by always doing at least sleep (2). */ - if (c < 2) - c = 2; - (void) sleep (c); -#endif -} diff --git a/gnu/libexec/uucp/libunix/spawn.c b/gnu/libexec/uucp/libunix/spawn.c deleted file mode 100644 index 6a413c48a063..000000000000 --- a/gnu/libexec/uucp/libunix/spawn.c +++ /dev/null @@ -1,456 +0,0 @@ -/* spawn.c - Spawn a program securely. - - Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* $FreeBSD$ */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -#include -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#ifndef environ -extern char **environ; -#endif - -/* Spawn a child in a fairly secure fashion. This returns the process - ID of the child or -1 on error. It takes far too many arguments: - - pazargs -- arguments (element 0 is command) - aidescs -- file descriptors for stdin, stdout and stderr - fkeepuid -- TRUE if euid should be left unchanged - fkeepenv -- TRUE if environment should be left unmodified - zchdir -- directory to chdir to - fnosigs -- TRUE if child should ignore SIGHUP, SIGINT and SIGQUIT - fshell -- TRUE if should try /bin/sh if execve gets ENOEXEC - zpath -- value for environment variable PATH - zuu_machine -- value for environment variable UU_MACHINE - zuu_user -- value for environment variable UU_USER - - The aidescs array is three elements long. 0 is stdin, 1 is stdout - and 2 is stderr. The array may contain either file descriptor - numbers to dup appropriately, or one of the following: - - SPAWN_NULL -- set descriptor to /dev/null - SPAWN_READ_PIPE -- set aidescs element to pipe for parent to read - SPAWN_WRITE_PIPE -- set aidescs element to pipe for parent to write - - If fkeepenv is FALSE, a standard environment is created. The - environment arguments (zpath, zuu_machine and zuu_user) are only - used if fkeepenv is FALSE; any of them may be NULL. - - This routine expects that all file descriptors have been set to - close-on-exec, so it doesn't have to worry about closing them - explicitly. It sets the close-on-exec flag for the new pipe - descriptors it returns. */ - -pid_t -ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, - zpath, zuu_machine, zuu_user) - const char **pazargs; - int aidescs[3]; - boolean fkeepuid; - boolean fkeepenv; - const char *zchdir; - boolean fnosigs; - boolean fshell; - const char *zpath; - const char *zuu_machine; - const char *zuu_user; -{ - char *zshcmd; - int i; - char *azenv[9]; - char **pazenv; - boolean ferr; -#if HAVE_FULLDUPLEX_PIPES - boolean ffullduplex; -#endif - int ierr = 0; - int onull; - int aichild_descs[3]; - int cpar_close; - int aipar_close[4]; - int cchild_close; - int aichild_close[3]; - pid_t iret = 0; - const char *zcmd; - - /* If we might have to use the shell, allocate enough space for the - quoted command before forking. Otherwise the allocation would - modify the data segment and we could not safely use vfork. */ - zshcmd = NULL; - if (fshell) - { - size_t clen; - - clen = 0; - for (i = 0; pazargs[i] != NULL; i++) - clen += strlen (pazargs[i]); - zshcmd = zbufalc (2 * clen + i); - } - - /* Set up a standard environment. This is again done before forking - because it will modify the data segment. */ - if (fkeepenv) - pazenv = environ; - else - { - const char *zterm, *ztz; - char *zspace; - int ienv; - - if (zpath == NULL) - zpath = CMDPATH; - - azenv[0] = zbufalc (sizeof "PATH=" + strlen (zpath)); - sprintf (azenv[0], "PATH=%s", zpath); - zspace = azenv[0] + sizeof "PATH=" - 1; - while ((zspace = strchr (zspace, ' ')) != NULL) - *zspace = ':'; - - azenv[1] = zbufalc (sizeof "HOME=" + strlen (zSspooldir)); - sprintf (azenv[1], "HOME=%s", zSspooldir); - - zterm = getenv ("TERM"); - if (zterm == NULL) - zterm = "unknown"; - azenv[2] = zbufalc (sizeof "TERM=" + strlen (zterm)); - sprintf (azenv[2], "TERM=%s", zterm); - - azenv[3] = zbufcpy ("SHELL=/bin/sh"); - - azenv[4] = zbufalc (sizeof "USER=" + strlen (OWNER)); - sprintf (azenv[4], "USER=%s", OWNER); - - ienv = 5; - - ztz = getenv ("TZ"); - if (ztz != NULL) - { - azenv[ienv] = zbufalc (sizeof "TZ=" + strlen (ztz)); - sprintf (azenv[ienv], "TZ=%s", ztz); - ++ienv; - } - - if (zuu_machine != NULL) - { - azenv[ienv] = zbufalc (sizeof "UU_MACHINE=" - + strlen (zuu_machine)); - sprintf (azenv[ienv], "UU_MACHINE=%s", zuu_machine); - ++ienv; - } - - if (zuu_user != NULL) - { - azenv[ienv] = zbufalc (sizeof "UU_USER=" - + strlen (zuu_user)); - sprintf (azenv[ienv], "UU_USER=%s", zuu_user); - ++ienv; - } - - azenv[ienv] = NULL; - pazenv = azenv; - } - - /* Set up any needed pipes. */ - - ferr = FALSE; - onull = -1; - cpar_close = 0; - cchild_close = 0; - -#if HAVE_FULLDUPLEX_PIPES - ffullduplex = (aidescs[0] == SPAWN_WRITE_PIPE - && aidescs[1] == SPAWN_READ_PIPE); -#endif - - for (i = 0; i < 3; i++) - { - if (aidescs[i] == SPAWN_NULL) - { - if (onull < 0) - { - onull = open ((char *) _PATH_DEVNULL, O_RDWR); - if (onull < 0 - || fcntl (onull, F_SETFD, - fcntl (onull, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ierr = errno; - (void) close (onull); - ferr = TRUE; - break; - } - aipar_close[cpar_close] = onull; - ++cpar_close; - } - aichild_descs[i] = onull; - } - else if (aidescs[i] != SPAWN_READ_PIPE - && aidescs[i] != SPAWN_WRITE_PIPE) - aichild_descs[i] = aidescs[i]; - else - { - int aipipe[2]; - -#if HAVE_FULLDUPLEX_PIPES - if (ffullduplex && i == 1) - { - /* Just use the fullduplex pipe. */ - aidescs[i] = aidescs[0]; - aichild_descs[i] = aichild_descs[0]; - continue; - } -#endif - - if (pipe (aipipe) < 0) - { - ierr = errno; - ferr = TRUE; - break; - } - - if (aidescs[i] == SPAWN_READ_PIPE) - { - aidescs[i] = aipipe[0]; - aichild_close[cchild_close] = aipipe[0]; - aichild_descs[i] = aipipe[1]; - aipar_close[cpar_close] = aipipe[1]; - } - else - { - aidescs[i] = aipipe[1]; - aichild_close[cchild_close] = aipipe[1]; - aichild_descs[i] = aipipe[0]; - aipar_close[cpar_close] = aipipe[0]; - } - - ++cpar_close; - ++cchild_close; - - if (fcntl (aipipe[0], F_SETFD, - fcntl (aipipe[0], F_GETFD, 0) | FD_CLOEXEC) < 0 - || fcntl (aipipe[1], F_SETFD, - fcntl (aipipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ierr = errno; - ferr = TRUE; - break; - } - } - } - -#if DEBUG > 1 - if (! ferr && FDEBUGGING (DEBUG_EXECUTE)) - { - ulog (LOG_DEBUG_START, "Forking %s", pazargs[0]); - for (i = 1; pazargs[i] != NULL; i++) - ulog (LOG_DEBUG_CONTINUE, " %s", pazargs[i]); - ulog (LOG_DEBUG_END, "%s", ""); - } -#endif - - if (! ferr) - { - /* This should really be vfork if available. */ - iret = ixsfork (); - if (iret < 0) - { - ferr = TRUE; - ierr = errno; - } - } - - if (ferr) - { - for (i = 0; i < cchild_close; i++) - (void) close (aichild_close[i]); - iret = -1; - } - - if (iret != 0) - { - /* The parent. Close the child's ends of the pipes and return - the process ID, or an error. */ - for (i = 0; i < cpar_close; i++) - (void) close (aipar_close[i]); - ubuffree (zshcmd); - if (! fkeepenv) - { - char **pz; - - for (pz = azenv; *pz != NULL; pz++) - ubuffree (*pz); - } - errno = ierr; - return iret; - } - - /* The child. */ - -#ifdef STDIN_FILENO -#if STDIN_FILENO != 0 || STDOUT_FILENO != 1 || STDERR_FILENO != 2 - #error The following code makes invalid assumptions -#endif -#endif - - for (i = 0; i < 3; i++) - { - if (aichild_descs[i] != i) - (void) dup2 (aichild_descs[i], i); - /* This should only be necessary if aichild_descs[i] == i, but - some systems copy the close-on-exec flag for a dupped - descriptor, which is wrong according to POSIX. */ - (void) fcntl (i, F_SETFD, fcntl (i, F_GETFD, 0) &~ FD_CLOEXEC); - } - - zcmd = pazargs[0]; - pazargs[0] = strrchr (zcmd, '/'); - if (pazargs[0] == NULL) - pazargs[0] = zcmd; - else - ++pazargs[0]; - - if (! fkeepuid) - { - /* Return to the uid of the invoking user. */ - (void) setuid (getuid ()); - (void) setgid (getgid ()); - } - else - { - /* Try to force the UUCP uid to be both real and effective user - ID, in order to present a consistent environment regardless - of the invoking user. This won't work on older System V - based systems, where it can cause trouble if ordinary users - wind up executing uuxqt, perhaps via uucico; any program - which uuxqt executes will have an arbitrary real user ID, so - if the program is itself a setuid program, any security - checks it does based on the real user ID will be incorrect. - Fixing this problem would seem to require a special setuid - root program; I have not used this approach because - modern systems should not suffer from it. */ -#if HAVE_SETREUID - (void) setreuid (geteuid (), -1); - (void) setregid (getegid (), -1); -#else - (void) setuid (geteuid ()); - (void) setgid (getegid ()); -#endif - } - - if (zchdir != NULL) - (void) chdir (zchdir); - - if (fnosigs) - { -#ifdef SIGHUP - (void) signal (SIGHUP, SIG_IGN); -#endif -#ifdef SIGINT - (void) signal (SIGINT, SIG_IGN); -#endif -#ifdef SIGQUIT - (void) signal (SIGQUIT, SIG_IGN); -#endif - } - -#ifdef isc386 -#ifdef _POSIX_SOURCE - /* ISC has a remarkably stupid notion of environments. If a program - is compiled in the POSIX environment, it sets a process state. - If you then exec a program which expects the USG environment, the - process state is not reset, so the execed program fails. The - __setostype call is required to change back to the USG - environment. This ought to be a switch in policy.h, but it seems - too trivial, so I will leave this code here and wait for it to - break in some fashion in the next version of ISC. */ - __setostype (0); -#endif -#endif - - (void) execve ((char *) zcmd, (char **) pazargs, pazenv); - - /* The exec failed. If permitted, try using /bin/sh to execute a - shell script. */ - if (errno == ENOEXEC && fshell) - { - char *zto; - const char *azshargs[4]; - - pazargs[0] = zcmd; - zto = zshcmd; - for (i = 0; pazargs[i] != NULL; i++) - { - const char *zfrom; - - for (zfrom = pazargs[i]; *zfrom != '\0'; zfrom++) - { - /* Some versions of /bin/sh appear to have a bug such - that quoting a '/' sometimes causes an error. I - don't know exactly when this happens (I can recreate - it on Ultrix 4.0), but in any case it is harmless to - not quote a '/'. */ - if (*zfrom != '/') - *zto++ = '\\'; - *zto++ = *zfrom; - } - *zto++ = ' '; - } - *(zto - 1) = '\0'; - - azshargs[0] = "sh"; - azshargs[1] = "-c"; - azshargs[2] = zshcmd; - azshargs[3] = NULL; - - (void) execve ((char *) "/bin/sh", (char **) azshargs, pazenv); - } - - _exit (EXIT_FAILURE); - - /* Avoid compiler warning. */ - return -1; -} diff --git a/gnu/libexec/uucp/libunix/sync.c b/gnu/libexec/uucp/libunix/sync.c deleted file mode 100644 index c346c58ccb7a..000000000000 --- a/gnu/libexec/uucp/libunix/sync.c +++ /dev/null @@ -1,42 +0,0 @@ -/* sync.c - Sync a file to disk, if FSYNC_ON_CLOSE is set. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -boolean -fsysdep_sync (e, zmsg) - openfile_t e; - const char *zmsg; -{ - int o; - -#if USE_STDIO - if (fflush (e) == EOF) - { - ulog (LOG_ERROR, "%s: fflush: %s", zmsg, strerror (errno)); - return FALSE; - } -#endif - -#if USE_STDIO - o = fileno (e); -#else - o = e; -#endif - -#if FSYNC_ON_CLOSE - if (fsync (o) < 0) - { - ulog (LOG_ERROR, "%s: fsync: %s", zmsg, strerror (errno)); - return FALSE; - } -#endif - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/tcp.c b/gnu/libexec/uucp/libunix/tcp.c deleted file mode 100644 index 595b4149c289..000000000000 --- a/gnu/libexec/uucp/libunix/tcp.c +++ /dev/null @@ -1,483 +0,0 @@ -/* tcp.c - Code to handle TCP connections. - - Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char tcp_rcsid[] = "$FreeBSD$"; -#endif - -#if HAVE_TCP - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "conn.h" -#include "system.h" - -#include - -#if HAVE_SYS_TYPES_TCP_H -#include -#endif -#include -#include -#include -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -/* This code handles TCP connections. It assumes a Berkeley socket - interface. */ - -/* The normal "uucp" port number. */ -#define IUUCP_PORT "540" - -/* Local functions. */ -static void utcp_free P((struct sconnection *qconn)); -static boolean ftcp_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean ftcp_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean ftcp_dial P((struct sconnection *qconn, pointer puuconf, - const struct uuconf_system *qsys, - const char *zphone, - struct uuconf_dialer *qdialer, - enum tdialerfound *ptdialer)); -static int itcp_getaddrinfo P((const char *zhost, const char *zport, - const struct addrinfo *hints, - struct addrinfo **res)); - -/* The command table for a TCP connection. */ -static const struct sconncmds stcpcmds = -{ - utcp_free, - NULL, /* pflock */ - NULL, /* pfunlock */ - ftcp_open, - ftcp_close, - ftcp_dial, - fsysdep_conn_read, - fsysdep_conn_write, - fsysdep_conn_io, - NULL, /* pfbreak */ - NULL, /* pfset */ - NULL, /* pfcarrier */ - fsysdep_conn_chat, - NULL /* pibaud */ -}; - -/* Initialize a TCP connection. */ - -boolean -fsysdep_tcp_init (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *q; - - q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn)); - q->o = -1; - q->ord = -1; - q->owr = -1; - q->zdevice = NULL; - q->iflags = -1; - q->iwr_flags = -1; - q->fterminal = FALSE; - q->ftli = FALSE; - q->ibaud = 0; - - qconn->psysdep = (pointer) q; - qconn->qcmds = &stcpcmds; - return TRUE; -} - -/* Free a TCP connection. */ - -static void -utcp_free (qconn) - struct sconnection *qconn; -{ - xfree (qconn->psysdep); -} - -static boolean -utcp_init (qsysdep) - struct ssysdep_conn *qsysdep; -{ - if (!qsysdep) - return FALSE; - if (fcntl (qsysdep->o, F_SETFD, - fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) close (qsysdep->o); - qsysdep->o = -1; - return FALSE; - } - - qsysdep->iflags = fcntl (qsysdep->o, F_GETFL, 0); - if (qsysdep->iflags < 0) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - (void) close (qsysdep->o); - qsysdep->o = -1; - return FALSE; - } -} - -/* Open a TCP connection. If the fwait argument is TRUE, we are - running as a server. Otherwise we are just trying to reach another - system. */ - -static boolean -ftcp_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - struct ssysdep_conn *qsysdep; - struct addrinfo hints, *res, *res0; - struct sockaddr_storage s; - const char *zport; - int zfamily; - uid_t ieuid; - boolean fswap; - int err; - - ulog_device ("TCP"); - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - qsysdep->o = -1; - - /* We save our process ID in the qconn structure. This is checked - in ftcp_close. */ - qsysdep->ipid = getpid (); - - /* If we aren't waiting for a connection, we're done. */ - if (! fwait) - return TRUE; - - /* Run as a server and wait for a new connection. The code in - uucico.c has already detached us from our controlling terminal. - From this point on if the server gets an error we exit; we only - return if we have received a connection. It would be more robust - to respawn the server if it fails; someday. */ - zport = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zport; - zfamily = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zfamily; - memset (&hints, 0, sizeof(hints)); - hints.ai_family = zfamily; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - if ((err = itcp_getaddrinfo (NULL, zport, &hints, &res0)) != 0) - { - ulog (LOG_ERROR, "getaddrinfo (NULL, %s): %s", - zport, gai_strerror (err)); - return FALSE; - } -#if HAVE_GETADDRINFO - if (zfamily == PF_UNSPEC) - { - for (res = res0; res; res = res->ai_next) - { - if (res->ai_family == AF_INET6) - { - qsysdep->o = socket (res->ai_family, res->ai_socktype, - res->ai_protocol); - if (qsysdep->o >= 0) - break; - } - } - } -#endif - if (qsysdep->o < 0) - { - for (res = res0; res; res = res->ai_next) - { - qsysdep->o = socket (res->ai_family, res->ai_socktype, - res->ai_protocol); - if (qsysdep->o >= 0) - break; - } - if (qsysdep->o < 0) - { - freeaddrinfo (res); - ulog (LOG_ERROR, "socket: %s", strerror (errno)); - return FALSE; - } - } -#ifdef IPV6_BINDV6ONLY - if (res->ai_family == AF_INET6) - { - int flag = (zfamily == PF_UNSPEC) ? 0 : 1; - - if (setsockopt (qsysdep->o, IPPROTO_IPV6, IPV6_BINDV6ONLY, - (char *)&flag, sizeof (flag)) < 0) - { - freeaddrinfo (res); - ulog (LOG_FATAL, "setsockopt: %s", strerror (errno)); - return FALSE; - } - } -#endif - if (!utcp_init (qsysdep)) - { - freeaddrinfo (res); - return FALSE; - } - - /* Swap to our real user ID when doing the bind call. This will - permit the server to use privileged TCP ports when invoked by - root. We only swap if our effective user ID is not root, so that - the program can also be made suid root in order to get privileged - ports when invoked by anybody. */ - fswap = geteuid () != 0; - if (fswap) - { - if (! fsuser_perms (&ieuid)) - { - (void) close (qsysdep->o); - qsysdep->o = -1; - freeaddrinfo (res); - return FALSE; - } - } - - if (bind (qsysdep->o, res->ai_addr, res->ai_addrlen) < 0) - { - freeaddrinfo (res); - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_FATAL, "bind: %s", strerror (errno)); - } - freeaddrinfo (res); - - /* Now swap back to the uucp user ID. */ - if (fswap) - { - if (! fsuucp_perms ((long) ieuid)) - ulog (LOG_FATAL, "Could not swap back to UUCP user permissions"); - } - - if (listen (qsysdep->o, 5) < 0) - ulog (LOG_FATAL, "listen: %s", strerror (errno)); - - while (! FGOT_SIGNAL ()) - { - size_t clen; - int onew; - pid_t ipid; - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftcp_open: Waiting for connections"); - - clen = sizeof s; - onew = accept (qsysdep->o, (struct sockaddr *) &s, &clen); - if (onew < 0) - ulog (LOG_FATAL, "accept: %s", strerror (errno)); - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftcp_open: Got connection; forking"); - - ipid = ixsfork (); - if (ipid < 0) - ulog (LOG_FATAL, "fork: %s", strerror (errno)); - if (ipid == 0) - { - (void) close (qsysdep->o); - qsysdep->o = onew; - - /* Now we fork and let our parent die, so that we become - a child of init. This lets the main server code wait - for its child and then continue without accumulating - zombie children. */ - ipid = ixsfork (); - if (ipid < 0) - { - ulog (LOG_ERROR, "fork: %s", strerror (errno)); - _exit (EXIT_FAILURE); - } - - if (ipid != 0) - _exit (EXIT_SUCCESS); - - ulog_id (getpid ()); - - return TRUE; - } - - (void) close (onew); - - /* Now wait for the child. */ - (void) ixswait ((unsigned long) ipid, (const char *) NULL); - } - - /* We got a signal. */ - usysdep_exit (FALSE); - - /* Avoid compiler warnings. */ - return FALSE; -} - -/* Close the port. */ - -/*ARGSUSED*/ -static boolean -ftcp_close (qconn, puuconf, qdialer, fsuccess) - struct sconnection *qconn; - pointer puuconf; - struct uuconf_dialer *qdialer; - boolean fsuccess; -{ - struct ssysdep_conn *qsysdep; - boolean fret; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - fret = TRUE; - if (qsysdep->o >= 0 && close (qsysdep->o) < 0) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - fret = FALSE; - } - qsysdep->o = -1; - - /* If the current pid is not the one we used to open the port, then - we must have forked up above and we are now the child. In this - case, we are being called from within the fendless loop in - uucico.c. We return FALSE to force the loop to end and the child - to exit. This should be handled in a cleaner fashion. */ - if (qsysdep->ipid != getpid ()) - fret = FALSE; - - return fret; -} - -/* Dial out on a TCP port, so to speak: connect to a remote computer. */ - -/*ARGSUSED*/ -static boolean -ftcp_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialer; -{ - struct ssysdep_conn *qsysdep; - const char *zhost; - struct addrinfo hints, *res, *res0; - int err, connected = FALSE; - const char *zport; - char **pzdialer; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - *ptdialer = DIALERFOUND_FALSE; - - zhost = zphone; - if (zhost == NULL) - { - if (qsys == NULL) - { - ulog (LOG_ERROR, "No address for TCP connection"); - return FALSE; - } - zhost = qsys->uuconf_zname; - } - - errno = 0; - zport = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zport; - memset (&hints, 0, sizeof(hints)); - hints.ai_family = qconn->qport->uuconf_u.uuconf_stcp.uuconf_zfamily; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = 0; - if ((err = itcp_getaddrinfo (zhost, zport, &hints, &res0)) != 0) - { - ulog (LOG_ERROR, "getaddrinfo (%s, %s): %s", - zhost, zport, gai_strerror (err)); - return FALSE; - } - - for (res = res0; res; res = res->ai_next) - { - qsysdep->o = socket (res->ai_family, res->ai_socktype, res->ai_protocol); - if (qsysdep->o < 0) - continue; - if (connect (qsysdep->o, res->ai_addr, res->ai_addrlen) >= 0) - { - connected = TRUE; - break; - } - close (qsysdep->o); - } - freeaddrinfo (res0); - if (!connected) - { - ulog (LOG_ERROR, "connect: %s", strerror (errno)); - return FALSE; - } - if (!utcp_init (qsysdep)) - return FALSE; - - /* Handle the dialer sequence, if any. */ - pzdialer = qconn->qport->uuconf_u.uuconf_stcp.uuconf_pzdialer; - if (pzdialer != NULL && *pzdialer != NULL) - { - if (! fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone, - qdialer, ptdialer)) - return FALSE; - } - - return TRUE; -} - -static int -itcp_getaddrinfo (zhost, zport, hints, res) - const char *zhost, *zport; - const struct addrinfo *hints; - struct addrinfo **res; -{ - int err; - - if ((err = getaddrinfo (zhost, zport, hints, res)) != EAI_SERVICE || - strcmp(zport, "uucp") != 0) - return err; - return getaddrinfo (zhost, IUUCP_PORT, hints, res); -} - -#endif /* HAVE_TCP */ diff --git a/gnu/libexec/uucp/libunix/time.c b/gnu/libexec/uucp/libunix/time.c deleted file mode 100644 index d0462433a7dd..000000000000 --- a/gnu/libexec/uucp/libunix/time.c +++ /dev/null @@ -1,32 +0,0 @@ -/* time.c - Get the current time. */ - -#include "uucp.h" - -#if HAVE_TIME_H -#include -#endif - -#include "system.h" - -#ifndef time -extern time_t time (); -#endif - -/* Get the time in seconds since the epoch, with optional - microseconds. We use ixsysdep_process_time to get the microseconds - if it will work (it won't if it uses times, since that returns a - time based only on the process). */ - -long -ixsysdep_time (pimicros) - long *pimicros; -{ -#if HAVE_GETTIMEOFDAY || HAVE_FTIME - return ixsysdep_process_time (pimicros); -#else - if (pimicros != NULL) - *pimicros = 0; - return (long) time ((time_t *) NULL); -#endif -} diff --git a/gnu/libexec/uucp/libunix/ufopen.c b/gnu/libexec/uucp/libunix/ufopen.c deleted file mode 100644 index d79d9a0a5e53..000000000000 --- a/gnu/libexec/uucp/libunix/ufopen.c +++ /dev/null @@ -1,135 +0,0 @@ -/* ufopen.c - Open a file with the permissions of the invoking user. - - Copyright (C) 1992, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -/* Open a file with the permissions of the invoking user. Ignore the - fbinary argument since Unix has no distinction between text and - binary files. */ - -/*ARGSUSED*/ -openfile_t -esysdep_user_fopen (zfile, frd, fbinary) - const char *zfile; - boolean frd; - boolean fbinary; -{ - uid_t ieuid; - openfile_t e; - const char *zerr; - int o = 0; - - if (! fsuser_perms (&ieuid)) - return EFILECLOSED; - - zerr = NULL; - -#if USE_STDIO - e = fopen (zfile, frd ? "r" : "w"); - if (e == NULL) - zerr = "fopen"; - else - o = fileno (e); -#else - if (frd) - { - e = open ((char *) zfile, O_RDONLY | O_NOCTTY, 0); - zerr = "open"; - } - else - { - e = creat ((char *) zfile, IPUBLIC_FILE_MODE); - zerr = "creat"; - } - if (e >= 0) - { - o = e; - zerr = NULL; - } -#endif - - if (! fsuucp_perms ((long) ieuid)) - { - if (ffileisopen (e)) - (void) ffileclose (e); - return EFILECLOSED; - } - - if (zerr != NULL) - { - ulog (LOG_ERROR, "%s (%s): %s", zerr, zfile, strerror (errno)); -#if ! HAVE_SETREUID - /* Are these error messages helpful or confusing? */ -#if HAVE_SAVED_SETUID - if (errno == EACCES && getuid () == 0) - ulog (LOG_ERROR, - "The superuser may only transfer files that are readable by %s", - OWNER); -#else - if (errno == EACCES) - ulog (LOG_ERROR, - "You may only transfer files that are readable by %s", OWNER); -#endif -#endif /* ! HAVE_SETREUID */ - return EFILECLOSED; - } - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) ffileclose (e); - return EFILECLOSED; - } - - return e; -} diff --git a/gnu/libexec/uucp/libunix/uid.c b/gnu/libexec/uucp/libunix/uid.c deleted file mode 100644 index 66b8fc70001f..000000000000 --- a/gnu/libexec/uucp/libunix/uid.c +++ /dev/null @@ -1,116 +0,0 @@ -/* uid.c - Switch back and forth between UUCP and user permissions. - - Copyright (C) 1992, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -#include - -/* NetBSD apparently does not support setuid as required by POSIX when - using saved setuid, so use seteuid instead. */ - -#if HAVE_SETEUID -#define setuid seteuid -#endif - -/* Switch to permissions of the invoking user. */ - -boolean -fsuser_perms (pieuid) - uid_t *pieuid; -{ - uid_t ieuid, iuid; - - ieuid = geteuid (); - iuid = getuid (); - if (pieuid != NULL) - *pieuid = ieuid; - -#if HAVE_SETREUID - /* Swap the effective user id and the real user id. We can then - swap them back again when we want to return to the uucp user's - permissions. */ - if (setreuid (ieuid, iuid) < 0) - { - ulog (LOG_ERROR, "setreuid (%ld, %ld): %s", - (long) ieuid, (long) iuid, strerror (errno)); - return FALSE; - } -#else /* ! HAVE_SETREUID */ -#if HAVE_SAVED_SETUID - /* Set the effective user id to the real user id. Since the - effective user id is saved (it's the saved setuid) we will able - to set back to it later. If the real user id is root we will not - be able to switch back and forth, so don't even try. */ - if (iuid != 0) - { - if (setuid (iuid) < 0) - { - ulog (LOG_ERROR, "setuid (%ld): %s", (long) iuid, strerror (errno)); - return FALSE; - } - } -#else /* ! HAVE_SAVED_SETUID */ - /* There's no way to switch between real permissions and effective - permissions. Just try to open the file with the uucp - permissions. */ -#endif /* ! HAVE_SAVED_SETUID */ -#endif /* ! HAVE_SETREUID */ - - return TRUE; -} - -/* Restore the uucp permissions. */ - -/*ARGSUSED*/ -boolean -fsuucp_perms (ieuid) - long ieuid; -{ -#if HAVE_SETREUID - /* Swap effective and real user id's back to what they were. */ - if (! fsuser_perms ((uid_t *) NULL)) - return FALSE; -#else /* ! HAVE_SETREUID */ -#if HAVE_SAVED_SETUID - /* Set ourselves back to our original effective user id. */ - if (setuid ((uid_t) ieuid) < 0) - { - ulog (LOG_ERROR, "setuid (%ld): %s", (long) ieuid, strerror (errno)); - /* Is this error message helpful or confusing? */ - if (errno == EPERM) - ulog (LOG_ERROR, - "Probably HAVE_SAVED_SETUID in policy.h should be set to 0"); - return FALSE; - } -#else /* ! HAVE_SAVED_SETUID */ - /* We didn't switch, no need to switch back. */ -#endif /* ! HAVE_SAVED_SETUID */ -#endif /* ! HAVE_SETREUID */ - - return TRUE; -} diff --git a/gnu/libexec/uucp/libuuconf/COPYING.LIB b/gnu/libexec/uucp/libuuconf/COPYING.LIB deleted file mode 100644 index eb685a5ec981..000000000000 --- a/gnu/libexec/uucp/libuuconf/COPYING.LIB +++ /dev/null @@ -1,481 +0,0 @@ - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/gnu/libexec/uucp/libuuconf/Makefile b/gnu/libexec/uucp/libuuconf/Makefile deleted file mode 100644 index 3118be2686a9..000000000000 --- a/gnu/libexec/uucp/libuuconf/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# This is the Makefile for the Taylor UUCP uuconf library -# $FreeBSD$ - -LIB= uuconf -SRCS= addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \ - calout.c chatc.c cmdarg.c cmdfil.c cmdlin.c debfil.c deblev.c \ - diacod.c dial.c diasub.c dnams.c errno.c errstr.c filnam.c \ - freblk.c fredia.c free.c freprt.c fresys.c grdcmp.c hdial.c \ - hdnams.c hinit.c hlocnm.c hport.c hrmunk.c hsinfo.c hsnams.c \ - hsys.c hunk.c iniglb.c init.c int.c lckdir.c lineno.c llocnm.c \ - local.c locnm.c logfil.c maxuxq.c mrgblk.c paramc.c port.c \ - prtsub.c pubdir.c rdlocs.c rdperm.c reliab.c remunk.c runuxq.c \ - sinfo.c snams.c split.c spool.c stafil.c strip.c syssub.c \ - tcalou.c tdial.c tdialc.c tdnams.c tgcmp.c thread.c time.c \ - tinit.c tlocnm.c tport.c tportc.c tsinfo.c tsnams.c tsys.c \ - tval.c ugtlin.c unk.c val.c vinit.c vport.c vsinfo.c vsnams.c \ - vsys.c -CFLAGS+= -I$(.CURDIR)/../common_sources \ - -DNEWCONFIGLIB=\"$(newconfigdir)\"\ - -DOLDCONFIGLIB=\"$(oldconfigdir)\" - -NOMAN= noman -NOPROFILE= noprofile - -install: - -.include diff --git a/gnu/libexec/uucp/libuuconf/addblk.c b/gnu/libexec/uucp/libuuconf/addblk.c deleted file mode 100644 index 3f502df302d9..000000000000 --- a/gnu/libexec/uucp/libuuconf/addblk.c +++ /dev/null @@ -1,56 +0,0 @@ -/* addblk.c - Add an malloc block to a memory block. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_addblk_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Add a memory buffer allocated by malloc to a memory block. This is - used by the uuconf_cmd functions so that they don't have to - constantly copy data into memory. Returns 0 on success, non 0 on - failure. */ - -int -uuconf_add_block (pblock, padd) - pointer pblock; - pointer padd; -{ - struct sblock *q = (struct sblock *) pblock; - struct sadded *qnew; - - qnew = (struct sadded *) uuconf_malloc (pblock, sizeof (struct sadded)); - if (qnew == NULL) - return 1; - - qnew->qnext = q->qadded; - qnew->padded = padd; - q->qadded = qnew; - - return 0; -} diff --git a/gnu/libexec/uucp/libuuconf/addstr.c b/gnu/libexec/uucp/libuuconf/addstr.c deleted file mode 100644 index f95d528fddc9..000000000000 --- a/gnu/libexec/uucp/libuuconf/addstr.c +++ /dev/null @@ -1,139 +0,0 @@ -/* addstr.c - Add a string to a list of strings. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_addstr_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* When setting system information, we need to be able to distinguish - between a value that is not set and a value that has been set to - NULL. We do this by initializing the value to point to the - variable _uuconf_unset, and then correcting it in the function - _uuconf_isystem_basic_default. This variable is declared in this - file because some linkers will apparently not pull in an object - file which merely declarates a variable. This functions happens to - be pulled in by almost everything. */ - -char *_uuconf_unset; - -/* Add a string to a list of strings. The list is maintained as an - array of elements ending in NULL. The total number of available - slots is always a multiple of CSLOTS, so by counting the current - number of elements we can tell whether a new slot is needed. If - the fcopy argument is TRUE, the new string is duplicated into - memory. If the fcheck argument is TRUE, this does not add a string - that is already in the list. The pblock argument may be used to do - the allocations within a memory block. This returns a standard - uuconf error code. */ - -#define CSLOTS (8) - -int -_uuconf_iadd_string (qglobal, zadd, fcopy, fcheck, ppzstrings, pblock) - struct sglobal *qglobal; - char *zadd; - boolean fcopy; - boolean fcheck; - char ***ppzstrings; - pointer pblock; -{ - char **pz; - size_t c; - - if (fcheck && *ppzstrings != NULL) - { - for (pz = *ppzstrings; *pz != NULL; pz++) - if (strcmp (zadd, *pz) == 0) - return UUCONF_SUCCESS; - } - - if (fcopy) - { - size_t clen; - char *znew; - - clen = strlen (zadd) + 1; - znew = (char *) uuconf_malloc (pblock, clen); - if (znew == NULL) - { - if (qglobal != NULL) - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) znew, (pointer) zadd, clen); - zadd = znew; - } - - pz = *ppzstrings; - if (pz == NULL || pz == (char **) &_uuconf_unset) - { - pz = (char **) uuconf_malloc (pblock, CSLOTS * sizeof (char *)); - if (pz == NULL) - { - if (qglobal != NULL) - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - *ppzstrings = pz; - } - else - { - c = 0; - while (*pz != NULL) - { - ++pz; - ++c; - } - - if ((c + 1) % CSLOTS == 0) - { - char **pznew; - - pznew = (char **) uuconf_malloc (pblock, - ((c + 1 + CSLOTS) - * sizeof (char *))); - if (pznew == NULL) - { - if (qglobal != NULL) - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) pznew, (pointer) *ppzstrings, - c * sizeof (char *)); - uuconf_free (pblock, *ppzstrings); - *ppzstrings = pznew; - pz = pznew + c; - } - } - - pz[0] = zadd; - pz[1] = NULL; - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/allblk.c b/gnu/libexec/uucp/libuuconf/allblk.c deleted file mode 100644 index 045740e2f8aa..000000000000 --- a/gnu/libexec/uucp/libuuconf/allblk.c +++ /dev/null @@ -1,51 +0,0 @@ -/* allblk.c - Allocate a memory block. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_allblk_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Allocate a new memory block. If this fails, uuconf_errno will be - set, and the calling routine may return UUCONF_MALLOC_FAILED | - UUCONF_ERROR_ERRNO. */ - -pointer -uuconf_malloc_block () -{ - struct sblock *qret; - - qret = (struct sblock *) malloc (sizeof (struct sblock)); - if (qret == NULL) - return NULL; - qret->qnext = NULL; - qret->ifree = 0; - qret->plast = NULL; - qret->qadded = NULL; - return (pointer) qret; -} diff --git a/gnu/libexec/uucp/libuuconf/alloc.c b/gnu/libexec/uucp/libuuconf/alloc.c deleted file mode 100644 index e64875a526fe..000000000000 --- a/gnu/libexec/uucp/libuuconf/alloc.c +++ /dev/null @@ -1,82 +0,0 @@ -/* alloc.c - Allocate within a memory block. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_alloc_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Allocate some memory out of a memory block. If the memory block is - NULL, this just calls malloc; this is convenient for a number of - routines. If this fails, uuconf_errno will be set, and the calling - routine may return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO. */ - -pointer -uuconf_malloc (pblock, c) - pointer pblock; - size_t c; -{ - struct sblock *q = (struct sblock *) pblock; - pointer pret; - - if (c == 0) - return NULL; - - if (q == NULL) - return malloc (c); - - /* Make sure that c is aligned to a double boundary. */ - c = ((c + sizeof (double) - 1) / sizeof (double)) * sizeof (double); - - while (q->ifree + c > CALLOC_SIZE) - { - if (q->qnext != NULL) - q = q->qnext; - else - { - if (c > CALLOC_SIZE) - q->qnext = (struct sblock *) malloc (sizeof (struct sblock) - + c - CALLOC_SIZE); - else - q->qnext = (struct sblock *) malloc (sizeof (struct sblock)); - if (q->qnext == NULL) - return NULL; - q = q->qnext; - q->qnext = NULL; - q->ifree = 0; - q->qadded = NULL; - break; - } - } - - pret = q->u.ab + q->ifree; - q->ifree += c; - q->plast = pret; - - return pret; -} diff --git a/gnu/libexec/uucp/libuuconf/alloc.h b/gnu/libexec/uucp/libuuconf/alloc.h deleted file mode 100644 index d35e0fb3ea01..000000000000 --- a/gnu/libexec/uucp/libuuconf/alloc.h +++ /dev/null @@ -1,71 +0,0 @@ -/* alloc.h - Header file for uuconf memory allocation routines. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* This header file is private to the uuconf memory allocation - routines, and should not be included by any other files. */ - -/* We want to be able to keep track of allocated memory blocks, so - that we can free them up later. This will let us free up all the - memory allocated to hold information for a system, for example. We - do this by allocating large chunks and doling them out. Calling - uuconf_malloc_block will return a pointer to a magic cookie which - can then be passed to uuconf_malloc and uuconf_free. Passing the - pointer to uuconf_free_block will free all memory allocated for - that block. */ - -/* We allocate this much space in each block. On most systems, this - will make the actual structure 1024 bytes, which may be convenient - for some types of memory allocators. */ -#define CALLOC_SIZE (1008) - -/* This is the actual structure of a block. */ -struct sblock -{ - /* Next block in linked list. */ - struct sblock *qnext; - /* Index of next free spot. */ - size_t ifree; - /* Last value returned by uuconf_malloc for this block. */ - pointer plast; - /* List of additional memory blocks. */ - struct sadded *qadded; - /* Buffer of data. We put it in a union with a double to make sure - it is adequately aligned. */ - union - { - char ab[CALLOC_SIZE]; - double l; - } u; -}; - -/* There is a linked list of additional memory blocks inserted by - uuconf_add_block. */ -struct sadded -{ - /* The next in the list. */ - struct sadded *qnext; - /* The added block. */ - pointer padded; -}; diff --git a/gnu/libexec/uucp/libuuconf/base.c b/gnu/libexec/uucp/libuuconf/base.c deleted file mode 100644 index c6441230eb74..000000000000 --- a/gnu/libexec/uucp/libuuconf/base.c +++ /dev/null @@ -1,54 +0,0 @@ -/* base.c - Subroutine to turn a cmdtab_offset table into a uuconf_cmdtab table. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_base_rcsid[] = "$FreeBSD$"; -#endif - -/* This turns a cmdtab_offset table into a uuconf_cmdtab table. Each - offset is adjusted by a base value. */ - -void -_uuconf_ucmdtab_base (qoff, celes, pbase, qset) - register const struct cmdtab_offset *qoff; - size_t celes; - char *pbase; - register struct uuconf_cmdtab *qset; -{ - register size_t i; - - for (i = 0; i < celes; i++, qoff++, qset++) - { - qset->uuconf_zcmd = qoff->zcmd; - qset->uuconf_itype = qoff->itype; - if (qoff->ioff == (size_t) -1) - qset->uuconf_pvar = NULL; - else - qset->uuconf_pvar = pbase + qoff->ioff; - qset->uuconf_pifn = qoff->pifn; - } -} diff --git a/gnu/libexec/uucp/libuuconf/bool.c b/gnu/libexec/uucp/libuuconf/bool.c deleted file mode 100644 index f32c9bb5dcf2..000000000000 --- a/gnu/libexec/uucp/libuuconf/bool.c +++ /dev/null @@ -1,64 +0,0 @@ -/* bool.c - Parse a boolean string into a variable. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_bool_rcsid[] = "$FreeBSD$"; -#endif - -/* Parse a boolean string into a variable. This is called by - uuconf_cmd_args, as well as other functions. The parsing is done - in a single place to make it easy to change. This should return an - error code, including both UUCONF_CMDTABRET_KEEP and - UUCONF_CMDTABRET_EXIT if appropriate. */ - -/*ARGSIGNORED*/ -int -_uuconf_iboolean (qglobal, zval, pi) - struct sglobal *qglobal; - const char *zval; - boolean *pi; -{ - switch (*zval) - { - case 'y': - case 'Y': - case 't': - case 'T': - *pi = TRUE; - break; - case 'n': - case 'N': - case 'f': - case 'F': - *pi = FALSE; - break; - default: - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - } - - return UUCONF_CMDTABRET_CONTINUE; -} diff --git a/gnu/libexec/uucp/libuuconf/callin.c b/gnu/libexec/uucp/libuuconf/callin.c deleted file mode 100644 index e8b80adb807d..000000000000 --- a/gnu/libexec/uucp/libuuconf/callin.c +++ /dev/null @@ -1,195 +0,0 @@ -/* callin.c - Check a login name and password against the UUCP password file. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_callin_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int ipcheck P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -struct sinfo -{ - int (*pcmpfn) P((int, pointer, const char *)); - pointer pinfo; - boolean ffound; - boolean fmatched; -}; - -/* Check a login name and password against the UUCP password file. - This looks at the Taylor UUCP password file, but will work even if - uuconf_taylor_init was not called. It accepts either spaces or - colons as field delimiters. */ - -int -uuconf_callin (pglobal, pcmpfn, pinfo) - pointer pglobal; - int (*pcmpfn) P((int, pointer, const char *)); - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - char **pz; - struct uuconf_cmdtab as[1]; - struct sinfo s; - char *zline; - size_t cline; - - /* If we have no password file names, fill in the default name. */ - if (qglobal->qprocess->pzpwdfiles == NULL) - { - char ab[sizeof NEWCONFIGLIB + sizeof PASSWDFILE - 1]; - - memcpy ((pointer) ab, (pointer) NEWCONFIGLIB, - sizeof NEWCONFIGLIB - 1); - memcpy ((pointer) (ab + sizeof NEWCONFIGLIB - 1), (pointer) PASSWDFILE, - sizeof PASSWDFILE); - iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE, - &qglobal->qprocess->pzpwdfiles, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - - as[0].uuconf_zcmd = NULL; - - s.pcmpfn = pcmpfn; - s.pinfo = pinfo; - s.ffound = FALSE; - s.fmatched = FALSE; - - zline = NULL; - cline = 0; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzpwdfiles; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - qglobal->ilineno = 0; - - iret = UUCONF_SUCCESS; - - while (getline (&zline, &cline, e) > 0) - { - char *z0, *z1; - - ++qglobal->ilineno; - - /* We have a few hacks to make Unix style passwd files work. - 1) We turn the first two colon characters into spaces. - 2) If the colon characters are adjacent, we assume there - is no password, and we skip the entry. - 3) If the password between colon characters contains a - space, we assume that it has been disabled, and we - skip the entry. */ - z0 = strchr (zline, ':'); - if (z0 != NULL) - { - *z0 = ' '; - z1 = strchr (z0, ':'); - if (z1 != NULL) - { - if (z1 - z0 == 1) - continue; - *z1 = '\0'; - if (strchr (z0 + 1, ' ') != NULL) - continue; - } - } - iret = uuconf_cmd_line (pglobal, zline, as, (pointer) &s, - ipcheck, 0, (pointer) NULL); - if ((iret & UUCONF_CMDTABRET_EXIT) != 0) - { - iret &=~ UUCONF_CMDTABRET_EXIT; - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_ERROR_LINENO; - break; - } - - iret = UUCONF_SUCCESS; - } - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS || s.ffound) - break; - } - - if (zline != NULL) - free ((pointer) zline); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME; - } - else if (! s.ffound || ! s.fmatched) - iret = UUCONF_NOT_FOUND; - - return iret; -} - -/* This is called on each line of the file. It checks to see if the - login name from the file is the one we are looking for. If it is, - it sets ffound, and then sets fmatched according to whether the - password matches or not. */ - -static int -ipcheck (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sinfo *q = (struct sinfo *) pinfo; - - if (argc != 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (! (*q->pcmpfn) (0, q->pinfo, argv[0])) - return UUCONF_CMDTABRET_CONTINUE; - - q->ffound = TRUE; - q->fmatched = (*q->pcmpfn) (1, q->pinfo, argv[1]) != 0; - - return UUCONF_CMDTABRET_EXIT; -} diff --git a/gnu/libexec/uucp/libuuconf/calout.c b/gnu/libexec/uucp/libuuconf/calout.c deleted file mode 100644 index 26ce361fdb43..000000000000 --- a/gnu/libexec/uucp/libuuconf/calout.c +++ /dev/null @@ -1,93 +0,0 @@ -/* calout.c - Find callout login name and password for a system. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_calout_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Find callout login name and password for a system. */ - -/*ARGSUSED*/ -int -uuconf_callout (pglobal, qsys, pzlog, pzpass) - pointer pglobal; - const struct uuconf_system *qsys; - char **pzlog; - char **pzpass; -{ -#if HAVE_TAYLOR_CONFIG - - return uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass); - -#else /* ! HAVE_TAYLOR_CONFIG */ - - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzlog = NULL; - *pzpass = NULL; - - if (qsys->uuconf_zcall_login == NULL - && qsys->uuconf_zcall_password == NULL) - return UUCONF_NOT_FOUND; - - if ((qsys->uuconf_zcall_login != NULL - && strcmp (qsys->uuconf_zcall_login, "*") == 0) - || (qsys->uuconf_zcall_password != NULL - && strcmp (qsys->uuconf_zcall_password, "*") == 0)) - return UUCONF_NOT_FOUND; - - if (qsys->uuconf_zcall_login != NULL) - { - *pzlog = strdup (qsys->uuconf_zcall_login); - if (*pzlog == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - } - - if (qsys->uuconf_zcall_password != NULL) - { - *pzpass = strdup (qsys->uuconf_zcall_password); - if (*pzpass == NULL) - { - qglobal->ierrno = errno; - if (*pzlog != NULL) - { - free ((pointer) *pzlog); - *pzlog = NULL; - } - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - } - - return UUCONF_SUCCESS; - -#endif /* ! HAVE_TAYLOR_CONFIG */ -} diff --git a/gnu/libexec/uucp/libuuconf/chatc.c b/gnu/libexec/uucp/libuuconf/chatc.c deleted file mode 100644 index bf3aed63a082..000000000000 --- a/gnu/libexec/uucp/libuuconf/chatc.c +++ /dev/null @@ -1,202 +0,0 @@ -/* chatc.c - Subroutines to handle chat script commands. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_chatc_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -static int icchat P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int icchat_fail P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int icunknown P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* The chat script commands. */ - -static const struct cmdtab_offset asChat_cmds[] = -{ - { "chat", UUCONF_CMDTABTYPE_FN, - offsetof (struct uuconf_chat, uuconf_pzchat), icchat }, - { "chat-program", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_chat, uuconf_pzprogram), NULL }, - { "chat-timeout", UUCONF_CMDTABTYPE_INT, - offsetof (struct uuconf_chat, uuconf_ctimeout), NULL }, - { "chat-fail", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_chat, uuconf_pzfail), icchat_fail }, - { "chat-seven-bit", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_chat, uuconf_fstrip), NULL }, - { NULL, 0, 0, NULL } -}; - -#define CCHAT_CMDS (sizeof asChat_cmds / sizeof asChat_cmds[0]) - -/* Handle a chat script command. The chat script commands are entered - as UUCONF_CMDTABTYPE_PREFIX, and the commands are routed to this - function. We copy the command table onto the stack and repoint it - at qchat in order to make the function reentrant. The return value - can include UUCONF_CMDTABRET_KEEP, but should not include - UUCONF_CMDTABRET_EXIT. */ - -int -_uuconf_ichat_cmd (qglobal, argc, argv, qchat, pblock) - struct sglobal *qglobal; - int argc; - char **argv; - struct uuconf_chat *qchat; - pointer pblock; -{ - char *zchat; - struct uuconf_cmdtab as[CCHAT_CMDS]; - int iret; - - /* This is only invoked when argv[0] will contain the string "chat"; - the specific chat script command comes after that point. */ - for (zchat = argv[0]; *zchat != '\0'; zchat++) - if ((*zchat == 'c' || *zchat == 'C') - && strncasecmp (zchat, "chat", sizeof "chat" - 1) == 0) - break; - if (*zchat == '\0') - return UUCONF_SYNTAX_ERROR; - argv[0] = zchat; - - _uuconf_ucmdtab_base (asChat_cmds, CCHAT_CMDS, (char *) qchat, as); - - iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as, pblock, - icunknown, 0, pblock); - return iret &~ UUCONF_CMDTABRET_EXIT; -} - -/* Handle the "chat" command. This breaks up substrings in expect - strings, and sticks the arguments into a NULL terminated array. */ - -static int -icchat (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char ***ppz = (char ***) pvar; - pointer pblock = pinfo; - int i; - - *ppz = NULL; - - for (i = 1; i < argc; i += 2) - { - char *z, *zdash; - int iret; - - /* Break the expect string into substrings. */ - z = argv[i]; - zdash = strchr (z, '-'); - while (zdash != NULL) - { - *zdash = '\0'; - iret = _uuconf_iadd_string (qglobal, z, TRUE, FALSE, ppz, - pblock); - if (iret != UUCONF_SUCCESS) - return iret; - *zdash = '-'; - z = zdash; - zdash = strchr (z + 1, '-'); - } - - iret = _uuconf_iadd_string (qglobal, z, FALSE, FALSE, ppz, pblock); - if (iret != UUCONF_SUCCESS) - return iret; - - /* Add the send string without breaking it up. If it starts - with a dash we must replace it with an escape sequence, to - prevent it from being interpreted as a subsend. */ - - if (i + 1 < argc) - { - if (argv[i + 1][0] != '-') - iret = _uuconf_iadd_string (qglobal, argv[i + 1], FALSE, - FALSE, ppz, pblock); - else - { - size_t clen; - - clen = strlen (argv[i + 1]); - z = uuconf_malloc (pblock, clen + 2); - if (z == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - z[0] = '\\'; - memcpy ((pointer) (z + 1), (pointer) argv[i + 1], clen + 1); - iret = _uuconf_iadd_string (qglobal, z, FALSE, FALSE, ppz, - pblock); - } - if (iret != UUCONF_SUCCESS) - return iret; - } - } - - return UUCONF_CMDTABRET_KEEP; -} - -/* Add a new chat failure string. */ - -/*ARGSUSED*/ -static int -icchat_fail (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char ***ppz = (char ***) pvar; - pointer pblock = pinfo; - - return _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE, ppz, pblock); -} - -/* Return a syntax error for an unknown command. */ - -/*ARGSUSED*/ -static int -icunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_SYNTAX_ERROR; -} diff --git a/gnu/libexec/uucp/libuuconf/cmdarg.c b/gnu/libexec/uucp/libuuconf/cmdarg.c deleted file mode 100644 index 701405c668fc..000000000000 --- a/gnu/libexec/uucp/libuuconf/cmdarg.c +++ /dev/null @@ -1,185 +0,0 @@ -/* cmdarg.c - Look up a command with arguments in a command table. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_cmdarg_rcsid[] = "$FreeBSD$"; -#endif - -#include - -#undef strcmp -#if HAVE_STRCASECMP -#undef strcasecmp -#endif -extern int strcmp (), strcasecmp (); - -/* Look up a command with arguments in a table and execute it. */ - -int -uuconf_cmd_args (pglobal, cargs, pzargs, qtab, pinfo, pfiunknown, iflags, - pblock) - pointer pglobal; - int cargs; - char **pzargs; - const struct uuconf_cmdtab *qtab; - pointer pinfo; - int (*pfiunknown) P((pointer, int, char **, pointer, pointer)); - int iflags; - pointer pblock; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int bfirstu, bfirstl; - int (*pficmp) P((const char *, const char *)); - register const struct uuconf_cmdtab *q; - int itype; - int callowed; - - bfirstu = bfirstl = pzargs[0][0]; - if ((iflags & UUCONF_CMDTABFLAG_CASE) != 0) - pficmp = strcmp; - else - { - if (islower (bfirstu)) - bfirstu = toupper (bfirstu); - if (isupper (bfirstl)) - bfirstl = tolower (bfirstl); - pficmp = strcasecmp; - } - - itype = 0; - - for (q = qtab; q->uuconf_zcmd != NULL; q++) - { - int bfirst; - - bfirst = q->uuconf_zcmd[0]; - if (bfirst != bfirstu && bfirst != bfirstl) - continue; - - itype = UUCONF_TTYPE_CMDTABTYPE (q->uuconf_itype); - if (itype != UUCONF_CMDTABTYPE_PREFIX) - { - if ((*pficmp) (q->uuconf_zcmd, pzargs[0]) == 0) - break; - } - else - { - size_t clen; - - clen = strlen (q->uuconf_zcmd); - if ((iflags & UUCONF_CMDTABFLAG_CASE) != 0) - { - if (strncmp (q->uuconf_zcmd, pzargs[0], clen) == 0) - break; - } - else - { - if (strncasecmp (q->uuconf_zcmd, pzargs[0], clen) == 0) - break; - } - } - } - - if (q->uuconf_zcmd == NULL) - { - if (pfiunknown == NULL) - return UUCONF_CMDTABRET_CONTINUE; - return (*pfiunknown) (pglobal, cargs, pzargs, (pointer) NULL, pinfo); - } - - callowed = UUCONF_CARGS_CMDTABTYPE (q->uuconf_itype); - if (callowed != 0 && callowed != cargs) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - switch (itype) - { - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_STRING): - if (cargs == 1) - *(char **) q->uuconf_pvar = (char *) ""; - else if (cargs == 2) - *(char **) q->uuconf_pvar = pzargs[1]; - else - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - return UUCONF_CMDTABRET_KEEP; - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_INT): - return _uuconf_iint (qglobal, pzargs[1], q->uuconf_pvar, TRUE); - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_LONG): - return _uuconf_iint (qglobal, pzargs[1], q->uuconf_pvar, FALSE); - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_BOOLEAN): - return _uuconf_iboolean (qglobal, pzargs[1], (int *) q->uuconf_pvar); - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FULLSTRING): - if (cargs == 1) - { - char ***ppz = (char ***) q->uuconf_pvar; - int iret; - - *ppz = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppz, pblock); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_EXIT; - - return UUCONF_CMDTABRET_CONTINUE; - } - else - { - char ***ppz = (char ***) q->uuconf_pvar; - int i; - - *ppz = NULL; - for (i = 1; i < cargs; i++) - { - int iret; - - iret = _uuconf_iadd_string (qglobal, pzargs[i], FALSE, FALSE, - ppz, pblock); - if (iret != UUCONF_SUCCESS) - { - *ppz = NULL; - return iret | UUCONF_CMDTABRET_EXIT; - } - } - - return UUCONF_CMDTABRET_KEEP; - } - - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_FN): - case UUCONF_TTYPE_CMDTABTYPE (UUCONF_CMDTABTYPE_PREFIX): - return (*q->uuconf_pifn) (pglobal, cargs, pzargs, q->uuconf_pvar, - pinfo); - - default: - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - } - - /*NOTREACHED*/ -} diff --git a/gnu/libexec/uucp/libuuconf/cmdfil.c b/gnu/libexec/uucp/libuuconf/cmdfil.c deleted file mode 100644 index dd5183ff5a05..000000000000 --- a/gnu/libexec/uucp/libuuconf/cmdfil.c +++ /dev/null @@ -1,106 +0,0 @@ -/* cmdfil.c - Read and parse commands from a file. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_cmdfil_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Read and parse commands from a file, updating uuconf_lineno as - appropriate. */ - -int -uuconf_cmd_file (pglobal, e, qtab, pinfo, pfiunknown, iflags, pblock) - pointer pglobal; - FILE *e; - const struct uuconf_cmdtab *qtab; - pointer pinfo; - int (*pfiunknown) P((pointer, int, char **, pointer, pointer)); - int iflags; - pointer pblock; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - boolean fcont; - char *zline; - size_t cline; - int iret; - - fcont = (iflags & UUCONF_CMDTABFLAG_BACKSLASH) != 0; - - zline = NULL; - cline = 0; - - iret = UUCONF_SUCCESS; - - qglobal->ilineno = 0; - - while ((fcont - ? _uuconf_getline (qglobal, &zline, &cline, e) - : getline (&zline, &cline, e)) > 0) - { - ++qglobal->ilineno; - - iret = uuconf_cmd_line (pglobal, zline, qtab, pinfo, pfiunknown, - iflags, pblock); - - if ((iret & UUCONF_CMDTABRET_KEEP) != 0) - { - iret &=~ UUCONF_CMDTABRET_KEEP; - - if (pblock != NULL) - { - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - iret = (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_LINENO); - break; - } - } - - zline = NULL; - cline = 0; - } - - if ((iret & UUCONF_CMDTABRET_EXIT) != 0) - { - iret &=~ UUCONF_CMDTABRET_EXIT; - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_ERROR_LINENO; - break; - } - - iret = UUCONF_SUCCESS; - } - - if (zline != NULL) - free ((pointer) zline); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/cmdlin.c b/gnu/libexec/uucp/libuuconf/cmdlin.c deleted file mode 100644 index 59ec08aa815d..000000000000 --- a/gnu/libexec/uucp/libuuconf/cmdlin.c +++ /dev/null @@ -1,145 +0,0 @@ -/* cmdlin.c - Parse a command line. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_cmdlin_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Parse a command line into fields and process it via a command - table. The command table functions may keep the memory allocated - for the line, but they may not keep the memory allocated for the - argv list. This function strips # comments. */ - -#define CSTACK (16) - -int -uuconf_cmd_line (pglobal, zline, qtab, pinfo, pfiunknown, iflags, pblock) - pointer pglobal; - char *zline; - const struct uuconf_cmdtab *qtab; - pointer pinfo; - int (*pfiunknown) P((pointer, int, char **, pointer, pointer)); - int iflags; - pointer pblock; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char *z; - int cargs; - char *azargs[CSTACK]; - char **pzargs; - int iret; - - if ((iflags & UUCONF_CMDTABFLAG_NOCOMMENTS) == 0) - { - /* Any # not preceeded by a backslash starts a comment. */ - z = zline; - while ((z = strchr (z, '#')) != NULL) - { - if (z == zline || *(z - 1) != '\\') - { - *z = '\0'; - break; - } - /* Remove the backslash. */ - while ((*(z - 1) = *z) != '\0') - ++z; - } - } - - /* Parse the first CSTACK arguments by hand to avoid malloc. */ - - z = zline; - cargs = 0; - pzargs = azargs; - while (TRUE) - { - while (*z != '\0' && isspace (BUCHAR (*z))) - ++z; - - if (*z == '\0') - break; - - if (cargs >= CSTACK) - { - char **pzsplit; - size_t csplit; - int cmore; - - pzsplit = NULL; - csplit = 0; - cmore = _uuconf_istrsplit (z, '\0', &pzsplit, &csplit); - if (cmore < 0) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - pzargs = (char **) malloc ((cmore + CSTACK) * sizeof (char *)); - if (pzargs == NULL) - { - qglobal->ierrno = errno; - free ((pointer) pzsplit); - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - memcpy ((pointer) pzargs, (pointer) azargs, - CSTACK * sizeof (char *)); - memcpy ((pointer) (pzargs + CSTACK), (pointer) pzsplit, - cmore * sizeof (char *)); - cargs = cmore + CSTACK; - - free ((pointer) pzsplit); - - break; - } - - azargs[cargs] = z; - ++cargs; - - while (*z != '\0' && ! isspace (BUCHAR (*z))) - z++; - - if (*z == '\0') - break; - - *z++ = '\0'; - } - - if (cargs <= 0) - return UUCONF_CMDTABRET_CONTINUE; - - iret = uuconf_cmd_args (pglobal, cargs, pzargs, qtab, pinfo, pfiunknown, - iflags, pblock); - - if (pzargs != azargs) - free ((pointer) pzargs); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/debfil.c b/gnu/libexec/uucp/libuuconf/debfil.c deleted file mode 100644 index 6d4c0cb8d05a..000000000000 --- a/gnu/libexec/uucp/libuuconf/debfil.c +++ /dev/null @@ -1,43 +0,0 @@ -/* debfil.c - Get the name of the UUCP debugging file. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_debfil_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP debugging file. */ - -int -uuconf_debugfile (pglobal, pzdebug) - pointer pglobal; - const char **pzdebug; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzdebug = qglobal->qprocess->zdebugfile; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/deblev.c b/gnu/libexec/uucp/libuuconf/deblev.c deleted file mode 100644 index 7653aeedb88c..000000000000 --- a/gnu/libexec/uucp/libuuconf/deblev.c +++ /dev/null @@ -1,43 +0,0 @@ -/* deblev.c - Get the UUCP debugging level. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_deblev_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the UUCP debugging level. */ - -int -uuconf_debuglevel (pglobal, pzdebug) - pointer pglobal; - const char **pzdebug; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzdebug = qglobal->qprocess->zdebug; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/diacod.c b/gnu/libexec/uucp/libuuconf/diacod.c deleted file mode 100644 index df0e9a7beec0..000000000000 --- a/gnu/libexec/uucp/libuuconf/diacod.c +++ /dev/null @@ -1,129 +0,0 @@ -/* diacod.c - Translate a dialcode. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_diacod_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int idcode P((pointer pglobal, int argc, char **argv, - pointer pinfo, pointer pvar)); - -/* Get the name of the UUCP log file. */ - -int -uuconf_dialcode (pglobal, zdial, pznum) - pointer pglobal; - const char *zdial; - char **pznum; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_cmdtab as[2]; - char **pz; - int iret; - - as[0].uuconf_zcmd = zdial; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 0; - as[0].uuconf_pvar = (pointer) pznum; - as[0].uuconf_pifn = idcode; - - as[1].uuconf_zcmd = NULL; - - *pznum = NULL; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzdialcodefiles; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL, - (uuconf_cmdtabfn) NULL, 0, (pointer) NULL); - (void) fclose (e); - - if (iret != UUCONF_SUCCESS || *pznum != NULL) - break; - } - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME; - } - else if (*pznum == NULL) - iret = UUCONF_NOT_FOUND; - - return iret; -} - -/* This is called if the dialcode is found. It copies the number into - the heap and gets out of reading the file. */ - -/*ARGSUSED*/ -static int -idcode (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pznum = (char **) pvar; - - if (argc == 1) - { - *pznum = malloc (1); - if (*pznum != NULL) - **pznum = '\0'; - } - else if (argc == 2) - *pznum = strdup (argv[1]); - else - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (*pznum == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - return UUCONF_CMDTABRET_EXIT; -} diff --git a/gnu/libexec/uucp/libuuconf/dial.c b/gnu/libexec/uucp/libuuconf/dial.c deleted file mode 100644 index 7b84416b77d0..000000000000 --- a/gnu/libexec/uucp/libuuconf/dial.c +++ /dev/null @@ -1,61 +0,0 @@ -/* dial.c - Find a dialer. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_dial_rcsid[] = "$FreeBSD$"; -#endif - -/* Find a dialer by name. */ - -int -uuconf_dialer_info (pglobal, zdialer, qdialer) - pointer pglobal; - const char *zdialer; - struct uuconf_dialer *qdialer; -{ -#if HAVE_HDB_CONFIG - struct sglobal *qglobal = (struct sglobal *) pglobal; -#endif - int iret; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_dialer_info (pglobal, zdialer, qdialer); - if (iret != UUCONF_NOT_FOUND) - return iret; -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - iret = uuconf_hdb_dialer_info (pglobal, zdialer, qdialer); - if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - - return UUCONF_NOT_FOUND; -} diff --git a/gnu/libexec/uucp/libuuconf/diasub.c b/gnu/libexec/uucp/libuuconf/diasub.c deleted file mode 100644 index 80358cc26af8..000000000000 --- a/gnu/libexec/uucp/libuuconf/diasub.c +++ /dev/null @@ -1,63 +0,0 @@ -/* diasub.c - Dialer information subroutines. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_diasub_rcsid[] = "$FreeBSD$"; -#endif - -/* Clear the information in a dialer. */ - -#define INIT_CHAT(q) \ - ((q)->uuconf_pzchat = NULL, \ - (q)->uuconf_pzprogram = NULL, \ - (q)->uuconf_ctimeout = 60, \ - (q)->uuconf_pzfail = NULL, \ - (q)->uuconf_fstrip = TRUE) - -void -_uuconf_uclear_dialer (qdialer) - struct uuconf_dialer *qdialer; -{ - qdialer->uuconf_zname = NULL; - INIT_CHAT (&qdialer->uuconf_schat); - qdialer->uuconf_zdialtone = (char *) ","; - qdialer->uuconf_zpause = (char *) ","; - qdialer->uuconf_fcarrier = TRUE; - qdialer->uuconf_ccarrier_wait = 60; - qdialer->uuconf_fdtr_toggle = FALSE; - qdialer->uuconf_fdtr_toggle_wait = FALSE; - INIT_CHAT (&qdialer->uuconf_scomplete); - INIT_CHAT (&qdialer->uuconf_sabort); - qdialer->uuconf_qproto_params = NULL; - /* Note that we do not set RELIABLE_SPECIFIED; this just sets - defaults, so that ``seven-bit true'' does not imply ``reliable - false''. */ - qdialer->uuconf_ireliable = (UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX); - qdialer->uuconf_palloc = NULL; -} diff --git a/gnu/libexec/uucp/libuuconf/dnams.c b/gnu/libexec/uucp/libuuconf/dnams.c deleted file mode 100644 index 2d295e6aaaf2..000000000000 --- a/gnu/libexec/uucp/libuuconf/dnams.c +++ /dev/null @@ -1,103 +0,0 @@ -/* dnams.c - Get all known dialer names. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_dnams_rcsid[] = "$FreeBSD$"; -#endif - -/* Get all known dialer names. */ - -int -uuconf_dialer_names (pglobal, ppzdialers) - pointer pglobal; - char ***ppzdialers; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pztaylor; - char **pzhdb; - int iret; - - *ppzdialers = NULL; - pztaylor = NULL; - pzhdb = NULL; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_dialer_names (pglobal, &pztaylor); - if (iret != UUCONF_SUCCESS) - return iret; -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - iret = uuconf_hdb_dialer_names (pglobal, &pzhdb); - if (iret != UUCONF_SUCCESS) - return iret; - } -#endif - - if (pzhdb == NULL) - *ppzdialers = pztaylor; - else if (pztaylor == NULL) - *ppzdialers = pzhdb; - else - { - char **pz; - - iret = UUCONF_SUCCESS; - - for (pz = pztaylor; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE, - ppzdialers, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - - if (iret == UUCONF_SUCCESS) - { - for (pz = pzhdb; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE, - ppzdialers, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - } - - if (pztaylor != NULL) - free ((pointer) pztaylor); - if (pzhdb != NULL) - free ((pointer) pzhdb); - } - - if (iret == UUCONF_SUCCESS && *ppzdialers == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzdialers, (pointer) NULL); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/errno.c b/gnu/libexec/uucp/libuuconf/errno.c deleted file mode 100644 index 129c4a4b88b7..000000000000 --- a/gnu/libexec/uucp/libuuconf/errno.c +++ /dev/null @@ -1,46 +0,0 @@ -/* errno.c - Return the saved errno value. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_errno_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Return the saved errno value. */ - -int -uuconf_error_errno (pglobal) - pointer pglobal; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - if (qglobal == NULL) - return errno; - else - return qglobal->ierrno; -} diff --git a/gnu/libexec/uucp/libuuconf/errstr.c b/gnu/libexec/uucp/libuuconf/errstr.c deleted file mode 100644 index d5370c963ec8..000000000000 --- a/gnu/libexec/uucp/libuuconf/errstr.c +++ /dev/null @@ -1,241 +0,0 @@ -/* errstr.c - Return a string for a uuconf error. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_errstr_rcsid[] = "$FreeBSD$"; -#endif - -static char *zeprint_num P((char *zbuf, size_t cbuf, int ival)); - -/* Return an error string for a uuconf error. This does not return a - uuconf error code, but instead returns the total buffer length. */ - -int -uuconf_error_string (pglobal, ierr, zbuf, cbuf) - pointer pglobal; - int ierr; - char *zbuf; - size_t cbuf; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - const char *zfile; - size_t cfile; - const char *zlineno; - char ablineno[100]; - size_t clineno; - const char *zmsg; - char abmsg[100]; - size_t cmsg; - const char *zerrno; - size_t cerrno; - size_t cret; - size_t ccopy; - - /* The format of the message is - - filename:lineno: message: errno - - If there is no filename, the trailing colon is not output. If - there is no linenumber, the trailing colon is not output. If - there is no filename, the linenumber is not output, and neither - is the space before message. If there is no errno, the - preceeding colon and space are not output. */ - - /* Get the filename to put in the error message, if any. */ - if ((ierr & UUCONF_ERROR_FILENAME) == 0 - || qglobal == NULL - || qglobal->zfilename == NULL) - { - zfile = ""; - cfile = 0; - } - else - { - zfile = qglobal->zfilename; - cfile = strlen (zfile) + 1; - } - - /* Get the line number to put in the error message, if any. */ - if (cfile == 0 - || (ierr & UUCONF_ERROR_LINENO) == 0 - || qglobal == NULL - || qglobal->ilineno <= 0) - { - zlineno = ""; - clineno = 0; - } - else - { - zlineno = zeprint_num (ablineno, sizeof ablineno, qglobal->ilineno); - clineno = strlen (zlineno) + 1; - } - - /* Get the main message. */ - switch (UUCONF_ERROR_VALUE (ierr)) - { - case UUCONF_SUCCESS: - zmsg = "no error"; - break; - case UUCONF_NOT_FOUND: - zmsg = "not found"; - break; - case UUCONF_FOPEN_FAILED: - zmsg = "fopen"; - break; - case UUCONF_FSEEK_FAILED: - zmsg = "fseek"; - break; - case UUCONF_MALLOC_FAILED: - zmsg = "malloc"; - break; - case UUCONF_SYNTAX_ERROR: - zmsg = "syntax error"; - break; - default: - zmsg = zeprint_num (abmsg, sizeof abmsg, UUCONF_ERROR_VALUE (ierr)); - zmsg -= sizeof "error " - 1; - memcpy ((pointer) zmsg, (pointer) "error ", sizeof "error " - 1); - break; - } - - cmsg = strlen (zmsg); - if (cfile > 0) - ++cmsg; - - /* Get the errno string. Note that strerror is not necessarily - reentrant. */ - if ((ierr & UUCONF_ERROR_ERRNO) == 0 - || qglobal == NULL) - { - zerrno = ""; - cerrno = 0; - } - else - { - zerrno = strerror (qglobal->ierrno); - cerrno = strlen (zerrno) + 2; - } - - cret = cfile + clineno + cmsg + cerrno + 1; - - if (cbuf == 0) - return cret; - - /* Leave room for the null byte. */ - --cbuf; - - if (cfile > 0) - { - ccopy = cfile - 1; - if (ccopy > cbuf) - ccopy = cbuf; - memcpy ((pointer) zbuf, (pointer) zfile, ccopy); - zbuf += ccopy; - cbuf -= ccopy; - if (cbuf > 0) - { - *zbuf++ = ':'; - --cbuf; - } - } - - if (clineno > 0) - { - ccopy = clineno - 1; - if (ccopy > cbuf) - ccopy = cbuf; - memcpy ((pointer) zbuf, (pointer) zlineno, ccopy); - zbuf += ccopy; - cbuf -= ccopy; - if (cbuf > 0) - { - *zbuf++ = ':'; - --cbuf; - } - } - - if (cbuf > 0 && cfile > 0) - { - *zbuf++ = ' '; - --cbuf; - --cmsg; - } - ccopy = cmsg; - if (ccopy > cbuf) - ccopy = cbuf; - memcpy ((pointer) zbuf, (pointer) zmsg, ccopy); - zbuf += ccopy; - cbuf -= ccopy; - - if (cerrno > 0) - { - if (cbuf > 0) - { - *zbuf++ = ':'; - --cbuf; - } - if (cbuf > 0) - { - *zbuf++ = ' '; - --cbuf; - } - ccopy = cerrno - 2; - if (ccopy > cbuf) - ccopy = cbuf; - memcpy ((pointer) zbuf, (pointer) zerrno, ccopy); - zbuf += ccopy; - cbuf -= ccopy; - } - - *zbuf = '\0'; - - return cret; -} - -/* Turn a number into a string. This should really call sprintf, but - since nothing else in the uuconf library calls any print routine, - it's more interesting to not call it here either. */ - -static char * -zeprint_num (ab, c, i) - char *ab; - size_t c; - register int i; -{ - register char *z; - - z = ab + c; - *--z = '\0'; - do - { - *--z = i % 10 + '0'; - i /= 10; - } - while (i != 0); - - return z; -} diff --git a/gnu/libexec/uucp/libuuconf/filnam.c b/gnu/libexec/uucp/libuuconf/filnam.c deleted file mode 100644 index 55c23b75ec18..000000000000 --- a/gnu/libexec/uucp/libuuconf/filnam.c +++ /dev/null @@ -1,44 +0,0 @@ -/* filnam.c - Return the saved file name. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_filnam_rcsid[] = "$FreeBSD$"; -#endif - -/* Return the saved file name. */ - -UUCONF_CONST char * -uuconf_error_filename (pglobal) - pointer pglobal; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - if (qglobal == NULL) - return ""; - else - return qglobal->zfilename; -} diff --git a/gnu/libexec/uucp/libuuconf/freblk.c b/gnu/libexec/uucp/libuuconf/freblk.c deleted file mode 100644 index df01897e29a3..000000000000 --- a/gnu/libexec/uucp/libuuconf/freblk.c +++ /dev/null @@ -1,63 +0,0 @@ -/* freblk.c - Free up an entire memory block. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_freblk_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Free up an entire memory block. */ - -#if UUCONF_ANSI_C -void -#endif -uuconf_free_block (pblock) - pointer pblock; -{ - struct sblock *q = (struct sblock *) pblock; - struct sblock *qloop; - - /* We have to free the added blocks first because the list may link - into blocks that are earlier on the list. */ - for (qloop = q; qloop != NULL; qloop = qloop->qnext) - { - struct sadded *qadd; - - for (qadd = qloop->qadded; qadd != NULL; qadd = qadd->qnext) - free (qadd->padded); - } - - while (q != NULL) - { - struct sblock *qnext; - - qnext = q->qnext; - free ((pointer) q); - q = qnext; - } -} diff --git a/gnu/libexec/uucp/libuuconf/fredia.c b/gnu/libexec/uucp/libuuconf/fredia.c deleted file mode 100644 index c1f8f46786b0..000000000000 --- a/gnu/libexec/uucp/libuuconf/fredia.c +++ /dev/null @@ -1,44 +0,0 @@ -/* fredia.c - Free dialer information. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_fredia_rcsid[] = "$FreeBSD$"; -#endif - -/* Free the memory allocated for a dialer. */ - -#undef uuconf_dialer_free - -/*ARGSUSED*/ -int -uuconf_dialer_free (pglobal, qdialer) - pointer pglobal; - struct uuconf_dialer *qdialer; -{ - uuconf_free_block (qdialer->uuconf_palloc); - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/free.c b/gnu/libexec/uucp/libuuconf/free.c deleted file mode 100644 index c31f337925e8..000000000000 --- a/gnu/libexec/uucp/libuuconf/free.c +++ /dev/null @@ -1,68 +0,0 @@ -/* free.c - Free a buffer from within a memory block. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_free_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Free memory allocated by uuconf_malloc. If the memory block is - NULL, this just calls free; this is convenient for a number of - routines. Otherwise, this will only do something if this was the - last buffer allocated for one of the memory blocks in the list; in - other cases, the memory is lost until the entire memory block is - freed. */ - -#if UUCONF_ANSI_C -void -#endif -uuconf_free (pblock, pbuf) - pointer pblock; - pointer pbuf; -{ - struct sblock *q = (struct sblock *) pblock; - - if (pbuf == NULL) - return; - - if (q == NULL) - { - free (pbuf); - return; - } - - for (; q != NULL; q = q->qnext) - { - if (q->plast == pbuf) - { - q->ifree = (char *) pbuf - q->u.ab; - /* We could reset q->plast here, but it doesn't matter. */ - return; - } - } -} diff --git a/gnu/libexec/uucp/libuuconf/freprt.c b/gnu/libexec/uucp/libuuconf/freprt.c deleted file mode 100644 index 265275804b31..000000000000 --- a/gnu/libexec/uucp/libuuconf/freprt.c +++ /dev/null @@ -1,44 +0,0 @@ -/* freprt.c - Free port information. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_freprt_rcsid[] = "$FreeBSD$"; -#endif - -/* Free the memory allocated for a port. */ - -#undef uuconf_port_free - -/*ARGSUSED*/ -int -uuconf_port_free (pglobal, qport) - pointer pglobal; - struct uuconf_port *qport; -{ - uuconf_free_block (qport->uuconf_palloc); - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/fresys.c b/gnu/libexec/uucp/libuuconf/fresys.c deleted file mode 100644 index a8a71cba2a7c..000000000000 --- a/gnu/libexec/uucp/libuuconf/fresys.c +++ /dev/null @@ -1,44 +0,0 @@ -/* fresys.c - Free system information. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_fresys_rcsid[] = "$FreeBSD$"; -#endif - -/* Free the memory allocated for a system. */ - -#undef uuconf_system_free - -/*ARGSUSED*/ -int -uuconf_system_free (pglobal, qsys) - pointer pglobal; - struct uuconf_system *qsys; -{ - uuconf_free_block (qsys->uuconf_palloc); - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/grdcmp.c b/gnu/libexec/uucp/libuuconf/grdcmp.c deleted file mode 100644 index 65b5e6311cf8..000000000000 --- a/gnu/libexec/uucp/libuuconf/grdcmp.c +++ /dev/null @@ -1,76 +0,0 @@ -/* grdcmp.c - Compare two grades. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_grdcmp_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Compare two grades, returning < 0 if b1 should be executed before - b2, == 0 if they are the same, or > 0 if b1 should be executed - after b2. This can not fail, and does not return a standard uuconf - error code. - - This implementation assumes that the upper case letters are in - sequence, and that the lower case letters are in sequence. */ - -int -uuconf_grade_cmp (barg1, barg2) - int barg1; - int barg2; -{ - int b1, b2; - - /* Make sure the arguments are unsigned. */ - b1 = (int) BUCHAR (barg1); - b2 = (int) BUCHAR (barg2); - - if (isdigit (b1)) - { - if (isdigit (b2)) - return b1 - b2; - else - return -1; - } - else if (isupper (b1)) - { - if (isdigit (b2)) - return 1; - else if (isupper (b2)) - return b1 - b2; - else - return -1; - } - else - { - if (! islower (b2)) - return 1; - else - return b1 - b2; - } -} diff --git a/gnu/libexec/uucp/libuuconf/hdial.c b/gnu/libexec/uucp/libuuconf/hdial.c deleted file mode 100644 index 6c524f8ec58c..000000000000 --- a/gnu/libexec/uucp/libuuconf/hdial.c +++ /dev/null @@ -1,187 +0,0 @@ -/* hdial.c - Find a dialer in the HDB configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hdial_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Find a dialer in the HDB configuration files by name. */ - -int -uuconf_hdb_dialer_info (pglobal, zname, qdialer) - pointer pglobal; - const char *zname; - struct uuconf_dialer *qdialer; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pz; - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - int iret; - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - - iret = UUCONF_NOT_FOUND; - - for (pz = qglobal->qprocess->pzhdb_dialers; *pz != NULL; pz++) - { - FILE *e; - int cchars; - - qglobal->ilineno = 0; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int ctoks; - pointer pblock; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - if (isspace (BUCHAR (zline[0])) || zline[0] == '#') - continue; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - if (ctoks < 1) - continue; - - if (strcmp (zname, pzsplit[0]) != 0) - continue; - - /* We found the dialer. */ - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - zline = NULL; - - _uuconf_uclear_dialer (qdialer); - qdialer->uuconf_zname = pzsplit[0]; - qdialer->uuconf_palloc = pblock; - - if (ctoks > 1) - { - /* The second field is characters to send instead of "=" - and "-" in phone numbers. */ - if (strcmp (pzsplit[1], "\"\"") == 0) - { - char *zsubs; - char bnext; - - zsubs = pzsplit[1]; - bnext = *zsubs; - while (bnext != '\0') - { - if (bnext == '=') - qdialer->uuconf_zdialtone = zsubs + 1; - else if (bnext == '-') - qdialer->uuconf_zpause = zsubs + 1; - if (zsubs[1] == '\0') - break; - zsubs += 2; - bnext = *zsubs; - *zsubs = '\0'; - } - } - - /* Any remaining fields form a chat script. */ - if (ctoks > 2) - { - pzsplit[1] = (char *) "chat"; - iret = _uuconf_ichat_cmd (qglobal, ctoks - 1, - pzsplit + 1, - &qdialer->uuconf_schat, - pblock); - iret &=~ UUCONF_CMDTABRET_KEEP; - if (iret != UUCONF_SUCCESS) - { - uuconf_free_block (pblock); - break; - } - } - } - - iret = UUCONF_SUCCESS; - break; - } - - (void) fclose (e); - - if (iret != UUCONF_NOT_FOUND) - break; - } - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - - if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/hdnams.c b/gnu/libexec/uucp/libuuconf/hdnams.c deleted file mode 100644 index f02019b7ef9f..000000000000 --- a/gnu/libexec/uucp/libuuconf/hdnams.c +++ /dev/null @@ -1,109 +0,0 @@ -/* hdnams.c - Get all known dialer names from the HDB configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hdnams_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Get all the dialer names from the HDB Dialers file. */ - -int -uuconf_hdb_dialer_names (pglobal, ppzdialers) - pointer pglobal; - char ***ppzdialers; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - char *zline; - size_t cline; - char **pz; - - *ppzdialers = NULL; - - iret = UUCONF_SUCCESS; - - zline = NULL; - cline = 0; - - for (pz = qglobal->qprocess->pzhdb_dialers; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - qglobal->ilineno = 0; - - while (_uuconf_getline (qglobal, &zline, &cline, e) > 0) - { - ++qglobal->ilineno; - - /* Lines beginning with whitespace are treated as comments. - No dialer name can contain a '#', which is another - comment character, so eliminating the first '#' does no - harm and catches comments. */ - zline[strcspn (zline, " \t#\n")] = '\0'; - if (*zline == '\0') - continue; - - iret = _uuconf_iadd_string (qglobal, zline, TRUE, TRUE, - ppzdialers, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - { - iret |= UUCONF_ERROR_LINENO; - break; - } - } - - (void) fclose (e); - } - - if (zline != NULL) - free ((pointer) zline); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME; - } - - if (*ppzdialers == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzdialers, (pointer) NULL); - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/hinit.c b/gnu/libexec/uucp/libuuconf/hinit.c deleted file mode 100644 index 5a0e32a4b291..000000000000 --- a/gnu/libexec/uucp/libuuconf/hinit.c +++ /dev/null @@ -1,295 +0,0 @@ -/* hinit.c - Initialize for reading HDB configuration files. - - Copyright (C) 1992, 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hinit_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Avoid replicating OLDCONFIGLIB several times if not necessary. */ -static const char abHoldconfiglib[] = OLDCONFIGLIB; - -/* Initialize the routines which read HDB configuration files. */ - -int -uuconf_hdb_init (ppglobal, zprogram) - pointer *ppglobal; - const char *zprogram; -{ - struct sglobal **pqglobal = (struct sglobal **) ppglobal; - int iret; - struct sglobal *qglobal; - pointer pblock; - char abdialcodes[sizeof OLDCONFIGLIB + sizeof HDB_DIALCODES - 1]; - char *zsys; - FILE *e; - - if (*pqglobal == NULL) - { - iret = _uuconf_iinit_global (pqglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - qglobal = *pqglobal; - pblock = qglobal->pblock; - - if (zprogram == NULL - || strcmp (zprogram, "uucp") == 0) - zprogram = "uucico"; - - /* Add the Dialcodes file to the global list. */ - memcpy ((pointer) abdialcodes, (pointer) abHoldconfiglib, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (abdialcodes + sizeof OLDCONFIGLIB - 1), - (pointer) HDB_DIALCODES, sizeof HDB_DIALCODES); - iret = _uuconf_iadd_string (qglobal, abdialcodes, TRUE, FALSE, - &qglobal->qprocess->pzdialcodefiles, - pblock); - if (iret != UUCONF_SUCCESS) - return iret; - - /* Read the Sysfiles file. We allocate the name on the heap rather - than the stack so that we can return it in - qerr->uuconf_zfilename. */ - - zsys = uuconf_malloc (pblock, - sizeof OLDCONFIGLIB + sizeof HDB_SYSFILES - 1); - if (zsys == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) zsys, (pointer) abHoldconfiglib, sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (zsys + sizeof OLDCONFIGLIB - 1), (pointer) HDB_SYSFILES, - sizeof HDB_SYSFILES); - - iret = UUCONF_SUCCESS; - - e = fopen (zsys, "r"); - if (e == NULL) - uuconf_free (pblock, zsys); - else - { - char *zline; - size_t cline; - char **pzargs; - size_t cargs; - char **pzcolon; - size_t ccolon; - int cchars; - - zline = NULL; - cline = 0; - pzargs = NULL; - cargs = 0; - pzcolon = NULL; - ccolon = 0; - - qglobal->ilineno = 0; - - while (iret == UUCONF_SUCCESS - && (cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int ctypes, cnames; - int i; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - if (zline[0] == '#') - continue; - - ctypes = _uuconf_istrsplit (zline, '\0', &pzargs, &cargs); - if (ctypes < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - if (ctypes == 0) - continue; - - if (strncmp (pzargs[0], "service=", sizeof "service=" - 1) != 0) - { - iret = UUCONF_SYNTAX_ERROR; - break; - } - pzargs[0] += sizeof "service=" - 1; - - cnames = _uuconf_istrsplit (pzargs[0], ':', &pzcolon, &ccolon); - if (cnames < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - for (i = 0; i < cnames; i++) - if (strcmp (zprogram, pzcolon[i]) == 0) - break; - - if (i >= cnames) - continue; - - for (i = 1; i < ctypes && iret == UUCONF_SUCCESS; i++) - { - char ***ppz; - int cfiles, ifile; - - if (strncmp (pzargs[i], "systems=", sizeof "systems=" - 1) - == 0) - { - ppz = &qglobal->qprocess->pzhdb_systems; - pzargs[i] += sizeof "systems=" - 1; - } - else if (strncmp (pzargs[i], "devices=", sizeof "devices=" - 1) - == 0) - { - ppz = &qglobal->qprocess->pzhdb_devices; - pzargs[i] += sizeof "devices=" - 1; - } - else if (strncmp (pzargs[i], "dialers=", sizeof "dialers=" - 1) - == 0) - { - ppz = &qglobal->qprocess->pzhdb_dialers; - pzargs[i] += sizeof "dialers=" - 1; - } - else - { - iret = UUCONF_SYNTAX_ERROR; - break; - } - - cfiles = _uuconf_istrsplit (pzargs[i], ':', &pzcolon, &ccolon); - if (cfiles < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - for (ifile = 0; - ifile < cfiles && iret == UUCONF_SUCCESS; - ifile++) - { - /* Looking for a leading '/' is Unix dependent, and - should probably be changed. */ - if (pzcolon[ifile][0] == '/') - iret = _uuconf_iadd_string (qglobal, pzcolon[ifile], TRUE, - FALSE, ppz, pblock); - else - { - char *zdir; - size_t clen; - - clen = strlen (pzcolon[ifile]); - zdir = (char *) uuconf_malloc (pblock, - (sizeof OLDCONFIGLIB - + sizeof HDB_SEPARATOR - + clen - - 1)); - if (zdir == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) zdir, (pointer) abHoldconfiglib, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (zdir + sizeof OLDCONFIGLIB - 1), - HDB_SEPARATOR, sizeof HDB_SEPARATOR - 1); - memcpy ((pointer) (zdir - + sizeof OLDCONFIGLIB - 1 - + sizeof HDB_SEPARATOR - 1), - (pointer) pzcolon[ifile], clen + 1); - iret = _uuconf_iadd_string (qglobal, zdir, FALSE, FALSE, - ppz, pblock); - } - } - } - } - - (void) fclose (e); - if (zline != NULL) - free ((pointer) zline); - if (pzargs != NULL) - free ((pointer) pzargs); - if (pzcolon != NULL) - free ((pointer) pzcolon); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = zsys; - return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - } - - if (qglobal->qprocess->pzhdb_systems == NULL) - { - char ab[sizeof OLDCONFIGLIB + sizeof HDB_SYSTEMS - 1]; - - memcpy ((pointer) ab, (pointer) abHoldconfiglib, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1), - (pointer) HDB_SYSTEMS, sizeof HDB_SYSTEMS); - iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE, - &qglobal->qprocess->pzhdb_systems, - pblock); - } - if (qglobal->qprocess->pzhdb_devices == NULL && iret == UUCONF_SUCCESS) - { - char ab[sizeof OLDCONFIGLIB + sizeof HDB_DEVICES - 1]; - - memcpy ((pointer) ab, (pointer) abHoldconfiglib, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1), - (pointer) HDB_DEVICES, sizeof HDB_DEVICES); - iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE, - &qglobal->qprocess->pzhdb_devices, - pblock); - } - if (qglobal->qprocess->pzhdb_dialers == NULL && iret == UUCONF_SUCCESS) - { - char ab[sizeof OLDCONFIGLIB + sizeof HDB_DIALERS - 1]; - - memcpy ((pointer) ab, (pointer) abHoldconfiglib, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1), - (pointer) HDB_DIALERS, sizeof HDB_DIALERS); - iret = _uuconf_iadd_string (qglobal, ab, TRUE, FALSE, - &qglobal->qprocess->pzhdb_dialers, - pblock); - } - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/hlocnm.c b/gnu/libexec/uucp/libuuconf/hlocnm.c deleted file mode 100644 index 0ede436c5f61..000000000000 --- a/gnu/libexec/uucp/libuuconf/hlocnm.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hlocnm.c - Get the local name to use from the HDB configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hlocnm_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get the local name to use, based on the login name, from the HDB - configuration files. */ - -int -uuconf_hdb_login_localname (pglobal, zlogin, pzname) - pointer pglobal; - const char *zlogin; - char **pzname; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct shpermissions *qperm; - - if (! qglobal->qprocess->fhdb_read_permissions) - { - int iret; - - iret = _uuconf_ihread_permissions (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - for (qperm = qglobal->qprocess->qhdb_permissions; - qperm != NULL; - qperm = qperm->qnext) - { - if (qperm->zmyname != NULL - && qperm->zmyname != (char *) &_uuconf_unset - && qperm->pzlogname != NULL - && qperm->pzlogname != (char **) &_uuconf_unset) - { - char **pz; - - for (pz = qperm->pzlogname; *pz != NULL; pz++) - { - if (strcmp (*pz, zlogin) == 0) - { - *pzname = strdup (qperm->zmyname); - if (*pzname == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - return UUCONF_SUCCESS; - } - } - } - } - - *pzname = NULL; - return UUCONF_NOT_FOUND; -} diff --git a/gnu/libexec/uucp/libuuconf/hport.c b/gnu/libexec/uucp/libuuconf/hport.c deleted file mode 100644 index 2836fbc54ae3..000000000000 --- a/gnu/libexec/uucp/libuuconf/hport.c +++ /dev/null @@ -1,374 +0,0 @@ -/* hport.c - Find a port in the HDB configuration files. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hport_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include -#include - -/* Find a port in the HDB configuration files by name, baud rate, and - special purpose function. */ - -int -uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) - pointer pglobal; - const char *zname; - long ibaud; - long ihighbaud; - int (*pifn) P((struct uuconf_port *, pointer)); - pointer pinfo; - struct uuconf_port *qport; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - int iret; - char **pz; - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - - iret = UUCONF_NOT_FOUND; - - for (pz = qglobal->qprocess->pzhdb_devices; *pz != NULL; pz++) - { - FILE *e; - int cchars; - - qglobal->ilineno = 0; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - iret = UUCONF_NOT_FOUND; - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int ctoks; - char *z, *zprotos, *zport; - long ilow, ihigh; - pointer pblock; - char ***ppzdialer; - - ++qglobal->ilineno; - - iret = UUCONF_NOT_FOUND; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - if (isspace (BUCHAR (zline[0])) || zline[0] == '#') - continue; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - /* An entry in Devices is - - type device dial-device baud dialer-token pairs - - The type (normally "ACU") is treated as the name. */ - - /* If there aren't enough entries, ignore the line; this - should probably do something more useful. */ - if (ctoks < 4) - continue; - - /* There may be a comma separated list of protocols after - the name. */ - zprotos = strchr (pzsplit[0], ','); - if (zprotos != NULL) - { - *zprotos = '\0'; - ++zprotos; - } - - zport = pzsplit[0]; - - /* Get any modem class, and pick up the baud rate while - we're at it. The modem class will be appended to the - name, so we need to get it before we see if we've found - the port with the right name. */ - z = pzsplit[3]; - if (strcasecmp (z, "Any") == 0 - || strcmp (z, "-") == 0) - { - ilow = 0L; - ihigh = 0L; - } - else - { - char *zend; - - while (*z != '\0' && ! isdigit (BUCHAR (*z))) - ++z; - - ilow = strtol (z, &zend, 10); - if (*zend == '-') - ihigh = strtol (zend + 1, (char **) NULL, 10); - else - ihigh = ilow; - - if (z != pzsplit[3]) - { - size_t cclass, cport; - - cclass = z - pzsplit[3]; - cport = strlen (pzsplit[0]); - zport = malloc (cport + cclass + 1); - if (zport == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) zport, (pointer) pzsplit[0], cport); - memcpy ((pointer) (zport + cport), (pointer) pzsplit[3], - cclass); - zport[cport + cclass] = '\0'; - } - } - - /* Make sure the name and baud rate match any argument. */ - if ((zname != NULL - && strcmp (zport, zname) != 0) - || (ibaud != 0 - && ilow != 0 - && (ilow > ibaud || ihigh < ibaud))) - { - if (zport != pzsplit[0]) - free ((pointer) zport); - continue; - } - - /* Some systems permit ,M after the device name. This means - to open the port with O_NDELAY and then change it. We - just ignore this flag, although perhaps we should record - it somewhere. */ - pzsplit[1][strcspn (pzsplit[1], ",")] = '\0'; - - /* Now we must construct the port information, so that we - can pass it to pifn. The port type is determined by its - name, unfortunately. The name "Direct" is used for a - direct port, "TCP" for a TCP port, and anything else for - a modem port. */ - pblock = NULL; - _uuconf_uclear_port (qport); - qport->uuconf_zname = zport; - qport->uuconf_zprotocols = zprotos; - if (strcmp (pzsplit[0], "Direct") == 0) - { - qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT; - qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1]; - qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow; - qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; - qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; - ppzdialer = NULL; - } - else if (strcmp (pzsplit[0], "TCP") == 0) - { - /* For a TCP port, the device name is taken as the TCP - port to use. */ - qport->uuconf_ttype = UUCONF_PORTTYPE_TCP; - qport->uuconf_ireliable - = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX - | UUCONF_RELIABLE_SPECIFIED); - qport->uuconf_u.uuconf_stcp.uuconf_zport = pzsplit[1]; - - /* I leave with IPv4 only for compatibility reason. If - you wish to use IPv6, please try Taylor UUCP - configuration instead. If you still wish to use IPv6 - with HDB configuration, re-make with INET6 defined. - In this case, you cannot specify the protocol family - in HDB configuration file. */ -#ifdef INET6 - qport->uuconf_u.uuconf_stcp.uuconf_zfamily = PF_UNSPEC; -#else - qport->uuconf_u.uuconf_stcp.uuconf_zfamily = PF_INET; -#endif - - ppzdialer = &qport->uuconf_u.uuconf_stcp.uuconf_pzdialer; - } - else if (ctoks >= 5 - && (strcmp (pzsplit[4], "TLI") == 0 - || strcmp (pzsplit[4], "TLIS") == 0)) - { - qport->uuconf_ttype = UUCONF_PORTTYPE_TLI; - qport->uuconf_u.uuconf_stli.uuconf_zdevice = pzsplit[1]; - qport->uuconf_u.uuconf_stli.uuconf_fstream - = strcmp (pzsplit[4], "TLIS") == 0; - qport->uuconf_u.uuconf_stli.uuconf_pzpush = NULL; - qport->uuconf_u.uuconf_stli.uuconf_zservaddr = NULL; - qport->uuconf_ireliable - = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX - | UUCONF_RELIABLE_SPECIFIED); - ppzdialer = &qport->uuconf_u.uuconf_stli.uuconf_pzdialer; - } - else - { - qport->uuconf_ttype = UUCONF_PORTTYPE_MODEM; - qport->uuconf_u.uuconf_smodem.uuconf_zdevice = pzsplit[1]; - if (strcmp (pzsplit[2], "-") != 0) - qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = - pzsplit[2]; - else - qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL; - if (ilow == ihigh) - { - qport->uuconf_u.uuconf_smodem.uuconf_ibaud = ilow; - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L; - } - else - { - qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = ilow; - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh; - } - qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; - qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; - qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; - ppzdialer = &qport->uuconf_u.uuconf_smodem.uuconf_pzdialer; - } - - if (ppzdialer != NULL) - { - if (ctoks < 5) - *ppzdialer = NULL; - else - { - size_t c; - char **pzd; - - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - c = (ctoks - 4) * sizeof (char *); - pzd = (char **) uuconf_malloc (pblock, c + sizeof (char *)); - if (pzd == NULL) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c); - pzd[ctoks - 4] = NULL; - - *ppzdialer = pzd; - } - } - - if (pifn != NULL) - { - iret = (*pifn) (qport, pinfo); - if (iret != UUCONF_SUCCESS) - { - if (zport != pzsplit[0]) - free ((pointer) zport); - if (pblock != NULL) - uuconf_free_block (pblock); - if (iret != UUCONF_NOT_FOUND) - break; - continue; - } - } - - /* This is the port we want. */ - if (pblock == NULL) - { - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - } - - if (uuconf_add_block (pblock, zline) != 0 - || (zport != pzsplit[0] - && uuconf_add_block (pblock, zport) != 0)) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - zline = NULL; - - qport->uuconf_palloc = pblock; - - iret = UUCONF_SUCCESS; - - break; - } - - (void) fclose (e); - - if (iret != UUCONF_NOT_FOUND) - break; - } - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - - if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/hrmunk.c b/gnu/libexec/uucp/libuuconf/hrmunk.c deleted file mode 100644 index fba3af97f1f1..000000000000 --- a/gnu/libexec/uucp/libuuconf/hrmunk.c +++ /dev/null @@ -1,55 +0,0 @@ -/* remunk.c - Get the name of the HDB remote.unknown shell script. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hrmunk_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get the name of the HDB remote.unknown shell script. */ - -int -uuconf_hdb_remote_unknown (pglobal, pzname) - pointer pglobal; - char **pzname; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - size_t csize; - - csize = sizeof OLDCONFIGLIB + sizeof HDB_REMOTE_UNKNOWN - 1; - *pzname = malloc (csize); - if (*pzname == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy (*pzname, OLDCONFIGLIB, sizeof OLDCONFIGLIB - 1); - memcpy (*pzname + sizeof OLDCONFIGLIB - 1, HDB_REMOTE_UNKNOWN, - sizeof HDB_REMOTE_UNKNOWN); - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/hsinfo.c b/gnu/libexec/uucp/libuuconf/hsinfo.c deleted file mode 100644 index 94343cc11015..000000000000 --- a/gnu/libexec/uucp/libuuconf/hsinfo.c +++ /dev/null @@ -1,637 +0,0 @@ -/* hsinfo.c - Get information about a system from the HDB configuration files. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hsinfo_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -static int ihadd_machine_perm P((struct sglobal *qglobal, - struct uuconf_system *qsys, - struct shpermissions *qperm)); -static int ihadd_logname_perm P((struct sglobal *qglobal, - struct uuconf_system *qsys, - struct shpermissions *qperm)); - -/* Get the information for a particular system from the HDB - configuration files. This does not make sure that all the default - values are set. */ - -int -_uuconf_ihdb_system_internal (qglobal, zsystem, qsys) - struct sglobal *qglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - int iret; - struct shpermissions *qperm; - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - char **pzcomma; - size_t ccomma; - pointer pblock; - char **pz; - boolean ffound_machine, ffound_login; - struct shpermissions *qother_machine; - struct uuconf_system *qalt; - - if (! qglobal->qprocess->fhdb_read_permissions) - { - iret = _uuconf_ihread_permissions (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* First look through the Permissions information to see if this is - an alias for some system. I assume that an alias applies to the - first name in the corresponding MACHINE entry. */ - - for (qperm = qglobal->qprocess->qhdb_permissions; - qperm != NULL; - qperm = qperm->qnext) - { - if (qperm->pzalias == NULL - || qperm->pzmachine == NULL - || qperm->pzalias == (char **) &_uuconf_unset - || qperm->pzmachine == (char **) &_uuconf_unset) - continue; - - for (pz = qperm->pzalias; *pz != NULL; pz++) - { - if (strcmp (*pz, zsystem) == 0) - { - zsystem = qperm->pzmachine[0]; - break; - } - } - if (*pz != NULL) - break; - } - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - pzcomma = NULL; - ccomma = 0; - - pblock = NULL; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzhdb_systems; *pz != NULL; pz++) - { - FILE *e; - int cchars; - - qglobal->ilineno = 0; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int ctoks, ctimes, i; - struct uuconf_system *qset; - char *z, *zretry; - int cretry; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - if (isspace (BUCHAR (zline[0])) || zline[0] == '#') - continue; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - /* If this isn't the system we're looking for, keep reading - the file. */ - if (ctoks < 1 - || strcmp (zsystem, pzsplit[0]) != 0) - continue; - - /* If this is the first time we've found the system, we want - to set *qsys directly. Otherwise, we allocate a new - alternate. */ - if (pblock == NULL) - { - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - _uuconf_uclear_system (qsys); - qsys->uuconf_palloc = pblock; - qset = qsys; - } - else - { - struct uuconf_system **pq; - - qset = ((struct uuconf_system *) - uuconf_malloc (pblock, sizeof (struct uuconf_system))); - if (qset == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - _uuconf_uclear_system (qset); - for (pq = &qsys->uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qset; - } - - /* Add this line to the memory block we are building for the - system. */ - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - zline = NULL; - cline = 0; - - /* The format of a line in Systems is - system time device speed phone chat - For example, - airs Any ACU 9600 5551212 ogin: foo pass: bar - */ - - /* Get the system name. */ - - qset->uuconf_zname = pzsplit[0]; - qset->uuconf_fcall = TRUE; - qset->uuconf_fcalled = FALSE; - - if (ctoks < 2) - continue; - - /* A time string is "time/grade,time/grade;retry". A - missing grade is taken as BGRADE_LOW. */ - zretry = strchr (pzsplit[1], ';'); - if (zretry == NULL) - cretry = 0; - else - { - *zretry = '\0'; - cretry = (int) strtol (zretry + 1, (char **) NULL, 10); - } - - ctimes = _uuconf_istrsplit (pzsplit[1], ',', &pzcomma, &ccomma); - if (ctimes < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - for (i = 0; i < ctimes; i++) - { - char *zslash; - char bgrade; - - z = pzcomma[i]; - zslash = strchr (z, '/'); - if (zslash == NULL) - bgrade = UUCONF_GRADE_LOW; - else - { - *zslash = '\0'; - bgrade = zslash[1]; - if (! UUCONF_GRADE_LEGAL (bgrade)) - bgrade = UUCONF_GRADE_LOW; - } - - iret = _uuconf_itime_parse (qglobal, z, (long) bgrade, - cretry, _uuconf_itime_grade_cmp, - &qset->uuconf_qtimegrade, - pblock); - - /* We treat a syntax error in the time field as - equivalent to ``never'', on the assumption that that - is what HDB does. */ - if (iret == UUCONF_SYNTAX_ERROR) - iret = UUCONF_SUCCESS; - - if (iret != UUCONF_SUCCESS) - break; - - /* Treat any time/grade setting as both a timegrade and - a call-timegrade. */ - if (bgrade != UUCONF_GRADE_LOW) - qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade; - } - - if (iret != UUCONF_SUCCESS) - break; - - if (ctoks < 3) - continue; - - /* Pick up the device name. It can be followed by a comma - and a list of protocols. */ - qset->uuconf_zport = pzsplit[2]; - z = strchr (pzsplit[2], ','); - if (z != NULL) - { - qset->uuconf_zprotocols = z + 1; - *z = '\0'; - } - - if (ctoks < 4) - continue; - - /* The speed entry can be a numeric speed, or a range of - speeds, or "Any", or "-". If it starts with a letter, - the initial nonnumeric prefix is a modem class, which - gets appended to the port name. */ - z = pzsplit[3]; - if (strcasecmp (z, "Any") != 0 - && strcmp (z, "-") != 0) - { - char *zend; - - while (*z != '\0' && ! isdigit (BUCHAR (*z))) - ++z; - - qset->uuconf_ibaud = strtol (z, &zend, 10); - if (*zend == '-') - qset->uuconf_ihighbaud = strtol (zend + 1, (char **) NULL, - 10); - - if (z != pzsplit[3]) - { - size_t cport, cclass; - - cport = strlen (pzsplit[2]); - cclass = z - pzsplit[3]; - qset->uuconf_zport = uuconf_malloc (pblock, - cport + cclass + 1); - if (qset->uuconf_zport == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) qset->uuconf_zport, (pointer) pzsplit[2], - cport); - memcpy ((pointer) (qset->uuconf_zport + cport), - (pointer) pzsplit[3], cclass); - qset->uuconf_zport[cport + cclass] = '\0'; - } - } - - if (ctoks < 5) - continue; - - /* Get the phone number. */ - qset->uuconf_zphone = pzsplit[4]; - - if (ctoks < 6) - continue; - - /* Get the chat script. We just hand this off to the chat - script processor, so that it will parse subsend and - subexpect strings correctly. */ - pzsplit[4] = (char *) "chat"; - iret = _uuconf_ichat_cmd (qglobal, ctoks - 4, pzsplit + 4, - &qset->uuconf_schat, pblock); - iret &=~ UUCONF_CMDTABRET_KEEP; - if (iret != UUCONF_SUCCESS) - break; - } - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - break; - } - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - if (pzcomma != NULL) - free ((pointer) pzcomma); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - if (pblock == NULL) - return UUCONF_NOT_FOUND; - - /* Now we have to put in the Permissions information. The relevant - Permissions entries are those with this system in the MACHINE - list and (if this system does not have a VALIDATE entry) those - with a LOGNAME list but no MACHINE list. If no entry is found - with this system in the MACHINE list, then we must look for an - entry with "OTHER" in the MACHINE list. */ - ffound_machine = FALSE; - ffound_login = FALSE; - qother_machine = NULL; - for (qperm = qglobal->qprocess->qhdb_permissions; - qperm != NULL; - qperm = qperm->qnext) - { - boolean fmachine; - - /* MACHINE=OTHER is recognized specially. It appears that OTHER - need only be recognized by itself, not when combined with - other machine names. */ - if (qother_machine == NULL - && qperm->pzmachine != NULL - && qperm->pzmachine != (char **) &_uuconf_unset - && qperm->pzmachine[0][0] == 'O' - && strcmp (qperm->pzmachine[0], "OTHER") == 0) - qother_machine = qperm; - - /* If this system is named in a MACHINE entry, we must add the - appropriate information to every alternate that could be used - for calling out. */ - fmachine = FALSE; - if (! ffound_machine - && qperm->pzmachine != NULL - && qperm->pzmachine != (char **) &_uuconf_unset) - { - for (pz = qperm->pzmachine; *pz != NULL; pz++) - { - if ((*pz)[0] == zsystem[0] - && strcmp (*pz, zsystem) == 0) - { - for (qalt = qsys; - qalt != NULL; - qalt = qalt->uuconf_qalternate) - { - if (qalt->uuconf_fcall) - { - iret = ihadd_machine_perm (qglobal, qalt, qperm); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - - fmachine = TRUE; - ffound_machine = TRUE; - - break; - } - } - } - - /* A LOGNAME line applies to this machine if it is listed in the - corresponding VALIDATE entry, or if it is not listed in any - VALIDATE entry. On this pass through the Permissions entry - we pick up the information if the system appears in a - VALIDATE entry; if it does not, we make another pass to put - in all the LOGNAME lines. */ - if (qperm->pzlogname != NULL - && qperm->pzlogname != (char **) &_uuconf_unset - && qperm->pzvalidate != NULL - && qperm->pzvalidate != (char **) &_uuconf_unset) - { - for (pz = qperm->pzvalidate; *pz != NULL; ++pz) - if ((*pz)[0] == zsystem[0] - && strcmp (*pz, zsystem) == 0) - break; - if (*pz != NULL) - { - for (pz = qperm->pzlogname; *pz != NULL; ++pz) - { - /* If this LOGNAME line is also a matching MACHINE - line, we can add the LOGNAME permissions to the - first alternate. Otherwise, we must create a new - alternate. We cannot put a LOGNAME line in the - first alternate if MACHINE does not match, - because certain permissions (e.g. READ) may be - specified by both types of lines, and we must use - LOGNAME entries only when accepting calls and - MACHINE entries only when placing calls. */ - if (fmachine - && (qsys->uuconf_zcalled_login == NULL - || (qsys->uuconf_zcalled_login - == (char *) &_uuconf_unset))) - { - qsys->uuconf_zcalled_login = *pz; - iret = ihadd_logname_perm (qglobal, qsys, qperm); - } - else - { - struct uuconf_system *qnew; - struct uuconf_system **pq; - - qnew = ((struct uuconf_system *) - uuconf_malloc (pblock, - sizeof (struct uuconf_system))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - *qnew = *qsys; - qnew->uuconf_qalternate = NULL; - for (pq = &qsys->uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qnew; - - qnew->uuconf_zcalled_login = *pz; - qnew->uuconf_fcall = FALSE; - iret = ihadd_logname_perm (qglobal, qnew, qperm); - } - - if (iret != UUCONF_SUCCESS) - return iret; - } - - ffound_login = TRUE; - } - } - } - - /* If we didn't find an entry for the machine, we must use the - MACHINE=OTHER entry, if any. */ - if (! ffound_machine && qother_machine != NULL) - { - for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate) - { - if (qalt->uuconf_fcall) - { - iret = ihadd_machine_perm (qglobal, qalt, qother_machine); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - } - - /* If this system was not listed in any VALIDATE entry, then we must - add a called-login for each LOGNAME entry in Permissions. */ - if (! ffound_login) - { - for (qperm = qglobal->qprocess->qhdb_permissions; - qperm != NULL; - qperm = qperm->qnext) - { - if (qperm->pzlogname == NULL - || qperm->pzlogname == (char **) &_uuconf_unset) - continue; - - for (pz = qperm->pzlogname; *pz != NULL; pz++) - { - struct uuconf_system *qnew; - struct uuconf_system **pq; - - qnew = ((struct uuconf_system *) - uuconf_malloc (pblock, - sizeof (struct uuconf_system))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - *qnew = *qsys; - qnew->uuconf_qalternate = NULL; - for (pq = &qsys->uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qnew; - - /* We recognize LOGNAME=OTHER specially, although this - appears to be an SCO innovation. */ - if (strcmp (*pz, "OTHER") == 0) - qnew->uuconf_zcalled_login = (char *) "ANY"; - else - qnew->uuconf_zcalled_login = *pz; - qnew->uuconf_fcall = FALSE; - iret = ihadd_logname_perm (qglobal, qnew, qperm); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - } - - /* HDB permits local requests to receive to any directory, which is - not the default put in by _uuconf_isystem_basic_default. We set - it here instead. */ - for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate) - { - iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR, - FALSE, FALSE, - &qalt->uuconf_pzlocal_receive, - pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* HDB does not have a maximum number of retries if a retry time is - given in the time field. */ - if (qsys->uuconf_qtimegrade != NULL - && qsys->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset - && qsys->uuconf_qtimegrade->uuconf_cretry > 0) - qsys->uuconf_cmax_retries = 0; - - return UUCONF_SUCCESS; -} - -/* Add the settings of a MACHINE line in Permissions to a system. */ - -/*ARGSIGNORED*/ -static int -ihadd_machine_perm (qglobal, qsys, qperm) - struct sglobal *qglobal; - struct uuconf_system *qsys; - struct shpermissions *qperm; -{ - if (qperm->frequest >= 0) - qsys->uuconf_fsend_request = qperm->frequest; - else - qsys->uuconf_fsend_request = FALSE; - qsys->uuconf_pzremote_send = qperm->pzread; - qsys->uuconf_pzremote_receive = qperm->pzwrite; - qsys->uuconf_pzcmds = qperm->pzcommands; - qsys->uuconf_zlocalname = qperm->zmyname; - qsys->uuconf_zpubdir = qperm->zpubdir; - qsys->uuconf_pzalias = qperm->pzalias; - - return UUCONF_SUCCESS; -} - -/* Add the settings of a LOGNAME line in Permissions to a system. */ - -/*ARGSIGNORED*/ -static int -ihadd_logname_perm (qglobal, qsys, qperm) - struct sglobal *qglobal; - struct uuconf_system *qsys; - struct shpermissions *qperm; -{ - qsys->uuconf_fcalled = TRUE; - if (qperm->frequest >= 0) - qsys->uuconf_fsend_request = qperm->frequest; - else - qsys->uuconf_fsend_request = FALSE; - qsys->uuconf_fcalled_transfer = qperm->fsendfiles; - qsys->uuconf_pzremote_send = qperm->pzread; - qsys->uuconf_pzremote_receive = qperm->pzwrite; - qsys->uuconf_fcallback = qperm->fcallback; - qsys->uuconf_zlocalname = qperm->zmyname; - qsys->uuconf_zpubdir = qperm->zpubdir; - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/hsnams.c b/gnu/libexec/uucp/libuuconf/hsnams.c deleted file mode 100644 index 18cec1bc0c21..000000000000 --- a/gnu/libexec/uucp/libuuconf/hsnams.c +++ /dev/null @@ -1,142 +0,0 @@ -/* hsnams.c - Get all known system names from the HDB configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hsnams_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Get all the system names from the HDB Systems file. We have to - read the Permissions file in order to support aliases. */ - -int -uuconf_hdb_system_names (pglobal, ppzsystems, falias) - pointer pglobal; - char ***ppzsystems; - int falias; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - char *zline; - size_t cline; - char **pz; - - *ppzsystems = NULL; - - iret = UUCONF_SUCCESS; - - zline = NULL; - cline = 0; - - for (pz = qglobal->qprocess->pzhdb_systems; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - qglobal->ilineno = 0; - - while (_uuconf_getline (qglobal, &zline, &cline, e) > 0) - { - ++qglobal->ilineno; - - /* Lines beginning with whitespace are treated as comments. - No system name can contain a '#', which is another - comment character, so eliminating the first '#' does no - harm and catches comments. */ - zline[strcspn (zline, " \t#\n")] = '\0'; - if (*zline == '\0') - continue; - - iret = _uuconf_iadd_string (qglobal, zline, TRUE, TRUE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - { - iret |= UUCONF_ERROR_LINENO; - break; - } - } - - (void) fclose (e); - } - - if (zline != NULL) - free ((pointer) zline); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME; - } - - /* If we are supposed to return aliases, we must read the - Permissions file. */ - if (falias) - { - struct shpermissions *q; - - if (! qglobal->qprocess->fhdb_read_permissions) - { - iret = _uuconf_ihread_permissions (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - for (q = qglobal->qprocess->qhdb_permissions; - q != NULL; - q = q->qnext) - { - pz = q->pzalias; - if (pz == NULL || pz == (char **) &_uuconf_unset) - continue; - - for (; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, TRUE, TRUE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - } - - if (*ppzsystems == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzsystems, (pointer) NULL); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/hsys.c b/gnu/libexec/uucp/libuuconf/hsys.c deleted file mode 100644 index 72254cc8a534..000000000000 --- a/gnu/libexec/uucp/libuuconf/hsys.c +++ /dev/null @@ -1,49 +0,0 @@ -/* hsys.c - User function to get a system from the HDB configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hsys_rcsid[] = "$FreeBSD$"; -#endif - -/* Get system information from the HDB configuration files. This is a - wrapper for the internal function which makes sure that every field - gets a default value. */ - -int -uuconf_hdb_system_info (pglobal, zsystem, qsys) - pointer pglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - - iret = _uuconf_ihdb_system_internal (qglobal, zsystem, qsys); - if (iret != UUCONF_SUCCESS) - return iret; - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/hunk.c b/gnu/libexec/uucp/libuuconf/hunk.c deleted file mode 100644 index c829817d76de..000000000000 --- a/gnu/libexec/uucp/libuuconf/hunk.c +++ /dev/null @@ -1,142 +0,0 @@ -/* hunk.c - Get information about an unknown system from the HDB Permissions file. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_hunk_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get information about an unknown system from the HDB Permissions - file. This doesn't run the remote.unknown shell script, because - that's too system dependent. */ - -int -uuconf_hdb_system_unknown (pglobal, qsys) - pointer pglobal; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - boolean ffirst; - struct shpermissions *qperm; - struct uuconf_system *qalt; - - if (! qglobal->qprocess->fhdb_read_permissions) - { - iret = _uuconf_ihread_permissions (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - _uuconf_uclear_system (qsys); - qsys->uuconf_palloc = uuconf_malloc_block (); - if (qsys->uuconf_palloc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - ffirst = TRUE; - - for (qperm = qglobal->qprocess->qhdb_permissions; - qperm != NULL; - qperm = qperm->qnext) - { - char **pz; - - if (qperm->pzlogname == NULL - || qperm->pzlogname == (char **) &_uuconf_unset) - continue; - - for (pz = qperm->pzlogname; *pz != NULL; pz++) - { - if (ffirst) - { - qalt = qsys; - ffirst = FALSE; - } - else - { - struct uuconf_system **pq; - - qalt = ((struct uuconf_system *) - uuconf_malloc (qsys->uuconf_palloc, - sizeof (struct uuconf_system))); - if (qalt == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - _uuconf_uclear_system (qalt); - for (pq = &qsys->uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qalt; - } - - /* We recognize LOGNAME=OTHER specially, although this - appears to be an SCO innovation. */ - if (strcmp (*pz, "OTHER") == 0) - qalt->uuconf_zcalled_login = (char *) "ANY"; - else - qalt->uuconf_zcalled_login = *pz; - qalt->uuconf_fcall = FALSE; - qsys->uuconf_fcalled = TRUE; - if (qperm->frequest >= 0) - qsys->uuconf_fsend_request = qperm->frequest; - else - qsys->uuconf_fsend_request = FALSE; - qsys->uuconf_fcalled_transfer = qperm->fsendfiles; - qsys->uuconf_pzremote_send = qperm->pzread; - qsys->uuconf_pzremote_receive = qperm->pzwrite; - qsys->uuconf_fcallback = qperm->fcallback; - qsys->uuconf_zlocalname = qperm->zmyname; - qsys->uuconf_zpubdir = qperm->zpubdir; - } - } - - if (ffirst) - return UUCONF_NOT_FOUND; - - /* HDB permits local requests to receive to any directory, which is - not the default put in by _uuconf_isystem_basic_default. We set - it here instead. */ - for (qalt = qsys; qalt != NULL; qalt = qalt->uuconf_qalternate) - { - iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR, - FALSE, FALSE, - &qalt->uuconf_pzlocal_receive, - qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/iniglb.c b/gnu/libexec/uucp/libuuconf/iniglb.c deleted file mode 100644 index d0b8dd081924..000000000000 --- a/gnu/libexec/uucp/libuuconf/iniglb.c +++ /dev/null @@ -1,180 +0,0 @@ -/* iniglb.c - Initialize the global information structure. - - Copyright (C) 1992, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_iniglb_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Initialize the global information structure. */ - -int -_uuconf_iinit_global (pqglobal) - struct sglobal **pqglobal; -{ - pointer pblock; - register struct sprocess *qprocess; - char *azargs[3]; - int iret; - - pblock = uuconf_malloc_block (); - if (pblock == NULL) - return UUCONF_MALLOC_FAILED; - - *pqglobal = (struct sglobal *) uuconf_malloc (pblock, - sizeof (struct sglobal)); - if (*pqglobal == NULL) - { - uuconf_free_block (pblock); - return UUCONF_MALLOC_FAILED; - } - - (*pqglobal)->qprocess = ((struct sprocess *) - uuconf_malloc (pblock, - sizeof (struct sprocess))); - if ((*pqglobal)->qprocess == NULL) - { - uuconf_free_block (pblock); - *pqglobal = NULL; - return UUCONF_MALLOC_FAILED; - } - - (*pqglobal)->pblock = pblock; - (*pqglobal)->ierrno = 0; - (*pqglobal)->ilineno = 0; - (*pqglobal)->zfilename = NULL; - - qprocess = (*pqglobal)->qprocess; - - qprocess->zlocalname = NULL; - qprocess->zspooldir = SPOOLDIR; - qprocess->zpubdir = PUBDIR; -#ifdef LOCKDIR - qprocess->zlockdir = LOCKDIR; -#else - qprocess->zlockdir = SPOOLDIR; -#endif - qprocess->zlogfile = LOGFILE; - qprocess->zstatsfile = STATFILE; - qprocess->zdebugfile = DEBUGFILE; - qprocess->zdebug = ""; - qprocess->fstrip_login = TRUE; - qprocess->fstrip_proto = TRUE; - qprocess->cmaxuuxqts = 0; - qprocess->zrunuuxqt = NULL; - qprocess->fv2 = TRUE; - qprocess->fhdb = TRUE; - qprocess->pzdialcodefiles = NULL; - qprocess->pztimetables = NULL; - qprocess->zconfigfile = NULL; - qprocess->pzsysfiles = NULL; - qprocess->pzportfiles = NULL; - qprocess->pzdialfiles = NULL; - qprocess->pzpwdfiles = NULL; - qprocess->pzcallfiles = NULL; - qprocess->qunknown = NULL; - qprocess->fread_syslocs = FALSE; - qprocess->qsyslocs = NULL; - qprocess->qvalidate = NULL; - qprocess->fuses_myname = FALSE; - qprocess->zv2systems = NULL; - qprocess->zv2devices = NULL; - qprocess->zv2userfile = NULL; - qprocess->zv2cmds = NULL; - qprocess->pzhdb_systems = NULL; - qprocess->pzhdb_devices = NULL; - qprocess->pzhdb_dialers = NULL; - qprocess->fhdb_read_permissions = FALSE; - qprocess->qhdb_permissions = NULL; - - azargs[0] = NULL; - azargs[1] = (char *) "Evening"; - azargs[2] = (char *) "Wk1705-0755,Sa,Su"; - iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs, - (pointer) NULL, (pointer) NULL); - if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS) - { - azargs[1] = (char *) "Night"; - azargs[2] = (char *) "Wk2305-0755,Sa,Su2305-1655"; - iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs, - (pointer) NULL, (pointer) NULL); - } - if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS) - { - azargs[1] = (char *) "NonPeak"; - azargs[2] = (char *) "Wk1805-0655,Sa,Su"; - iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs, - (pointer) NULL, (pointer) NULL); - } - if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) - { - uuconf_free_block (pblock); - *pqglobal = NULL; - - /* Strip off any special bits, since there's no global - structure. */ - return UUCONF_ERROR_VALUE (iret); - } - - return UUCONF_SUCCESS; -} - -/* Add a timetable. This is also called by the Taylor UUCP - initialization code, as well as by the Taylor UUCP sys file code - (although the latter is obsolete). There's no point in putting - this in a separate file, since everything must call - _uuconf_init_global. There is a race condition here if this is - called by two different threads on a sys file command, but the sys - file command is obsolete anyhow. */ - -/*ARGSUSED*/ -int -_uuconf_itimetable (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - - iret = _uuconf_iadd_string (qglobal, argv[1], FALSE, FALSE, - &qglobal->qprocess->pztimetables, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_EXIT; - - iret = _uuconf_iadd_string (qglobal, argv[2], FALSE, FALSE, - &qglobal->qprocess->pztimetables, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_EXIT; - - return UUCONF_CMDTABRET_KEEP; -} diff --git a/gnu/libexec/uucp/libuuconf/init.c b/gnu/libexec/uucp/libuuconf/init.c deleted file mode 100644 index e06c0019434e..000000000000 --- a/gnu/libexec/uucp/libuuconf/init.c +++ /dev/null @@ -1,74 +0,0 @@ -/* init.c - Initialize for reading UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_init_rcsid[] = "$FreeBSD$"; -#endif - -/* Initialize the UUCP configuration file reading routines. This is - just a generic routine which calls the type specific routines. */ - -/*ARGSUSED*/ -int -uuconf_init (ppglobal, zprogram, zname) - pointer *ppglobal; - const char *zprogram; - const char *zname; -{ - struct sglobal **pqglob = (struct sglobal **) ppglobal; - int iret; - - iret = UUCONF_NOT_FOUND; - - *pqglob = NULL; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_init (ppglobal, zprogram, zname); - if (iret != UUCONF_SUCCESS) - return iret; -#endif - -#if HAVE_V2_CONFIG - if (*pqglob == NULL || (*pqglob)->qprocess->fv2) - { - iret = uuconf_v2_init (ppglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } -#endif - -#if HAVE_HDB_CONFIG - if (*pqglob == NULL || (*pqglob)->qprocess->fhdb) - { - iret = uuconf_hdb_init (ppglobal, zprogram); - if (iret != UUCONF_SUCCESS) - return iret; - } -#endif - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/int.c b/gnu/libexec/uucp/libuuconf/int.c deleted file mode 100644 index f559ec97a1e0..000000000000 --- a/gnu/libexec/uucp/libuuconf/int.c +++ /dev/null @@ -1,59 +0,0 @@ -/* int.c - Parse a string into an int or a long. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_int_rcsid[] = "$FreeBSD$"; -#endif - -/* Parse a string into a variable. This is called by uuconf_cmd_args, - as well as other functions. The parsing is done in a single place - to make it easy to change. This should return an error code, - including both UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT if - appropriate. */ - -/*ARGSIGNORED*/ -int -_uuconf_iint (qglobal, zval, p, fint) - struct sglobal *qglobal; - const char *zval; - pointer p; - boolean fint; -{ - long i; - char *zend; - - i = strtol ((char *) zval, &zend, 10); - if (*zend != '\0') - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (fint) - *(int *) p = (int) i; - else - *(long *) p = i; - - return UUCONF_CMDTABRET_CONTINUE; -} diff --git a/gnu/libexec/uucp/libuuconf/lckdir.c b/gnu/libexec/uucp/libuuconf/lckdir.c deleted file mode 100644 index cb00f12fdc80..000000000000 --- a/gnu/libexec/uucp/libuuconf/lckdir.c +++ /dev/null @@ -1,43 +0,0 @@ -/* lckdir.c - Get the name of the UUCP lock directory. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_lckdir_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP lock directory. */ - -int -uuconf_lockdir (pglobal, pzlock) - pointer pglobal; - const char **pzlock; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzlock = qglobal->qprocess->zlockdir; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/lineno.c b/gnu/libexec/uucp/libuuconf/lineno.c deleted file mode 100644 index df5ff4b18cba..000000000000 --- a/gnu/libexec/uucp/libuuconf/lineno.c +++ /dev/null @@ -1,44 +0,0 @@ -/* lineno.c - Return the saved line number. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_lineno_rcsid[] = "$FreeBSD$"; -#endif - -/* Return the saved line number. */ - -int -uuconf_error_lineno (pglobal) - pointer pglobal; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - if (qglobal == NULL) - return 0; - else - return qglobal->ilineno; -} diff --git a/gnu/libexec/uucp/libuuconf/llocnm.c b/gnu/libexec/uucp/libuuconf/llocnm.c deleted file mode 100644 index ce7a6a049e59..000000000000 --- a/gnu/libexec/uucp/libuuconf/llocnm.c +++ /dev/null @@ -1,73 +0,0 @@ -/* llocnm.c - Get the local name to use, given a login name. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_llocnm_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get the local name to use, given a login name. */ - -int -uuconf_login_localname (pglobal, zlogin, pzname) - pointer pglobal; - const char *zlogin; - char **pzname; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_login_localname (pglobal, zlogin, pzname); - if (iret != UUCONF_NOT_FOUND) - return iret; -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - iret = uuconf_hdb_login_localname (pglobal, zlogin, pzname); - if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - - if (qglobal->qprocess->zlocalname != NULL) - { - *pzname = strdup ((char *) qglobal->qprocess->zlocalname); - if (*pzname == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - return UUCONF_SUCCESS; - } - - *pzname = NULL; - return UUCONF_NOT_FOUND; -} diff --git a/gnu/libexec/uucp/libuuconf/local.c b/gnu/libexec/uucp/libuuconf/local.c deleted file mode 100644 index 8687f459b017..000000000000 --- a/gnu/libexec/uucp/libuuconf/local.c +++ /dev/null @@ -1,70 +0,0 @@ -/* local.c - Get default information for the local system. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_local_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get default information about the local system. */ - -int -uuconf_system_local (pglobal, qsys) - pointer pglobal; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - - _uuconf_uclear_system (qsys); - qsys->uuconf_palloc = uuconf_malloc_block (); - if (qsys->uuconf_palloc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - qsys->uuconf_zname = (char *) qglobal->qprocess->zlocalname; - - /* By default, we permit the local system to forward to and from any - system. */ - iret = _uuconf_iadd_string (qglobal, (char *) "ANY", FALSE, FALSE, - &qsys->uuconf_pzforward_from, - qsys->uuconf_palloc); - if (iret == UUCONF_SUCCESS) - iret = _uuconf_iadd_string (qglobal, (char *) "ANY", FALSE, FALSE, - &qsys->uuconf_pzforward_to, - qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - { - uuconf_free_block (qsys->uuconf_palloc); - return iret; - } - - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/locnm.c b/gnu/libexec/uucp/libuuconf/locnm.c deleted file mode 100644 index 3b01474ffd0b..000000000000 --- a/gnu/libexec/uucp/libuuconf/locnm.c +++ /dev/null @@ -1,46 +0,0 @@ -/* locnm.c - Get the local node name. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_locnm_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the local node name. */ - -int -uuconf_localname (pglobal, pzname) - pointer pglobal; - const char **pzname; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzname = qglobal->qprocess->zlocalname; - if (*pzname != NULL) - return UUCONF_SUCCESS; - else - return UUCONF_NOT_FOUND; -} diff --git a/gnu/libexec/uucp/libuuconf/logfil.c b/gnu/libexec/uucp/libuuconf/logfil.c deleted file mode 100644 index 24439e2a27ce..000000000000 --- a/gnu/libexec/uucp/libuuconf/logfil.c +++ /dev/null @@ -1,43 +0,0 @@ -/* logfil.c - Get the name of the UUCP log file. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_logfil_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP log file. */ - -int -uuconf_logfile (pglobal, pzlog) - pointer pglobal; - const char **pzlog; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzlog = qglobal->qprocess->zlogfile; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/maxuxq.c b/gnu/libexec/uucp/libuuconf/maxuxq.c deleted file mode 100644 index 909de08d5411..000000000000 --- a/gnu/libexec/uucp/libuuconf/maxuxq.c +++ /dev/null @@ -1,86 +0,0 @@ -/* maxuxq.c - Get the maximum number of simultaneous uuxqt executions. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_maxuxq_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the maximum number of simultaneous uuxqt executions. When - using TAYLOR_CONFIG, this is from the ``max-uuxqts'' command in - config. Otherwise, when using HDB_CONFIG, we read the file - Maxuuxqts. */ - -int -uuconf_maxuuxqts (pglobal, pcmax) - pointer pglobal; - int *pcmax; -{ -#if HAVE_TAYLOR_CONFIG - { - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pcmax = qglobal->qprocess->cmaxuuxqts; - return UUCONF_SUCCESS; - } -#else /* ! HAVE_TAYLOR_CONFIG */ -#if HAVE_HDB_CONFIG - { - char ab[sizeof OLDCONFIGLIB + sizeof HDB_MAXUUXQTS - 1]; - FILE *e; - - *pcmax = 0; - - memcpy ((pointer) ab, (constpointer) OLDCONFIGLIB, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (ab + sizeof OLDCONFIGLIB - 1), - (constpointer) HDB_MAXUUXQTS, sizeof HDB_MAXUUXQTS); - e = fopen (ab, "r"); - if (e != NULL) - { - char *z; - size_t c; - - z = NULL; - c = 0; - if (getline (&z, &c, e) > 0) - { - *pcmax = (int) strtol (z, (char **) NULL, 10); - if (*pcmax < 0) - *pcmax = 0; - free ((pointer) z); - } - (void) fclose (e); - } - - return UUCONF_SUCCESS; - } -#else /* ! HAVE_HDB_CONFIG */ - *pcmax = 0; - return UUCONF_SUCCESS; -#endif /* ! HAVE_HDB_CONFIG */ -#endif /* ! HAVE_TAYLOR_CONFIG */ -} diff --git a/gnu/libexec/uucp/libuuconf/mrgblk.c b/gnu/libexec/uucp/libuuconf/mrgblk.c deleted file mode 100644 index e0dea6afe85a..000000000000 --- a/gnu/libexec/uucp/libuuconf/mrgblk.c +++ /dev/null @@ -1,50 +0,0 @@ -/* mrgblk.c - Merge two memory blocks together. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_mrgblk_rcsid[] = "$FreeBSD$"; -#endif - -#include "alloc.h" - -/* Merge one memory block into another one, returning the combined - memory block. */ - -pointer -_uuconf_pmalloc_block_merge (p1, p2) - pointer p1; - pointer p2; -{ - struct sblock *q1 = (struct sblock *) p1; - struct sblock *q2 = (struct sblock *) p2; - struct sblock **pq; - - for (pq = &q1; *pq != NULL; pq = &(*pq)->qnext) - ; - *pq = q2; - return (pointer) q1; -} diff --git a/gnu/libexec/uucp/libuuconf/paramc.c b/gnu/libexec/uucp/libuuconf/paramc.c deleted file mode 100644 index a5074d3b381b..000000000000 --- a/gnu/libexec/uucp/libuuconf/paramc.c +++ /dev/null @@ -1,175 +0,0 @@ -/* paramc.c - Handle protocol-parameter commands. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_paramc_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Handle protocol-parameter commands by inserting them into an array - of structures. The return value may include UUCONF_CMDTABRET_KEEP - and UUCONF_CMDTABRET_EXIT, if appropriate. */ - -int -_uuconf_iadd_proto_param (qglobal, argc, argv, pqparam, pblock) - struct sglobal *qglobal; - int argc; - char **argv; - struct uuconf_proto_param **pqparam; - pointer pblock; -{ - struct uuconf_proto_param *q; - size_t c; - struct uuconf_proto_param_entry *qentry; - - if (argc < 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - /* The first argument is the protocol character. */ - if (argv[0][1] != '\0') - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (*pqparam == NULL) - { - *pqparam = ((struct uuconf_proto_param *) - uuconf_malloc (pblock, - 2 * sizeof (struct uuconf_proto_param))); - if (*pqparam == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - (*pqparam)[1].uuconf_bproto = '\0'; - q = *pqparam; - q->uuconf_bproto = argv[0][0]; - q->uuconf_qentries = NULL; - } - else - { - c = 0; - for (q = *pqparam; q->uuconf_bproto != '\0'; q++) - { - if (q->uuconf_bproto == argv[0][0]) - break; - ++c; - } - - if (q->uuconf_bproto == '\0') - { - struct uuconf_proto_param *qnew; - - qnew = ((struct uuconf_proto_param *) - uuconf_malloc (pblock, - ((c + 2) - * sizeof (struct uuconf_proto_param)))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - memcpy ((pointer) qnew, (pointer) *pqparam, - c * sizeof (struct uuconf_proto_param)); - qnew[c + 1].uuconf_bproto = '\0'; - - uuconf_free (pblock, *pqparam); - *pqparam = qnew; - - q = qnew + c; - q->uuconf_bproto = argv[0][0]; - q->uuconf_qentries = NULL; - } - } - - if (q->uuconf_qentries == NULL) - { - qentry = ((struct uuconf_proto_param_entry *) - uuconf_malloc (pblock, - 2 * sizeof (struct uuconf_proto_param_entry))); - if (qentry == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - qentry[1].uuconf_cargs = 0; - q->uuconf_qentries = qentry; - } - else - { - struct uuconf_proto_param_entry *qnewent; - - c = 0; - for (qentry = q->uuconf_qentries; qentry->uuconf_cargs != 0; qentry++) - ++c; - - qnewent = ((struct uuconf_proto_param_entry *) - uuconf_malloc (pblock, - ((c + 2) * - sizeof (struct uuconf_proto_param_entry)))); - if (qnewent == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - memcpy ((pointer) qnewent, (pointer) q->uuconf_qentries, - c * sizeof (struct uuconf_proto_param_entry)); - qnewent[c + 1].uuconf_cargs = 0; - - uuconf_free (pblock, q->uuconf_qentries); - q->uuconf_qentries = qnewent; - - qentry = qnewent + c; - } - - qentry->uuconf_cargs = argc - 1; - qentry->uuconf_pzargs = (char **) uuconf_malloc (pblock, - ((argc - 1) - * sizeof (char *))); - if (qentry->uuconf_pzargs == NULL) - { - qglobal->ierrno = errno; - qentry->uuconf_cargs = 0; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - memcpy ((pointer) qentry->uuconf_pzargs, (pointer) (argv + 1), - (argc - 1) * sizeof (char *)); - - return UUCONF_CMDTABRET_KEEP; -} diff --git a/gnu/libexec/uucp/libuuconf/port.c b/gnu/libexec/uucp/libuuconf/port.c deleted file mode 100644 index bb3a16fccd67..000000000000 --- a/gnu/libexec/uucp/libuuconf/port.c +++ /dev/null @@ -1,77 +0,0 @@ -/* port.c - Find a port. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_port_rcsid[] = "$FreeBSD$"; -#endif - -/* Find a port by name, baud rate, and special purpose function. */ - -int -uuconf_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) - pointer pglobal; - const char *zname; - long ibaud; - long ihighbaud; - int (*pifn) P((struct uuconf_port *, pointer)); - pointer pinfo; - struct uuconf_port *qport; -{ -#if HAVE_V2_CONFIG || HAVE_HDB_CONFIG - struct sglobal *qglobal = (struct sglobal *) pglobal; -#endif - int iret; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_find_port (pglobal, zname, ibaud, ihighbaud, pifn, - pinfo, qport); - if (iret != UUCONF_NOT_FOUND) - return iret; -#endif - -#if HAVE_V2_CONFIG - if (qglobal->qprocess->fv2) - { - iret = uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn, - pinfo, qport); - if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - iret = uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, - pinfo, qport); - if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - - return UUCONF_NOT_FOUND; -} diff --git a/gnu/libexec/uucp/libuuconf/prtsub.c b/gnu/libexec/uucp/libuuconf/prtsub.c deleted file mode 100644 index 667bc1c9d71c..000000000000 --- a/gnu/libexec/uucp/libuuconf/prtsub.c +++ /dev/null @@ -1,54 +0,0 @@ -/* prtsub.c - Port information subroutines. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_prtsub_rcsid[] = "$FreeBSD$"; -#endif - -/* Clear the information in a port. This can only clear the type - independent information; the port type specific information is - cleared when the type of the port is set. */ - -void -_uuconf_uclear_port (qport) - struct uuconf_port *qport; -{ - qport->uuconf_zname = NULL; - qport->uuconf_ttype = UUCONF_PORTTYPE_UNKNOWN; - qport->uuconf_zprotocols = NULL; - qport->uuconf_qproto_params = NULL; - - /* Note that we do not set RELIABLE_SPECIFIED; this just sets - defaults, so that ``seven-bit true'' does not imply ``reliable - false''. */ - qport->uuconf_ireliable = (UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX); - - qport->uuconf_zlockname = NULL; - qport->uuconf_palloc = NULL; -} diff --git a/gnu/libexec/uucp/libuuconf/pubdir.c b/gnu/libexec/uucp/libuuconf/pubdir.c deleted file mode 100644 index 5192c6246df2..000000000000 --- a/gnu/libexec/uucp/libuuconf/pubdir.c +++ /dev/null @@ -1,43 +0,0 @@ -/* pubdir.c - Get the name of the UUCP public directory. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_pubdir_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP public directory. */ - -int -uuconf_pubdir (pglobal, pzpub) - pointer pglobal; - const char **pzpub; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzpub = qglobal->qprocess->zpubdir; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/rdlocs.c b/gnu/libexec/uucp/libuuconf/rdlocs.c deleted file mode 100644 index 3baabc251df2..000000000000 --- a/gnu/libexec/uucp/libuuconf/rdlocs.c +++ /dev/null @@ -1,305 +0,0 @@ -/* rdlocs.c - Get the locations of systems in the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_rdlocs_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int itsystem P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int itcalled_login P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int itmyname P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* This code scans through the Taylor UUCP system files in order to - locate each system and to gather the login restrictions (since this - information is held in additional arguments to the "called-login" - command, it can appear anywhere in the systems files). It also - records whether any "myname" appears, as an optimization for - uuconf_taylor_localname. - - This table is used to dispatch the appropriate commands. Most - commands are simply ignored. Note that this is a uuconf_cmdtab, - not a cmdtab_offset. */ - -static const struct uuconf_cmdtab asTcmds[] = -{ - { "system", UUCONF_CMDTABTYPE_FN | 2, NULL, itsystem }, - { "alias", UUCONF_CMDTABTYPE_FN | 2, (pointer) asTcmds, itsystem }, - { "called-login", UUCONF_CMDTABTYPE_FN | 0, NULL, itcalled_login }, - { "myname", UUCONF_CMDTABTYPE_FN | 2, NULL, itmyname }, - { NULL, 0, NULL, NULL } -}; - -/* This structure is used to pass information into the command table - functions. */ - -struct sinfo -{ - /* The sys file name. */ - const char *zname; - /* The open sys file. */ - FILE *e; - /* The list of locations we are building. */ - struct stsysloc *qlocs; - /* The list of validation restrictions we are building. */ - struct svalidate *qvals; -}; - -/* Look through the sys files to find the location and names of all - the systems. Since we're scanning the sys files, we also record - the validation information specified by the additional arguments to - the called-login command. We don't use uuconf_cmd_file to avoid - the overhead of breaking the line up into arguments if not - necessary. */ - -int -_uuconf_iread_locations (qglobal) - struct sglobal *qglobal; -{ - char *zline; - size_t cline; - struct sinfo si; - int iret; - char **pz; - - if (qglobal->qprocess->fread_syslocs) - return UUCONF_SUCCESS; - - zline = NULL; - cline = 0; - - si.qlocs = NULL; - si.qvals = NULL; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzsysfiles; *pz != NULL; pz++) - { - FILE *e; - int cchars; - - qglobal->ilineno = 0; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - -#ifdef CLOSE_ON_EXEC - CLOSE_ON_EXEC (e); -#endif - - si.zname = *pz; - si.e = e; - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - char *zcmd; - - ++qglobal->ilineno; - - zcmd = zline + strspn (zline, " \t"); - if (strncasecmp (zcmd, "system", sizeof "system" - 1) == 0 - || strncasecmp (zcmd, "alias", sizeof "alias" - 1) == 0 - || strncasecmp (zcmd, "called-login", - sizeof "called-login" - 1) == 0 - || strncasecmp (zcmd, "myname", sizeof "myname" - 1) == 0) - { - iret = uuconf_cmd_line ((pointer) qglobal, zline, asTcmds, - (pointer) &si, (uuconf_cmdtabfn) NULL, - 0, qglobal->pblock); - if ((iret & UUCONF_CMDTABRET_KEEP) != 0) - { - iret &=~ UUCONF_CMDTABRET_KEEP; - zline = NULL; - cline = 0; - } - if (iret != UUCONF_SUCCESS) - { - iret &=~ UUCONF_CMDTABRET_EXIT; - break; - } - } - } - - if (iret != UUCONF_SUCCESS) - break; - } - - if (zline != NULL) - free ((pointer) zline); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - if (UUCONF_ERROR_VALUE (iret) != UUCONF_MALLOC_FAILED) - qglobal->qprocess->fread_syslocs = TRUE; - } - else - { - qglobal->qprocess->qsyslocs = si.qlocs; - qglobal->qprocess->qvalidate = si.qvals; - qglobal->qprocess->fread_syslocs = TRUE; - } - - return iret; -} - -/* Handle a "system" or "alias" command by recording the file and - location. If pvar is not NULL, this is an "alias" command. */ - -/*ARGSUSED*/ -static int -itsystem (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - struct stsysloc *q; - size_t csize; - - q = (struct stsysloc *) uuconf_malloc (qglobal->pblock, - sizeof (struct stsysloc)); - if (q == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - csize = strlen (argv[1]) + 1; - q->zname = uuconf_malloc (qglobal->pblock, csize); - if (q->zname == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - q->qnext = qinfo->qlocs; - memcpy ((pointer) q->zname, (pointer) argv[1], csize); - q->falias = pvar != NULL; - q->zfile = qinfo->zname; - q->e = qinfo->e; - q->iloc = ftell (qinfo->e); - q->ilineno = qglobal->ilineno; - - qinfo->qlocs = q; - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the "called-login" command. This just records any extra - arguments, so that uuconf_validate can check them later if - necessary. */ - -/*ARGSUSED*/ -static int -itcalled_login (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - register struct svalidate *qval; - int i; - - if (argc <= 2) - return UUCONF_CMDTABRET_CONTINUE; - - for (qval = qinfo->qvals; qval != NULL; qval = qval->qnext) - if (strcmp (argv[1], qval->zlogname) == 0) - break; - - if (qval == NULL) - { - qval = (struct svalidate *) uuconf_malloc (qglobal->pblock, - sizeof (struct svalidate)); - if (qval == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - qval->qnext = qinfo->qvals; - qval->zlogname = argv[1]; - qval->pzmachines = NULL; - - qinfo->qvals = qval; - } - - for (i = 2; i < argc; i++) - { - int iret; - - iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, TRUE, - &qval->pzmachines, qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_EXIT; - } - - return UUCONF_CMDTABRET_KEEP; -} - -/* Handle the "myname" command by simply recording that it appears. - This information is used by uuconf_taylor_localname. */ - -/*ARGSUSED*/ -static int -itmyname (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - qglobal->qprocess->fuses_myname = TRUE; - return UUCONF_CMDTABRET_CONTINUE; -} diff --git a/gnu/libexec/uucp/libuuconf/rdperm.c b/gnu/libexec/uucp/libuuconf/rdperm.c deleted file mode 100644 index a7d29a41b63b..000000000000 --- a/gnu/libexec/uucp/libuuconf/rdperm.c +++ /dev/null @@ -1,452 +0,0 @@ -/* rdperm.c - Read the HDB Permissions file. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_rdperm_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -static int ihcolon P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int ihsendfiles P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int ihunknownperm P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int ihadd_norw P((struct sglobal *qglobal, char ***ppz, char **pzno)); - -/* These routines reads in the HDB Permissions file. We store the - entries in a linked list of shpermissions structures, so we only - have to actually read the file once. */ - -/* This command table and static structure are used to parse a line - from Permissions. The entries are parsed as follows: - - Multiple strings separated by colons: LOGNAME, MACHINE, READ, - WRITE, NOREAD, NOWRITE, COMMANDS, VALIDATE, ALIAS. - - Boolean values: REQUEST, CALLBACK. - - Simple strings: MYNAME, PUBDIR. - - "Yes" or "call": SENDFILES. - - The NOREAD and NOWRITE entries are merged into the READ and WRITE - entries, rather than being permanently stored. They are handled - specially in the uuconf_cmdtab table. */ - -static const struct cmdtab_offset asHperm_cmds[] = -{ - { "NOREAD", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, ihcolon }, - { "NOWRITE", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, ihcolon }, - { "LOGNAME", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzlogname), ihcolon }, - { "MACHINE", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzmachine), ihcolon }, - { "REQUEST", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct shpermissions, frequest), NULL }, - { "SENDFILES", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, fsendfiles), ihsendfiles }, - { "READ", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzread), ihcolon }, - { "WRITE", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzwrite), ihcolon }, - { "CALLBACK", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct shpermissions, fcallback), NULL }, - { "COMMANDS", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzcommands), ihcolon }, - { "VALIDATE", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzvalidate), ihcolon }, - { "MYNAME", UUCONF_CMDTABTYPE_STRING, - offsetof (struct shpermissions, zmyname), NULL }, - { "PUBDIR", UUCONF_CMDTABTYPE_STRING, - offsetof (struct shpermissions, zpubdir), NULL }, - { "ALIAS", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct shpermissions, pzalias), ihcolon }, - { NULL, 0, 0, NULL } -}; - -#define CHPERM_CMDS (sizeof asHperm_cmds / sizeof asHperm_cmds[0]) - -/* Actually read the Permissions file into a linked list of - structures. */ - -int -_uuconf_ihread_permissions (qglobal) - struct sglobal *qglobal; -{ - char *zperm; - FILE *e; - int iret; - struct uuconf_cmdtab as[CHPERM_CMDS]; - char **pznoread, **pznowrite; - struct shpermissions shperm; - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - int cchars; - struct shpermissions *qlist, **pq; - - if (qglobal->qprocess->fhdb_read_permissions) - return UUCONF_SUCCESS; - - zperm = (char *) uuconf_malloc (qglobal->pblock, - (sizeof OLDCONFIGLIB - + sizeof HDB_PERMISSIONS - 1)); - if (zperm == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - memcpy ((pointer) zperm, (pointer) OLDCONFIGLIB, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (zperm + sizeof OLDCONFIGLIB - 1), - (pointer) HDB_PERMISSIONS, sizeof HDB_PERMISSIONS); - - e = fopen (zperm, "r"); - if (e == NULL) - { - uuconf_free (qglobal->pblock, zperm); - qglobal->qprocess->fhdb_read_permissions = TRUE; - return UUCONF_SUCCESS; - } - - _uuconf_ucmdtab_base (asHperm_cmds, CHPERM_CMDS, (char *) &shperm, as); - as[0].uuconf_pvar = (pointer) &pznoread; - as[1].uuconf_pvar = (pointer) &pznowrite; - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - - qlist = NULL; - pq = &qlist; - - qglobal->ilineno = 0; - - iret = UUCONF_SUCCESS; - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int centries; - struct shpermissions *qnew; - int i; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - if (zline[0] == '#') - continue; - - centries = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (centries < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - if (centries == 0) - continue; - - shperm.pzlogname = (char **) &_uuconf_unset; - shperm.pzmachine = (char **) &_uuconf_unset; - shperm.frequest = -1; - shperm.fsendfiles = -1; - shperm.pzread = (char **) &_uuconf_unset; - shperm.pzwrite = (char **) &_uuconf_unset; - shperm.fcallback = -1; - shperm.pzcommands = (char **) &_uuconf_unset; - shperm.pzvalidate = (char **) &_uuconf_unset; - shperm.zmyname = (char *) &_uuconf_unset; - shperm.zpubdir = (char *) &_uuconf_unset; - shperm.pzalias = (char **) &_uuconf_unset; - pznoread = (char **) &_uuconf_unset; - pznowrite = (char **) &_uuconf_unset; - - for (i = 0; i < centries; i++) - { - char *zeq; - char *azargs[2]; - - zeq = strchr (pzsplit[i], '='); - if (zeq == NULL) - { - iret = UUCONF_SYNTAX_ERROR; - qglobal->qprocess->fhdb_read_permissions = TRUE; - break; - } - *zeq = '\0'; - - azargs[0] = pzsplit[i]; - azargs[1] = zeq + 1; - - iret = uuconf_cmd_args (qglobal, 2, azargs, as, (pointer) NULL, - ihunknownperm, 0, qglobal->pblock); - if ((iret & UUCONF_CMDTABRET_KEEP) != 0) - { - iret &=~ UUCONF_CMDTABRET_KEEP; - - if (uuconf_add_block (qglobal->pblock, zline) != 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - zline = NULL; - cline = 0; - } - if ((iret & UUCONF_CMDTABRET_EXIT) != 0) - { - iret &=~ UUCONF_CMDTABRET_EXIT; - break; - } - } - - if (iret != UUCONF_SUCCESS) - break; - - if (shperm.pzmachine == (char **) &_uuconf_unset - && shperm.pzlogname == (char **) &_uuconf_unset) - { - iret = UUCONF_SYNTAX_ERROR; - qglobal->qprocess->fhdb_read_permissions = TRUE; - break; - } - - /* Attach any NOREAD or NOWRITE entries to the corresponding - READ or WRITE entries in the format expected for the - pzlocal_receive, etc., fields in uuconf_system. */ - if (pznoread != NULL) - { - iret = ihadd_norw (qglobal, &shperm.pzread, pznoread); - if (iret != UUCONF_SUCCESS) - break; - uuconf_free (qglobal->pblock, pznoread); - } - - if (pznowrite != NULL) - { - iret = ihadd_norw (qglobal, &shperm.pzwrite, pznowrite); - if (iret != UUCONF_SUCCESS) - break; - uuconf_free (qglobal->pblock, pznowrite); - } - - qnew = ((struct shpermissions *) - uuconf_malloc (qglobal->pblock, - sizeof (struct shpermissions))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - *qnew = shperm; - *pq = qnew; - pq = &qnew->qnext; - *pq = NULL; - } - - (void) fclose (e); - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - - if (iret == UUCONF_SUCCESS) - { - qglobal->qprocess->qhdb_permissions = qlist; - qglobal->qprocess->fhdb_read_permissions = TRUE; - } - else - { - qglobal->zfilename = zperm; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - return iret; -} - -/* Split the argument into colon separated strings, and assign a NULL - terminated array of strings to pvar. */ - -/*ARGSUSED*/ -static int -ihcolon (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char ***ppz = (char ***) pvar; - char **pzsplit; - size_t csplit; - int centries; - int i; - int iret; - - *ppz = NULL; - - pzsplit = NULL; - csplit = 0; - - centries = _uuconf_istrsplit (argv[1], ':', &pzsplit, &csplit); - if (centries < 0) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - if (centries == 0) - { - if (pzsplit != NULL) - free ((pointer) pzsplit); - return UUCONF_CMDTABRET_CONTINUE; - } - - iret = UUCONF_SUCCESS; - - for (i = 0; i < centries; i++) - { - iret = _uuconf_iadd_string (qglobal, pzsplit[i], FALSE, FALSE, - ppz, qglobal->pblock); - if (iret != UUCONF_SUCCESS) - { - iret |= UUCONF_CMDTABRET_EXIT; - break; - } - } - - free ((pointer) pzsplit); - - return UUCONF_CMDTABRET_KEEP; -} - -/* Handle the SENDFILES parameter, which can take "yes" or "call" or - "no" as an argument. The string "call" is equivalent to "no". */ - -/*ARGSUSED*/ -static int -ihsendfiles (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - int *pi = (int *) pvar; - - switch (argv[1][0]) - { - case 'C': - case 'c': - case 'N': - case 'n': - *pi = FALSE; - break; - case 'Y': - case 'y': - *pi = TRUE; - break; - default: - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - } - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* If there is an unknown Permissions entry, return a syntax error. - This should probably be more clever. */ - -/*ARGSUSED*/ -static int -ihunknownperm (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; -} - -/* Add a NOREAD or NOWRITE entry to a READ or WRITE entry. */ - -static int -ihadd_norw (qglobal, ppz, pzno) - struct sglobal *qglobal; - char ***ppz; - char **pzno; -{ - register char **pz; - - if (pzno == (char **) &_uuconf_unset) - return UUCONF_SUCCESS; - - for (pz = pzno; *pz != NULL; pz++) - { - size_t csize; - char *znew; - int iret; - - /* Ignore an attempt to say NOREAD or NOWRITE with an empty - string, since it will be interpreted as an attempt to deny - everything. */ - if (**pz != '\0') - { - csize = strlen (*pz) + 1; - znew = (char *) uuconf_malloc (qglobal->pblock, csize + 1); - if (znew == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - znew[0] = '!'; - memcpy ((pointer) (znew + 1), (pointer) *pz, csize); - iret = _uuconf_iadd_string (qglobal, znew, FALSE, FALSE, ppz, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/reliab.c b/gnu/libexec/uucp/libuuconf/reliab.c deleted file mode 100644 index 8a232cd1253f..000000000000 --- a/gnu/libexec/uucp/libuuconf/reliab.c +++ /dev/null @@ -1,123 +0,0 @@ -/* reliab.c - Subroutines to handle reliability commands for ports and dialers. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_reliab_rcsid[] = "$FreeBSD$"; -#endif - -/* Handle the "seven-bit" command for a port or a dialer. The pvar - argument points to an integer which should be set to hold - reliability information. */ - -/*ARGSUSED*/ -int -_uuconf_iseven_bit (pglobal,argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int *pi = (int *) pvar; - int fval; - int iret; - - iret = _uuconf_iboolean (qglobal, argv[1], &fval); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - return iret; - - *pi |= UUCONF_RELIABLE_SPECIFIED; - if (fval) - *pi &=~ UUCONF_RELIABLE_EIGHT; - else - *pi |= UUCONF_RELIABLE_EIGHT; - - return iret; -} - -/* Handle the "reliable" command for a port or a dialer. The pvar - argument points to an integer which should be set to hold - reliability information. */ - -/*ARGSUSED*/ -int -_uuconf_ireliable (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int *pi = (int *) pvar; - int fval; - int iret; - - iret = _uuconf_iboolean (qglobal, argv[1], &fval); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - return iret; - - *pi |= UUCONF_RELIABLE_SPECIFIED; - if (fval) - *pi |= UUCONF_RELIABLE_RELIABLE; - else - *pi &=~ UUCONF_RELIABLE_RELIABLE; - - return iret; -} - -/* Handle the "half-duplex" command for a port or a dialer. The pvar - argument points to an integer which should be set to hold - reliability information. */ - -/*ARGSUSED*/ -int -_uuconf_ihalf_duplex (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int *pi = (int *) pvar; - int fval; - int iret; - - iret = _uuconf_iboolean (qglobal, argv[1], &fval); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - return iret; - - *pi |= UUCONF_RELIABLE_SPECIFIED; - if (fval) - *pi &=~ UUCONF_RELIABLE_FULLDUPLEX; - else - *pi |= UUCONF_RELIABLE_FULLDUPLEX; - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/remunk.c b/gnu/libexec/uucp/libuuconf/remunk.c deleted file mode 100644 index 8dc83d713a7f..000000000000 --- a/gnu/libexec/uucp/libuuconf/remunk.c +++ /dev/null @@ -1,54 +0,0 @@ -/* remunk.c - Get the name of the remote.unknown shell script. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_remunk_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the remote.unknown shell script. */ - -/*ARGSUSED*/ -int -uuconf_remote_unknown (pglobal, pzname) - pointer pglobal; - char **pzname; -{ -#if ! HAVE_HDB_CONFIG - return UUCONF_NOT_FOUND; -#else -#if HAVE_TAYLOR_CONFIG - struct sglobal *qglobal = (struct sglobal *) pglobal; - - /* If ``unknown'' commands were used in the config file, then ignore - any remote.unknown script. */ - if (qglobal->qprocess->qunknown != NULL) - return UUCONF_NOT_FOUND; -#endif /* HAVE_TAYLOR_CONFIG */ - - return uuconf_hdb_remote_unknown (pglobal, pzname); -#endif /* HAVE_HDB_CONFIG */ -} diff --git a/gnu/libexec/uucp/libuuconf/runuxq.c b/gnu/libexec/uucp/libuuconf/runuxq.c deleted file mode 100644 index 0c5296cbf613..000000000000 --- a/gnu/libexec/uucp/libuuconf/runuxq.c +++ /dev/null @@ -1,77 +0,0 @@ -/* maxuxq.c - Return how often to spawn a uuxqt process. - - Copyright (C) 1994 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_runuxq_rcsid[] = "$FreeBSD$"; -#endif - -/* Return how often to spawn a uuxqt process. This is either a - positive number representing the number of execution files to be - received between spawns, or a special code. When using - TAYLOR_CONFIG, this is from the ``run-uuxqt'' command in config - (the default is UUCONF_RUNUUXQT_ONCE, for compatibility). - Otherwise, we return UUCONF_RUNUUXQT_PERCALL for HDB_CONFIG and 10 - for V2_CONFIG, to emulate traditional HDB and V2 emulations. */ - -int -uuconf_runuuxqt (pglobal, pirunuuxqt) - pointer pglobal; - int *pirunuuxqt; -{ -#if HAVE_TAYLOR_CONFIG - { - struct sglobal *qglobal = (struct sglobal *) pglobal; - const char *zrun; - - zrun = qglobal->qprocess->zrunuuxqt; - if (zrun == NULL - || strcasecmp (zrun, "once") == 0) - *pirunuuxqt = UUCONF_RUNUUXQT_ONCE; - else if (strcasecmp (zrun, "never") == 0) - *pirunuuxqt = UUCONF_RUNUUXQT_NEVER; - else if (strcasecmp (zrun, "percall") == 0) - *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL; - else - { - char *zend; - - *pirunuuxqt = strtol ((char *) qglobal->qprocess->zrunuuxqt, - &zend, 10); - if (*zend != '\0' || *pirunuuxqt <= 0) - *pirunuuxqt = UUCONF_RUNUUXQT_ONCE; - } - } -#else /* ! HAVE_TAYLOR_CONFIG */ -#if HAVE_HDB_CONFIG - *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL; -#else /* ! HAVE_HDB_CONFIG */ - *pirunuuxqt = 10; -#endif /* ! HAVE_HDB_CONFIG */ -#endif /* ! HAVE_TAYLOR_CONFIG */ - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/sinfo.c b/gnu/libexec/uucp/libuuconf/sinfo.c deleted file mode 100644 index fe7b7b972731..000000000000 --- a/gnu/libexec/uucp/libuuconf/sinfo.c +++ /dev/null @@ -1,112 +0,0 @@ -/* sinfo.c - Get information about a system. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_sinfo_rcsid[] = "$FreeBSD$"; -#endif - -/* Get information about a particular system. We combine the - definitions for this system from each type of configuration file, - by passing what we have so far into each one. */ - -int -uuconf_system_info (pglobal, zsystem, qsys) - pointer pglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - boolean fgot; - - fgot = FALSE; - -#if HAVE_TAYLOR_CONFIG - iret = _uuconf_itaylor_system_internal (qglobal, zsystem, qsys); - if (iret == UUCONF_SUCCESS) - fgot = TRUE; - else if (iret != UUCONF_NOT_FOUND) - return iret; -#endif - -#if HAVE_V2_CONFIG - if (qglobal->qprocess->fv2) - { - struct uuconf_system *q; - struct uuconf_system sv2; - - if (fgot) - q = &sv2; - else - q = qsys; - iret = _uuconf_iv2_system_internal (qglobal, zsystem, q); - if (iret == UUCONF_SUCCESS) - { - if (fgot) - { - iret = _uuconf_isystem_default (qglobal, qsys, &sv2, TRUE); - if (iret != UUCONF_SUCCESS) - return iret; - } - fgot = TRUE; - } - else if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - struct uuconf_system *q; - struct uuconf_system shdb; - - if (fgot) - q = &shdb; - else - q = qsys; - iret = _uuconf_ihdb_system_internal (qglobal, zsystem, q); - if (iret == UUCONF_SUCCESS) - { - if (fgot) - { - iret = _uuconf_isystem_default (qglobal, qsys, &shdb, TRUE); - if (iret != UUCONF_SUCCESS) - return iret; - } - fgot = TRUE; - } - else if (iret != UUCONF_NOT_FOUND) - return iret; - } -#endif - - if (! fgot) - return UUCONF_NOT_FOUND; - - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/snams.c b/gnu/libexec/uucp/libuuconf/snams.c deleted file mode 100644 index f648e61a6d0f..000000000000 --- a/gnu/libexec/uucp/libuuconf/snams.c +++ /dev/null @@ -1,133 +0,0 @@ -/* snams.c - Get all known system names. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_snams_rcsid[] = "$FreeBSD$"; -#endif - -/* Get all known system names. */ - -int -uuconf_system_names (pglobal, ppzsystems, falias) - pointer pglobal; - char ***ppzsystems; - int falias; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pztaylor; - char **pzv2; - char **pzhdb; - int iret; - - *ppzsystems = NULL; - pztaylor = NULL; - pzv2 = NULL; - pzhdb = NULL; - -#if HAVE_TAYLOR_CONFIG - iret = uuconf_taylor_system_names (pglobal, &pztaylor, falias); - if (iret != UUCONF_SUCCESS) - return iret; -#endif - -#if HAVE_V2_CONFIG - if (qglobal->qprocess->fv2) - { - iret = uuconf_v2_system_names (pglobal, &pzv2, falias); - if (iret != UUCONF_SUCCESS) - return iret; - } -#endif - -#if HAVE_HDB_CONFIG - if (qglobal->qprocess->fhdb) - { - iret = uuconf_hdb_system_names (pglobal, &pzhdb, falias); - if (iret != UUCONF_SUCCESS) - return iret; - } -#endif - - if (pzv2 == NULL && pzhdb == NULL) - *ppzsystems = pztaylor; - else if (pztaylor == NULL && pzhdb == NULL) - *ppzsystems = pzv2; - else if (pztaylor == NULL && pzv2 == NULL) - *ppzsystems = pzhdb; - else - { - char **pz; - - iret = UUCONF_SUCCESS; - - if (pztaylor != NULL) - { - for (pz = pztaylor; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - } - - if (pzv2 != NULL && iret == UUCONF_SUCCESS) - { - for (pz = pzv2; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - } - - if (pzhdb != NULL && iret == UUCONF_SUCCESS) - { - for (pz = pzhdb; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string (qglobal, *pz, FALSE, TRUE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - } - - if (pztaylor != NULL) - free ((pointer) pztaylor); - if (pzv2 != NULL) - free ((pointer) pzv2); - if (pzhdb != NULL) - free ((pointer) pzhdb); - } - - if (iret == UUCONF_SUCCESS && *ppzsystems == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzsystems, (pointer) NULL); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/split.c b/gnu/libexec/uucp/libuuconf/split.c deleted file mode 100644 index 8b90a660d682..000000000000 --- a/gnu/libexec/uucp/libuuconf/split.c +++ /dev/null @@ -1,106 +0,0 @@ -/* split.c - Split a string into tokens. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_split_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Split a string into tokens. The bsep argument is the separator to - use. If it is the null byte, white space is used as the separator, - and leading white space is discarded. Otherwise, each occurrence - of the separator character delimits a field (and thus some fields - may be empty). The array and size arguments may be used to reuse - the same memory. This function is not tied to uuconf; the only way - it can fail is if malloc or realloc fails. */ - -int -_uuconf_istrsplit (zline, bsep, ppzsplit, pcsplit) - register char *zline; - int bsep; - char ***ppzsplit; - size_t *pcsplit; -{ - size_t i; - - i = 0; - - while (TRUE) - { - if (bsep == '\0') - { - while (isspace (BUCHAR (*zline))) - ++zline; - if (*zline == '\0') - break; - } - - if (i >= *pcsplit) - { - char **pznew; - size_t cnew; - - if (*pcsplit == 0) - { - cnew = 8; - pznew = (char **) malloc (cnew * sizeof (char *)); - } - else - { - cnew = *pcsplit * 2; - pznew = (char **) realloc ((pointer) *ppzsplit, - cnew * sizeof (char *)); - } - if (pznew == NULL) - return -1; - *ppzsplit = pznew; - *pcsplit = cnew; - } - - (*ppzsplit)[i] = zline; - ++i; - - if (bsep == '\0') - { - while (*zline != '\0' && ! isspace (BUCHAR (*zline))) - ++zline; - } - else - { - while (*zline != '\0' && *zline != bsep) - ++zline; - } - - if (*zline == '\0') - break; - - *zline++ = '\0'; - } - - return i; -} diff --git a/gnu/libexec/uucp/libuuconf/spool.c b/gnu/libexec/uucp/libuuconf/spool.c deleted file mode 100644 index 0fe073334c90..000000000000 --- a/gnu/libexec/uucp/libuuconf/spool.c +++ /dev/null @@ -1,43 +0,0 @@ -/* spool.c - Get the name of the UUCP spool directory. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_spool_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP spool directory. */ - -int -uuconf_spooldir (pglobal, pzspool) - pointer pglobal; - const char **pzspool; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzspool = qglobal->qprocess->zspooldir; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/stafil.c b/gnu/libexec/uucp/libuuconf/stafil.c deleted file mode 100644 index 205e05c7bb89..000000000000 --- a/gnu/libexec/uucp/libuuconf/stafil.c +++ /dev/null @@ -1,43 +0,0 @@ -/* stafil.c - Get the name of the UUCP statistics file. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_stafil_rcsid[] = "$FreeBSD$"; -#endif - -/* Get the name of the UUCP statistics file. */ - -int -uuconf_statsfile (pglobal, pzstats) - pointer pglobal; - const char **pzstats; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pzstats = qglobal->qprocess->zstatsfile; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/strip.c b/gnu/libexec/uucp/libuuconf/strip.c deleted file mode 100644 index 03f962bf1da4..000000000000 --- a/gnu/libexec/uucp/libuuconf/strip.c +++ /dev/null @@ -1,50 +0,0 @@ -/* maxuxq.c - Get information about what things should be stripped. - - Copyright (C) 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_strip_rcsid[] = "$FreeBSD$"; -#endif - -/* Get information about what types of global information should be - stripped. There are currently only two, which we return as a - couple of bits. We store them as two separate variables, so we - don't need to have a special function to set the values correctly. */ - -int -uuconf_strip (pglobal, pistrip) - pointer pglobal; - int *pistrip; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - - *pistrip = 0; - if (qglobal->qprocess->fstrip_login) - *pistrip |= UUCONF_STRIP_LOGIN; - if (qglobal->qprocess->fstrip_proto) - *pistrip |= UUCONF_STRIP_PROTO; - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/syshdr.h b/gnu/libexec/uucp/libuuconf/syshdr.h deleted file mode 100644 index 12d4aa427c5b..000000000000 --- a/gnu/libexec/uucp/libuuconf/syshdr.h +++ /dev/null @@ -1,140 +0,0 @@ -/* syshdr.unx -*- C -*- - Unix system header for the uuconf library. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* The root directory (used when setting local-send and local-receive - values). */ -#define ZROOTDIR "/" - -/* The current directory (used by uuconv as a prefix for the newly - created file names). */ -#define ZCURDIR "." - -/* The names of the Taylor UUCP configuration files. These are - appended to NEWCONFIGLIB which is defined in Makefile. */ -#define CONFIGFILE "/config" -#define SYSFILE "/sys" -#define PORTFILE "/port" -#define DIALFILE "/dial" -#define CALLFILE "/call" -#define PASSWDFILE "/passwd" -#define DIALCODEFILE "/dialcode" - -/* The names of the various V2 configuration files. These are - appended to OLDCONFIGLIB which is defined in Makefile. */ -#define V2_SYSTEMS "/L.sys" -#define V2_DEVICES "/L-devices" -#define V2_USERFILE "/USERFILE" -#define V2_CMDS "/L.cmds" -#define V2_DIALCODES "/L-dialcodes" - -/* The names of the HDB configuration files. These are appended to - OLDCONFIGLIB which is defined in Makefile. */ -#define HDB_SYSFILES "/Sysfiles" -#define HDB_SYSTEMS "/Systems" -#define HDB_PERMISSIONS "/Permissions" -#define HDB_DEVICES "/Devices" -#define HDB_DIALERS "/Dialers" -#define HDB_DIALCODES "/Dialcodes" -#define HDB_MAXUUXQTS "/Maxuuxqts" -#define HDB_REMOTE_UNKNOWN "/remote.unknown" - -/* A string which is inserted between the value of OLDCONFIGLIB - (defined in the Makefile) and any names specified in the HDB - Sysfiles file. */ -#define HDB_SEPARATOR "/" - -/* A macro to check whether fopen failed because the file did not - exist. */ -#define FNO_SUCH_FILE() (errno == ENOENT) - -#if ! HAVE_STRERROR - -/* We need a definition for strerror; normally the function in the - unix directory is used, but we want to be independent of that - library. This macro evaluates its argument multiple times. */ -extern int sys_nerr; -extern char *sys_errlist[]; - -#define strerror(ierr) \ - ((ierr) >= 0 && (ierr) < sys_nerr ? sys_errlist[ierr] : "unknown error") - -#endif /* ! HAVE_STRERROR */ - -/* This macro is used to make a filename found in a configuration file - into an absolute path. The zdir argument is the directory to put it - in. The zset argument is set to the new string. The fallocated - argument is set to TRUE if the new string was allocated. */ -#define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \ - do \ - { \ - if (*(zfile) == '/') \ - { \ - (zset) = (zfile); \ - (fallocated) = FALSE; \ - } \ - else \ - { \ - size_t abs_cdir, abs_cfile; \ - char *abs_zret; \ -\ - abs_cdir = strlen (zdir); \ - abs_cfile = strlen (zfile); \ - abs_zret = (char *) uuconf_malloc ((pblock), \ - abs_cdir + abs_cfile + 2); \ - (zset) = abs_zret; \ - (fallocated) = TRUE; \ - if (abs_zret != NULL) \ - { \ - memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \ - abs_zret[abs_cdir] = '/'; \ - memcpy ((pointer) (abs_zret + abs_cdir + 1), \ - (pointer) (zfile), abs_cfile + 1); \ - } \ - } \ - } \ - while (0) - -/* We want to be able to mark the Taylor UUCP system files as close on - exec. */ -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#define CLOSE_ON_EXEC(e) \ - do \ - { \ - int cle_i = fileno (e); \ - \ - fcntl (cle_i, F_SETFD, fcntl (cle_i, F_GETFD, 0) | FD_CLOEXEC); \ - } \ - while (0) diff --git a/gnu/libexec/uucp/libuuconf/syssub.c b/gnu/libexec/uucp/libuuconf/syssub.c deleted file mode 100644 index 81b0dd84e651..000000000000 --- a/gnu/libexec/uucp/libuuconf/syssub.c +++ /dev/null @@ -1,524 +0,0 @@ -/* syssub.c - System information subroutines. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_syssub_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* This macro operates on every string (char *) field in struct - uuconf_system. */ -#define SYSTEM_STRINGS(OP) \ - do \ - { \ - OP (uuconf_zname); \ - OP (uuconf_zalternate); \ - OP (uuconf_zdebug); \ - OP (uuconf_zmax_remote_debug); \ - OP (uuconf_zphone); \ - OP (uuconf_zcall_login); \ - OP (uuconf_zcall_password); \ - OP (uuconf_zcalled_login); \ - OP (uuconf_zprotocols); \ - OP (uuconf_zpubdir); \ - OP (uuconf_zlocalname); \ - } \ - while (0) - -/* This macro operates on every string array (char **) field in struct - uuconf_system. */ -#define SYSTEM_STRING_ARRAYS(OP) \ - do \ - { \ - OP (uuconf_pzalias); \ - OP (uuconf_pzlocal_send); \ - OP (uuconf_pzremote_send); \ - OP (uuconf_pzlocal_receive); \ - OP (uuconf_pzremote_receive); \ - OP (uuconf_pzpath); \ - OP (uuconf_pzcmds); \ - OP (uuconf_pzforward_from); \ - OP (uuconf_pzforward_to); \ - OP (uuconf_schat.uuconf_pzchat); \ - OP (uuconf_schat.uuconf_pzprogram); \ - OP (uuconf_schat.uuconf_pzfail); \ - OP (uuconf_scalled_chat.uuconf_pzchat); \ - OP (uuconf_scalled_chat.uuconf_pzprogram); \ - OP (uuconf_scalled_chat.uuconf_pzfail); \ - } \ - while (0) - -/* This macro operations on every timespan pointer (struct - uuconf_timespan *) in struct uuconf_system. */ -#define SYSTEM_TIMESPANS(OP) \ - do \ - { \ - OP (uuconf_qtimegrade); \ - OP (uuconf_qcalltimegrade); \ - OP (uuconf_qcalledtimegrade); \ - OP (uuconf_qcall_local_size); \ - OP (uuconf_qcall_remote_size); \ - OP (uuconf_qcalled_local_size); \ - OP (uuconf_qcalled_remote_size); \ - } \ - while (0) - -/* This macro operates on every boolean value (of type int, although - some type int are not boolean) field in uuconf_system. */ -#define SYSTEM_BOOLEANS(OP) \ - do \ - { \ - OP (uuconf_fcall); \ - OP (uuconf_fcalled); \ - OP (uuconf_fcallback); \ - OP (uuconf_fsequence); \ - OP (uuconf_fsend_request); \ - OP (uuconf_frec_request); \ - OP (uuconf_fcall_transfer); \ - OP (uuconf_fcalled_transfer); \ - OP (uuconf_schat.uuconf_fstrip); \ - OP (uuconf_scalled_chat.uuconf_fstrip); \ - } \ - while (0) - -/* This macro operates on every generic integer (type int or long) in - uuconf_system. */ -#define SYSTEM_INTEGERS(OP) \ - do \ - { \ - OP (uuconf_cmax_retries); \ - OP (uuconf_csuccess_wait); \ - OP (uuconf_ibaud); \ - OP (uuconf_ihighbaud); \ - OP (uuconf_cfree_space); \ - OP (uuconf_schat.uuconf_ctimeout); \ - OP (uuconf_scalled_chat.uuconf_ctimeout); \ - } \ - while (0) - -/* There is no macro for uuconf_qalternate, uuconf_zport, - uuconf_qport, uuconf_qproto_params, or uuconf_palloc. */ - -/* Clear the contents of a struct uuconf_system. */ - -void -_uuconf_uclear_system (q) - struct uuconf_system *q; -{ -#define CLEAR(x) q->x = (char *) &_uuconf_unset - SYSTEM_STRINGS (CLEAR); -#undef CLEAR -#define CLEAR(x) q->x = (char **) &_uuconf_unset - SYSTEM_STRING_ARRAYS (CLEAR); -#undef CLEAR -#define CLEAR(x) q->x = (struct uuconf_timespan *) &_uuconf_unset - SYSTEM_TIMESPANS (CLEAR); -#undef CLEAR -#define CLEAR(x) q->x = -1 - SYSTEM_BOOLEANS (CLEAR); - SYSTEM_INTEGERS (CLEAR); -#undef CLEAR - q->uuconf_qalternate = NULL; - q->uuconf_zport = (char *) &_uuconf_unset; - q->uuconf_qport = (struct uuconf_port *) &_uuconf_unset; - q->uuconf_qproto_params = (struct uuconf_proto_param *) &_uuconf_unset; - q->uuconf_palloc = NULL; -} - -/* Default the contents of one struct uuconf_system to the contents of - another. This default alternate by alternate. Any additional - alternates in q default to the last alternate of qdefault. If the - faddalternates arguments is TRUE, additional alternates or qdefault - are added to q; these alternates are copies of the first alternate - of q, and defaults are set from the additional alternates of - qdefault. */ - -int -_uuconf_isystem_default (qglobal, qset, qdefault, faddalternates) - struct sglobal *qglobal; - struct uuconf_system *qset; - struct uuconf_system *qdefault; - boolean faddalternates; -{ - struct uuconf_system *qalt; - - if (qset->uuconf_palloc != qdefault->uuconf_palloc) - qset->uuconf_palloc = - _uuconf_pmalloc_block_merge (qset->uuconf_palloc, - qdefault->uuconf_palloc); - - /* If we are adding alternates from the default, make sure we have - at least as many alternates in qset as we do in qdefault. Each - new alternate we create gets initialized to the first alternate - of the system. */ - if (faddalternates) - { - struct uuconf_system **pq, *qdef; - - for (qdef = qdefault, pq = &qset; - qdef != NULL; - qdef = qdef->uuconf_qalternate, pq = &(*pq)->uuconf_qalternate) - { - if (*pq == NULL) - { - *pq = ((struct uuconf_system *) - uuconf_malloc (qset->uuconf_palloc, - sizeof (struct uuconf_system))); - if (*pq == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - **pq = *qset; - (*pq)->uuconf_qalternate = NULL; - } - } - } - - for (qalt = qset; qalt != NULL; qalt = qalt->uuconf_qalternate) - { -#define DEFAULT(x) \ - if (qalt->x == (char *) &_uuconf_unset) qalt->x = qdefault->x - SYSTEM_STRINGS (DEFAULT); -#undef DEFAULT -#define DEFAULT(x) \ - if (qalt->x == (char **) &_uuconf_unset) qalt->x = qdefault->x - SYSTEM_STRING_ARRAYS (DEFAULT); -#undef DEFAULT -#define DEFAULT(x) \ - if (qalt->x == (struct uuconf_timespan *) &_uuconf_unset) \ - qalt->x = qdefault->x - SYSTEM_TIMESPANS (DEFAULT); -#undef DEFAULT -#define DEFAULT(x) if (qalt->x < 0) qalt->x = qdefault->x - SYSTEM_BOOLEANS (DEFAULT); - SYSTEM_INTEGERS (DEFAULT); -#undef DEFAULT - - /* We only copy over zport if both zport and qport are NULL, - because otherwise a default zport would override a specific - qport. */ - if (qalt->uuconf_zport == (char *) &_uuconf_unset - && qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset) - qalt->uuconf_zport = qdefault->uuconf_zport; - if (qalt->uuconf_qport == (struct uuconf_port *) &_uuconf_unset) - qalt->uuconf_qport = qdefault->uuconf_qport; - - if (qalt->uuconf_qproto_params - == (struct uuconf_proto_param *) &_uuconf_unset) - qalt->uuconf_qproto_params = qdefault->uuconf_qproto_params; - else if (qdefault->uuconf_qproto_params != NULL) - { - int cnew, ca; - struct uuconf_proto_param *qd, *qa; - - /* Merge in the default protocol parameters, so that a - system with 'g' protocol parameters won't lose the - default 'i' protocol parameters. */ - ca = 0; - cnew = 0; - for (qd = qdefault->uuconf_qproto_params; - qd->uuconf_bproto != '\0'; - qd++) - { - int c; - - c = 0; - for (qa = qalt->uuconf_qproto_params; - (qa->uuconf_bproto != '\0' - && qa->uuconf_bproto != qd->uuconf_bproto); - qa++) - ++c; - if (qa->uuconf_bproto == '\0') - { - ++cnew; - ca = c; - } - } - - if (cnew > 0) - { - struct uuconf_proto_param *qnew; - - qnew = ((struct uuconf_proto_param *) - uuconf_malloc (qset->uuconf_palloc, - ((ca + cnew + 1) - * sizeof (struct uuconf_proto_param)))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) qnew, (pointer) qalt->uuconf_qproto_params, - ca * sizeof (struct uuconf_proto_param)); - cnew = 0; - for (qd = qdefault->uuconf_qproto_params; - qd->uuconf_bproto != '\0'; - qd++) - { - for (qa = qalt->uuconf_qproto_params; - (qa->uuconf_bproto != '\0' - && qa->uuconf_bproto != qd->uuconf_bproto); - qa++) - ; - if (qa->uuconf_bproto == '\0') - { - qnew[ca + cnew] = *qd; - ++cnew; - } - } - qnew[ca + cnew].uuconf_bproto = '\0'; - uuconf_free (qset->uuconf_palloc, qalt->uuconf_qproto_params); - qalt->uuconf_qproto_params = qnew; - } - } - - if (qdefault->uuconf_qalternate != NULL) - qdefault = qdefault->uuconf_qalternate; - } - - return UUCONF_SUCCESS; -} - -/* Put in the basic defaults. This ensures that the fields are valid - on every uuconf_system structure. */ - -int -_uuconf_isystem_basic_default (qglobal, q) - struct sglobal *qglobal; - register struct uuconf_system *q; -{ - int iret; - - iret = UUCONF_SUCCESS; - - for (; q != NULL && iret == UUCONF_SUCCESS; q = q->uuconf_qalternate) - { - /* The default of 26 allowable retries is traditional. */ - if (q->uuconf_cmax_retries < 0) - q->uuconf_cmax_retries = 26; - if (q->uuconf_schat.uuconf_pzchat == (char **) &_uuconf_unset) - { - q->uuconf_schat.uuconf_pzchat = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) "\"\"", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "\\r\\c", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "ogin:", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "-BREAK", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "-ogin:", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "\\L", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "word:", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - iret = _uuconf_iadd_string (qglobal, (char *) "\\P", FALSE, - FALSE, - &q->uuconf_schat.uuconf_pzchat, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - if (q->uuconf_schat.uuconf_ctimeout < 0) - q->uuconf_schat.uuconf_ctimeout = 10; - if (q->uuconf_schat.uuconf_fstrip < 0) - q->uuconf_schat.uuconf_fstrip = TRUE; - if (q->uuconf_scalled_chat.uuconf_ctimeout < 0) - q->uuconf_scalled_chat.uuconf_ctimeout = 60; - if (q->uuconf_scalled_chat.uuconf_fstrip < 0) - q->uuconf_scalled_chat.uuconf_fstrip = TRUE; - if (q->uuconf_fsend_request < 0) - q->uuconf_fsend_request = TRUE; - if (q->uuconf_frec_request < 0) - q->uuconf_frec_request = TRUE; - if (q->uuconf_fcall_transfer < 0) - q->uuconf_fcall_transfer = TRUE; - if (q->uuconf_fcalled_transfer < 0) - q->uuconf_fcalled_transfer = TRUE; - if (q->uuconf_pzlocal_send == (char **) &_uuconf_unset) - { - q->uuconf_pzlocal_send = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) ZROOTDIR, FALSE, - FALSE, &q->uuconf_pzlocal_send, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - if (q->uuconf_pzremote_send == (char **) &_uuconf_unset) - { - q->uuconf_pzremote_send = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE, - &q->uuconf_pzremote_send, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - if (q->uuconf_pzlocal_receive == (char **) &_uuconf_unset) - { - q->uuconf_pzlocal_receive = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE, - &q->uuconf_pzlocal_receive, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - if (q->uuconf_pzremote_receive == (char **) &_uuconf_unset) - { - q->uuconf_pzremote_receive = NULL; - iret = _uuconf_iadd_string (qglobal, (char *) "~", FALSE, FALSE, - &q->uuconf_pzremote_receive, - q->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret; - } - - if (q->uuconf_pzpath == (char **) &_uuconf_unset) - { - char *zdup; - char **pz; - size_t csplit; - int c; - - zdup = (char *) uuconf_malloc (q->uuconf_palloc, sizeof CMDPATH); - if (zdup == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - memcpy ((pointer) zdup, (pointer) CMDPATH, sizeof CMDPATH); - pz = NULL; - csplit = 0; - if ((c = _uuconf_istrsplit (zdup, '\0', &pz, &csplit)) < 0) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - q->uuconf_pzpath = (char **) uuconf_malloc (q->uuconf_palloc, - ((c + 1) - * sizeof (char *))); - if (q->uuconf_pzpath == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) q->uuconf_pzpath, (pointer) pz, - c * sizeof (char *)); - q->uuconf_pzpath[c] = NULL; - free ((pointer) pz); - } - - if (q->uuconf_pzcmds == (char **) &_uuconf_unset) - { - q->uuconf_pzcmds = ((char **) - uuconf_malloc (q->uuconf_palloc, - 3 * sizeof (const char *))); - if (q->uuconf_pzcmds == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - q->uuconf_pzcmds[0] = (char *) "rnews"; - q->uuconf_pzcmds[1] = (char *) "rmail"; - q->uuconf_pzcmds[2] = NULL; - } - - if (q->uuconf_cfree_space < 0) - q->uuconf_cfree_space = DEFAULT_FREE_SPACE; - - if (q->uuconf_zpubdir == (const char *) &_uuconf_unset) - q->uuconf_zpubdir = qglobal->qprocess->zpubdir; - -#define SET(x) if (q->x == (char *) &_uuconf_unset) q->x = NULL - SYSTEM_STRINGS(SET); -#undef SET -#define SET(x) if (q->x == (char **) &_uuconf_unset) q->x = NULL - SYSTEM_STRING_ARRAYS(SET); -#undef SET -#define SET(x) \ - if (q->x == (struct uuconf_timespan *) &_uuconf_unset) q->x = NULL - SYSTEM_TIMESPANS (SET); -#undef SET -#define SET(x) if (q->x < 0) q->x = 0 - SYSTEM_BOOLEANS (SET); - SYSTEM_INTEGERS (SET); -#undef SET - - if (q->uuconf_zport == (char *) &_uuconf_unset) - q->uuconf_zport = NULL; - if (q->uuconf_qport == (struct uuconf_port *) &_uuconf_unset) - q->uuconf_qport = NULL; - if (q->uuconf_qproto_params - == (struct uuconf_proto_param *) &_uuconf_unset) - q->uuconf_qproto_params = NULL; - } - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/tcalou.c b/gnu/libexec/uucp/libuuconf/tcalou.c deleted file mode 100644 index 8ff0493bde54..000000000000 --- a/gnu/libexec/uucp/libuuconf/tcalou.c +++ /dev/null @@ -1,207 +0,0 @@ -/* tcalou.c - Find callout login name and password from Taylor UUCP configuration files. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tcalou_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int icsys P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); - -/* Find the callout login name and password for a system from the - Taylor UUCP configuration files. */ - -int -uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass) - pointer pglobal; - const struct uuconf_system *qsys; - char **pzlog; - char **pzpass; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - boolean flookup; - struct uuconf_cmdtab as[2]; - char **pz; - int iret; - pointer pinfo; - - *pzlog = NULL; - *pzpass = NULL; - - flookup = FALSE; - - if (qsys->uuconf_zcall_login != NULL) - { - if (strcmp (qsys->uuconf_zcall_login, "*") == 0) - flookup = TRUE; - else - { - *pzlog = strdup (qsys->uuconf_zcall_login); - if (*pzlog == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - } - } - - if (qsys->uuconf_zcall_password != NULL) - { - if (strcmp (qsys->uuconf_zcall_password, "*") == 0) - flookup = TRUE; - else - { - *pzpass = strdup (qsys->uuconf_zcall_password); - if (*pzpass == NULL) - { - qglobal->ierrno = errno; - if (*pzlog != NULL) - { - free ((pointer) *pzlog); - *pzlog = NULL; - } - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - } - } - - if (! flookup) - { - if (*pzlog == NULL && *pzpass == NULL) - return UUCONF_NOT_FOUND; - return UUCONF_SUCCESS; - } - - as[0].uuconf_zcmd = qsys->uuconf_zname; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 0; - if (*pzlog == NULL) - as[0].uuconf_pvar = (pointer) pzlog; - else - as[0].uuconf_pvar = NULL; - as[0].uuconf_pifn = icsys; - - as[1].uuconf_zcmd = NULL; - - if (*pzpass == NULL) - pinfo = (pointer) pzpass; - else - pinfo = NULL; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzcallfiles; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - iret = uuconf_cmd_file (pglobal, e, as, pinfo, - (uuconf_cmdtabfn) NULL, 0, - qsys->uuconf_palloc); - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - break; - if (*pzlog != NULL) - break; - } - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME; - } - - if (*pzlog == NULL && *pzpass == NULL) - return UUCONF_NOT_FOUND; - - return UUCONF_SUCCESS; -} - -/* Copy the login name and password onto the heap and set the - pointers. The pzlog argument is passed in pvar, and the pzpass - argument is passed in pinfo. */ - -static int -icsys (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pzlog = (char **) pvar; - char **pzpass = (char **) pinfo; - - if (argc < 2 || argc > 3) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (pzlog != NULL) - { - *pzlog = strdup (argv[1]); - if (*pzlog == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - } - - if (pzpass != NULL) - { - if (argc < 3) - *pzpass = strdup (""); - else - *pzpass = strdup (argv[2]); - if (*pzpass == NULL) - { - qglobal->ierrno = errno; - if (pzlog != NULL) - { - free ((pointer) *pzlog); - *pzlog = NULL; - } - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - } - - return UUCONF_CMDTABRET_EXIT; -} diff --git a/gnu/libexec/uucp/libuuconf/tdial.c b/gnu/libexec/uucp/libuuconf/tdial.c deleted file mode 100644 index 1bf57d240fb3..000000000000 --- a/gnu/libexec/uucp/libuuconf/tdial.c +++ /dev/null @@ -1,227 +0,0 @@ -/* tdial.c - Find a dialer in the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tdial_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int iddialer P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int idunknown P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); - -/* Find a dialer in the Taylor UUCP configuration files by name. */ - -int -uuconf_taylor_dialer_info (pglobal, zname, qdialer) - pointer pglobal; - const char *zname; - struct uuconf_dialer *qdialer; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - FILE *e; - pointer pblock; - int iret; - char **pz; - - e = NULL; - pblock = NULL; - iret = UUCONF_NOT_FOUND; - - for (pz = qglobal->qprocess->pzdialfiles; *pz != NULL; pz++) - { - struct uuconf_cmdtab as[2]; - char *zdialer; - struct uuconf_dialer sdefault; - int ilineno; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - qglobal->ilineno = 0; - - /* Gather the default information from the top of the file. We - do this by handling the "dialer" command ourselves and - passing every other command to _uuconf_idialer_cmd via - idunknown. The value of zdialer will be an malloc block. */ - as[0].uuconf_zcmd = "dialer"; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2; - as[0].uuconf_pvar = (pointer) &zdialer; - as[0].uuconf_pifn = iddialer; - - as[1].uuconf_zcmd = NULL; - - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - _uuconf_uclear_dialer (&sdefault); - sdefault.uuconf_palloc = pblock; - zdialer = NULL; - iret = uuconf_cmd_file (pglobal, e, as, (pointer) &sdefault, - idunknown, UUCONF_CMDTABFLAG_BACKSLASH, - pblock); - - /* Now skip until we find a dialer with a matching name. */ - while (iret == UUCONF_SUCCESS - && zdialer != NULL - && strcmp (zname, zdialer) != 0) - { - free ((pointer) zdialer); - zdialer = NULL; - ilineno = qglobal->ilineno; - iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL, - (uuconf_cmdtabfn) NULL, - UUCONF_CMDTABFLAG_BACKSLASH, - pblock); - qglobal->ilineno += ilineno; - } - - if (iret != UUCONF_SUCCESS) - { - if (zdialer != NULL) - free ((pointer) zdialer); - break; - } - - if (zdialer != NULL) - { - size_t csize; - - /* We've found the dialer we're looking for. Read the rest - of the commands for it. */ - as[0].uuconf_pvar = NULL; - - *qdialer = sdefault; - csize = strlen (zdialer) + 1; - qdialer->uuconf_zname = uuconf_malloc (pblock, csize); - if (qdialer->uuconf_zname == NULL) - { - qglobal->ierrno = errno; - free ((pointer) zdialer); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) qdialer->uuconf_zname, (pointer) zdialer, - csize); - free ((pointer) zdialer); - - ilineno = qglobal->ilineno; - iret = uuconf_cmd_file (pglobal, e, as, qdialer, idunknown, - UUCONF_CMDTABFLAG_BACKSLASH, pblock); - qglobal->ilineno += ilineno; - break; - } - - (void) fclose (e); - e = NULL; - uuconf_free_block (pblock); - pblock = NULL; - - iret = UUCONF_NOT_FOUND; - } - - if (e != NULL) - (void) fclose (e); - if (iret != UUCONF_SUCCESS && pblock != NULL) - uuconf_free_block (pblock); - - if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME; - } - - return iret; -} - -/* Handle a "dialer" command. This copies the string onto the heap - and returns the pointer in *pvar, unless pvar is NULL. It returns - UUCONF_CMDTABRET_EXIT to force _uuconf_icmd_file_internal to stop - reading and return to the code above, which will then check the - dialer name just read to see if it matches. */ - -/*ARGSUSED*/ -static int -iddialer (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pz = (char **) pvar; - - if (pz != NULL) - { - size_t csize; - - csize = strlen (argv[1]) + 1; - *pz = malloc (csize); - if (*pz == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - memcpy ((pointer) *pz, (pointer) argv[1], csize); - } - return UUCONF_CMDTABRET_EXIT; -} - -/* Handle an unknown command by passing it on to _uuconf_idialer_cmd, - which will parse it into the dialer structure. */ - -/*ARGSUSED*/ -static int -idunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; - - return _uuconf_idialer_cmd (qglobal, argc, argv, qdialer); -} diff --git a/gnu/libexec/uucp/libuuconf/tdialc.c b/gnu/libexec/uucp/libuuconf/tdialc.c deleted file mode 100644 index c13a7a5d2c43..000000000000 --- a/gnu/libexec/uucp/libuuconf/tdialc.c +++ /dev/null @@ -1,211 +0,0 @@ -/* tdialc.c - Handle a Taylor UUCP dialer command. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tdialc_rcsid[] = "$FreeBSD$"; -#endif - -static int idchat P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int iddtr_toggle P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int idcomplete P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int idproto_param P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int idcunknown P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* The command table for dialer commands. The "dialer" command is - handled specially. */ -static const struct cmdtab_offset asDialer_cmds[] = -{ - { "chat", UUCONF_CMDTABTYPE_PREFIX | 0, - offsetof (struct uuconf_dialer, uuconf_schat), idchat }, - { "dialtone", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_dialer, uuconf_zdialtone), NULL }, - { "pause", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_dialer, uuconf_zpause), NULL }, - { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_dialer, uuconf_fcarrier), NULL }, - { "carrier-wait", UUCONF_CMDTABTYPE_INT, - offsetof (struct uuconf_dialer, uuconf_ccarrier_wait), NULL }, - { "dtr-toggle", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iddtr_toggle }, - { "complete", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_dialer, uuconf_scomplete), idcomplete }, - { "complete-chat", UUCONF_CMDTABTYPE_PREFIX, - offsetof (struct uuconf_dialer, uuconf_scomplete), idchat }, - { "abort", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_dialer, uuconf_sabort), idcomplete }, - { "abort-chat", UUCONF_CMDTABTYPE_PREFIX, - offsetof (struct uuconf_dialer, uuconf_sabort), idchat }, - { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_dialer, uuconf_qproto_params), idproto_param }, - { "seven-bit", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_iseven_bit }, - { "reliable", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_dialer, uuconf_ireliable), _uuconf_ireliable }, - { "half-duplex", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_dialer, uuconf_ireliable), - _uuconf_ihalf_duplex }, - { NULL, 0, 0, NULL } -}; - -#define CDIALER_CMDS (sizeof asDialer_cmds / sizeof asDialer_cmds[0]) - -/* Handle a command passed to a dialer from a Taylor UUCP - configuration file. This can be called when reading the dialer - file, the port file, or the sys file. The return value may have - UUCONF_CMDTABRET_KEEP set, but not UUCONF_CMDTABRET_EXIT. It - assigns values to the elements of qdialer. The first time this is - called, qdialer->uuconf_palloc should be set. This will not set - qdialer->uuconf_zname. */ - -int -_uuconf_idialer_cmd (qglobal, argc, argv, qdialer) - struct sglobal *qglobal; - int argc; - char **argv; - struct uuconf_dialer *qdialer; -{ - struct uuconf_cmdtab as[CDIALER_CMDS]; - int iret; - - _uuconf_ucmdtab_base (asDialer_cmds, CDIALER_CMDS, (char *) qdialer, as); - - iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as, - (pointer) qdialer, idcunknown, 0, - qdialer->uuconf_palloc); - - return iret &~ UUCONF_CMDTABRET_EXIT; -} - -/* Reroute a chat script command. */ - -static int -idchat (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_chat *qchat = (struct uuconf_chat *) pvar; - struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; - - return _uuconf_ichat_cmd (qglobal, argc, argv, qchat, - qdialer->uuconf_palloc); -} - -/* Handle the "dtr-toggle" command, which may take two arguments. */ - -/*ARGSUSED*/ -static int -iddtr_toggle (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; - int iret; - - if (argc < 2 || argc > 3) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - iret = _uuconf_iboolean (qglobal, argv[1], &qdialer->uuconf_fdtr_toggle); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - return iret; - - if (argc < 3) - return iret; - - iret |= _uuconf_iboolean (qglobal, argv[2], - &qdialer->uuconf_fdtr_toggle_wait); - - return iret; -} - -/* Handle the "complete" and "abort" commands. These just turn a - string into a trivial chat script. */ - -/*ARGSUSED*/ -static int -idcomplete (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_chat *qchat = (struct uuconf_chat *) pvar; - struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; - char *azargs[3]; - - azargs[0] = (char *) "complete-chat"; - azargs[1] = (char *) "\"\""; - azargs[2] = (char *) argv[1]; - - return _uuconf_ichat_cmd (qglobal, 3, azargs, qchat, - qdialer->uuconf_palloc); -} - -/* Handle the "protocol-parameter" command. */ - -static int -idproto_param (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar; - struct uuconf_dialer *qdialer = (struct uuconf_dialer *) pinfo; - - return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam, - qdialer->uuconf_palloc); -} - -/* Give an error for an unknown dialer command. */ - -/*ARGSUSED*/ -static int -idcunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; -} diff --git a/gnu/libexec/uucp/libuuconf/tdnams.c b/gnu/libexec/uucp/libuuconf/tdnams.c deleted file mode 100644 index 38e30070bb83..000000000000 --- a/gnu/libexec/uucp/libuuconf/tdnams.c +++ /dev/null @@ -1,119 +0,0 @@ -/* tdnams.c - Get all known dialer names from the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tdnams_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int indialer P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); - -/* Get the names of all the dialers from the Taylor UUCP configuration - files. */ - -int -uuconf_taylor_dialer_names (pglobal, ppzdialers) - pointer pglobal; - char ***ppzdialers; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_cmdtab as[2]; - char **pz; - int iret; - - *ppzdialers = NULL; - - as[0].uuconf_zcmd = "dialer"; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2; - as[0].uuconf_pvar = (pointer) ppzdialers; - as[0].uuconf_pifn = indialer; - - as[1].uuconf_zcmd = NULL; - - iret = UUCONF_SUCCESS; - - for (pz = qglobal->qprocess->pzdialfiles; *pz != NULL; pz++) - { - FILE *e; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL, - (uuconf_cmdtabfn) NULL, - UUCONF_CMDTABFLAG_BACKSLASH, - (pointer) NULL); - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - break; - } - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME; - } - - if (*ppzdialers == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzdialers, (pointer) NULL); - - return UUCONF_SUCCESS; -} - -/* Add a dialer name to the list. */ - -/*ARGSUSED*/ -static int -indialer (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char ***ppzdialers = (char ***) pvar; - int iret; - - iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, TRUE, ppzdialers, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/tgcmp.c b/gnu/libexec/uucp/libuuconf/tgcmp.c deleted file mode 100644 index 16f2a2c229c6..000000000000 --- a/gnu/libexec/uucp/libuuconf/tgcmp.c +++ /dev/null @@ -1,42 +0,0 @@ -/* tgcmp.c - A comparison function for grades for _uuconf_time_parse. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tgcmp_rcsid[] = "$FreeBSD$"; -#endif - -/* A comparison function to pass to _uuconf_itime_parse. This - compares grades. We can't just pass uuconf_grade_cmp, since - _uuconf_itime_parse wants a function takes longs as arguments. */ - -int -_uuconf_itime_grade_cmp (i1, i2) - long i1; - long i2; -{ - return UUCONF_GRADE_CMP ((int) i1, (int) i2); -} diff --git a/gnu/libexec/uucp/libuuconf/thread.c b/gnu/libexec/uucp/libuuconf/thread.c deleted file mode 100644 index 23af8ebe8bcc..000000000000 --- a/gnu/libexec/uucp/libuuconf/thread.c +++ /dev/null @@ -1,70 +0,0 @@ -/* thread.c - Initialize for a new thread. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_thread_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Initialize for a new thread, by allocating a new sglobal structure - which points to the same sprocess structure. */ - -int -uuconf_init_thread (ppglobal) - pointer *ppglobal; -{ - struct sglobal **pqglob = (struct sglobal **) ppglobal; - pointer pblock; - struct sglobal *qnew; - - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - (*pqglob)->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - qnew = (struct sglobal *) uuconf_malloc (pblock, - sizeof (struct sglobal)); - if (qnew == NULL) - { - (*pqglob)->ierrno = errno; - uuconf_free_block (pblock); - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - qnew->pblock = pblock; - qnew->ierrno = 0; - qnew->ilineno = 0; - qnew->zfilename = NULL; - qnew->qprocess = (*pqglob)->qprocess; - - *pqglob = qnew; - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/time.c b/gnu/libexec/uucp/libuuconf/time.c deleted file mode 100644 index db00d6a993e3..000000000000 --- a/gnu/libexec/uucp/libuuconf/time.c +++ /dev/null @@ -1,407 +0,0 @@ -/* time.c - Parse a time string into a uuconf_timespan structure. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_time_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -static int itadd_span P((struct sglobal *qglobal, int istart, int iend, - long ival, int cretry, - int (*picmp) P((long, long)), - struct uuconf_timespan **pqspan, - pointer pblock)); -static int itnew P((struct sglobal *qglobal, struct uuconf_timespan **pqset, - struct uuconf_timespan *qnext, int istart, int iend, - long ival, int cretry, pointer pblock)); - -/* An array of weekday abbreviations. The code below assumes that - each one starts with a lower case letter. */ - -static const struct -{ - const char *zname; - int imin; - int imax; -} asTdays[] = -{ - { "any", 0, 6 }, - { "wk", 1, 5 }, - { "su", 0, 0 }, - { "mo", 1, 1 }, - { "tu", 2, 2 }, - { "we", 3, 3 }, - { "th", 4, 4 }, - { "fr", 5, 5 }, - { "sa", 6, 6 }, - { "never", -1, -2 }, - { "none", -1, -2 }, - { NULL, 0, 0 } -}; - -/* Parse a time string and add it to a span list. This function is - given the value, the retry time, and the comparison function to - use. */ - -int -_uuconf_itime_parse (qglobal, ztime, ival, cretry, picmp, pqspan, pblock) - struct sglobal *qglobal; - char *ztime; - long ival; - int cretry; - int (*picmp) P((long, long)); - struct uuconf_timespan **pqspan; - pointer pblock; -{ - struct uuconf_timespan *qlist; - char bfirst; - const char *z; - - qlist = *pqspan; - if (qlist == (struct uuconf_timespan *) &_uuconf_unset) - qlist = NULL; - - /* Expand the string using a timetable. Keep rechecking the string - until it does not match. */ - while (TRUE) - { - char **pz; - char *zfound; - - bfirst = *ztime; - if (isupper (BUCHAR (bfirst))) - bfirst = tolower (BUCHAR (bfirst)); - - zfound = NULL; - pz = qglobal->qprocess->pztimetables; - - /* We want the last timetable to have been defined with this - name, so we always look through the entire table. */ - while (*pz != NULL) - { - if ((bfirst == (*pz)[0] - || (isupper (BUCHAR ((*pz)[0])) - && (int) bfirst == (int) tolower (BUCHAR ((*pz)[0])))) - && strcasecmp (ztime, *pz) == 0) - zfound = pz[1]; - pz += 2; - } - if (zfound == NULL) - break; - ztime = zfound; - } - - /* Look through the time string. */ - z = ztime; - while (*z != '\0') - { - int iday; - boolean afday[7]; - int istart, iend; - - if (*z == ',' || *z == '|') - ++z; - if (*z == '\0' || *z == ';') - break; - - for (iday = 0; iday < 7; iday++) - afday[iday] = FALSE; - - /* Get the days. */ - do - { - bfirst = *z; - if (isupper (BUCHAR (bfirst))) - bfirst = tolower (BUCHAR (bfirst)); - for (iday = 0; asTdays[iday].zname != NULL; iday++) - { - size_t clen; - - if (bfirst != asTdays[iday].zname[0]) - continue; - - clen = strlen (asTdays[iday].zname); - if (strncasecmp (z, asTdays[iday].zname, clen) == 0) - { - int iset; - - for (iset = asTdays[iday].imin; - iset <= asTdays[iday].imax; - iset++) - afday[iset] = TRUE; - z += clen; - break; - } - } - if (asTdays[iday].zname == NULL) - return UUCONF_SYNTAX_ERROR; - } - while (isalpha (BUCHAR (*z))); - - /* Get the hours. */ - if (! isdigit (BUCHAR (*z))) - { - istart = 0; - iend = 24 * 60; - } - else - { - char *zendnum; - - istart = (int) strtol ((char *) z, &zendnum, 10); - if (*zendnum != '-' || ! isdigit (BUCHAR (zendnum[1]))) - return UUCONF_SYNTAX_ERROR; - z = zendnum + 1; - iend = (int) strtol ((char *) z, &zendnum, 10); - z = zendnum; - - istart = (istart / 100) * 60 + istart % 100; - iend = (iend / 100) * 60 + iend % 100; - } - - /* Add the times we've found onto the list. */ - for (iday = 0; iday < 7; iday++) - { - if (afday[iday]) - { - int iminute, iret; - - iminute = iday * 24 * 60; - if (istart < iend) - iret = itadd_span (qglobal, iminute + istart, - iminute + iend, ival, cretry, picmp, - &qlist, pblock); - else - { - /* Wrap around midnight. */ - iret = itadd_span (qglobal, iminute, iminute + iend, - ival, cretry, picmp, &qlist, pblock); - if (iret == UUCONF_SUCCESS) - iret = itadd_span (qglobal, iminute + istart, - iminute + 24 * 60, ival, cretry, - picmp, &qlist, pblock); - } - - if (iret != UUCONF_SUCCESS) - return iret; - } - } - } - - *pqspan = qlist; - - return UUCONF_SUCCESS; -} - -/* Add a time span to an existing list of time spans. We keep the - list sorted by time to make this operation easier. This modifies - the existing list, and returns the modified version. It takes a - comparison function which should return < 0 if the first argument - should take precedence over the second argument and == 0 if they - are the same (for grades this is igradecmp; for sizes it is minus - (the binary operator)). */ - -static int -itadd_span (qglobal, istart, iend, ival, cretry, picmp, pqspan, pblock) - struct sglobal *qglobal; - int istart; - int iend; - long ival; - int cretry; - int (*picmp) P((long, long)); - struct uuconf_timespan **pqspan; - pointer pblock; -{ - struct uuconf_timespan **pq; - int iret; - - /* istart < iend */ - for (pq = pqspan; *pq != NULL; pq = &(*pq)->uuconf_qnext) - { - int icmp; - - /* Invariant: PREV (*pq) == NULL || PREV (*pq)->iend <= istart */ - /* istart < iend && (*pq)->istart < (*pq)->iend */ - - if (iend <= (*pq)->uuconf_istart) - { - /* istart < iend <= (*pq)->istart < (*pq)->iend */ - /* No overlap, and we're at the right spot. See if we can - combine these spans. */ - if (iend == (*pq)->uuconf_istart - && cretry == (*pq)->uuconf_cretry - && (*picmp) (ival, (*pq)->uuconf_ival) == 0) - { - (*pq)->uuconf_istart = istart; - return UUCONF_SUCCESS; - } - /* We couldn't combine them. */ - break; - } - - if ((*pq)->uuconf_iend <= istart) - { - /* (*pq)->istart < (*pq)->iend <= istart < iend */ - /* No overlap. Try attaching this span. */ - if ((*pq)->uuconf_iend == istart - && (*pq)->uuconf_cretry == cretry - && ((*pq)->uuconf_qnext == NULL - || iend <= (*pq)->uuconf_qnext->uuconf_istart) - && (*picmp) (ival, (*pq)->uuconf_ival) == 0) - { - (*pq)->uuconf_iend = iend; - return UUCONF_SUCCESS; - } - /* Couldn't attach; keep looking for the right spot. We - might be able to combine part of the new span onto an - existing span, but it's probably not worth it. */ - continue; - } - - /* istart < iend - && (*pq)->istart < (*pq)->iend - && istart < (*pq)->iend - && (*pq)->istart < iend */ - /* Overlap. */ - - icmp = (*picmp) (ival, (*pq)->uuconf_ival); - - if (icmp == 0) - { - /* Just expand the old span to include the new span. */ - if (istart < (*pq)->uuconf_istart) - (*pq)->uuconf_istart = istart; - if ((*pq)->uuconf_iend >= iend) - return UUCONF_SUCCESS; - if ((*pq)->uuconf_qnext == NULL - || iend <= (*pq)->uuconf_qnext->uuconf_istart) - { - (*pq)->uuconf_iend = iend; - return UUCONF_SUCCESS; - } - /* The span we are adding overlaps the next span as well. - Expand the old span up to the next old span, and keep - trying to add the new span. */ - (*pq)->uuconf_iend = (*pq)->uuconf_qnext->uuconf_istart; - istart = (*pq)->uuconf_iend; - } - else if (icmp < 0) - { - /* Replace the old span with the new span. */ - if ((*pq)->uuconf_istart < istart) - { - /* Save the initial portion of the old span. */ - iret = itnew (qglobal, pq, *pq, (*pq)->uuconf_istart, istart, - (*pq)->uuconf_ival, (*pq)->uuconf_cretry, - pblock); - if (iret != UUCONF_SUCCESS) - return iret; - pq = &(*pq)->uuconf_qnext; - } - if (iend < (*pq)->uuconf_iend) - { - /* Save the final portion of the old span. */ - iret = itnew (qglobal, &(*pq)->uuconf_qnext, - (*pq)->uuconf_qnext, iend, (*pq)->uuconf_iend, - (*pq)->uuconf_ival, (*pq)->uuconf_cretry, - pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - (*pq)->uuconf_ival = ival; - (*pq)->uuconf_istart = istart; - (*pq)->uuconf_cretry = cretry; - if ((*pq)->uuconf_qnext == NULL - || iend <= (*pq)->uuconf_qnext->uuconf_istart) - { - (*pq)->uuconf_iend = iend; - return UUCONF_SUCCESS; - } - /* Move this span up to the next one, and keep trying to add - the new span. */ - (*pq)->uuconf_iend = (*pq)->uuconf_qnext->uuconf_istart; - istart = (*pq)->uuconf_iend; - } - else - { - /* Leave the old span untouched. */ - if (istart < (*pq)->uuconf_istart) - { - /* Put in the initial portion of the new span. */ - iret = itnew (qglobal, pq, *pq, istart, (*pq)->uuconf_istart, - ival, cretry, pblock); - if (iret != UUCONF_SUCCESS) - return iret; - pq = &(*pq)->uuconf_qnext; - } - if (iend <= (*pq)->uuconf_iend) - return UUCONF_SUCCESS; - /* Keep trying to add the new span. */ - istart = (*pq)->uuconf_iend; - } - } - - /* This is the spot for the new span, and there's no overlap. */ - - return itnew (qglobal, pq, *pq, istart, iend, ival, cretry, pblock); -} - -/* A utility function to create a new uuconf_timespan structure. */ - -static int -itnew (qglobal, pqset, qnext, istart, iend, ival, cretry, pblock) - struct sglobal *qglobal; - struct uuconf_timespan **pqset; - struct uuconf_timespan *qnext; - int istart; - int iend; - long ival; - int cretry; - pointer pblock; -{ - register struct uuconf_timespan *qnew; - - qnew = ((struct uuconf_timespan *) - uuconf_malloc (pblock, sizeof (struct uuconf_timespan))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - qnew->uuconf_qnext = qnext; - qnew->uuconf_istart = istart; - qnew->uuconf_iend = iend; - qnew->uuconf_ival = ival; - qnew->uuconf_cretry = cretry; - - *pqset = qnew; - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/tinit.c b/gnu/libexec/uucp/libuuconf/tinit.c deleted file mode 100644 index 6ab9869d285e..000000000000 --- a/gnu/libexec/uucp/libuuconf/tinit.c +++ /dev/null @@ -1,465 +0,0 @@ -/* tinit.c - Initialize for reading Taylor UUCP configuration files. - - Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tinit_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Local functions. */ - -static int itset_default P((struct sglobal *qglobal, char ***ppzvar, - const char *zfile)); -static int itdebug P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int itaddfile P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int itunknown P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int itprogram P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); - -static const struct cmdtab_offset asCmds[] = -{ - { "nodename", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zlocalname), NULL }, - { "hostname", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zlocalname), NULL }, - { "uuname", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zlocalname), NULL }, - { "spool", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zspooldir), NULL }, - { "pubdir", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zpubdir), NULL }, - { "lockdir", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zlockdir), NULL }, - { "logfile", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zlogfile), NULL }, - { "statfile", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zstatsfile), NULL }, - { "debugfile", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zdebugfile), NULL }, - { "debug", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, zdebug), itdebug }, - { "strip-login", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct sprocess, fstrip_login), NULL }, - { "strip-proto", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct sprocess, fstrip_proto), NULL }, - { "max-uuxqts", UUCONF_CMDTABTYPE_INT, - offsetof (struct sprocess, cmaxuuxqts), NULL }, - { "run-uuxqt", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zrunuuxqt), NULL }, - { "sysfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzsysfiles), itaddfile }, - { "portfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzportfiles), itaddfile }, - { "dialfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzdialfiles), itaddfile }, - { "dialcodefile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzdialcodefiles), itaddfile }, - { "callfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzcallfiles), itaddfile }, - { "passwdfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzpwdfiles), itaddfile }, - { "unknown", UUCONF_CMDTABTYPE_FN, offsetof (struct sprocess, qunknown), - itunknown }, - { "v2-files", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct sprocess, fv2), NULL }, - { "hdb-files", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct sprocess, fhdb), NULL }, - { "bnu-files", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct sprocess, fhdb), NULL }, - { "timetable", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct sprocess, pztimetables), _uuconf_itimetable }, - { NULL, 0, 0, NULL } -}; - -#define CCMDS (sizeof asCmds / sizeof asCmds[0]) - -/* This structure is used to pass information into the command table - functions. */ - -struct sinfo -{ - /* The program name. */ - const char *zname; - /* A pointer to the command table being used, passed to isystem so - it can call uuconf_cmd_args. */ - struct uuconf_cmdtab *qcmds; -}; - -/* Initialize the routines which read the Taylor UUCP configuration - files. */ - -int -uuconf_taylor_init (ppglobal, zprogram, zname) - pointer *ppglobal; - const char *zprogram; - const char *zname; -{ - struct sglobal **pqglobal = (struct sglobal **) ppglobal; - int iret; - char *zcopy; - struct sglobal *qglobal; - boolean fdefault; - FILE *e; - struct sinfo si; - - if (*pqglobal == NULL) - { - iret = _uuconf_iinit_global (pqglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - qglobal = *pqglobal; - - if (zname != NULL) - { - size_t csize; - - csize = strlen (zname) + 1; - zcopy = uuconf_malloc (qglobal->pblock, csize); - if (zcopy == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) zcopy, (pointer) zname, csize); - fdefault = FALSE; - } - else - { - zcopy = uuconf_malloc (qglobal->pblock, - sizeof NEWCONFIGLIB + sizeof CONFIGFILE - 1); - if (zcopy == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - memcpy ((pointer) zcopy, (pointer) NEWCONFIGLIB, - sizeof NEWCONFIGLIB - 1); - memcpy ((pointer) (zcopy + sizeof NEWCONFIGLIB - 1), - (pointer) CONFIGFILE, sizeof CONFIGFILE); - fdefault = TRUE; - } - - qglobal->qprocess->zconfigfile = zcopy; - - e = fopen (zcopy, "r"); - if (e == NULL) - { - if (! fdefault) - { - qglobal->ierrno = errno; - qglobal->zfilename = zcopy; - return (UUCONF_FOPEN_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_FILENAME); - } - - /* There is no config file, so just use the default values. */ - } - else - { - struct uuconf_cmdtab as[CCMDS]; - - _uuconf_ucmdtab_base (asCmds, CCMDS, (char *) qglobal->qprocess, - as); - - if (zprogram == NULL) - zprogram = "uucp"; - - si.zname = zprogram; - si.qcmds = as; - iret = uuconf_cmd_file (qglobal, e, as, (pointer) &si, itprogram, - UUCONF_CMDTABFLAG_BACKSLASH, - qglobal->pblock); - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = zcopy; - return iret | UUCONF_ERROR_FILENAME; - } - } - - /* Get the defaults for the file names. */ - - iret = itset_default (qglobal, &qglobal->qprocess->pzsysfiles, SYSFILE); - if (iret != UUCONF_SUCCESS) - return iret; - iret = itset_default (qglobal, &qglobal->qprocess->pzportfiles, PORTFILE); - if (iret != UUCONF_SUCCESS) - return iret; - iret = itset_default (qglobal, &qglobal->qprocess->pzdialfiles, DIALFILE); - if (iret != UUCONF_SUCCESS) - return iret; - iret = itset_default (qglobal, &qglobal->qprocess->pzdialcodefiles, - DIALCODEFILE); - if (iret != UUCONF_SUCCESS) - return iret; - iret = itset_default (qglobal, &qglobal->qprocess->pzpwdfiles, PASSWDFILE); - if (iret != UUCONF_SUCCESS) - return iret; - iret = itset_default (qglobal, &qglobal->qprocess->pzcallfiles, CALLFILE); - if (iret != UUCONF_SUCCESS) - return iret; - - return UUCONF_SUCCESS; -} - -/* Local interface to the _uuconf_idebug_cmd function, which handles - the "debug" command. */ - -static int -itdebug (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pzdebug = (char **) pvar; - - return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, - qglobal->pblock); -} - -/* Add new filenames to a list of files. */ - -/*ARGSUSED*/ -static int -itaddfile (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char ***ppz = (char ***) pvar; - int i; - int iret; - - if (argc == 1) - { - iret = _uuconf_iadd_string (qglobal, NULL, FALSE, FALSE, ppz, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - else - { - for (i = 1; i < argc; i++) - { - char *z; - boolean fallocated; - - MAKE_ABSOLUTE (z, fallocated, argv[i], NEWCONFIGLIB, - qglobal->pblock); - if (z == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - iret = _uuconf_iadd_string (qglobal, z, ! fallocated, FALSE, ppz, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret; - } - } - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle an "unknown" command. We accumulate this into a linked - list, and only parse them later in uuconf_unknown_system_info. */ - -/*ARGSUSED*/ -static int -itunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sunknown **pq = (struct sunknown **) pvar; - struct sunknown *q; - - q = (struct sunknown *) uuconf_malloc (qglobal->pblock, - sizeof (struct sunknown)); - if (q == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - q->qnext = NULL; - q->ilineno = qglobal->ilineno; - q->cargs = argc - 1; - q->pzargs = (char **) uuconf_malloc (qglobal->pblock, - (argc - 1) * sizeof (char *)); - if (q->pzargs == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - memcpy ((pointer) q->pzargs, (pointer) (argv + 1), - (argc - 1) * sizeof (char *)); - - while (*pq != NULL) - pq = &(*pq)->qnext; - - *pq = q; - - return UUCONF_CMDTABRET_KEEP; -} - -/* If we encounter an unknown command, see if it is the program with - which we were invoked. If it was, pass the remaining arguments - back through the table. */ - -/*ARGSUSED*/ -static int -itprogram (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - - if (argc <= 1 - || strcasecmp (qinfo->zname, argv[0]) != 0) - return UUCONF_CMDTABRET_CONTINUE; - - return uuconf_cmd_args (pglobal, argc - 1, argv + 1, qinfo->qcmds, - (pointer) NULL, (uuconf_cmdtabfn) NULL, 0, - qglobal->pblock); -} - -/* If a filename was not set by the configuration file, add in the - default value. */ - -static int -itset_default (qglobal, ppzvar, zfile) - struct sglobal *qglobal; - char ***ppzvar; - const char *zfile; -{ - size_t clen; - char *zadd; - - if (*ppzvar != NULL) - return UUCONF_SUCCESS; - - clen = strlen (zfile); - zadd = (char *) uuconf_malloc (qglobal->pblock, - sizeof NEWCONFIGLIB + clen); - if (zadd == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - memcpy ((pointer) zadd, (pointer) NEWCONFIGLIB, sizeof NEWCONFIGLIB - 1); - memcpy ((pointer) (zadd + sizeof NEWCONFIGLIB - 1), (pointer) zfile, - clen + 1); - - return _uuconf_iadd_string (qglobal, zadd, FALSE, FALSE, ppzvar, - qglobal->pblock); -} - -/* Handle the "debug" command which is documented to take multiple - arguments. This is also called by the ``debug'' command in a sys - file. It returns a CMDTABRET code. This should probably be in its - own file, but the only other place it is called is from tsinfo.c, - and any user of tsinfo.c it sure to link in this file as well. */ - -int -_uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, pblock) - struct sglobal *qglobal; - char **pzdebug; - int argc; - char **argv; - pointer pblock; -{ - if (argc == 1) - { - *pzdebug = NULL; - return UUCONF_CMDTABRET_CONTINUE; - } - else if (argc == 2) - { - *pzdebug = argv[1]; - return UUCONF_CMDTABRET_KEEP; - } - else - { - size_t cdebug; - int i; - char *zdebug; - - cdebug = 0; - for (i = 1; i < argc; i++) - cdebug += strlen (argv[i]) + 1; - zdebug = (char *) uuconf_malloc (pblock, cdebug); - if (zdebug == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - cdebug = 0; - for (i = 1; i < argc; i++) - { - size_t clen; - - clen = strlen (argv[i]); - memcpy (zdebug + cdebug, argv[i], clen); - zdebug[cdebug + clen] = ' '; - cdebug += clen + 1; - } - zdebug[cdebug - 1] = '\0'; - *pzdebug = zdebug; - return UUCONF_CMDTABRET_CONTINUE; - } -} diff --git a/gnu/libexec/uucp/libuuconf/tlocnm.c b/gnu/libexec/uucp/libuuconf/tlocnm.c deleted file mode 100644 index 96280acdbc44..000000000000 --- a/gnu/libexec/uucp/libuuconf/tlocnm.c +++ /dev/null @@ -1,112 +0,0 @@ -/* tlocnm.c - Get the local name to use from the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tlocnm_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get the local name to use, based on the login name, from the Taylor - UUCP configuration files. This could probably be done in a - slightly more intelligent fashion, but no matter what it has to - read the systems files. */ - -int -uuconf_taylor_login_localname (pglobal, zlogin, pzname) - pointer pglobal; - const char *zlogin; - char **pzname; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pznames, **pz; - int iret; - - if (! qglobal->qprocess->fread_syslocs) - { - iret = _uuconf_iread_locations (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* As a simple optimization, if there is no "myname" command we can - simply return immediately. */ - if (! qglobal->qprocess->fuses_myname) - { - *pzname = NULL; - return UUCONF_NOT_FOUND; - } - - iret = uuconf_taylor_system_names (pglobal, &pznames, 0); - if (iret != UUCONF_SUCCESS) - return iret; - - *pzname = NULL; - iret = UUCONF_NOT_FOUND; - - for (pz = pznames; *pz != NULL; pz++) - { - struct uuconf_system ssys; - struct uuconf_system *qsys; - - iret = uuconf_system_info (pglobal, *pz, &ssys); - if (iret != UUCONF_SUCCESS) - break; - - for (qsys = &ssys; qsys != NULL; qsys = qsys->uuconf_qalternate) - { - if (qsys->uuconf_zlocalname != NULL - && qsys->uuconf_fcalled - && qsys->uuconf_zcalled_login != NULL - && strcmp (qsys->uuconf_zcalled_login, zlogin) == 0) - { - *pzname = strdup (qsys->uuconf_zlocalname); - if (*pzname != NULL) - iret = UUCONF_SUCCESS; - else - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - break; - } - } - - (void) uuconf_system_free (pglobal, &ssys); - - if (qsys != NULL) - break; - - iret = UUCONF_NOT_FOUND; - } - - for (pz = pznames; *pz != NULL; pz++) - free ((pointer) *pz); - free ((pointer) pznames); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/tport.c b/gnu/libexec/uucp/libuuconf/tport.c deleted file mode 100644 index 3e052f375382..000000000000 --- a/gnu/libexec/uucp/libuuconf/tport.c +++ /dev/null @@ -1,299 +0,0 @@ -/* tport.c - Find a port in the Taylor UUCP configuration files. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tport_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int ipport P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int ipunknown P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* Find a port in the Taylor UUCP configuration files by name, baud - rate, and special purpose function. */ - -int -uuconf_taylor_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, - qport) - pointer pglobal; - const char *zname; - long ibaud; - long ihighbaud; - int (*pifn) P((struct uuconf_port *, pointer)); - pointer pinfo; - struct uuconf_port *qport; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - FILE *e; - pointer pblock; - char *zfree; - int iret; - char **pz; - - if (ihighbaud == 0L) - ihighbaud = ibaud; - - e = NULL; - pblock = NULL; - zfree = NULL; - iret = UUCONF_NOT_FOUND; - - for (pz = qglobal->qprocess->pzportfiles; *pz != NULL; pz++) - { - struct uuconf_cmdtab as[2]; - char *zport; - struct uuconf_port sdefault; - int ilineno; - - e = fopen (*pz, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - continue; - qglobal->ierrno = errno; - iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - qglobal->ilineno = 0; - - /* Gather the default information from the top of the file. We - do this by handling the "port" command ourselves and passing - every other command to _uuconf_iport_cmd via ipunknown. The - value of zport will be an malloc block. */ - as[0].uuconf_zcmd = "port"; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2; - as[0].uuconf_pvar = (pointer) &zport; - as[0].uuconf_pifn = ipport; - - as[1].uuconf_zcmd = NULL; - - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - _uuconf_uclear_port (&sdefault); - sdefault.uuconf_palloc = pblock; - zport = NULL; - iret = uuconf_cmd_file (pglobal, e, as, (pointer) &sdefault, - ipunknown, UUCONF_CMDTABFLAG_BACKSLASH, - pblock); - if (iret != UUCONF_SUCCESS) - { - zfree = zport; - break; - } - - /* Now skip until we find a port with a matching name. If the - zname argument is NULL, we will have to read every port. */ - iret = UUCONF_NOT_FOUND; - while (zport != NULL) - { - uuconf_cmdtabfn piunknown; - boolean fmatch; - - if (zname == NULL || strcmp (zname, zport) == 0) - { - piunknown = ipunknown; - *qport = sdefault; - qport->uuconf_zname = zport; - zfree = zport; - fmatch = TRUE; - } - else - { - piunknown = NULL; - free ((pointer) zport); - fmatch = FALSE; - } - - zport = NULL; - ilineno = qglobal->ilineno; - iret = uuconf_cmd_file (pglobal, e, as, (pointer) qport, - piunknown, UUCONF_CMDTABFLAG_BACKSLASH, - pblock); - qglobal->ilineno += ilineno; - if (iret != UUCONF_SUCCESS) - break; - iret = UUCONF_NOT_FOUND; - - /* We may have just gathered information about a port. See - if it matches the name, the baud rate and the special - function. */ - if (fmatch) - { - if (ibaud != 0) - { - if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM) - { - long imbaud, imhigh, imlow; - - imbaud = qport->uuconf_u.uuconf_smodem.uuconf_ibaud; - imhigh = qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud; - imlow = qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud; - - if (imbaud == 0 && imlow == 0) - ; - else if (ibaud <= imbaud && imbaud <= ihighbaud) - ; - else if (imlow != 0 - && imlow <= ihighbaud - && imhigh >= ibaud) - ; - else - fmatch = FALSE; - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT) - { - long idbaud; - - idbaud = qport->uuconf_u.uuconf_sdirect.uuconf_ibaud; - if (idbaud != 0 && idbaud != ibaud) - fmatch = FALSE; - } - } - } - - if (fmatch) - { - if (pifn != NULL) - { - iret = (*pifn) (qport, pinfo); - if (iret == UUCONF_NOT_FOUND) - fmatch = FALSE; - else if (iret != UUCONF_SUCCESS) - break; - } - } - - if (fmatch) - { - if (uuconf_add_block (pblock, zfree) == 0) - { - zfree = NULL; - iret = UUCONF_SUCCESS; - } - else - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - break; - } - - if (zfree != NULL) - { - free ((pointer) zfree); - zfree = NULL; - } - } - - (void) fclose (e); - e = NULL; - - if (iret != UUCONF_NOT_FOUND) - break; - - uuconf_free_block (pblock); - pblock = NULL; - } - - if (e != NULL) - (void) fclose (e); - if (zfree != NULL) - free ((pointer) zfree); - if (iret != UUCONF_SUCCESS && pblock != NULL) - uuconf_free_block (pblock); - - if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND) - { - qglobal->zfilename = *pz; - iret |= UUCONF_ERROR_FILENAME; - } - - return iret; -} - -/* Handle a "port" command. This copies the string onto the heap and - returns the pointer in *pvar. It returns UUCONF_CMDTABRET_EXIT to - force uuconf_cmd_file to stop reading and return to the code above, - which will then check the port just read to see if it matches. */ - -/*ARGSUSED*/ -static int -ipport (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pz = (char **) pvar; - size_t csize; - - csize = strlen (argv[1]) + 1; - *pz = malloc (csize); - if (*pz == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - memcpy ((pointer) *pz, (pointer) argv[1], csize); - return UUCONF_CMDTABRET_EXIT; -} - -/* Handle an unknown command by passing it on to _uuconf_iport_cmd, - which will parse it into the port structure. */ - -/*ARGSUSED*/ -static int -ipunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_port *qport = (struct uuconf_port *) pinfo; - int iret; - - iret = _uuconf_iport_cmd (qglobal, argc, argv, qport); - if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/tportc.c b/gnu/libexec/uucp/libuuconf/tportc.c deleted file mode 100644 index 60467bc03429..000000000000 --- a/gnu/libexec/uucp/libuuconf/tportc.c +++ /dev/null @@ -1,541 +0,0 @@ -/* tportc.c - Handle a Taylor UUCP port command. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tportc_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -static int ipproto_param P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int ipbaud_range P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int ipdialer P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int ipfamily P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int ipcunknown P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* The string names of the port types. This array corresponds to the - uuconf_porttype enumeration. */ - -static const char * const azPtype_names[] = -{ - NULL, - "stdin", - "modem", - "direct", - "tcp", - "tli", - "pipe" -}; - -#define CPORT_TYPES (sizeof azPtype_names / sizeof azPtype_names[0]) - -/* The command table for generic port commands. The "port" and "type" - commands are handled specially. */ -static const struct cmdtab_offset asPort_cmds[] = -{ - { "protocol", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_zprotocols), NULL }, - { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_port, uuconf_qproto_params), ipproto_param }, - { "seven-bit", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_port, uuconf_ireliable), _uuconf_iseven_bit }, - { "reliable", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_port, uuconf_ireliable), _uuconf_ireliable }, - { "half-duplex", UUCONF_CMDTABTYPE_FN | 2, - offsetof (struct uuconf_port, uuconf_ireliable), - _uuconf_ihalf_duplex }, - { "lockname", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_zlockname), NULL }, - { NULL, 0, 0, NULL } -}; - -#define CPORT_CMDS (sizeof asPort_cmds / sizeof asPort_cmds[0]) - -/* The stdin port command table. */ -static const struct cmdtab_offset asPstdin_cmds[] = -{ - { NULL, 0, 0, NULL } -}; - -#define CSTDIN_CMDS (sizeof asPstdin_cmds / sizeof asPstdin_cmds[0]) - -/* The modem port command table. */ -static const struct cmdtab_offset asPmodem_cmds[] = -{ - { "device", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_zdevice), - NULL }, - { "baud", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_ibaud), - NULL }, - { "speed", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_ibaud), - NULL }, - { "baud-range", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipbaud_range }, - { "speed-range", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipbaud_range }, - { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fcarrier), - NULL }, - { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fhardflow), - NULL }, - { "dial-device", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, - uuconf_u.uuconf_smodem.uuconf_zdial_device), - NULL }, - { "dialer", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem), ipdialer }, - { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_pzdialer), - NULL }, - { NULL, 0, 0, NULL } -}; - -#define CMODEM_CMDS (sizeof asPmodem_cmds / sizeof asPmodem_cmds[0]) - -/* The direct port command table. */ -static const struct cmdtab_offset asPdirect_cmds[] = -{ - { "device", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_zdevice), - NULL }, - { "baud", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_ibaud), - NULL }, - { "speed", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_ibaud), - NULL }, - { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fcarrier), - NULL }, - { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fhardflow), - NULL }, - { NULL, 0, 0, NULL } -}; - -#define CDIRECT_CMDS (sizeof asPdirect_cmds / sizeof asPdirect_cmds[0]) - -/* The TCP port command table. */ -static const struct cmdtab_offset asPtcp_cmds[] = -{ - { "service", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_zport), - NULL }, - { "family", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_zfamily), - ipfamily }, - { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_pzdialer), - NULL }, - { NULL, 0, 0, NULL } -}; - -#define CTCP_CMDS (sizeof asPtcp_cmds / sizeof asPtcp_cmds[0]) - -/* The TLI port command table. */ -static const struct cmdtab_offset asPtli_cmds[] = -{ - { "device", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_zdevice), - NULL }, - { "stream", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_fstream), - NULL }, - { "push", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_pzpush), - NULL }, - { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_pzdialer), - NULL }, - { "server-address", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_stli.uuconf_zservaddr), - NULL }, - { NULL, 0, 0, NULL } -}; - -#define CTLI_CMDS (sizeof asPtli_cmds / sizeof asPtli_cmds[0]) - -/* The pipe port command table. */ -static const struct cmdtab_offset asPpipe_cmds[] = -{ - { "command", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_port, uuconf_u.uuconf_spipe.uuconf_pzcmd), - NULL }, - { NULL, 0, 0, NULL} -}; - -#define CPIPE_CMDS (sizeof asPpipe_cmds / sizeof asPpipe_cmds[0]) - -#undef max -#define max(i1, i2) ((i1) > (i2) ? (i1) : (i2)) -#define CCMDS \ - max (max (max (CPORT_CMDS, CSTDIN_CMDS), CMODEM_CMDS), \ - max (max (CDIRECT_CMDS, CTCP_CMDS), max (CTLI_CMDS, CPIPE_CMDS))) - -/* Handle a command passed to a port from a Taylor UUCP configuration - file. This can be called when reading either the port file or the - sys file. The return value may have UUCONF_CMDTABRET_KEEP set, but - not UUCONF_CMDTABRET_EXIT. It assigns values to the elements of - qport. The first time this is called, qport->uuconf_zname and - qport->uuconf_palloc should be set and qport->uuconf_ttype should - be UUCONF_PORTTYPE_UNKNOWN. */ - -int -_uuconf_iport_cmd (qglobal, argc, argv, qport) - struct sglobal *qglobal; - int argc; - char **argv; - struct uuconf_port *qport; -{ - boolean fgottype; - const struct cmdtab_offset *qcmds; - size_t ccmds; - struct uuconf_cmdtab as[CCMDS]; - int i; - int iret; - - fgottype = strcasecmp (argv[0], "type") == 0; - - if (fgottype || qport->uuconf_ttype == UUCONF_PORTTYPE_UNKNOWN) - { - enum uuconf_porttype ttype; - - /* We either just got a "type" command, or this is an - uninitialized port. If the first command to a port is not - "type", it is assumed to be a modem port. This - implementation will actually permit "type" at any point, but - will effectively discard any type specific information that - appears before the "type" command. This supports defaults, - in that the default may be of a specific type while future - ports in the same file may be of other types. */ - if (! fgottype) - ttype = UUCONF_PORTTYPE_MODEM; - else - { - if (argc != 2) - return UUCONF_SYNTAX_ERROR; - - for (i = 0; i < CPORT_TYPES; i++) - if (azPtype_names[i] != NULL - && strcasecmp (argv[1], azPtype_names[i]) == 0) - break; - - if (i >= CPORT_TYPES) - return UUCONF_SYNTAX_ERROR; - - ttype = (enum uuconf_porttype) i; - } - - qport->uuconf_ttype = ttype; - - switch (ttype) - { - default: - case UUCONF_PORTTYPE_STDIN: - break; - case UUCONF_PORTTYPE_MODEM: - qport->uuconf_u.uuconf_smodem.uuconf_zdevice = NULL; - qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL; - qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; - qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL; - qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; - break; - case UUCONF_PORTTYPE_DIRECT: - qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL; - qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = -1; - qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; - qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; - break; - case UUCONF_PORTTYPE_TCP: - qport->uuconf_u.uuconf_stcp.uuconf_zport = (char *) "uucp"; - qport->uuconf_u.uuconf_stcp.uuconf_zfamily = PF_UNSPEC; - qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL; - qport->uuconf_ireliable = (UUCONF_RELIABLE_SPECIFIED - | UUCONF_RELIABLE_ENDTOEND - | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX); - break; - case UUCONF_PORTTYPE_TLI: - qport->uuconf_u.uuconf_stli.uuconf_zdevice = NULL; - qport->uuconf_u.uuconf_stli.uuconf_fstream = FALSE; - qport->uuconf_u.uuconf_stli.uuconf_pzpush = NULL; - qport->uuconf_u.uuconf_stli.uuconf_pzdialer = NULL; - qport->uuconf_u.uuconf_stli.uuconf_zservaddr = NULL; - qport->uuconf_ireliable = (UUCONF_RELIABLE_SPECIFIED - | UUCONF_RELIABLE_ENDTOEND - | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX); - break; - case UUCONF_PORTTYPE_PIPE: - qport->uuconf_u.uuconf_spipe.uuconf_pzcmd = NULL; - break; - } - - if (fgottype) - return UUCONF_CMDTABRET_CONTINUE; - } - - /* See if this command is one of the generic ones. */ - qcmds = asPort_cmds; - ccmds = CPORT_CMDS; - - for (i = 0; i < CPORT_CMDS - 1; i++) - if (strcasecmp (argv[0], asPort_cmds[i].zcmd) == 0) - break; - - if (i >= CPORT_CMDS - 1) - { - /* It's not a generic command, so we must check the type - specific commands. */ - switch (qport->uuconf_ttype) - { - case UUCONF_PORTTYPE_STDIN: - qcmds = asPstdin_cmds; - ccmds = CSTDIN_CMDS; - break; - case UUCONF_PORTTYPE_MODEM: - qcmds = asPmodem_cmds; - ccmds = CMODEM_CMDS; - break; - case UUCONF_PORTTYPE_DIRECT: - qcmds = asPdirect_cmds; - ccmds = CDIRECT_CMDS; - break; - case UUCONF_PORTTYPE_TCP: - qcmds = asPtcp_cmds; - ccmds = CTCP_CMDS; - break; - case UUCONF_PORTTYPE_TLI: - qcmds = asPtli_cmds; - ccmds = CTLI_CMDS; - break; - case UUCONF_PORTTYPE_PIPE: - qcmds = asPpipe_cmds; - ccmds = CPIPE_CMDS; - break; - default: - return UUCONF_SYNTAX_ERROR; - } - } - - /* Copy the command table onto the stack and modify it to point to - qport. */ - _uuconf_ucmdtab_base (qcmds, ccmds, (char *) qport, as); - - iret = uuconf_cmd_args ((pointer) qglobal, argc, argv, as, - (pointer) qport, ipcunknown, 0, - qport->uuconf_palloc); - - return iret &~ UUCONF_CMDTABRET_EXIT; -} - -/* Handle the "protocol-parameter" command. */ - -static int -ipproto_param (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar; - struct uuconf_port *qport = (struct uuconf_port *) pinfo; - - return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam, - qport->uuconf_palloc); -} - -/* Handle the "baud-range" command. */ - -/*ARGSUSED*/ -static int -ipbaud_range (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_modem_port *qmodem = (struct uuconf_modem_port *) pvar; - int iret; - - iret = _uuconf_iint (qglobal, argv[1], - (pointer) &qmodem->uuconf_ilowbaud, FALSE); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - return iret; - - iret |= _uuconf_iint (qglobal, argv[2], - (pointer) &qmodem->uuconf_ihighbaud, FALSE); - - return iret; -} - -/* Handle the "dialer" command. If there is one argument, this names - a dialer. Otherwise, the remaining arguments form a command - describing the dialer. */ - -static int -ipdialer (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_modem_port *qmodem = (struct uuconf_modem_port *) pvar; - struct uuconf_port *qport = (struct uuconf_port *) pinfo; - int iret; - - if (argc < 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (argc > 2) - { - if (qmodem->uuconf_qdialer == NULL) - { - struct uuconf_dialer *qnew; - size_t clen; - - qnew = ((struct uuconf_dialer *) - uuconf_malloc (qport->uuconf_palloc, - sizeof (struct uuconf_dialer))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - _uuconf_uclear_dialer (qnew); - - if (qport->uuconf_zname == NULL) - qnew->uuconf_zname = (char *) "default port file dialer"; - else - { - clen = strlen (qport->uuconf_zname); - qnew->uuconf_zname = - (char *) uuconf_malloc (qport->uuconf_palloc, - clen + sizeof " dialer"); - if (qnew->uuconf_zname == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - memcpy ((pointer) qnew->uuconf_zname, - (pointer) qport->uuconf_zname, clen); - memcpy ((pointer) (qnew->uuconf_zname + clen), - (pointer) " dialer", sizeof " dialer"); - } - - qnew->uuconf_palloc = qport->uuconf_palloc; - - qmodem->uuconf_qdialer = qnew; - } - - iret = _uuconf_idialer_cmd (qglobal, argc - 1, argv + 1, - qmodem->uuconf_qdialer); - if ((iret &~ UUCONF_CMDTABRET_KEEP) != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; - } - else - { - qmodem->uuconf_pzdialer = NULL; - iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE, - &qmodem->uuconf_pzdialer, - qport->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; - } -} - -/* Handle a "family" commands. The first argument is "inet" for - PF_INET or "inet6" for PF_INET6 */ - -/*ARGSUSED*/ -static int -ipfamily (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - int *pzfamily = (int *) pvar; - - if (argc < 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - if (!strcmp(argv[1], "inet")) - *pzfamily = PF_INET; -#if HAVE_GETADDRINFO - else if (!strcmp(argv[1], "inet6")) - *pzfamily = PF_INET6; -#endif - else if (!strcmp(argv[1], "inet46")) - *pzfamily = PF_UNSPEC; - else - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - return UUCONF_CMDTABRET_KEEP; -} - -/* Give an error for an unknown port command. */ - -/*ARGSUSED*/ -static int -ipcunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; -} diff --git a/gnu/libexec/uucp/libuuconf/tsinfo.c b/gnu/libexec/uucp/libuuconf/tsinfo.c deleted file mode 100644 index 6766153f5203..000000000000 --- a/gnu/libexec/uucp/libuuconf/tsinfo.c +++ /dev/null @@ -1,954 +0,0 @@ -/* tsinfo.c - Get information about a system from the Taylor UUCP configuration files. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tsinfo_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -static void uiset_call P((struct uuconf_system *qsys)); -static int iisizecmp P((long i1, long i2)); - -/* Local functions needed to parse the system information file. */ - -#define CMDTABFN(z) \ - static int z P((pointer, int, char **, pointer, pointer)) - -CMDTABFN (iisystem); -CMDTABFN (iialias); -CMDTABFN (iialternate); -CMDTABFN (iidefault_alternates); -CMDTABFN (iitime); -CMDTABFN (iitimegrade); -CMDTABFN (iisize); -CMDTABFN (iibaud_range); -CMDTABFN (iiport); -CMDTABFN (iichat); -CMDTABFN (iidebug); -CMDTABFN (iicalled_login); -CMDTABFN (iiproto_param); -CMDTABFN (iirequest); -CMDTABFN (iitransfer); -CMDTABFN (iiforward); -CMDTABFN (iiunknown); - -#undef CMDTABFN - -/* We have to pass a fair amount of information in and out of the - various system commands. Using global variables would make the - code non-reentrant, so we instead pass a pointer to single - structure as the pinfo argument to the system commands. */ - -struct sinfo -{ - /* The system information we're building up. */ - struct uuconf_system *qsys; - /* Whether any alternates have been used. */ - boolean falternates; - /* A list of the previous alternates. */ - struct uuconf_system salternate; - /* Whether to use extra alternates from the file wide defaults. */ - int fdefault_alternates; -}; - -/* The command table for system commands. */ -static const struct cmdtab_offset asIcmds[] = -{ - { "system", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iisystem }, - { "alias", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iialias }, - { "alternate", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iialternate }, - { "default-alternates", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, - iidefault_alternates }, - { "time", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_system, uuconf_qtimegrade), iitime }, - { "timegrade", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_system, uuconf_qtimegrade), iitimegrade }, - { "max-retries", UUCONF_CMDTABTYPE_INT, - offsetof (struct uuconf_system, uuconf_cmax_retries), NULL }, - { "success-wait", UUCONF_CMDTABTYPE_INT, - offsetof (struct uuconf_system, uuconf_csuccess_wait), NULL }, - { "call-timegrade", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcalltimegrade), iitimegrade }, - { "called-timegrade", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcalledtimegrade), iitimegrade }, - { "call-local-size", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcall_local_size), iisize }, - { "call-remote-size", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcall_remote_size), iisize }, - { "called-local-size", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcalled_local_size), iisize }, - { "called-remote-size", UUCONF_CMDTABTYPE_FN | 3, - offsetof (struct uuconf_system, uuconf_qcalled_remote_size), iisize }, - { "timetable", UUCONF_CMDTABTYPE_FN | 3, (size_t) -1, _uuconf_itimetable }, - { "baud", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_system, uuconf_ibaud), NULL }, - { "speed", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_system, uuconf_ibaud), NULL }, - { "baud-range", UUCONF_CMDTABTYPE_FN | 3, 0, iibaud_range }, - { "speed-range", UUCONF_CMDTABTYPE_FN | 3, 0, iibaud_range }, - { "port", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iiport }, - { "phone", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zphone), NULL }, - { "address", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zphone), NULL }, - { "chat", UUCONF_CMDTABTYPE_PREFIX | 0, - offsetof (struct uuconf_system, uuconf_schat), iichat }, - { "call-login", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zcall_login), NULL }, - { "call-password", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zcall_password), NULL }, - { "called-login", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_system, uuconf_zcalled_login), iicalled_login }, - { "callback", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_fcallback), NULL }, - { "sequence", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_fsequence), NULL }, - { "protocol", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zprotocols), NULL }, - { "protocol-parameter", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_system, uuconf_qproto_params), iiproto_param }, - { "called-chat", UUCONF_CMDTABTYPE_PREFIX | 0, - offsetof (struct uuconf_system, uuconf_scalled_chat), iichat }, - { "debug", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct uuconf_system, uuconf_zdebug), iidebug }, - { "max-remote-debug", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zmax_remote_debug), NULL }, - { "send-request", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_fsend_request), NULL }, - { "receive-request", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_frec_request), NULL }, - { "request", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iirequest }, - { "call-transfer", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_fcall_transfer), NULL }, - { "called-transfer", UUCONF_CMDTABTYPE_BOOLEAN, - offsetof (struct uuconf_system, uuconf_fcalled_transfer), NULL }, - { "transfer", UUCONF_CMDTABTYPE_FN | 2, (size_t) -1, iitransfer }, - { "local-send", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzlocal_send), NULL }, - { "remote-send", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzremote_send), NULL }, - { "local-receive", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzlocal_receive), NULL }, - { "remote-receive", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzremote_receive), NULL }, - { "command-path", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzpath), NULL }, - { "commands", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzcmds), NULL }, - { "free-space", UUCONF_CMDTABTYPE_LONG, - offsetof (struct uuconf_system, uuconf_cfree_space), NULL }, - { "forward-from", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzforward_from), NULL }, - { "forward-to", UUCONF_CMDTABTYPE_FULLSTRING, - offsetof (struct uuconf_system, uuconf_pzforward_to), NULL }, - { "forward", UUCONF_CMDTABTYPE_FN | 0, (size_t) -1, iiforward }, - { "pubdir", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zpubdir), NULL }, - { "myname", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zlocalname), NULL }, - { NULL, 0, 0, NULL } -}; - -#define CSYSTEM_CMDS (sizeof asIcmds / sizeof asIcmds[0]) - -/* Get information about the system zsystem from the Taylor UUCP - configuration files. Sets *qsys. This does not ensure that all - default information is set. */ - -int -_uuconf_itaylor_system_internal (qglobal, zsystem, qsys) - struct sglobal *qglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - int iret; - struct stsysloc *qloc; - struct uuconf_cmdtab as[CSYSTEM_CMDS]; - struct sinfo si; - struct uuconf_system sdefaults; - - if (! qglobal->qprocess->fread_syslocs) - { - iret = _uuconf_iread_locations (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* Find the system in the list of locations. */ - for (qloc = qglobal->qprocess->qsyslocs; qloc != NULL; qloc = qloc->qnext) - if (qloc->zname[0] == zsystem[0] - && strcmp (qloc->zname, zsystem) == 0) - break; - if (qloc == NULL) - return UUCONF_NOT_FOUND; - - /* If this is an alias, then the real system is the next non-alias - in the list. */ - while (qloc->falias) - { - qloc = qloc->qnext; - if (qloc == NULL) - return UUCONF_NOT_FOUND; - } - - _uuconf_ucmdtab_base (asIcmds, CSYSTEM_CMDS, (char *) qsys, as); - - rewind (qloc->e); - - /* Read the file wide defaults from the start of the file. */ - _uuconf_uclear_system (qsys); - - si.qsys = qsys; - si.falternates = FALSE; - si.fdefault_alternates = TRUE; - qsys->uuconf_palloc = uuconf_malloc_block (); - if (qsys->uuconf_palloc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - iret = uuconf_cmd_file ((pointer) qglobal, qloc->e, as, (pointer) &si, - iiunknown, UUCONF_CMDTABFLAG_BACKSLASH, - qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = qloc->zfile; - return iret | UUCONF_ERROR_FILENAME; - } - - if (! si.falternates) - uiset_call (qsys); - else - { - /* Attach the final alternate. */ - iret = iialternate ((pointer) qglobal, 0, (char **) NULL, - (pointer) NULL, (pointer) &si); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* Save off the defaults. */ - sdefaults = *qsys; - - /* Advance to the information for the system we want. */ - if (fseek (qloc->e, qloc->iloc, SEEK_SET) != 0) - { - qglobal->ierrno = errno; - qglobal->zfilename = qloc->zfile; - return (UUCONF_FSEEK_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_FILENAME); - } - - /* Read in the system we want. */ - _uuconf_uclear_system (qsys); - qsys->uuconf_zname = (char *) qloc->zname; - qsys->uuconf_palloc = sdefaults.uuconf_palloc; - - si.falternates = FALSE; - - iret = uuconf_cmd_file (qglobal, qloc->e, as, (pointer) &si, iiunknown, - UUCONF_CMDTABFLAG_BACKSLASH, qsys->uuconf_palloc); - qglobal->ilineno += qloc->ilineno; - - if (iret == UUCONF_SUCCESS) - { - if (! si.falternates) - uiset_call (qsys); - else - iret = iialternate ((pointer) qglobal, 0, (char **) NULL, - (pointer) NULL, (pointer) &si); - } - - /* Merge in the defaults. */ - if (iret == UUCONF_SUCCESS) - iret = _uuconf_isystem_default (qglobal, qsys, &sdefaults, - si.fdefault_alternates); - - /* The first alternate is always available for calling in. It is - always available for calling out if it has some way to choose a - port (this would normally be set by uiset_call anyhow, but it - won't be if all the port information comes from the defaults). */ - if (iret == UUCONF_SUCCESS) - { - qsys->uuconf_fcalled = TRUE; - if (qsys->uuconf_zport != (char *) &_uuconf_unset - || qsys->uuconf_qport != (struct uuconf_port *) &_uuconf_unset - || qsys->uuconf_ibaud >= 0 - || qsys->uuconf_zphone != (char *) &_uuconf_unset) - qsys->uuconf_fcall = TRUE; - } - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = qloc->zfile; - iret |= UUCONF_ERROR_FILENAME; - } - - return iret; -} - -/* Set the fcall and fcalled field for the system. This marks a - particular alternate for use when calling out or calling in. This - is where we implement the semantics described in the documentation: - a change to a relevant field implies that the alternate is used. - If all the relevant fields are unchanged, the alternate is not - used. */ - -static void -uiset_call (qsys) - struct uuconf_system *qsys; -{ - qsys->uuconf_fcall = - (qsys->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset - || qsys->uuconf_zport != (char *) &_uuconf_unset - || qsys->uuconf_qport != (struct uuconf_port *) &_uuconf_unset - || qsys->uuconf_ibaud >= 0 - || qsys->uuconf_zphone != (char *) &_uuconf_unset - || qsys->uuconf_schat.uuconf_pzchat != (char **) &_uuconf_unset - || qsys->uuconf_schat.uuconf_pzprogram != (char **) &_uuconf_unset); - - qsys->uuconf_fcalled = - qsys->uuconf_zcalled_login != (char *) &_uuconf_unset; -} - -/* Handle the "system" command. Because we skip directly to the - system we want to read, a "system" command means we've reached the - end of it. */ - -static int -iisystem (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_CMDTABRET_EXIT; -} - -/* Handle the "alias" command. */ - -/*ARGSUSED*/ -static int -iialias (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - int iret; - - iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, FALSE, - &qinfo->qsys->uuconf_pzalias, - qinfo->qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} - -/* Handle the "alternate" command. The information just read is in - sIhold. If this is the first "alternate" command for this system, - we save off the current information in sIalternate. Otherwise we - default this information to sIalternate, and then add it to the end - of the list of alternates in sIalternate. */ - -static int -iialternate (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - - uiset_call (qinfo->qsys); - - if (! qinfo->falternates) - { - qinfo->salternate = *qinfo->qsys; - qinfo->falternates = TRUE; - } - else - { - int iret; - struct uuconf_system *qnew, **pq; - - iret = _uuconf_isystem_default (qglobal, qinfo->qsys, - &qinfo->salternate, FALSE); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_EXIT; - qnew = ((struct uuconf_system *) - uuconf_malloc (qinfo->qsys->uuconf_palloc, - sizeof (struct uuconf_system))); - if (qnew == NULL) - { - qglobal->ierrno = errno;; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - *qnew = *qinfo->qsys; - for (pq = &qinfo->salternate.uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qnew; - } - - /* If this is the last alternate command, move the information back - to qinfo->qsys. */ - if (argc == 0) - *qinfo->qsys = qinfo->salternate; - else - { - _uuconf_uclear_system (qinfo->qsys); - qinfo->qsys->uuconf_zname = qinfo->salternate.uuconf_zname; - qinfo->qsys->uuconf_palloc = qinfo->salternate.uuconf_palloc; - if (argc > 1) - { - qinfo->qsys->uuconf_zalternate = argv[1]; - return UUCONF_CMDTABRET_KEEP; - } - } - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the "default-alternates" command. This just takes a boolean - argument which is used to set the fdefault_alternates field of the - sinfo structure. */ - -/*ARGSUSED*/ -static int -iidefault_alternates (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - - return _uuconf_iboolean (qglobal, argv[1], &qinfo->fdefault_alternates); -} - -/* Handle the "time" command. We do this by turning it into a - "timegrade" command with a grade of BGRADE_LOW. The first argument - is a time string, and the optional second argument is the retry - time. */ - -/*ARGSUSED*/ -static int -iitime (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - char *aznew[4]; - char ab[2]; - - if (argc != 2 && argc != 3) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - aznew[0] = argv[0]; - ab[0] = UUCONF_GRADE_LOW; - ab[1] = '\0'; - aznew[1] = ab; - aznew[2] = argv[1]; - if (argc > 2) - aznew[3] = argv[2]; - - return iitimegrade (pglobal, argc + 1, aznew, pvar, pinfo); -} - -/* Handle the "timegrade" command by calling _uuconf_itime_parse with - appropriate ival (the work grade) and cretry (the retry time) - arguments. */ - -static int -iitimegrade (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_timespan **pqspan = (struct uuconf_timespan **) pvar; - struct sinfo *qinfo = (struct sinfo *) pinfo; - int cretry; - int iret; - - if (argc < 3 || argc > 4) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (argv[1][1] != '\0' || ! UUCONF_GRADE_LEGAL (argv[1][0])) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - - if (argc == 3) - cretry = 0; - else - { - iret = _uuconf_iint (qglobal, argv[3], (pointer) &cretry, TRUE); - if (iret != UUCONF_SUCCESS) - return iret; - } - - iret = _uuconf_itime_parse (qglobal, argv[2], (long) argv[1][0], - cretry, _uuconf_itime_grade_cmp, pqspan, - qinfo->qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} - -/* Handle the "baud-range" command, also known as "speed-range". */ - -static int -iibaud_range (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_system *qsys = (struct uuconf_system *) pvar; - int iret; - - iret = _uuconf_iint (qglobal, argv[1], (pointer) &qsys->uuconf_ibaud, - FALSE); - if (iret != UUCONF_SUCCESS) - return iret; - return _uuconf_iint (qglobal, argv[2], (pointer) &qsys->uuconf_ihighbaud, - FALSE); -} - -/* Handle one of the size commands ("call-local-size", etc.). The - first argument is a number of bytes, and the second argument is a - time string. The pvar argument points to the string array to which - we add this new string. */ - -/*ARGSUSED*/ -static int -iisize (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_timespan **pqspan = (struct uuconf_timespan **) pvar; - struct sinfo *qinfo = (struct sinfo *) pinfo; - long ival; - int iret; - - iret = _uuconf_iint (qglobal, argv[1], (pointer) &ival, FALSE); - if (iret != UUCONF_SUCCESS) - return iret; - - iret = _uuconf_itime_parse (qglobal, argv[2], ival, 0, iisizecmp, - pqspan, qinfo->qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} - -/* A comparison function for sizes to pass to _uuconf_itime_parse. */ - -static int -iisizecmp (i1, i2) - long i1; - long i2; -{ - /* We can't just return i1 - i2 because that would be a long. */ - if (i1 < i2) - return -1; - else if (i1 == i2) - return 0; - else - return 1; -} - -/* Handle the "port" command. If there is one argument, this names a - port. Otherwise, the remaining arguments form a command describing - the port. */ - -/*ARGSUSED*/ -static int -iiport (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - - if (argc < 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - else if (argc == 2) - { - qinfo->qsys->uuconf_zport = argv[1]; - return UUCONF_CMDTABRET_KEEP; - } - else - { - int iret; - - if (qinfo->qsys->uuconf_qport - == (struct uuconf_port *) &_uuconf_unset) - { - struct uuconf_port *qnew; - - qnew = ((struct uuconf_port *) - uuconf_malloc (qinfo->qsys->uuconf_palloc, - sizeof (struct uuconf_port))); - if (qnew == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - _uuconf_uclear_port (qnew); - - if (qinfo->qsys->uuconf_zname == NULL) - qnew->uuconf_zname = (char *) "default system file port"; - else - { - char *zname; - size_t clen; - - clen = strlen (qinfo->qsys->uuconf_zname); - zname = (char *) uuconf_malloc (qinfo->qsys->uuconf_palloc, - clen + sizeof "system port"); - if (zname == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } - - memcpy ((pointer) zname, (pointer) "system ", - sizeof "system " - 1); - memcpy ((pointer) (zname + sizeof "system " - 1), - (pointer) qinfo->qsys->uuconf_zname, - clen); - memcpy ((pointer) (zname + sizeof "system " - 1 + clen), - (pointer) " port", sizeof " port"); - - qnew->uuconf_zname = zname; - } - - qnew->uuconf_palloc = qinfo->qsys->uuconf_palloc; - - qinfo->qsys->uuconf_qport = qnew; - } - - iret = _uuconf_iport_cmd (qglobal, argc - 1, argv + 1, - qinfo->qsys->uuconf_qport); - if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; - } -} - -/* Handle the "chat" and "called-chat" set of commands. These just - hand off to the generic chat script function. */ - -static int -iichat (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - struct uuconf_chat *qchat = (struct uuconf_chat *) pvar; - int iret; - - iret = _uuconf_ichat_cmd (qglobal, argc, argv, qchat, - qinfo->qsys->uuconf_palloc); - if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) - iret |= UUCONF_CMDTABRET_EXIT; - return iret; -} - -/* Local interface to the _uuconf_idebug_cmd function, which handles - the "debug" command. */ - -static int -iidebug (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - char **pzdebug = (char **) pvar; - - return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, - qinfo->qsys->uuconf_palloc); -} - -/* Handle the "called-login" command. This only needs to be in a - function because there can be additional arguments listing the - remote systems which are permitted to use this login name. The - additional arguments are not actually handled here; they are - handled by uuconf_taylor_system_names, which already has to go - through all the system files. */ - -/*ARGSUSED*/ -static int -iicalled_login (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - char **pz = (char **) pvar; - - if (argc < 2) - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; - *pz = argv[1]; - return UUCONF_CMDTABRET_KEEP; -} - -/* Handle the "protocol-parameter" command. This just hands off to - the generic protocol parameter handler. */ - -static int -iiproto_param (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_proto_param **pqparam = (struct uuconf_proto_param **) pvar; - struct sinfo *qinfo = (struct sinfo *) pinfo; - - if (*pqparam == (struct uuconf_proto_param *) &_uuconf_unset) - *pqparam = NULL; - return _uuconf_iadd_proto_param (qglobal, argc - 1, argv + 1, pqparam, - qinfo->qsys->uuconf_palloc); -} - -/* Handle the "request" command. This is equivalent to specifying - both "call-request" and "called-request". */ - -/*ARGSUSED*/ -static int -iirequest (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - int iret; - - iret = _uuconf_iboolean (qglobal, argv[1], - &qinfo->qsys->uuconf_fsend_request); - if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS) - qinfo->qsys->uuconf_frec_request = qinfo->qsys->uuconf_fsend_request; - - return iret; -} - -/* Handle the "transfer" command. This is equivalent to specifying - both "call-transfer" and "called-transfer". */ - -/*ARGSUSED*/ -static int -iitransfer (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - int iret; - - iret = _uuconf_iboolean (qglobal, argv[1], - &qinfo->qsys->uuconf_fcall_transfer); - if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS) - qinfo->qsys->uuconf_fcalled_transfer = qinfo->qsys->uuconf_fcall_transfer; - - return iret; -} - -/* Handle the "forward" command. This is equivalent to specifying - both "forward-from" and "forward-to". */ - -/*ARGSUSED*/ -static int -iiforward (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct sinfo *qinfo = (struct sinfo *) pinfo; - struct uuconf_system *qsys; - int i; - int iret; - - qsys = qinfo->qsys; - qsys->uuconf_pzforward_from = NULL; - qsys->uuconf_pzforward_to = NULL; - for (i = 1; i < argc; i++) - { - iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, FALSE, - &qsys->uuconf_pzforward_to, - qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT; - iret = _uuconf_iadd_string (qglobal, argv[i], FALSE, FALSE, - &qsys->uuconf_pzforward_from, - qsys->uuconf_palloc); - if (iret != UUCONF_SUCCESS) - return iret | UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT; - } - - return UUCONF_CMDTABRET_KEEP; -} - -/* Handle an unknown command. This should probably be done more - intelligently. */ - -/*ARGSUSED*/ -static int -iiunknown (pglobal, argc, argv, pvar, pinfo) - pointer pglobal; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; -} - -/* Return information for an unknown system. It would be better to - put this in a different file, but it would require breaking several - functions out of this file. Perhaps I will do it sometime. */ - -int -uuconf_taylor_system_unknown (pglobal, qsys) - pointer pglobal; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct uuconf_cmdtab as[CSYSTEM_CMDS]; - struct sinfo si; - struct sunknown *q; - int iret; - - if (qglobal->qprocess->qunknown == NULL) - return UUCONF_NOT_FOUND; - - _uuconf_ucmdtab_base (asIcmds, CSYSTEM_CMDS, (char *) qsys, as); - - _uuconf_uclear_system (qsys); - - si.qsys = qsys; - si.falternates = FALSE; - si.fdefault_alternates = TRUE; - qsys->uuconf_palloc = uuconf_malloc_block (); - if (qsys->uuconf_palloc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - for (q = qglobal->qprocess->qunknown; q != NULL; q = q->qnext) - { - iret = uuconf_cmd_args (pglobal, q->cargs, q->pzargs, as, - (pointer) &si, iiunknown, - UUCONF_CMDTABFLAG_BACKSLASH, - qsys->uuconf_palloc); - iret &=~ UUCONF_CMDTABRET_KEEP; - if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) - { - qglobal->zfilename = qglobal->qprocess->zconfigfile; - qglobal->ilineno = q->ilineno; - return ((iret &~ UUCONF_CMDTABRET_EXIT) - | UUCONF_ERROR_FILENAME - | UUCONF_ERROR_LINENO); - } - if ((iret & UUCONF_CMDTABRET_EXIT) != 0) - break; - } - - if (! si.falternates) - uiset_call (qsys); - else - { - iret = iialternate (pglobal, 0, (char **) NULL, (pointer) NULL, - (pointer) &si); - if (iret != UUCONF_SUCCESS) - return iret; - } - - /* The first alternate is always available for calling in. */ - qsys->uuconf_fcalled = TRUE; - - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/tsnams.c b/gnu/libexec/uucp/libuuconf/tsnams.c deleted file mode 100644 index a60b3c7e120c..000000000000 --- a/gnu/libexec/uucp/libuuconf/tsnams.c +++ /dev/null @@ -1,84 +0,0 @@ -/* tsnams.c - Get all known system names from the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tsnams_rcsid[] = "$FreeBSD$"; -#endif - -/* Get all the system names from the Taylor UUCP configuration files. - These were actually already recorded by uuconf_taylor_init, so this - function is pretty simple. */ - -int -uuconf_taylor_system_names (pglobal, ppzsystems, falias) - pointer pglobal; - char ***ppzsystems; - int falias; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - register struct stsysloc *q; - char **pz; - int c, i; - - if (! qglobal->qprocess->fread_syslocs) - { - iret = _uuconf_iread_locations (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - *ppzsystems = NULL; - c = 0; - - for (q = qglobal->qprocess->qsyslocs; q != NULL; q = q->qnext) - { - if (! falias && q->falias) - continue; - - iret = _uuconf_iadd_string (qglobal, (char *) q->zname, TRUE, FALSE, - ppzsystems, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - return iret; - ++c; - } - - /* The order of the qSyslocs list is reversed from the list in the - configuration files. Reverse the returned list in order to make - uuname output more intuitive. */ - pz = *ppzsystems; - for (i = c / 2 - 1; i >= 0; i--) - { - char *zhold; - - zhold = pz[i]; - pz[i] = pz[c - i - 1]; - pz[c - i - 1] = zhold; - } - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/tsys.c b/gnu/libexec/uucp/libuuconf/tsys.c deleted file mode 100644 index bdb90a2f5c72..000000000000 --- a/gnu/libexec/uucp/libuuconf/tsys.c +++ /dev/null @@ -1,49 +0,0 @@ -/* tsys.c - User function to get a system from the Taylor UUCP configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tsys_rcsid[] = "$FreeBSD$"; -#endif - -/* Get system information from the Taylor UUCP configuration files. - This is a wrapper for the internal function which makes sure that - every field gets a default value. */ - -int -uuconf_taylor_system_info (pglobal, zsystem, qsys) - pointer pglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - - iret = _uuconf_itaylor_system_internal (qglobal, zsystem, qsys); - if (iret != UUCONF_SUCCESS) - return iret; - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuuconf/tval.c b/gnu/libexec/uucp/libuuconf/tval.c deleted file mode 100644 index c0a25351a318..000000000000 --- a/gnu/libexec/uucp/libuuconf/tval.c +++ /dev/null @@ -1,71 +0,0 @@ -/* tval.c - Validate a login name for a system using Taylor UUCP files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_tval_rcsid[] = "$FreeBSD$"; -#endif - -/* Validate a login name for a system using Taylor UUCP configuration - files. This assumes that the zcalled_login field is either NULL or - "ANY". If makes sure that the login name does not appear in some - other "called-login" command listing systems not including this - one. */ - -int -uuconf_taylor_validate (pglobal, qsys, zlogin) - pointer pglobal; - const struct uuconf_system *qsys; - const char *zlogin; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - struct svalidate *q; - - if (! qglobal->qprocess->fread_syslocs) - { - int iret; - - iret = _uuconf_iread_locations (qglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - for (q = qglobal->qprocess->qvalidate; q != NULL; q = q->qnext) - { - if (strcmp (q->zlogname, zlogin) == 0) - { - char **pz; - - for (pz = q->pzmachines; *pz != NULL; pz++) - if (strcmp (*pz, qsys->uuconf_zname) == 0) - return UUCONF_SUCCESS; - - return UUCONF_NOT_FOUND; - } - } - - return UUCONF_SUCCESS; -} diff --git a/gnu/libexec/uucp/libuuconf/ugtlin.c b/gnu/libexec/uucp/libuuconf/ugtlin.c deleted file mode 100644 index a328229759ad..000000000000 --- a/gnu/libexec/uucp/libuuconf/ugtlin.c +++ /dev/null @@ -1,110 +0,0 @@ -/* ugtlin.c - Read a line with backslash continuations. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_ugtlin_rcsid[] = "$FreeBSD$"; -#endif - -/* Read a line from a file with backslash continuations. This updates - the qglobal->ilineno count for each additional line it reads. */ - -int -_uuconf_getline (qglobal, pzline, pcline, e) - struct sglobal *qglobal; - char **pzline; - size_t *pcline; - FILE *e; -{ - int ctot; - char *zline; - size_t cline; - - ctot = -1; - - zline = NULL; - cline = 0; - - while (TRUE) - { - int cchars; - - if (ctot < 0) - cchars = getline (pzline, pcline, e); - else - cchars = getline (&zline, &cline, e); - if (cchars < 0) - { - if (zline != NULL) - free ((pointer) zline); - if (ctot >= 0) - return ctot; - else - return cchars; - } - - if (ctot < 0) - ctot = cchars; - else - { - if (*pcline <= ctot + cchars) - { - char *znew; - - if (*pcline > 0) - znew = (char *) realloc ((pointer) *pzline, - (size_t) (ctot + cchars + 1)); - else - znew = (char *) malloc ((size_t) (ctot + cchars + 1)); - if (znew == NULL) - { - free ((pointer) zline); - return -1; - } - *pzline = znew; - *pcline = ctot + cchars + 1; - } - - memcpy ((pointer) ((*pzline) + ctot), (pointer) zline, - (size_t) (cchars + 1)); - ctot += cchars; - } - - if (ctot < 2 - || (*pzline)[ctot - 1] != '\n' - || (*pzline)[ctot - 2] != '\\') - { - if (zline != NULL) - free ((pointer) zline); - return ctot; - } - - ++qglobal->ilineno; - - ctot -= 2; - (*pzline)[ctot] = '\0'; - } -} diff --git a/gnu/libexec/uucp/libuuconf/unk.c b/gnu/libexec/uucp/libuuconf/unk.c deleted file mode 100644 index 6345ffed9cb3..000000000000 --- a/gnu/libexec/uucp/libuuconf/unk.c +++ /dev/null @@ -1,70 +0,0 @@ -/* unk.c - Get information about an unknown system. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_unk_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get information about an unknown system. If we are using - HAVE_TAYLOR_CONFIG, we just use it. Otherwise if we are using - HAVE_HDB_CONFIG, we use it. Otherwise we return a default system. - This isn't right for HAVE_V2_CONFIG, because it is possible to - specify default directories to read and write in USERFILE. - However, I'm not going to bother to write that code unless somebody - actually wants it. */ - -/*ARGSUSED*/ -int -uuconf_system_unknown (pglobal, qsys) - pointer pglobal; - struct uuconf_system *qsys; -{ -#if HAVE_TAYLOR_CONFIG - return uuconf_taylor_system_unknown (pglobal, qsys); -#else /* ! HAVE_TAYLOR_CONFIG */ -#if HAVE_HDB_CONFIG - return uuconf_hdb_system_unknown (pglobal, qsys); -#else /* ! HAVE_HDB_CONFIG */ -#if HAVE_V2_CONFIG - struct sglobal *qglobal = (struct sglobal *) pglobal; - - _uuconf_uclear_system (qsys); - qsys->uuconf_palloc = uuconf_malloc_block (); - if (qsys->uuconf_palloc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - return _uuconf_isystem_basic_default (qglobal, qsys); -#else /* ! HAVE_V2_CONFIG */ - return UUCONF_NOT_FOUND; -#endif /* ! HAVE_V2_CONFIG */ -#endif /* ! HAVE_HDB_CONFIG */ -#endif /* ! HAVE_TAYLOR_CONFIG */ -} diff --git a/gnu/libexec/uucp/libuuconf/uucnfi.h b/gnu/libexec/uucp/libuuconf/uucnfi.h deleted file mode 100644 index 1f42391f7d8d..000000000000 --- a/gnu/libexec/uucp/libuuconf/uucnfi.h +++ /dev/null @@ -1,380 +0,0 @@ -/* uucnfi.h - Internal header file for the uuconf package. - - Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* This is the internal header file for the uuconf package. It should - not be included by anything other than the uuconf code itself. */ - -/* Get all the general definitions. */ -#include "uucp.h" - -/* Get the uuconf header file itself. */ -#include "uuconf.h" - -/* We need the system dependent header file. */ -#include "syshdr.h" - -/* This is the generic information structure. This holds all the - per-thread global information needed by the uuconf code. The - per-process global information is held in an sprocess structure, - which this structure points to. This permits the code to not have - any global variables at all. */ - -struct sglobal -{ - /* A pointer to the per-process global information. */ - struct sprocess *qprocess; - /* A memory block in which all the memory for these fields is - allocated. */ - pointer pblock; - /* The value of errno after an error. */ - int ierrno; - /* The filename for which an error occurred. */ - const char *zfilename; - /* The line number at which an error occurred. */ - int ilineno; -}; - -/* This is the per-process information structure. This essentially - holds all the global variables used by uuconf. */ - -struct sprocess -{ - /* The name of the local machine. This will be NULL if it is not - specified in a configuration file. */ - const char *zlocalname; - /* The spool directory. */ - const char *zspooldir; - /* The default public directory. */ - const char *zpubdir; - /* The lock directory. */ - const char *zlockdir; - /* The log file. */ - const char *zlogfile; - /* The statistics file. */ - const char *zstatsfile; - /* The debugging file. */ - const char *zdebugfile; - /* The default debugging level. */ - const char *zdebug; - /* Whether login information should be stripped. */ - boolean fstrip_login; - /* Whether protocol information should be stripped. */ - boolean fstrip_proto; - /* The maximum number of simultaneously executing uuxqts. */ - int cmaxuuxqts; - /* How often to spawn a uuxqt process. */ - const char *zrunuuxqt; - /* Whether we are reading the V2 configuration files. */ - boolean fv2; - /* Whether we are reading the HDB configuration files. */ - boolean fhdb; - /* The names of the dialcode files. */ - char **pzdialcodefiles; - /* Timetables. These are in pairs. The first element is the name, - the second is the time string. */ - char **pztimetables; - - /* Taylor UUCP config file name. */ - char *zconfigfile; - /* Taylor UUCP sys file names. */ - char **pzsysfiles; - /* Taylor UUCP port file names. */ - char **pzportfiles; - /* Taylor UUCP dial file names. */ - char **pzdialfiles; - /* Taylor UUCP passwd file names. */ - char **pzpwdfiles; - /* Taylor UUCP call file names. */ - char **pzcallfiles; - /* List of "unknown" commands from config file. */ - struct sunknown *qunknown; - /* Whether the Taylor UUCP system information locations have been - read. */ - boolean fread_syslocs; - /* Taylor UUCP system information locations. */ - struct stsysloc *qsyslocs; - /* Taylor UUCP validation restrictions. */ - struct svalidate *qvalidate; - /* Whether the "myname" command is used in a Taylor UUCP file. */ - boolean fuses_myname; - - /* V2 system file name (L.sys). */ - char *zv2systems; - /* V2 device file name (L-devices). */ - char *zv2devices; - /* V2 user permissions file name (USERFILE). */ - char *zv2userfile; - /* V2 user permitted commands file (L.cmds). */ - char *zv2cmds; - - /* HDB system file names (Systems). */ - char **pzhdb_systems; - /* HDB device file names (Devices). */ - char **pzhdb_devices; - /* HDB dialer file names (Dialers). */ - char **pzhdb_dialers; - /* Whether the HDB Permissions file has been read. */ - boolean fhdb_read_permissions; - /* The HDB Permissions file entries. */ - struct shpermissions *qhdb_permissions; -}; - -/* This structure is used to hold the "unknown" commands from the - Taylor UUCP config file before they have been parsed. */ - -struct sunknown -{ - /* Next element in linked list. */ - struct sunknown *qnext; - /* Line number in config file. */ - int ilineno; - /* Number of arguments. */ - int cargs; - /* Arguments. */ - char **pzargs; -}; - -/* This structure is used to hold the locations of systems within the - Taylor UUCP sys files. */ - -struct stsysloc -{ - /* Next element in linked list. */ - struct stsysloc *qnext; - /* System name. */ - const char *zname; - /* Whether system is an alias or a real system. If this is an - alias, the real system is the next entry in the linked list which - is not an alias. */ - boolean falias; - /* File name (one of the sys files). */ - const char *zfile; - /* Open file. */ - FILE *e; - /* Location within file (from ftell). */ - long iloc; - /* Line number within file. */ - int ilineno; -}; - -/* This structure is used to hold validation restrictions. This is a - list of machines which are permitted to use a particular login - name. If a machine logs in, and there is no called login entry for - it, the login name and machine name must be passed to - uuconf_validate to confirm that either there is no entry for this - login name or that the machine name appears on the entry. */ - -struct svalidate -{ - /* Next element in linked list. */ - struct svalidate *qnext; - /* Login name. */ - const char *zlogname; - /* NULL terminated list of machine names. */ - char **pzmachines; -}; - -/* This structure is used to hold a linked list of HDB Permissions - file entries. */ - -struct shpermissions -{ - /* Next entry in linked list. */ - struct shpermissions *qnext; - /* NULL terminated array of LOGNAME values. */ - char **pzlogname; - /* NULL terminated array of MACHINE values. */ - char **pzmachine; - /* Boolean REQUEST value. */ - int frequest; - /* Boolean SENDFILES value ("call" is taken as "no"). */ - int fsendfiles; - /* NULL terminated array of READ values. */ - char **pzread; - /* NULL terminated array of WRITE values. */ - char **pzwrite; - /* Boolean CALLBACK value. */ - int fcallback; - /* NULL terminated array of COMMANDS values. */ - char **pzcommands; - /* NULL terminated array of VALIDATE values. */ - char **pzvalidate; - /* String MYNAME value. */ - char *zmyname; - /* String PUBDIR value. */ - const char *zpubdir; - /* NULL terminated array of ALIAS values. */ - char **pzalias; -}; - -/* This structure is used to build reentrant uuconf_cmdtab tables. - The ioff field is either (size_t) -1 or an offsetof macro. The - table is then copied into a uuconf_cmdtab, except that offsets of - (size_t) -1 are converted to pvar elements of NULL, and other - offsets are converted to an offset off some base address. */ - -struct cmdtab_offset -{ - const char *zcmd; - int itype; - size_t ioff; - uuconf_cmdtabfn pifn; -}; - -/* A value in a uuconf_system structure which holds the address of - this special variable is known to be uninitialized. */ -extern char *_uuconf_unset; - -/* Internal function to read a system from the Taylor UUCP - configuration files. This does not apply the basic defaults. */ -extern int _uuconf_itaylor_system_internal P((struct sglobal *qglobal, - const char *zsystem, - struct uuconf_system *qsys)); - -/* Read the system locations and validation information from the - Taylor UUCP configuration files. This sets the qsyslocs, - qvalidate, and fread_syslocs elements of the global structure. */ -extern int _uuconf_iread_locations P((struct sglobal *qglobal)); - -/* Process a command for a port from a Taylor UUCP file. */ -extern int _uuconf_iport_cmd P((struct sglobal *qglobal, int argc, - char **argv, struct uuconf_port *qport)); - -/* Process a command for a dialer from a Taylor UUCP file. */ -extern int _uuconf_idialer_cmd P((struct sglobal *qglobal, int argc, - char **argv, - struct uuconf_dialer *qdialer)); - -/* Process a command for a chat script from a Taylor UUCP file; this - is also called for HDB or V2 files, with a made up command. */ -extern int _uuconf_ichat_cmd P((struct sglobal *qglobal, int argc, - char **argv, struct uuconf_chat *qchat, - pointer pblock)); - -/* Process a protocol-parameter command from a Taylor UUCP file. */ -extern int _uuconf_iadd_proto_param P((struct sglobal *qglobal, - int argc, char **argv, - struct uuconf_proto_param **pq, - pointer pblock)); - -/* Handle a "seven-bit", "reliable", or "half-duplex" command from a - Taylor UUCP port or dialer file. The pvar field should point to - the ireliable element of the structure. */ -extern int _uuconf_iseven_bit P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -extern int _uuconf_ireliable P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); -extern int _uuconf_ihalf_duplex P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* Internal function to read a system from the V2 configuration files. - This does not apply the basic defaults. */ -extern int _uuconf_iv2_system_internal P((struct sglobal *qglobal, - const char *zsystem, - struct uuconf_system *qsys)); - -/* Internal function to read a system from the HDB configuration - files. This does not apply the basic defaults. */ -extern int _uuconf_ihdb_system_internal P((struct sglobal *qglobal, - const char *zsystem, - struct uuconf_system *qsys)); - -/* Read the HDB Permissions file. */ -extern int _uuconf_ihread_permissions P((struct sglobal *qglobal)); - -/* Initialize the global information structure. */ -extern int _uuconf_iinit_global P((struct sglobal **pqglobal)); - -/* Clear system information. */ -extern void _uuconf_uclear_system P((struct uuconf_system *qsys)); - -/* Default unset aspects of one system to the contents of another. */ -extern int _uuconf_isystem_default P((struct sglobal *qglobal, - struct uuconf_system *q, - struct uuconf_system *qdefault, - boolean faddalternates)); - -/* Put in the basic system defaults. */ -extern int _uuconf_isystem_basic_default P((struct sglobal *qglobal, - struct uuconf_system *qsys)); - -/* Clear port information. */ -extern void _uuconf_uclear_port P((struct uuconf_port *qport)); - -/* Clear dialer information. */ -extern void _uuconf_uclear_dialer P((struct uuconf_dialer *qdialer)); - -/* Add a timetable. */ -extern int _uuconf_itimetable P((pointer pglobal, int argc, char **argv, - pointer pvar, pointer pinfo)); - -/* Parse a time string. */ -extern int _uuconf_itime_parse P((struct sglobal *qglobal, char *ztime, - long ival, int cretry, - int (*picmp) P((long, long)), - struct uuconf_timespan **pqspan, - pointer pblock)); - -/* A grade comparison function to pass to _uuconf_itime_parse. */ -extern int _uuconf_itime_grade_cmp P((long, long)); - -/* Parse a debugging string. */ - -extern int _uuconf_idebug_cmd P((struct sglobal *qglobal, - char **pzdebug, int argc, - char **argv, pointer pblock)); - -/* Add a string to a NULL terminated list of strings. */ -extern int _uuconf_iadd_string P((struct sglobal *qglobal, - char *zadd, boolean fcopy, - boolean fdupcheck, char ***ppzstrings, - pointer pblock)); - -/* Parse a string into a boolean value. */ -extern int _uuconf_iboolean P((struct sglobal *qglobal, const char *zval, - int *pi)); - -/* Parse a string into an integer value. The argument p is either an - int * or a long *, according to the argument fint. */ -extern int _uuconf_iint P((struct sglobal *qglobal, const char *zval, - pointer p, boolean fint)); - -/* Turn a cmdtab_offset table into a uuconf_cmdtab table. */ -extern void _uuconf_ucmdtab_base P((const struct cmdtab_offset *qoff, - size_t celes, char *pbase, - struct uuconf_cmdtab *qset)); - -/* Merge two memory blocks into one. This cannot fail. */ -extern pointer _uuconf_pmalloc_block_merge P((pointer, pointer)); - -/* A wrapper for getline that continues lines if they end in a - backslash. It needs qglobal so that it can increment ilineno - correctly. */ -extern int _uuconf_getline P((struct sglobal *qglobal, - char **, size_t *, FILE *)); - -/* Split a string into tokens. */ -extern int _uuconf_istrsplit P((char *zline, int bsep, - char ***ppzsplit, size_t *csplit)); diff --git a/gnu/libexec/uucp/libuuconf/val.c b/gnu/libexec/uucp/libuuconf/val.c deleted file mode 100644 index 1ef0182a27ec..000000000000 --- a/gnu/libexec/uucp/libuuconf/val.c +++ /dev/null @@ -1,46 +0,0 @@ -/* val.c - Validate a login name for a system. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_val_rcsid[] = "$FreeBSD$"; -#endif - -/* Validate a login name for a system. */ - -/*ARGSUSED*/ -int -uuconf_validate (pglobal, qsys, zlogin) - pointer pglobal; - const struct uuconf_system *qsys; - const char *zlogin; -{ -#if HAVE_TAYLOR_CONFIG - return uuconf_taylor_validate (pglobal, qsys, zlogin); -#else - return UUCONF_SUCCESS; -#endif -} diff --git a/gnu/libexec/uucp/libuuconf/vinit.c b/gnu/libexec/uucp/libuuconf/vinit.c deleted file mode 100644 index e1552c30cefe..000000000000 --- a/gnu/libexec/uucp/libuuconf/vinit.c +++ /dev/null @@ -1,112 +0,0 @@ -/* vinit.c - Initialize for reading V2 configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_vinit_rcsid[] = "$FreeBSD$"; -#endif - -#include - -static int ivinlib P((struct sglobal *qglobal, const char *z, size_t csize, - char **pz)); - -/* Return an allocated buffer holding a file name in OLDCONFIGLIB. - The c argument is the size of z including the trailing null byte, - since this is convenient for both the caller and this function. */ - -static int -ivinlib (qglobal, z, c, pz) - struct sglobal *qglobal; - const char *z; - size_t c; - char **pz; -{ - char *zalc; - - zalc = uuconf_malloc (qglobal->pblock, sizeof OLDCONFIGLIB - 1 + c); - if (zalc == NULL) - { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - memcpy ((pointer) zalc, (pointer) OLDCONFIGLIB, - sizeof OLDCONFIGLIB - 1); - memcpy ((pointer) (zalc + sizeof OLDCONFIGLIB - 1), (pointer) z, c); - - *pz = zalc; - - return UUCONF_SUCCESS; -} - -/* Initialize the routines which read V2 configuration files. The - only thing we do here is allocate the file names. */ - -int -uuconf_v2_init (ppglobal) - pointer *ppglobal; -{ - struct sglobal **pqglobal = (struct sglobal **) ppglobal; - int iret; - struct sglobal *qglobal; - char *zdialcodes; - - if (*pqglobal == NULL) - { - iret = _uuconf_iinit_global (pqglobal); - if (iret != UUCONF_SUCCESS) - return iret; - } - - qglobal = *pqglobal; - - iret = ivinlib (qglobal, V2_SYSTEMS, sizeof V2_SYSTEMS, - &qglobal->qprocess->zv2systems); - if (iret != UUCONF_SUCCESS) - return iret; - iret = ivinlib (qglobal, V2_DEVICES, sizeof V2_DEVICES, - &qglobal->qprocess->zv2devices); - if (iret != UUCONF_SUCCESS) - return iret; - iret = ivinlib (qglobal, V2_USERFILE, sizeof V2_USERFILE, - &qglobal->qprocess->zv2userfile); - if (iret != UUCONF_SUCCESS) - return iret; - iret = ivinlib (qglobal, V2_CMDS, sizeof V2_CMDS, - &qglobal->qprocess->zv2cmds); - if (iret != UUCONF_SUCCESS) - return iret; - - iret = ivinlib (qglobal, V2_DIALCODES, sizeof V2_DIALCODES, - &zdialcodes); - if (iret != UUCONF_SUCCESS) - return iret; - - return _uuconf_iadd_string (qglobal, zdialcodes, FALSE, FALSE, - &qglobal->qprocess->pzdialcodefiles, - qglobal->pblock); -} diff --git a/gnu/libexec/uucp/libuuconf/vport.c b/gnu/libexec/uucp/libuuconf/vport.c deleted file mode 100644 index 1e39d2d647b7..000000000000 --- a/gnu/libexec/uucp/libuuconf/vport.c +++ /dev/null @@ -1,254 +0,0 @@ -/* vport.c - Find a port in the V2 configuration files. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_vport_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include - -/* Find a port in the V2 configuration files by name, baud rate, and - special purpose function. */ - -int -uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) - pointer pglobal; - const char *zname; - long ibaud; - long ihighbaud; - int (*pifn) P((struct uuconf_port *, pointer)); - pointer pinfo; - struct uuconf_port *qport; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - FILE *e; - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - int iret; - int cchars; - - e = fopen (qglobal->qprocess->zv2devices, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - return UUCONF_NOT_FOUND; - qglobal->ierrno = errno; - qglobal->zfilename = qglobal->qprocess->zv2devices; - return (UUCONF_FOPEN_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_FILENAME); - } - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - - iret = UUCONF_NOT_FOUND; - - qglobal->ilineno = 0; - - while ((cchars = getline (&zline, &cline, e)) > 0) - { - int ctoks; - char *zend; - long ilow, ihigh; - pointer pblock; - - ++qglobal->ilineno; - - iret = UUCONF_NOT_FOUND; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - zline[strcspn (zline, "#")] = '\0'; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - /* An entry in L-devices is - - type device dial-device baud dialer - - The type (normally "ACU") is treated as the name. */ - - /* If there aren't enough entries, ignore the line; this - should probably do something more useful. */ - if (ctoks < 4) - continue; - - /* Make sure the name matches any argument. */ - if (zname != NULL - && strcmp (pzsplit[0], zname) != 0) - continue; - - /* Get the baud rate. */ - ilow = strtol (pzsplit[3], &zend, 10); - if (*zend == '-') - ihigh = strtol (zend + 1, (char **) NULL, 10); - else - ihigh = ilow; - - /* Make sure the baud rate matches any argument. */ - if (ibaud != 0 - && ilow != 0 - && (ilow > ibaud || ihigh < ibaud)) - continue; - - /* Now we must construct the port information, so that we can - pass it to pifn. The port type is determined by it's name, - unfortunately. The name "DIR" is used for a direct port, and - anything else for a modem port. */ - pblock = NULL; - _uuconf_uclear_port (qport); - qport->uuconf_zname = pzsplit[0]; - if (strcmp (pzsplit[0], "DIR") == 0) - { - qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT; - qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1]; - qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow; - qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; - qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; - } - else - { - qport->uuconf_ttype = UUCONF_PORTTYPE_MODEM; - qport->uuconf_u.uuconf_smodem.uuconf_zdevice = pzsplit[1]; - if (strcmp (pzsplit[2], "-") != 0) - qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = pzsplit[2]; - else - qport->uuconf_u.uuconf_smodem.uuconf_zdial_device = NULL; - if (ilow == ihigh) - { - qport->uuconf_u.uuconf_smodem.uuconf_ibaud = ilow; - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L; - } - else - { - qport->uuconf_u.uuconf_smodem.uuconf_ibaud = 0L; - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = ilow; - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh; - } - qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; - qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; - if (ctoks < 5) - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL; - else - { - size_t c; - char **pzd; - - /* We support dialer/token pairs, although normal V2 - doesn't. */ - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - c = (ctoks - 4) * sizeof (char *); - pzd = (char **) uuconf_malloc (pblock, c + sizeof (char *)); - if (pzd == NULL) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c); - pzd[ctoks - 4] = NULL; - - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = pzd; - } - qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; - } - - if (pifn != NULL) - { - iret = (*pifn) (qport, pinfo); - if (iret != UUCONF_SUCCESS) - { - if (pblock != NULL) - uuconf_free_block (pblock); - if (iret != UUCONF_NOT_FOUND) - break; - continue; - } - } - - /* This is the port we want. */ - if (pblock == NULL) - { - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - } - - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - zline = NULL; - - qport->uuconf_palloc = pblock; - - break; - } - - (void) fclose (e); - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - - if (iret != UUCONF_SUCCESS && iret != UUCONF_NOT_FOUND) - { - qglobal->zfilename = qglobal->qprocess->zv2devices; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/vsinfo.c b/gnu/libexec/uucp/libuuconf/vsinfo.c deleted file mode 100644 index 853ae70483e3..000000000000 --- a/gnu/libexec/uucp/libuuconf/vsinfo.c +++ /dev/null @@ -1,624 +0,0 @@ -/* vsinfo.c - Get information about a system from the V2 configuration files. - - Copyright (C) 1992, 1993, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_vsinfo_rcsid[] = "$FreeBSD$"; -#endif - -#include -#include -#include - -/* Get the information for a particular system from the V2 - configuration files. This does not make sure that all the default - values are set. */ - -int -_uuconf_iv2_system_internal (qglobal, zsystem, qsys) - struct sglobal *qglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - char *zline; - size_t cline; - char **pzsplit; - size_t csplit; - char **pzcomma; - size_t ccomma; - FILE *e; - int cchars; - pointer pblock; - int iret; - - e = fopen (qglobal->qprocess->zv2systems, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - return UUCONF_NOT_FOUND; - qglobal->ierrno = errno; - qglobal->zfilename = qglobal->qprocess->zv2systems; - return (UUCONF_FOPEN_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_FILENAME); - } - - zline = NULL; - cline = 0; - pzsplit = NULL; - csplit = 0; - pzcomma = NULL; - ccomma = 0; - - pblock = NULL; - iret = UUCONF_SUCCESS; - - qglobal->ilineno = 0; - - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) - { - int ctoks, ctimes, i; - struct uuconf_system *qset; - char *z, *zretry; - int cretry; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - zline[strcspn (zline, "#")] = '\0'; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - /* If this isn't the system we're looking for, keep reading - the file. */ - if (ctoks < 1 - || strcmp (zsystem, pzsplit[0]) != 0) - continue; - - /* If this is the first time we've found the system, we want - to set *qsys directly. Otherwise, we allocate a new - alternate. */ - if (pblock == NULL) - { - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - _uuconf_uclear_system (qsys); - qsys->uuconf_palloc = pblock; - qset = qsys; - } - else - { - struct uuconf_system **pq; - - qset = ((struct uuconf_system *) - uuconf_malloc (pblock, sizeof (struct uuconf_system))); - if (qset == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - _uuconf_uclear_system (qset); - for (pq = &qsys->uuconf_qalternate; - *pq != NULL; - pq = &(*pq)->uuconf_qalternate) - ; - *pq = qset; - } - - /* Add this line to the memory block we are building for the - system. */ - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - zline = NULL; - cline = 0; - - /* The format of a line in Systems is - system time device speed phone chat - For example, - airs Any ACU 9600 5551212 ogin: foo pass: bar - */ - - /* Get the system name. */ - - qset->uuconf_zname = pzsplit[0]; - qset->uuconf_fcall = TRUE; - qset->uuconf_fcalled = TRUE; - - if (ctoks < 2) - continue; - - /* A time string is "time/grade,time/grade;retry". A missing - grade is taken as BGRADE_LOW. On some versions the retry - time is actually separated by a comma, which won't work right - here. */ - zretry = strchr (pzsplit[1], ';'); - if (zretry == NULL) - cretry = 55; - else - { - *zretry = '\0'; - cretry = (int) strtol (zretry + 1, (char **) NULL, 10); - } - - ctimes = _uuconf_istrsplit (pzsplit[1], ',', &pzcomma, &ccomma); - if (ctimes < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - for (i = 0; i < ctimes; i++) - { - char *zslash; - char bgrade; - - z = pzcomma[i]; - zslash = strchr (z, '/'); - if (zslash == NULL) - bgrade = UUCONF_GRADE_LOW; - else - { - *zslash = '\0'; - bgrade = zslash[1]; - if (! UUCONF_GRADE_LEGAL (bgrade)) - bgrade = UUCONF_GRADE_LOW; - } - - iret = _uuconf_itime_parse (qglobal, z, (long) bgrade, cretry, - _uuconf_itime_grade_cmp, - &qset->uuconf_qtimegrade, - pblock); - - /* We treat a syntax error in the time field as equivalent - to ``never'', on the assumption that that is what V2 - does. */ - if (iret == UUCONF_SYNTAX_ERROR) - iret = UUCONF_SUCCESS; - - if (iret != UUCONF_SUCCESS) - break; - - /* Treat any time/grade setting as both a timegrade and a - call-timegrade. */ - if (bgrade != UUCONF_GRADE_LOW) - qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade; - } - - if (iret != UUCONF_SUCCESS) - break; - - if (ctoks < 3) - continue; - - /* Pick up the device name. It can be followed by a comma and a - list of protocols (this is not actually supported by most V2 - systems, but it should be compatible). */ - qset->uuconf_zport = pzsplit[2]; - z = strchr (pzsplit[2], ','); - if (z != NULL) - { - qset->uuconf_zprotocols = z + 1; - *z = '\0'; - } - - /* If the port is "TCP", we set up a system specific port. The - baud rate becomes the service number and the phone number - becomes the address (still stored in qsys->zphone). */ - if (strcmp (qset->uuconf_zport, "TCP") == 0) - { - qset->uuconf_zport = NULL; - qset->uuconf_qport = ((struct uuconf_port *) - uuconf_malloc (pblock, - sizeof (struct uuconf_port))); - if (qset->uuconf_qport == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - _uuconf_uclear_port (qset->uuconf_qport); - qset->uuconf_qport->uuconf_zname = (char *) "TCP"; - qset->uuconf_qport->uuconf_ttype = UUCONF_PORTTYPE_TCP; - qset->uuconf_qport->uuconf_ireliable - = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX - | UUCONF_RELIABLE_SPECIFIED); - if (ctoks < 4) - qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zport - = (char *) "uucp"; - else - qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zport - = pzsplit[3]; - - /* I leave with IPv4 only for compatibility reason. If you - wish to use IPv6, please try Taylor UUCP configuration - instead. If you still wish to use IPv6 with V2 - configuration, re-make with INET6 defined. In this case, - you cannot specify the protocol family in V2 - configuration file. */ -#ifdef INET6 - qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zfamily = PF_UNSPEC; -#else - qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zfamily = PF_INET; -#endif - - qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL; - } - - if (ctoks < 4) - continue; - - qset->uuconf_ibaud = strtol (pzsplit[3], (char **) NULL, 10); - - if (ctoks < 5) - continue; - - /* Get the phone number. */ - qset->uuconf_zphone = pzsplit[4]; - - if (ctoks < 6) - continue; - - /* Get the chat script. We just hand this off to the chat - script processor, so that it will parse subsend and - subexpect strings correctly. */ - pzsplit[4] = (char *) "chat"; - iret = _uuconf_ichat_cmd (qglobal, ctoks - 4, pzsplit + 4, - &qset->uuconf_schat, pblock); - iret &=~ UUCONF_CMDTABRET_KEEP; - if (iret != UUCONF_SUCCESS) - break; - } - - (void) fclose (e); - - if (pzcomma != NULL) - free ((pointer) pzcomma); - - if (iret != UUCONF_SUCCESS) - { - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - qglobal->zfilename = qglobal->qprocess->zv2systems; - return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - if (pblock == NULL) - { - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - return UUCONF_NOT_FOUND; - } - - /* Now read USERFILE and L.cmds to get permissions. We can't fully - handle USERFILE since that specifies permissions based on local - users which we do not support. */ - { - e = fopen (qglobal->qprocess->zv2userfile, "r"); - if (e != NULL) - { - char **pzlocal, **pzremote; - boolean fdefault_callback; - char *zdefault_login; - struct uuconf_system *q; - - pzlocal = NULL; - pzremote = NULL; - fdefault_callback = FALSE; - zdefault_login = NULL; - - qglobal->ilineno = 0; - - while ((cchars = getline (&zline, &cline, e)) > 0) - { - int ctoks; - char *zcomma; - boolean fcallback; - char **pzlist, **pznew; - - ++qglobal->ilineno; - - --cchars; - if (zline[cchars] == '\n') - zline[cchars] = '\0'; - zline[strcspn (zline, "#")] = '\0'; - - ctoks = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - - if (ctoks == 0) - continue; - - /* The first field is username,machinename */ - zcomma = strchr (pzsplit[0], ','); - if (zcomma == NULL) - continue; - - *zcomma++ = '\0'; - - /* The rest of the line is the list of directories, except - that if the first directory is "c" we must call the - system back. */ - fcallback = FALSE; - pzlist = pzsplit + 1; - --ctoks; - if (ctoks > 0 - && pzsplit[1][0] == 'c' - && pzsplit[1][1] == '\0') - { - fcallback = TRUE; - pzlist = pzsplit + 2; - --ctoks; - } - - /* Now pzsplit[0] is the user name, zcomma is the system - name, fcallback indicates whether a call back is - required, ctoks is the number of directories and pzlist - points to the directories. If the system name matches, - then the user name is the name that the system must use - to log in, and the list of directories is what may be - transferred in by either local or remote request. - Otherwise, if no system name matches, then the first - line with no user name gives the list of directories - that may be transferred by local request, and the first - line with no system name gives the list of directories - that may be transferred by remote request. */ - if ((pzsplit[0][0] != '\0' || pzlocal != NULL) - && (zcomma[0] != '\0' || pzremote != NULL) - && strcmp (zcomma, zsystem) != 0) - continue; - - /* NULL terminate the list of directories. */ - pznew = (char **) uuconf_malloc (pblock, - (ctoks + 1) * sizeof (char *)); - if (pznew == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) pznew, (pointer) pzlist, - ctoks * sizeof (char *)); - pznew[ctoks] = NULL; - - if (uuconf_add_block (pblock, zline) != 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - zline = NULL; - cline = 0; - - if (pzsplit[0][0] == '\0') - { - pzlocal = pznew; - fdefault_callback = fcallback; - } - else if (zcomma[0] == '\0') - { - pzremote = pznew; - zdefault_login = pzsplit[0]; - } - else - { - /* Both the login name and the machine name were - listed; require the machine to be logged in under - this name. This is not fully backward compatible, - and perhaps should be changed. On the other hand, - it is more useful. */ - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - { - q->uuconf_zcalled_login = pzsplit[0]; - q->uuconf_fcallback = fcallback; - q->uuconf_pzlocal_send = pznew; - q->uuconf_pzlocal_receive = pznew; - q->uuconf_pzremote_send = pznew; - q->uuconf_pzremote_receive = pznew; - } - - break; - } - } - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - { - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - qglobal->zfilename = qglobal->qprocess->zv2userfile; - return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - if (qsys->uuconf_pzlocal_send == (char **) &_uuconf_unset - && pzlocal != NULL) - { - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - { - q->uuconf_fcallback = fdefault_callback; - q->uuconf_pzlocal_send = pzlocal; - q->uuconf_pzlocal_receive = pzlocal; - } - } - - if (qsys->uuconf_pzremote_send == (char **) &_uuconf_unset - && pzremote != NULL) - { - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - { - q->uuconf_zcalled_login = zdefault_login; - q->uuconf_pzremote_send = pzremote; - q->uuconf_pzremote_receive = pzremote; - } - } - } - } - - /* Now we must read L.cmds to determine which commands may be - executed. */ - { - e = fopen (qglobal->qprocess->zv2cmds, "r"); - if (e != NULL) - { - qglobal->ilineno = 0; - - if (getline (&zline, &cline, e) > 0) - { - ++qglobal->ilineno; - - zline[strcspn (zline, "#\n")] = '\0'; - - while (*zline == '\0') - { - if (getline (&zline, &cline, e) <= 0) - { - if (zline != NULL) - { - free ((pointer) zline); - zline = NULL; - } - } - else - { - ++qglobal->ilineno; - zline[strcspn (zline, "#\n")] = '\0'; - } - } - - if (zline != NULL - && strncmp (zline, "PATH=", sizeof "PATH=" - 1) == 0) - { - int ctoks; - char **pznew; - - zline += sizeof "PATH=" - 1; - ctoks = _uuconf_istrsplit (zline, ':', &pzsplit, &csplit); - if (ctoks < 0) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - - pznew = NULL; - if (iret == UUCONF_SUCCESS) - { - pznew = ((char **) - uuconf_malloc (pblock, - (ctoks + 1) * sizeof (char *))); - if (pznew == NULL) - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - } - if (iret == UUCONF_SUCCESS) - { - memcpy ((pointer) pznew, (pointer) pzsplit, - ctoks * sizeof (char *)); - pznew[ctoks] = NULL; - qsys->uuconf_pzpath = pznew; - zline = NULL; - cline = 0; - } - - if (getline (&zline, &cline, e) < 0) - { - if (zline != NULL) - { - free ((pointer) zline); - zline = NULL; - } - } - else - ++qglobal->ilineno; - } - } - - if (iret == UUCONF_SUCCESS && zline != NULL) - { - while (TRUE) - { - zline[strcspn (zline, "#,\n")] = '\0'; - if (*zline != '\0') - { - iret = _uuconf_iadd_string (qglobal, zline, TRUE, FALSE, - &qsys->uuconf_pzcmds, - pblock); - if (iret != UUCONF_SUCCESS) - break; - } - if (getline (&zline, &cline, e) < 0) - break; - ++qglobal->ilineno; - } - } - - (void) fclose (e); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = qglobal->qprocess->zv2cmds; - iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - } - } - - if (zline != NULL) - free ((pointer) zline); - if (pzsplit != NULL) - free ((pointer) pzsplit); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/vsnams.c b/gnu/libexec/uucp/libuuconf/vsnams.c deleted file mode 100644 index 432c9bf9a998..000000000000 --- a/gnu/libexec/uucp/libuuconf/vsnams.c +++ /dev/null @@ -1,106 +0,0 @@ -/* vsnams.c - Get all known system names from the V2 configuration files. - - Copyright (C) 1992, 1995 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_vsnams_rcsid[] = "$FreeBSD$"; -#endif - -#include - -/* Get all the system names from the V2 L.sys file. This code does - not support aliases, although some V2 versions do have an L-aliases - file. */ - -/*ARGSUSED*/ -int -uuconf_v2_system_names (pglobal, ppzsystems, falias) - pointer pglobal; - char ***ppzsystems; - int falias; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - FILE *e; - int iret; - char *zline; - size_t cline; - - *ppzsystems = NULL; - - e = fopen (qglobal->qprocess->zv2systems, "r"); - if (e == NULL) - { - if (FNO_SUCH_FILE ()) - return _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzsystems, (pointer) NULL); - qglobal->ierrno = errno; - qglobal->zfilename = qglobal->qprocess->zv2systems; - return (UUCONF_FOPEN_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_ERROR_FILENAME); - } - - qglobal->ilineno = 0; - iret = UUCONF_SUCCESS; - - zline = NULL; - cline = 0; - while (_uuconf_getline (qglobal, &zline, &cline, e) > 0) - { - char *zname; - - ++qglobal->ilineno; - - /* Skip leading whitespace to get to the system name. Then cut - the system name off at the first whitespace, comment, or - newline. */ - zname = zline + strspn (zline, " \t"); - zname[strcspn (zname, " \t#\n")] = '\0'; - if (*zname == '\0') - continue; - - iret = _uuconf_iadd_string (qglobal, zname, TRUE, TRUE, ppzsystems, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - break; - } - - (void) fclose (e); - if (zline != NULL) - free ((pointer) zline); - - if (iret != UUCONF_SUCCESS) - { - qglobal->zfilename = qglobal->qprocess->zv2systems; - return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; - } - - if (*ppzsystems == NULL) - iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE, - ppzsystems, (pointer) NULL); - - return iret; -} diff --git a/gnu/libexec/uucp/libuuconf/vsys.c b/gnu/libexec/uucp/libuuconf/vsys.c deleted file mode 100644 index c4431a04983a..000000000000 --- a/gnu/libexec/uucp/libuuconf/vsys.c +++ /dev/null @@ -1,49 +0,0 @@ -/* vsys.c - User function to get a system from the V2 configuration files. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP uuconf library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char _uuconf_vsys_rcsid[] = "$FreeBSD$"; -#endif - -/* Get system information from the V2 configuration files. This is a - wrapper for the internal function which makes sure that every field - gets a default value. */ - -int -uuconf_v2_system_info (pglobal, zsystem, qsys) - pointer pglobal; - const char *zsystem; - struct uuconf_system *qsys; -{ - struct sglobal *qglobal = (struct sglobal *) pglobal; - int iret; - - iret = _uuconf_iv2_system_internal (qglobal, zsystem, qsys); - if (iret != UUCONF_SUCCESS) - return iret; - return _uuconf_isystem_basic_default (qglobal, qsys); -} diff --git a/gnu/libexec/uucp/libuucp/Makefile b/gnu/libexec/uucp/libuucp/Makefile deleted file mode 100644 index 4acbd9f3845c..000000000000 --- a/gnu/libexec/uucp/libuucp/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# This is the Makefile for the libuucp subdirectory of Taylor UUCP -# $FreeBSD$ - -LIB= uucp -SRCS= buffer.c crc.c debug.c escape.c getlin.c getopt.c getop1.c \ - parse.c spool.c status.c xfree.c xmall.c xreall.c -CFLAGS+=-I$(.CURDIR)/../common_sources - -NOMAN= noman -NOPROFILE=noprofile - -install: - -.include diff --git a/gnu/libexec/uucp/libuucp/buffer.c b/gnu/libexec/uucp/libuucp/buffer.c deleted file mode 100644 index e33b282aea0f..000000000000 --- a/gnu/libexec/uucp/libuucp/buffer.c +++ /dev/null @@ -1,127 +0,0 @@ -/* buffer.c - Manipulate buffers used to hold strings. - - Copyright (C) 1992, 1993 Ian Lance Taylor - - This file is part of Taylor UUCP. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" - -/* We keep a linked list of buffers. The union is a hack because the - default definition of offsetof, in uucp.h, takes the address of the - field, and some C compilers will not let you take the address of an - array. */ - -struct sbuf -{ - struct sbuf *qnext; - size_t c; - union - { - char ab[4]; - char bdummy; - } - u; -}; - -static struct sbuf *qBlist; - -/* Get a buffer of a given size. The buffer is returned with the - ubuffree function. */ - -char * -zbufalc (c) - size_t c; -{ - register struct sbuf *q; - - if (qBlist == NULL) - { - q = (struct sbuf *) xmalloc (sizeof (struct sbuf) + c - 4); - q->c = c; - } - else - { - q = qBlist; - qBlist = q->qnext; - if (q->c < c) - { - q = (struct sbuf *) xrealloc ((pointer) q, - sizeof (struct sbuf) + c - 4); - q->c = c; - } - } - return q->u.ab; -} - -/* Get a buffer holding a given string. */ - -char * -zbufcpy (z) - const char *z; -{ - size_t csize; - char *zret; - - if (z == NULL) - return NULL; - csize = strlen (z) + 1; - zret = zbufalc (csize); - memcpy (zret, z, csize); - return zret; -} - -/* Free up a buffer back onto the linked list. */ - -void -ubuffree (z) - char *z; -{ - struct sbuf *q; - /* The type of ioff should be size_t, but making it int avoids a bug - in some versions of the HP/UX compiler, and will always work. */ - int ioff; - - if (z == NULL) - return; - ioff = offsetof (struct sbuf, u); - q = (struct sbuf *) (pointer) (z - ioff); - -#ifdef DEBUG_BUFFER - { - struct sbuf *qlook; - - for (qlook = qBlist; qlook != NULL; qlook = qlook->qnext) - { - if (qlook == q) - { - ulog (LOG_ERROR, "ubuffree: Attempt to free buffer twice"); - abort (); - } - } - } -#endif - - q->qnext = qBlist; - qBlist = q; -} diff --git a/gnu/libexec/uucp/libuucp/crc.c b/gnu/libexec/uucp/libuucp/crc.c deleted file mode 100644 index fc9687b57cf8..000000000000 --- a/gnu/libexec/uucp/libuucp/crc.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 1986 Gary S. Brown. You may use this program, or - * code or tables extracted from it, as desired without restriction. - */ - -/* Modified slightly by Ian Lance Taylor, ian@airs.com, for use with - Taylor UUCP. */ - -#include "uucp.h" -#include "prot.h" - -/* First, the polynomial itself and its table of feedback terms. The */ -/* polynomial is */ -/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ -/* Note that we take it "backwards" and put the highest-order term in */ -/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ -/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ -/* the MSB being 1. */ - -/* Note that the usual hardware shift register implementation, which */ -/* is what we're using (we're merely optimizing it by doing eight-bit */ -/* chunks at a time) shifts bits into the lowest-order term. In our */ -/* implementation, that means shifting towards the right. Why do we */ -/* do it this way? Because the calculated CRC must be transmitted in */ -/* order from highest-order term to lowest-order term. UARTs transmit */ -/* characters in order from LSB to MSB. By storing the CRC this way, */ -/* we hand it to the UART in the order low-byte to high-byte; the UART */ -/* sends each low-bit to hight-bit; and the result is transmission bit */ -/* by bit from highest- to lowest-order term without requiring any bit */ -/* shuffling on our part. Reception works similarly. */ - -/* The feedback terms table consists of 256, 32-bit entries. Notes: */ -/* */ -/* The table can be generated at runtime if desired; code to do so */ -/* is shown later. It might not be obvious, but the feedback */ -/* terms simply represent the results of eight shift/xor opera- */ -/* tions for all combinations of data and CRC register values. */ -/* [this code is no longer present--ian] */ -/* */ -/* The values must be right-shifted by eight bits by the "updcrc" */ -/* logic; the shift must be unsigned (bring in zeroes). On some */ -/* hardware you could probably optimize the shift in assembler by */ -/* using byte-swap instructions. */ - -static const unsigned long aicrc32tab[] = { /* CRC polynomial 0xedb88320 */ -0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, -0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, -0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, -0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, -0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, -0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, -0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, -0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, -0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, -0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, -0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, -0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, -0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, -0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, -0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, -0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, -0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, -0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, -0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, -0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, -0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, -0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, -0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, -0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, -0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, -0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, -0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, -0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, -0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, -0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, -0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, -0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL -}; - -/* - * IUPDC32 macro derived from article Copyright (C) 1986 Stephen Satchell. - * NOTE: First argument must be in range 0 to 255. - * Second argument is referenced twice. - * - * Programmers may incorporate any or all code into their programs, - * giving proper credit within the source. Publication of the - * source routines is permitted so long as proper credit is given - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, - * Omen Technology. - */ - -#define IUPDC32(b, ick) \ - (aicrc32tab[((int) (ick) ^ (b)) & 0xff] ^ (((ick) >> 8) & 0x00ffffffL)) - -unsigned long -icrc (z, c, ick) - const char *z; - size_t c; - unsigned long ick; -{ - while (c > 4) - { - ick = IUPDC32 (*z++, ick); - ick = IUPDC32 (*z++, ick); - ick = IUPDC32 (*z++, ick); - ick = IUPDC32 (*z++, ick); - c -= 4; - } - while (c-- != 0) - ick = IUPDC32 (*z++, ick); - return ick; -} diff --git a/gnu/libexec/uucp/libuucp/debug.c b/gnu/libexec/uucp/libuucp/debug.c deleted file mode 100644 index 6ae30632ad02..000000000000 --- a/gnu/libexec/uucp/libuucp/debug.c +++ /dev/null @@ -1,173 +0,0 @@ -/* debug.c - UUCP debugging functions. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include - -#include "uudefs.h" - -#if DEBUG > 1 - -/* The debugging level. */ -int iDebug; - -/* Parse a debugging string. This may be a simple number, which sets - the given number of bits in iDebug, or it may be a series of single - letters. */ - -static const char * const azDebug_names[] = DEBUG_NAMES; - -int -idebug_parse (z) - const char *z; -{ - char *zend; - int i, iret; - char *zcopy, *ztok; - - if (strncasecmp (z, DEBUG_NONE, sizeof DEBUG_NONE - 1) == 0) - return 0; - - i = (int) strtol ((char *) z, &zend, 0); - if (*zend == '\0') - { - if (i > 15) - i = 15; - else if (i < 0) - i = 0; - return (1 << i) - 1; - } - - zcopy = zbufcpy (z); - - iret = 0; - - for (ztok = strtok (zcopy, ", \t"); - ztok != NULL; - ztok = strtok ((char *) NULL, ", \t")) - { - if (strcasecmp (ztok, "all") == 0) - { - iret = DEBUG_MAX; - break; - } - for (i = 0; azDebug_names[i] != NULL; i++) - { - if (strncasecmp (ztok, azDebug_names[i], - strlen (azDebug_names[i])) == 0) - { - iret |= 1 << i; - break; - } - } - if (azDebug_names[i] == NULL) - ulog (LOG_ERROR, "Unrecognized debugging option \"%s\"", - ztok); - } - - ubuffree (zcopy); - - return iret; -} - -#endif /* DEBUG > 1 */ - -/* A debugging routine used when displaying buffers. */ - -size_t -cdebug_char (z, ichar) - char *z; - int ichar; -{ - char b; - - if (isprint (BUCHAR (ichar)) - && ichar != '\"' - && ichar != '\\') - { - *z++ = (char) ichar; - *z = '\0'; - return 1; - } - - *z++ = '\\'; - - switch (ichar) - { - case '\n': - b = 'n'; - break; - case '\r': - b = 'r'; - break; - case '\"': - b = '\"'; - break; - case '\\': - b = '\\'; - break; - default: - sprintf (z, "%03o", (unsigned int) BUCHAR (ichar)); - return strlen (z) + 1; - } - - *z++ = b; - *z = '\0'; - return 2; -} - -#if DEBUG > 1 - -/* Display a buffer when debugging. */ - -void -udebug_buffer (zhdr, zbuf, clen) - const char *zhdr; - const char *zbuf; - size_t clen; -{ - char *z, *zalc; - int i; - - zalc = zbufalc (clen * 4 + 1); - - z = zalc; - for (i = 0; i < clen && i < 80; i++) - z += cdebug_char (z, zbuf[i]); - if (i < clen) - { - *z++ = '.'; - *z++ = '.'; - *z++ = '.'; - } - *z = '\0'; - - ulog (LOG_DEBUG, "%s %lu \"%s\"", zhdr, (unsigned long) clen, zalc); - - ubuffree (zalc); -} - -#endif diff --git a/gnu/libexec/uucp/libuucp/escape.c b/gnu/libexec/uucp/libuucp/escape.c deleted file mode 100644 index 646b787d6e43..000000000000 --- a/gnu/libexec/uucp/libuucp/escape.c +++ /dev/null @@ -1,98 +0,0 @@ -/* escape.c - Translate escape sequences. */ - -#include "uucp.h" - -#include - -#include "uudefs.h" - -size_t -cescape (z) - char *z; -{ - char *zto, *zfrom; - - zto = z; - zfrom = z; - while (*zfrom != '\0') - { - if (*zfrom != '\\') - { - *zto++ = *zfrom++; - continue; - } - ++zfrom; - switch (*zfrom) - { - case '-': - *zto++ = '-'; - break; - case 'b': - *zto++ = '\b'; - break; - case 'n': - *zto++ = '\n'; - break; - case 'N': - *zto++ = '\0'; - break; - case 'r': - *zto++ = '\r'; - break; - case 's': - *zto++ = ' '; - break; - case 't': - *zto++ = '\t'; - break; - case '\0': - --zfrom; - /* Fall through. */ - case '\\': - *zto++ = '\\'; - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - { - int i; - - i = *zfrom - '0'; - if (zfrom[1] >= '0' && zfrom[1] <= '7') - i = 8 * i + *++zfrom - '0'; - if (zfrom[1] >= '0' && zfrom[1] <= '7') - i = 8 * i + *++zfrom - '0'; - *zto++ = (char) i; - } - break; - case 'x': - { - int i; - - i = 0; - while (isxdigit (BUCHAR (zfrom[1]))) - { - if (isdigit (BUCHAR (zfrom[1]))) - i = 16 * i + *++zfrom - '0'; - else if (isupper (BUCHAR (zfrom[1]))) - i = 16 * i + *++zfrom - 'A' + 10; - else - i = 16 * i + *++zfrom - 'a' + 10; - } - *zto++ = (char) i; - } - break; - default: - ulog (LOG_ERROR, "Unrecognized escape sequence \\%c", - *zfrom); - *zto++ = *zfrom; - break; - } - - ++zfrom; - } - - *zto = '\0'; - - return (size_t) (zto - z); -} diff --git a/gnu/libexec/uucp/libuucp/getlin.c b/gnu/libexec/uucp/libuucp/getlin.c deleted file mode 100644 index 822bc1c851c3..000000000000 --- a/gnu/libexec/uucp/libuucp/getlin.c +++ /dev/null @@ -1,81 +0,0 @@ -/* getlin.c - Replacement for getline. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of Taylor UUCP. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -/* Read a line from a file, returning the number of characters read. - This should really return ssize_t. Returns -1 on error. */ - -#define CGETLINE_DEFAULT (63) - -int -getline (pzline, pcline, e) - char **pzline; - size_t *pcline; - FILE *e; -{ - char *zput, *zend; - int bchar; - - if (*pzline == NULL) - { - *pzline = (char *) malloc (CGETLINE_DEFAULT); - if (*pzline == NULL) - return -1; - *pcline = CGETLINE_DEFAULT; - } - - zput = *pzline; - zend = *pzline + *pcline - 1; - - while ((bchar = getc (e)) != EOF) - { - if (zput >= zend) - { - size_t cnew; - char *znew; - - cnew = *pcline * 2 + 1; - znew = (char *) realloc ((pointer) *pzline, cnew); - if (znew == NULL) - return -1; - zput = znew + *pcline - 1; - zend = znew + cnew - 1; - *pzline = znew; - *pcline = cnew; - } - - *zput++ = bchar; - - if (bchar == '\n') - break; - } - - if (zput == *pzline) - return -1; - - *zput = '\0'; - return zput - *pzline; -} diff --git a/gnu/libexec/uucp/libuucp/getop1.c b/gnu/libexec/uucp/libuucp/getop1.c deleted file mode 100644 index c7c738377764..000000000000 --- a/gnu/libexec/uucp/libuucp/getop1.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Getopt for GNU. - Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, June 1992, for - Taylor UUCP. */ - -#include "uucp.h" - -#include "getopt.h" - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - -#ifdef TEST - -#include - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == EOF) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/gnu/libexec/uucp/libuucp/getopt.c b/gnu/libexec/uucp/libuucp/getopt.c deleted file mode 100644 index eed7d8e5b8ac..000000000000 --- a/gnu/libexec/uucp/libuucp/getopt.c +++ /dev/null @@ -1,621 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, June 1992, for - Taylor UUCP. */ - -#include "uucp.h" -#include "uudefs.h" - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#undef GETOPT_COMPAT - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = 0; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -int optind = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -static void -exchange (argv) - char **argv; -{ - size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) malloc (nonopts_size); - - if (temp == NULL) - abort (); - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &argv[first_nonopt + optind - last_nonopt], - nonopts_size); - - xfree (temp); - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns `EOF'. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - optarg = 0; - - /* Initialize the internal data when the first call is made. - Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - if (optind == 0) - { - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - if (nextchar == NULL || *nextchar == '\0') - { - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Now skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - optind++; - last_nonopt = optind; - } - - /* Special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return EOF; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if ((argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - if (ordering == REQUIRE_ORDER) - return EOF; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Start decoding its characters. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound = 0; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, (size_t) (s - nextchar))) - { - if (s - nextchar == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - } - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], BUCHAR (c)); - else - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); - } - return '?'; - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = 0; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == EOF) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/gnu/libexec/uucp/libuucp/parse.c b/gnu/libexec/uucp/libuucp/parse.c deleted file mode 100644 index d955e416f0cd..000000000000 --- a/gnu/libexec/uucp/libuucp/parse.c +++ /dev/null @@ -1,219 +0,0 @@ -/* parse.c - Parse a UUCP command string. - - Copyright (C) 1991, 1992, 1993 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char parse_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" - -/* Parse a UUCP command string into an scmd structure. This is called - by the 'g' protocol and the UNIX command file reading routines. It - destroys the string it is passed, and the scmd string pointers are - left pointing into it. For the convenience of the Unix work file - routines, it will parse "P" into a simple 'P' command (representing - a poll file). It returns TRUE if the string is successfully - parsed, FALSE otherwise. */ - -boolean -fparse_cmd (zcmd, qcmd) - char *zcmd; - struct scmd *qcmd; -{ - char *z, *zend; - - z = strtok (zcmd, " \t\n"); - if (z == NULL) - return FALSE; - - qcmd->bcmd = *z; - if (qcmd->bcmd != 'S' - && qcmd->bcmd != 'R' - && qcmd->bcmd != 'X' - && qcmd->bcmd != 'E' - && qcmd->bcmd != 'H' - && qcmd->bcmd != 'P') - return FALSE; - - qcmd->bgrade = '\0'; - qcmd->pseq = NULL; - qcmd->zfrom = NULL; - qcmd->zto = NULL; - qcmd->zuser = NULL; - qcmd->zoptions = NULL; - qcmd->ztemp = NULL; - qcmd->imode = 0666; - qcmd->znotify = NULL; - qcmd->cbytes = -1; - qcmd->zcmd = NULL; - qcmd->ipos = 0; - - /* Handle hangup commands specially. If it's just "H", return - the command 'H' to indicate a hangup request. If it's "HY" - return 'Y' and if it's "HN" return 'N'. */ - if (qcmd->bcmd == 'H') - { - if (z[1] != '\0') - { - if (z[1] == 'Y') - qcmd->bcmd = 'Y'; - else if (z[1] == 'N') - qcmd->bcmd = 'N'; - else - return FALSE; - } - - return TRUE; - } - if (qcmd->bcmd == 'P') - return TRUE; - - if (z[1] != '\0') - return FALSE; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zfrom = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zto = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zuser = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL || *z != '-') - return FALSE; - qcmd->zoptions = z + 1; - - if (qcmd->bcmd == 'X') - return TRUE; - - if (qcmd->bcmd == 'R') - { - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - { - if (strcmp (z, "dummy") != 0) - { - /* This may be the maximum number of bytes the remote - system wants to receive, if it using Taylor UUCP size - negotiation. */ - qcmd->cbytes = strtol (z, &zend, 0); - if (*zend != '\0') - qcmd->cbytes = -1; - } - else - { - /* This is from an SVR4 system, and may include the - position at which to start sending the file. The - next fields are the mode bits, the remote owner (?), - the remote temporary file name, and finally the - restart position. */ - if (strtok ((char *) NULL, " \t\n") != NULL - && strtok ((char *) NULL, " \t\n") != NULL - && strtok ((char *) NULL, " \t\n") != NULL) - { - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - { - qcmd->ipos = strtol (z, &zend, 0); - if (*zend != '\0') - qcmd->ipos = 0; - } - } - } - } - - return TRUE; - } - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->ztemp = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->imode = (int) strtol (z, &zend, 0); - if (*zend != '\0') - return FALSE; - - /* As a magic special case, if the mode came out as the decimal - values 666 or 777, assume that they actually meant the octal - values. Most systems use a leading zero, but a few do not. - Since both 666 and 777 are greater than the largest legal mode - value, which is 0777 == 511, this hack does not restrict any - legal values. */ - if (qcmd->imode == 666) - qcmd->imode = 0666; - else if (qcmd->imode == 777) - qcmd->imode = 0777; - - z = strtok ((char *) NULL, " \t\n"); - if (qcmd->bcmd == 'E' && z == NULL) - return FALSE; - qcmd->znotify = z; - - /* SVR4 UUCP will send the string "dummy" after the notify string - but before the size. I do not know when it sends anything other - than "dummy". Fortunately, it doesn't really hurt to not get the - file size. */ - if (z != NULL && strcmp (z, "dummy") == 0) - z = strtok ((char *) NULL, " \t\n"); - - if (z != NULL) - { - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - { - qcmd->cbytes = strtol (z, &zend, 0); - if (*zend != '\0') - qcmd->cbytes = -1; - } - else if (qcmd->bcmd == 'E') - return FALSE; - - if (z != NULL) - { - z = strtok ((char *) NULL, ""); - if (z != NULL) - z[strcspn (z, "\n")] = '\0'; - if (qcmd->bcmd == 'E' && z == NULL) - return FALSE; - qcmd->zcmd = z; - } - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/libuucp/spool.c b/gnu/libexec/uucp/libuucp/spool.c deleted file mode 100644 index 52223fb585a6..000000000000 --- a/gnu/libexec/uucp/libuucp/spool.c +++ /dev/null @@ -1,30 +0,0 @@ -/* spool.c - See whether a filename is legal for the spool directory. */ - -#include "uucp.h" - -#include - -#include "uudefs.h" - -/* See whether a file is a spool file. Spool file names are specially - crafted to hand around to other UUCP packages. They always begin - with 'C', 'D' or 'X', and the second character is always a period. - The remaining characters may be any printable characters, since - they may include a grade set by another system. */ - -boolean -fspool_file (zfile) - const char *zfile; -{ - const char *z; - - if (*zfile != 'C' && *zfile != 'D' && *zfile != 'X') - return FALSE; - if (zfile[1] != '.') - return FALSE; - for (z = zfile + 2; *z != '\0'; z++) - if (*z == '/' || ! isprint (BUCHAR (*z)) || isspace (BUCHAR (*z))) - return FALSE; - return TRUE; -} diff --git a/gnu/libexec/uucp/libuucp/status.c b/gnu/libexec/uucp/libuucp/status.c deleted file mode 100644 index 65e854ebdca2..000000000000 --- a/gnu/libexec/uucp/libuucp/status.c +++ /dev/null @@ -1,38 +0,0 @@ -/* status.c - Strings for status codes. */ - -#include "uucp.h" - -#include "uudefs.h" - -/* Status strings. These must match enum tstatus_type. */ - -#if USE_TRADITIONAL_STATUS - -const char *azStatus[] = -{ - "SUCCESSFUL", - "DEVICE FAILED", - "DIAL FAILED", - "LOGIN FAILED", - "STARTUP FAILED", - "CONVERSATION FAILED", - "TALKING", - "WRONG TIME TO CALL" -}; - -#else - -const char *azStatus[] = -{ - "Conversation complete", - "Port unavailable", - "Dial failed", - "Login failed", - "Handshake failed", - "Call failed", - "Talking", - "Wrong time to call" -}; - -#endif diff --git a/gnu/libexec/uucp/libuucp/xfree.c b/gnu/libexec/uucp/libuucp/xfree.c deleted file mode 100644 index 239b015db217..000000000000 --- a/gnu/libexec/uucp/libuucp/xfree.c +++ /dev/null @@ -1,15 +0,0 @@ -/* xfree.c - Some versions of free (like the one in SCO Unix 3.2.2) don't handle - null pointers correctly, so we go through our own routine. */ - -#include "uucp.h" - -#include "uudefs.h" - -void -xfree (p) - pointer p; -{ - if (p != NULL) - free (p); -} diff --git a/gnu/libexec/uucp/libuucp/xmall.c b/gnu/libexec/uucp/libuucp/xmall.c deleted file mode 100644 index 4aac23748c82..000000000000 --- a/gnu/libexec/uucp/libuucp/xmall.c +++ /dev/null @@ -1,18 +0,0 @@ -/* xmalloc.c - Allocate a block of memory without fail. */ - -#include "uucp.h" - -#include "uudefs.h" - -pointer -xmalloc (c) - size_t c; -{ - pointer pret; - - pret = malloc (c); - if (pret == NULL && c != 0) - ulog (LOG_FATAL, "Out of memory"); - return pret; -} diff --git a/gnu/libexec/uucp/libuucp/xreall.c b/gnu/libexec/uucp/libuucp/xreall.c deleted file mode 100644 index 36ae313a5081..000000000000 --- a/gnu/libexec/uucp/libuucp/xreall.c +++ /dev/null @@ -1,23 +0,0 @@ -/* xreall.c - Realloc a block of memory without fail. Supposedly some versions of - realloc can't handle a NULL first argument, so we check for that - here. */ - -#include "uucp.h" - -#include "uudefs.h" - -pointer -xrealloc (p, c) - pointer p; - size_t c; -{ - pointer pret; - - if (p == NULL) - return xmalloc (c); - pret = realloc (p, c); - if (pret == NULL && c != 0) - ulog (LOG_FATAL, "Out of memory"); - return pret; -}