diff options
Diffstat (limited to 'gnu/libexec/uucp/libuuconf')
95 files changed, 14309 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libuuconf/COPYING.LIB b/gnu/libexec/uucp/libuuconf/COPYING.LIB new file mode 100644 index 00000000000..eb685a5ec98 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/COPYING.LIB @@ -0,0 +1,481 @@ + 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. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/gnu/libexec/uucp/libuuconf/MANIFEST b/gnu/libexec/uucp/libuuconf/MANIFEST new file mode 100644 index 00000000000..d4ca25ead06 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/MANIFEST @@ -0,0 +1,94 @@ +README +COPYING.LIB +MANIFEST +Makefile.in +alloc.h +syshdr.unx +uucnfi.h +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 +pubdir.c +prtsub.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 diff --git a/gnu/libexec/uucp/libuuconf/Makefile b/gnu/libexec/uucp/libuuconf/Makefile new file mode 100644 index 00000000000..e13801faf80 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/Makefile @@ -0,0 +1,28 @@ +# This is the Makefile for the Taylor UUCP uuconf library +# $Id: Makefile,v 1.1 1995/10/18 08:38:32 deraadt Exp $ + +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 sinfo.c \ + snams.c split.c spool.c stafil.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 runuxq.c \ + strip.c +CFLAGS+= -I$(.CURDIR)/../common_sources \ + -DNEWCONFIGLIB=\"$(newconfigdir)\"\ + -DOLDCONFIGLIB=\"$(oldconfigdir)\" + +NOMAN= noman +NOPROFILE= noprofile +NOPIC= nopic + +install: + +.include <bsd.lib.mk> diff --git a/gnu/libexec/uucp/libuuconf/README b/gnu/libexec/uucp/libuuconf/README new file mode 100644 index 00000000000..cc022ad54fb --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/README @@ -0,0 +1,113 @@ +This is the README file for the beta release of the uuconf library. + +It was written by Ian Lance Taylor. I can be reached at ian@airs.com, +or, equivalently, uunet!cygint!airs!ian, or c/o Cygnus Support, +48 Grove Street, Somerville, MA, 02144, USA. + +This package is covered by the Gnu Library General Public License. +See the file COPYING.LIB for details. If you would like to do +something with this package that you feel is reasonable but you feel +is prohibited by the license, contact me to see if we can work it out. + +WHAT IT IS + +This is a beta release of the uuconf library. The uuconf library +provides a set of functions which can be used to read UUCP +configuration files. V2, HDB, and Taylor UUCP configuration files are +supported. + +Also included are two programs, uuchk and uuconv. uuchk will read +configuration files and display the information it finds in a verbose +format. This can be helpful to ensure that your configuration files +are set up as you expect. uuconv can be used to convert configuration +files from one type to another. This is particularly helpful for +people installing Taylor UUCP on a existing system who want to take +advantage of the additional functionality provided by the Taylor UUCP +configuration files. + +This is strictly a beta release. The library provides all the +information needed for uuchk and uuconv, but does not yet provide +everything needed for uucp or cu. I am releasing it now to get +feedback and to provide the uuconv program to people using Taylor +UUCP. + +This may well be the only time this library is release independently. +This library will be provided with Taylor UUCP, and future releases of +the library will probably only occur as part of the complete Taylor +UUCP package. + +HOW TO USE IT + +Configure and optionally install the package as described in INSTALL. + +The functions provided by the library are described in uuconf.h. At +the moment there is no additional documentation. + +Programs which use the library should include uuconf.h, and should not +include any of the other header files. The functions listed in +uuconf.h all begin with the string "uuconf_". The internal library +functions all begin with the string "_uuconf_". The internal library +functions should not be called by a program which uses the library, as +they may change in future releases. The uuchk program is an example +of program which uses the library; uuconv is not, as it relies upon +internal data structures. + +The uuchk program takes a single optional option, -I, which may be +used to specify an alternate Taylor UUCP main configuration file. The +default configuration file is $(newconfigdir)/config ($(newconfigdir) +is defined in Makefile). For example: + uuchk + uuchk -I /usr/tmp/tstuu/Config1 + +The uuconv program requires two options: -i to specify the input type +and -o to specify the output type. Both options take a string +argument, which must be one of "v2", "hdb", or "taylor". uuconv also +takes an optional -I option, which is the same as the -I option to +uuchk. The conversion is not intended to be perfect, and the results +should be manually inspected. In particular, the dialcode file is not +converted (as the format is the same for all three configuration file +types, it may simply be copied to the appropriate new name). uuconv +will create new files in the current working directory. For example: + uuconv -i hdb -o taylor + uuconv -i taylor -I /usr/tmp/tstuu/Config1 -o v2 + +NOTES + +The initial underscore on the internal library functions is required +by the GNU standards. As ANSI C reserves external identifiers with an +initial underscore for the implementation, it is possible, though +unlikely, that this will cause problems on other implementations; no +workaround is currently provided for such problems. + +The library functions rely upon the following functions: + + fclose fopen free fseek + ftell getc isalpha isdigit + islower isspace isupper malloc + realloc rewind strchr strcmp + strcspn strlen strncmp strspn + tolower toupper + +and the following header files: + + ctype.h errno.h stdio.h + +If the following functions cannot be found by the configure script, +replacements will be used (the replacement for strerror is Unix +dependent): + + getline memcpy strcasecmp strdup + strerror strncasecmp strtol + +If the following header files are found, they will be included: + + libc.h limits.h memory.h stddef.h + stdlib.h string.h strings.h sys/types.h + +The following functions are required on Unix only: + + fcntl fileno + +The following headers are used, if found, on Unix only: + + fcntl.h sys/file.h diff --git a/gnu/libexec/uucp/libuuconf/addblk.c b/gnu/libexec/uucp/libuuconf/addblk.c new file mode 100644 index 00000000000..81a7926627e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/addblk.c @@ -0,0 +1,56 @@ +/* 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[] = "$Id: addblk.c,v 1.1 1995/10/18 08:38:32 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..c9b459b81a3 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/addstr.c @@ -0,0 +1,139 @@ +/* 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[] = "$Id: addstr.c,v 1.1 1995/10/18 08:38:32 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..319d07d35b0 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/allblk.c @@ -0,0 +1,51 @@ +/* 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[] = "$Id: allblk.c,v 1.1 1995/10/18 08:38:32 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..857cbfff9b7 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/alloc.c @@ -0,0 +1,82 @@ +/* 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[] = "$Id: alloc.c,v 1.1 1995/10/18 08:38:32 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d35e0fb3ea0 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/alloc.h @@ -0,0 +1,71 @@ +/* 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 new file mode 100644 index 00000000000..b5624a0fc6c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/base.c @@ -0,0 +1,54 @@ +/* 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[] = "$Id: base.c,v 1.1 1995/10/18 08:38:32 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..dfbc9ac66d1 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/bool.c @@ -0,0 +1,64 @@ +/* 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[] = "$Id: bool.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..34403ca3be6 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/callin.c @@ -0,0 +1,195 @@ +/* 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[] = "$Id: callin.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..d09ee78ca9c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/calout.c @@ -0,0 +1,93 @@ +/* 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[] = "$Id: calout.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..7cf37c676f6 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/chatc.c @@ -0,0 +1,202 @@ +/* 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[] = "$Id: chatc.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <ctype.h> +#include <errno.h> + +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 new file mode 100644 index 00000000000..7520be6ef9c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/cmdarg.c @@ -0,0 +1,185 @@ +/* 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[] = "$Id: cmdarg.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <ctype.h> + +#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 new file mode 100644 index 00000000000..a28ef8a5163 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/cmdfil.c @@ -0,0 +1,106 @@ +/* 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[] = "$Id: cmdfil.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..265b941688d --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/cmdlin.c @@ -0,0 +1,145 @@ +/* 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[] = "$Id: cmdlin.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..1dac95b5dc5 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/debfil.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: debfil.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..56b1f428a85 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/deblev.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: deblev.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d7bc8cea565 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/diacod.c @@ -0,0 +1,129 @@ +/* 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[] = "$Id: diacod.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..8e5b229ff4e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/dial.c @@ -0,0 +1,61 @@ +/* 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[] = "$Id: dial.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..a537369fe9f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/diasub.c @@ -0,0 +1,63 @@ +/* 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[] = "$Id: diasub.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..2bcac2aa150 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/dnams.c @@ -0,0 +1,103 @@ +/* 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[] = "$Id: dnams.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d6b4a9d31e7 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/errno.c @@ -0,0 +1,46 @@ +/* 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[] = "$Id: errno.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..6404357e9e9 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/errstr.c @@ -0,0 +1,241 @@ +/* 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[] = "$Id: errstr.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..0b66c583946 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/filnam.c @@ -0,0 +1,44 @@ +/* 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[] = "$Id: filnam.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d520636d04c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/freblk.c @@ -0,0 +1,63 @@ +/* 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[] = "$Id: freblk.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..2af7a9dddc4 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/fredia.c @@ -0,0 +1,44 @@ +/* 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[] = "$Id: fredia.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..9a440f46da5 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/free.c @@ -0,0 +1,68 @@ +/* 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[] = "$Id: free.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..a81478d613d --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/freprt.c @@ -0,0 +1,44 @@ +/* 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[] = "$Id: freprt.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..7f6ac8df651 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/fresys.c @@ -0,0 +1,44 @@ +/* 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[] = "$Id: fresys.c,v 1.1 1995/10/18 08:38:33 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..ed328166cb3 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/grdcmp.c @@ -0,0 +1,76 @@ +/* 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[] = "$Id: grdcmp.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..7c70c4d3850 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hdial.c @@ -0,0 +1,187 @@ +/* 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[] = "$Id: hdial.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..c7657d7756e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hdnams.c @@ -0,0 +1,109 @@ +/* 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[] = "$Id: hdnams.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..a2230fc1353 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hinit.c @@ -0,0 +1,295 @@ +/* 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[] = "$Id: hinit.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..40a31b97fd7 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hlocnm.c @@ -0,0 +1,84 @@ +/* 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[] = "$Id: hlocnm.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..b7019a93830 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hport.c @@ -0,0 +1,360 @@ +/* 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[] = "$Id: hport.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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]; + 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 new file mode 100644 index 00000000000..3ffc080bd01 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hrmunk.c @@ -0,0 +1,55 @@ +/* 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[] = "$Id: hrmunk.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..27b4689132f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hsinfo.c @@ -0,0 +1,637 @@ +/* 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[] = "$Id: hsinfo.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +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 new file mode 100644 index 00000000000..f3a552ca512 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hsnams.c @@ -0,0 +1,142 @@ +/* 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[] = "$Id: hsnams.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..a542f4461da --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hsys.c @@ -0,0 +1,49 @@ +/* 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[] = "$Id: hsys.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..951c0eb317f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/hunk.c @@ -0,0 +1,142 @@ +/* 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[] = "$Id: hunk.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..0cef15f1f12 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/iniglb.c @@ -0,0 +1,180 @@ +/* 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[] = "$Id: iniglb.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..ffe6f334a58 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/init.c @@ -0,0 +1,74 @@ +/* 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[] = "$Id: init.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..30652b0ebcc --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/int.c @@ -0,0 +1,59 @@ +/* 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[] = "$Id: int.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d5173e6e1c8 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/lckdir.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: lckdir.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..d35a1edd624 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/lineno.c @@ -0,0 +1,44 @@ +/* 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[] = "$Id: lineno.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..4844253797f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/llocnm.c @@ -0,0 +1,73 @@ +/* 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[] = "$Id: llocnm.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..61399940ca0 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/local.c @@ -0,0 +1,70 @@ +/* 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[] = "$Id: local.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..c8692051f9e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/locnm.c @@ -0,0 +1,46 @@ +/* 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[] = "$Id: locnm.c,v 1.1 1995/10/18 08:38:34 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..b8fc56a95da --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/logfil.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: logfil.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..2f10a60a8e4 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/maxuxq.c @@ -0,0 +1,86 @@ +/* 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[] = "$Id: maxuxq.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..9aeb64fd7da --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/mrgblk.c @@ -0,0 +1,50 @@ +/* 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[] = "$Id: mrgblk.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..5336e264236 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/paramc.c @@ -0,0 +1,175 @@ +/* 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[] = "$Id: paramc.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..66bb054ee10 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/port.c @@ -0,0 +1,77 @@ +/* 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[] = "$Id: port.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..99680a74179 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/prtsub.c @@ -0,0 +1,54 @@ +/* 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[] = "$Id: prtsub.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..f71d5bae0ce --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/pubdir.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: pubdir.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..531477537fd --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/rdlocs.c @@ -0,0 +1,305 @@ +/* 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[] = "$Id: rdlocs.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..9ac6c97837b --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/rdperm.c @@ -0,0 +1,452 @@ +/* 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[] = "$Id: rdperm.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +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 new file mode 100644 index 00000000000..08bd4297fae --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/reliab.c @@ -0,0 +1,123 @@ +/* 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[] = "$Id: reliab.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..043d4f87edf --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/remunk.c @@ -0,0 +1,54 @@ +/* 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[] = "$Id: remunk.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..503b45d74e9 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/runuxq.c @@ -0,0 +1,77 @@ +/* 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[] = "$Id: runuxq.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..47620994183 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/sinfo.c @@ -0,0 +1,112 @@ +/* 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[] = "$Id: sinfo.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..977fdbc744f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/snams.c @@ -0,0 +1,133 @@ +/* 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[] = "$Id: snams.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..ab8d609e97e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/split.c @@ -0,0 +1,106 @@ +/* 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[] = "$Id: split.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#endif + +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..aca50585b04 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/spool.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: spool.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..fc3995a3bcf --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/stafil.c @@ -0,0 +1,43 @@ +/* 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[] = "$Id: stafil.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..97e354137b0 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/strip.c @@ -0,0 +1,50 @@ +/* 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[] = "$Id: strip.c,v 1.1 1995/10/18 08:38:35 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..b5a759fd1a6 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/syshdr.h @@ -0,0 +1,140 @@ +/* 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author of the program may be contacted at ian@airs.com or + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. + */ + +/* 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 <fcntl.h> +#else +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#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/syshdr.unx b/gnu/libexec/uucp/libuuconf/syshdr.unx new file mode 100644 index 00000000000..12d4aa427c5 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/syshdr.unx @@ -0,0 +1,140 @@ +/* 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 <fcntl.h> +#else +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#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 new file mode 100644 index 00000000000..531d86aa3bb --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/syssub.c @@ -0,0 +1,524 @@ +/* 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[] = "$Id: syssub.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..315042c0297 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tcalou.c @@ -0,0 +1,207 @@ +/* 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[] = "$Id: tcalou.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..2ed34880790 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tdial.c @@ -0,0 +1,227 @@ +/* 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[] = "$Id: tdial.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..3b4b35d534c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tdialc.c @@ -0,0 +1,211 @@ +/* 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[] = "$Id: tdialc.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..aa395a22286 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tdnams.c @@ -0,0 +1,119 @@ +/* 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[] = "$Id: tdnams.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..acaf901c567 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tgcmp.c @@ -0,0 +1,42 @@ +/* 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[] = "$Id: tgcmp.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..32978af4e50 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/thread.c @@ -0,0 +1,70 @@ +/* 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[] = "$Id: thread.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..c7cf25618ee --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/time.c @@ -0,0 +1,407 @@ +/* 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[] = "$Id: time.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <ctype.h> +#include <errno.h> + +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 new file mode 100644 index 00000000000..dcdc68f78ec --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tinit.c @@ -0,0 +1,465 @@ +/* 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[] = "$Id: tinit.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..a422b47c7ec --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tlocnm.c @@ -0,0 +1,112 @@ +/* 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[] = "$Id: tlocnm.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..ec73b771731 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tport.c @@ -0,0 +1,299 @@ +/* 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[] = "$Id: tport.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..84caaf92b0a --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tportc.c @@ -0,0 +1,505 @@ +/* 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[] = "$Id: tportc.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> + +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 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 }, + { "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_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; + } +} + +/* 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 new file mode 100644 index 00000000000..101b55f5679 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tsinfo.c @@ -0,0 +1,954 @@ +/* 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[] = "$Id: tsinfo.c,v 1.1 1995/10/18 08:38:36 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +#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 new file mode 100644 index 00000000000..e7dad50fd73 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tsnams.c @@ -0,0 +1,84 @@ +/* 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[] = "$Id: tsnams.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..5d050f7ae3d --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tsys.c @@ -0,0 +1,49 @@ +/* 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[] = "$Id: tsys.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..6f3cc9ba572 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/tval.c @@ -0,0 +1,71 @@ +/* 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[] = "$Id: tval.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..31ece28ede7 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/ugtlin.c @@ -0,0 +1,110 @@ +/* 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[] = "$Id: ugtlin.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..93daad975c6 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/unk.c @@ -0,0 +1,70 @@ +/* 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[] = "$Id: unk.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..1f42391f7d8 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/uucnfi.h @@ -0,0 +1,380 @@ +/* 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 new file mode 100644 index 00000000000..e66759f6c9a --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/val.c @@ -0,0 +1,46 @@ +/* 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[] = "$Id: val.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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 new file mode 100644 index 00000000000..1b1eda622f2 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/vinit.c @@ -0,0 +1,112 @@ +/* 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[] = "$Id: vinit.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#endif + +#include <errno.h> + +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 new file mode 100644 index 00000000000..899ecad0f9e --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/vport.c @@ -0,0 +1,254 @@ +/* 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[] = "$Id: vport.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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 new file mode 100644 index 00000000000..2028a1f2414 --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/vsinfo.c @@ -0,0 +1,610 @@ +/* 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[] = "$Id: vsinfo.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#endif + +#include <errno.h> +#include <ctype.h> + +/* 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]; + 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 new file mode 100644 index 00000000000..71b90e0845c --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/vsnams.c @@ -0,0 +1,106 @@ +/* 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[] = "$Id: vsnams.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#endif + +#include <errno.h> + +/* 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 new file mode 100644 index 00000000000..334e98f1aae --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/vsys.c @@ -0,0 +1,49 @@ +/* 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[] = "$Id: vsys.c,v 1.1 1995/10/18 08:38:37 deraadt Exp $"; +#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); +} |