]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - gnu/libexec/uucp/libuuconf/tdnams.c
This commit was generated by cvs2svn to compensate for changes in r54820,
[FreeBSD/FreeBSD.git] / gnu / libexec / uucp / libuuconf / tdnams.c
1 /* tdnams.c
2    Get all known dialer names from the Taylor UUCP configuration files.
3
4    Copyright (C) 1992 Ian Lance Taylor
5
6    This file is part of the Taylor UUCP uuconf library.
7
8    This library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Library General Public License
10    as published by the Free Software Foundation; either version 2 of
11    the License, or (at your option) any later version.
12
13    This library is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Library General Public License for more details.
17
18    You should have received a copy of the GNU Library General Public
19    License along with this library; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
22    The author of the program may be contacted at ian@airs.com or
23    c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
24    */
25
26 #include "uucnfi.h"
27
28 #if USE_RCS_ID
29 const char _uuconf_tdnams_rcsid[] = "$FreeBSD$";
30 #endif
31
32 #include <errno.h>
33 \f
34 static int indialer P((pointer pglobal, int argc, char **argv, pointer pvar,
35                        pointer pinfo));
36 \f
37 /* Get the names of all the dialers from the Taylor UUCP configuration
38    files.  */
39
40 int
41 uuconf_taylor_dialer_names (pglobal, ppzdialers)
42      pointer pglobal;
43      char ***ppzdialers;
44 {
45   struct sglobal *qglobal = (struct sglobal *) pglobal;
46   struct uuconf_cmdtab as[2];
47   char **pz;
48   int iret;
49   
50   *ppzdialers = NULL;
51
52   as[0].uuconf_zcmd = "dialer";
53   as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2;
54   as[0].uuconf_pvar = (pointer) ppzdialers;
55   as[0].uuconf_pifn = indialer;
56
57   as[1].uuconf_zcmd = NULL;
58
59   iret = UUCONF_SUCCESS;
60
61   for (pz = qglobal->qprocess->pzdialfiles; *pz != NULL; pz++)
62     {
63       FILE *e;
64
65       e = fopen (*pz, "r");
66       if (e == NULL)
67         {
68           if (FNO_SUCH_FILE ())
69             continue;
70           qglobal->ierrno = errno;
71           iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
72           break;
73         }
74
75       iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL,
76                               (uuconf_cmdtabfn) NULL,
77                               UUCONF_CMDTABFLAG_BACKSLASH,
78                               (pointer) NULL);
79
80       (void) fclose (e);
81
82       if (iret != UUCONF_SUCCESS)
83         break;
84     }
85
86   if (iret != UUCONF_SUCCESS)
87     {
88       qglobal->zfilename = *pz;
89       return iret | UUCONF_ERROR_FILENAME;
90     }
91
92   if (*ppzdialers == NULL)
93     iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
94                                 ppzdialers, (pointer) NULL);
95
96   return UUCONF_SUCCESS;
97 }
98
99 /* Add a dialer name to the list.  */
100
101 /*ARGSUSED*/
102 static int
103 indialer (pglobal, argc, argv, pvar, pinfo)
104      pointer pglobal;
105      int argc;
106      char **argv;
107      pointer pvar;
108      pointer pinfo;
109 {
110   struct sglobal *qglobal = (struct sglobal *) pglobal;
111   char ***ppzdialers = (char ***) pvar;
112   int iret;
113
114   iret = _uuconf_iadd_string (qglobal, argv[1], TRUE, TRUE, ppzdialers,
115                               (pointer) NULL);
116   if (iret != UUCONF_SUCCESS)
117     iret |= UUCONF_CMDTABRET_EXIT;
118   return iret;
119 }