|
|
1.1 root 1: /* hsnams.c
2: Get all known system names from the HDB 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21:
22: The author of the program may be contacted at [email protected] or
23: c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
24: */
25:
26: #include "uucnfi.h"
27:
28: #if USE_RCS_ID
29: const char _uuconf_hsnams_rcsid[] = "$Id: hsnams.c,v 1.1 93/07/30 08:07:19 bin Exp Locker: bin $";
30: #endif
31:
32: #include <errno.h>
33: #include <ctype.h>
34:
35: /* Get all the system names from the HDB Systems file. We have to
36: read the Permissions file in order to support aliases. */
37:
38: int
39: uuconf_hdb_system_names (pglobal, ppzsystems, falias)
40: pointer pglobal;
41: char ***ppzsystems;
42: int falias;
43: {
44: struct sglobal *qglobal = (struct sglobal *) pglobal;
45: int iret;
46: char *zline;
47: size_t cline;
48: char **pz;
49:
50: *ppzsystems = NULL;
51:
52: iret = UUCONF_SUCCESS;
53:
54: zline = NULL;
55: cline = 0;
56:
57: for (pz = qglobal->qprocess->pzhdb_systems; *pz != NULL; pz++)
58: {
59: FILE *e;
60:
61: e = fopen (*pz, "r");
62: if (e == NULL)
63: {
64: if (FNO_SUCH_FILE ())
65: continue;
66: qglobal->ierrno = errno;
67: iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;
68: break;
69: }
70:
71: qglobal->ilineno = 0;
72:
73: while (_uuconf_getline (qglobal, &zline, &cline, e) > 0)
74: {
75: ++qglobal->ilineno;
76:
77: /* Lines beginning with whitespace are treated as comments.
78: No system name can contain a '#', which is another
79: comment character, so eliminating the first '#' does no
80: harm and catches comments. */
81: zline[strcspn (zline, " \t#\n")] = '\0';
82: if (*zline == '\0')
83: continue;
84:
85: iret = _uuconf_iadd_string (qglobal, zline, TRUE, TRUE,
86: ppzsystems, (pointer) NULL);
87: if (iret != UUCONF_SUCCESS)
88: {
89: iret |= UUCONF_ERROR_LINENO;
90: break;
91: }
92: }
93:
94: (void) fclose (e);
95: }
96:
97: if (zline != NULL)
98: free ((pointer) zline);
99:
100: if (iret != UUCONF_SUCCESS)
101: {
102: qglobal->zfilename = *pz;
103: return iret | UUCONF_ERROR_FILENAME;
104: }
105:
106: /* If we are supposed to return aliases, we must read the
107: Permissions file. */
108: if (falias)
109: {
110: struct shpermissions *q;
111:
112: if (! qglobal->qprocess->fhdb_read_permissions)
113: {
114: iret = _uuconf_ihread_permissions (qglobal);
115: if (iret != UUCONF_SUCCESS)
116: return iret;
117: }
118:
119: for (q = qglobal->qprocess->qhdb_permissions;
120: q != NULL;
121: q = q->qnext)
122: {
123: pz = q->pzalias;
124: if (pz == NULL || pz == (char **) &_uuconf_unset)
125: continue;
126:
127: for (; *pz != NULL; pz++)
128: {
129: iret = _uuconf_iadd_string (qglobal, *pz, TRUE, TRUE,
130: ppzsystems, (pointer) NULL);
131: if (iret != UUCONF_SUCCESS)
132: return iret;
133: }
134: }
135: }
136:
137: if (*ppzsystems == NULL)
138: iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
139: ppzsystems, (pointer) NULL);
140:
141: return iret;
142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.