|
|
1.1 root 1: /* uuconf.h
2: Header file for UUCP configuration routines.
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 use of an object file which uses material from this header
23: file, and from no other portion of the uuconf library, is
24: unrestricted, as described in paragraph 4 of section 5 of version 2
25: of the GNU Library General Public License (this sentence is merely
26: informative, and does not modify the License in any way).
27:
28: The author of the program may be contacted at [email protected] or
29: c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
30: */
31:
32: #ifndef UUCONF_H
33:
34: #define UUCONF_H
35:
36: #include <stdio.h>
37:
38: /* The macro UUCONF_ANSI_C may be used to override __STDC__. */
39: #ifndef UUCONF_ANSI_C
40: #ifdef __STDC__
41: #define UUCONF_ANSI_C 1
42: #else /* ! defined (__STDC__) */
43: #define UUCONF_ANSI_C 0
44: #endif /* ! defined (__STDC__) */
45: #endif /* ! defined (UUCONF_ANSI_C) */
46:
47: #if UUCONF_ANSI_C
48: #define UUCONF_CONST const
49: typedef void *UUCONF_POINTER;
50: #include <stddef.h>
51: typedef size_t UUCONF_SIZE_T;
52: #else
53: #define UUCONF_CONST
54: typedef char *UUCONF_POINTER;
55: typedef unsigned int UUCONF_SIZE_T;
56: #endif
57:
58: /* The field names of each of the following structures begin with
59: "uuconf_". This is to avoid any conflicts with user defined
60: macros. The first character following the "uuconf_" string
61: indicates the type of the field.
62:
63: z -- a string (char *)
64: c -- a count (normally int)
65: i -- an integer value (normally int)
66: f -- a boolean value (normally int)
67: b -- a single character value (char or int)
68: t -- an enum (enum XX)
69: s -- a structure (struct XX)
70: u -- a union (union XX)
71: q -- a pointer to a structure (struct XX *)
72: p -- a pointer to something other than a string
73: */
74:
75: /* The information which is kept for a chat script. */
76:
77: struct uuconf_chat
78: {
79: /* The script itself. This is a NULL terminated list of expect/send
80: pairs. The first string is an expect string. A string starting
81: with a '-' indicates subsend string; the following strings which
82: start with '-' are subexpect/subsend strings. This field may be
83: NULL, in which case there is no chat script (but pzprogram may
84: hold a program to run). */
85: char **uuconf_pzchat;
86: /* The chat program to run. This is a NULL terminated list of
87: arguments; element 0 if the program. May be NULL, in which case
88: there is no program. */
89: char **uuconf_pzprogram;
90: /* The timeout in seconds to use for expect strings in the chat
91: script. */
92: int uuconf_ctimeout;
93: /* The NULL terminated list of failure strings. If any of these
94: strings appear, the chat script is aborted. May be NULL, in
95: which case there are no failure strings. */
96: char **uuconf_pzfail;
97: /* Non-zero if incoming characters should be stripped to seven bits
98: (by anding with 0x7f). */
99: int uuconf_fstrip;
100: };
101:
102: /* The information which is kept for a time specification. This is a
103: linked list of structures. Each element of the list represents a
104: span of time, giving a starting time and an ending time. The time
105: only depends on the day of the week, not on the day of the month or
106: of the year. The time is only specified down to the minute, not
107: down to the second or below. The list is sorted by starting time.
108:
109: The starting and ending time are expressed in minutes since the
110: beginning of the week, which is considered to be 12 midnight on
111: Sunday. Thus 60 is 1 am on Sunday, 1440 (== 60 * 24) is 12
112: midnight on Monday, and the largest possible value is 10080 (== 60
113: * 24 * 7) which is 12 midnight on the following Sunday.
114:
115: Each span of time has a value associated with it. This is the
116: lowest grade or the largest file size that may be transferred
117: during that time, depending on the source of the time span. When
118: time specifications overlap, the value used for the overlap is the
119: higher grade or the smaller file size. Thus specifying
120: ``call-timegrade z Any'' and ``call-timegrade Z Mo'' means that
121: only grade Z or higher may be sent on Monday, since Z is the higer
122: grade of the overlapping spans. The final array wil have no
123: overlaps.
124:
125: Each span also has a retry time associated with it. This permits
126: different retry times to be used at different times of day. The
127: retry time is only relevant if the span came from a ``time'' or
128: ``timegrade'' command for a system. */
129:
130: struct uuconf_timespan
131: {
132: /* Next element in list. */
133: struct uuconf_timespan *uuconf_qnext;
134: /* Starting minute (-1 at the end of the array). */
135: int uuconf_istart;
136: /* Ending minute. */
137: int uuconf_iend;
138: /* Value for this span (lowest grade or largest file that may be
139: transferred at this time). */
140: long uuconf_ival;
141: /* Retry time. */
142: int uuconf_cretry;
143: };
144:
145: /* The information which is kept for protocol parameters. Protocol
146: parameter information is stored as an array of the following
147: structures. */
148:
149: struct uuconf_proto_param
150: {
151: /* The name of the protocol to which this entry applies. This is
152: '\0' for the last element of the array. */
153: int uuconf_bproto;
154: /* Specific entries for this protocol. This points to an array
155: ending in an element with a uuconf_cargs field of 0. */
156: struct uuconf_proto_param_entry *uuconf_qentries;
157: };
158:
159: /* Each particular protocol parameter entry is one of the following
160: structures. */
161:
162: struct uuconf_proto_param_entry
163: {
164: /* The number of arguments to the ``protocol-parameter'' command
165: (not counting ``protocol-parameter'' itself). This is 0 for the
166: last element of the array. */
167: int uuconf_cargs;
168: /* The actual arguments to the ``protocol-parameter'' command; this
169: is an array with cargs entries. */
170: char **uuconf_pzargs;
171: };
172:
173: /* The information which is kept for a system. The zname and zalias
174: fields will be the same for all alternates. Every other fields is
175: specific to the particular alternate in which it appears (although
176: most will be the same for all alternates). */
177:
178: struct uuconf_system
179: {
180: /* The name of the system. */
181: char *uuconf_zname;
182: /* A list of aliases for the system. This is a NULL terminated list
183: of strings. May be NULL, in which case there are no aliases. */
184: char **uuconf_pzalias;
185: /* A linked list of alternate call in or call out information. Each
186: alternative way to call this system occupies an element of this
187: list. May be NULL, in which case there are no alternates. */
188: struct uuconf_system *uuconf_qalternate;
189: /* The name for this particular alternate. May be NULL, in which
190: case this alternate does not have a name. */
191: char *uuconf_zalternate;
192: /* If non-zero, this alternate may be used for calling out. */
193: int uuconf_fcall;
194: /* If non-zero, this alternate may be used for accepting a call. */
195: int uuconf_fcalled;
196: /* The times at which this system may be called. The ival field of
197: each uuconf_timespan structure is the lowest grade which may be
198: transferred at that time. The cretry field is the number of
199: minutes to wait before retrying the call, or 0 if it was not
200: specified. May be NULL, in which case the system may never be
201: called. */
202: struct uuconf_timespan *uuconf_qtimegrade;
203: /* The times at which to request a particular grade of the system
204: when calling it, and the grades to request. The ival field of
205: each uuconf_timespan structure is the lowest grade which the
206: other system should transfer at that time. May be NULL, in which
207: case there are no grade restrictions. */
208: struct uuconf_timespan *uuconf_qcalltimegrade;
209: /* The maximum number of times to retry calling this system. If
210: this is 0, there is no limit. */
211: int uuconf_cmax_retries;
212: /* The number of minutes to wait between successful calls to a
213: system. */
214: int uuconf_csuccess_wait;
215: /* The size restrictions by time for local requests during a locally
216: placed call. The ival field of each uuconf_timespan structure is
217: the size in bytes of the largest file which may be transferred at
218: that time. May be NULL, in which case there are no size
219: restrictions. */
220: struct uuconf_timespan *uuconf_qcall_local_size;
221: /* The size restrictions by time for remote requests during a
222: locally placed call. May be NULL. */
223: struct uuconf_timespan *uuconf_qcall_remote_size;
224: /* The size restrictions by time for local requests during a
225: remotely placed call. May be NULL. */
226: struct uuconf_timespan *uuconf_qcalled_local_size;
227: /* The size restrictions by time for remote requests during a
228: remotely placed call. May be NULL. */
229: struct uuconf_timespan *uuconf_qcalled_remote_size;
230: /* Baud rate, or speed. Zero means any baud rate. If ihighbaud is
231: non-zero, this is the low baud rate of a range. */
232: long uuconf_ibaud;
233: /* If non-zero, ibaud is the low baud rate of a range and ihighbaud
234: is the high baud rate. */
235: long uuconf_ihighbaud;
236: /* Port name to use. May be NULL. If an HDB configuration file
237: contains a modem class (alphabetic characters preceeding the baud
238: rate), the class is appended to the port name. */
239: char *uuconf_zport;
240: /* Specific port information, if the system entry includes port
241: information. May be NULL. */
242: struct uuconf_port *uuconf_qport;
243: /* Phone number to call, or address to use for a TCP connection.
244: May be NULL, in which case a dialer script may not use \D or \T
245: for this system, and a TCP port will use the system name. */
246: char *uuconf_zphone;
247: /* Chat script to use when logging in to the system. */
248: struct uuconf_chat uuconf_schat;
249: /* Login name to use for \L in the login chat script. This should
250: normally be accessed via uuconf_callout. If it is "*",
251: uuconf_callout will look it up in the call out file. This may be
252: NULL, in which case the login script may not use \L. */
253: char *uuconf_zcall_login;
254: /* Password to use for \P in the login chat script. This should
255: normally be accessed via uuconf_callout. If it is "*",
256: uuconf_callout will look it up in the call out file. This may be
257: NULL, in which case the login script may not use \P. */
258: char *uuconf_zcall_password;
259: /* The login name this system must use when calling in. This may be
260: different for different alternates. This should only be examined
261: if uuconf_fcalled is TRUE. If this is NULL or "ANY" then
262: uuconf_validate must be called to make sure that whatever login
263: name was used is permitted for this machine. */
264: char *uuconf_zcalled_login;
265: /* If non-zero, then when this system calls in the call should not
266: be allowed to proceed and the system should be called back. */
267: int uuconf_fcallback;
268: /* If non-zero, then conversation sequence numbers should be used
269: with this system. */
270: int uuconf_fsequence;
271: /* A list of protocols to use with this system. Each protocol has a
272: single character name. May be NULL, in which case any known
273: protocol may be used. */
274: char *uuconf_zprotocols;
275: /* Array of protocol parameters. Ends in an entry with a
276: uuconf_bproto field of '\0'. May be NULL. */
277: struct uuconf_proto_param *uuconf_qproto_params;
278: /* Chat script to run when called by this system. */
279: struct uuconf_chat uuconf_scalled_chat;
280: /* Debugging level to set during a conversation. May be NULL. */
281: char *uuconf_zdebug;
282: /* Maximum remote debugging level this system may request. May be
283: NULL. */
284: char *uuconf_zmax_remote_debug;
285: /* Non-zero if the remote system may request us to send files from
286: the local system to the remote. */
287: int uuconf_fsend_request;
288: /* Non-zero if the remote system may request us to receive files
289: from the remote system to the local. */
290: int uuconf_frec_request;
291: /* Non-zero if local requests are permitted when calling this
292: system. */
293: int uuconf_fcall_transfer;
294: /* Non-zero if local requests are permitted when this system calls
295: in. */
296: int uuconf_fcalled_transfer;
297: /* NULL terminated list of directories from which files may be sent
298: by local request. */
299: char **uuconf_pzlocal_send;
300: /* NULL terminated list of directories from which files may be sent
301: by remote request. */
302: char **uuconf_pzremote_send;
303: /* NULL terminated list of directories into which files may be
304: received by local request. */
305: char **uuconf_pzlocal_receive;
306: /* NULL terminated list of directories into which files may be
307: received by remote request. */
308: char **uuconf_pzremote_receive;
309: /* Path to use for command execution. This is a NULL terminated
310: list of directories. */
311: char **uuconf_pzpath;
312: /* NULL terminated List of commands that may be executed. */
313: char **uuconf_pzcmds;
314: /* Amount of free space to leave when accepting a file from this
315: system, in bytes. */
316: long uuconf_cfree_space;
317: /* NULL terminated list of systems that this system may forward
318: from. May be NULL if there are no systems from which files may
319: be forwarded. The list may include "ANY". */
320: char **uuconf_pzforward_from;
321: /* NULL terminated list of systems that this system may forward to.
322: May be NULL if there are no systems to which files may be
323: forwarded. The list may include "ANY". */
324: char **uuconf_pzforward_to;
325: /* The public directory to use for this sytem. */
326: const char *uuconf_zpubdir;
327: /* The local name to use for this remote system. May be NULL if the
328: usual local name should be used. */
329: char *uuconf_zlocalname;
330: /* Memory allocation block for the system. */
331: UUCONF_POINTER uuconf_palloc;
332: };
333:
334: /* Types of ports. */
335:
336: enum uuconf_porttype
337: {
338: /* Unknown port type. A port of this type should never be returned
339: by the uuconf functions. */
340: UUCONF_PORTTYPE_UNKNOWN,
341: /* Read from standard input and write to standard output. Not
342: normally used. */
343: UUCONF_PORTTYPE_STDIN,
344: /* A modem port. */
345: UUCONF_PORTTYPE_MODEM,
346: /* A direct connect port. */
347: UUCONF_PORTTYPE_DIRECT,
348: /* A TCP port. Not supported on all systems. */
349: UUCONF_PORTTYPE_TCP,
350: /* A TLI port. Not supported on all systems. */
351: UUCONF_PORTTYPE_TLI
352: };
353:
354: /* Additional information for a stdin port (there is none). */
355:
356: struct uuconf_stdin_port
357: {
358: int uuconf_idummy;
359: };
360:
361: /* Additional information for a modem port. */
362:
363: struct uuconf_modem_port
364: {
365: /* The device name. May be NULL, in which case the port name is
366: used instead. */
367: char *uuconf_zdevice;
368: /* The device name to send the dialer chat script to. May be NULL,
369: in which case the chat script is sent to the usual device. */
370: char *uuconf_zdial_device;
371: /* The default baud rate (speed). If zero, there is no default. */
372: long uuconf_ibaud;
373: /* The low baud rate, if a range is used. If zero, a range is not
374: used and ihighbaud should be ignored. */
375: long uuconf_ilowbaud;
376: /* The high baud rate, if ilowbaud is non-zero. */
377: long uuconf_ihighbaud;
378: /* Non-zero if the port supports carrier detect. */
379: int uuconf_fcarrier;
380: /* A NULL terminated sequence of dialer/token pairs (element 0 is a
381: dialer name, element 1 is a token, etc.) May be NULL, in which
382: case qdialer should not be NULL. */
383: char **uuconf_pzdialer;
384: /* Specific dialer information. Only used if pzdialer is NULL. */
385: struct uuconf_dialer *uuconf_qdialer;
386: };
387:
388: /* Additional information for a direct connect port. */
389:
390: struct uuconf_direct_port
391: {
392: /* The device name. May be NULL, in which case the port name is
393: used instead. */
394: char *uuconf_zdevice;
395: /* The baud rate (speed). */
396: long uuconf_ibaud;
397: };
398:
399: /* Additional information for a TCP port. */
400:
401: struct uuconf_tcp_port
402: {
403: /* The TCP port number to use. May be a name or a number. May be
404: NULL, in which case "uucp" is looked up using getservbyname. */
405: char *uuconf_zport;
406: };
407:
408: /* Additional information for a TLI port. */
409:
410: struct uuconf_tli_port
411: {
412: /* Device name to open. May be NULL, in which case the port name is
413: used. */
414: char *uuconf_zdevice;
415: /* Whether this port should be turned into a stream, permitting the
416: read and write calls instead of the t_rcv and t_send calls. */
417: int uuconf_fstream;
418: /* A NULL terminated list of modules to push after making the
419: connection. May be NULL, in which case if fstream is non-zero,
420: then "tirdwr" is pushed onto the stream, and otherwise nothing is
421: pushed. */
422: char **uuconf_pzpush;
423: /* A NULL terminated sequence of dialer/token pairs (element 0 is a
424: dialer name, element 1 is a token, etc.) May be NULL. If
425: element 0 is TLI or TLIS, element 1 is used as the address to
426: connect to; otherwise uuconf_zphone from the system information
427: is used. */
428: char **uuconf_pzdialer;
429: /* Address to use when operating as a server. This may contain
430: escape sequences. */
431: char *uuconf_zservaddr;
432: };
433:
434: /* Information kept for a port. */
435:
436: struct uuconf_port
437: {
438: /* The name of the port. */
439: char *uuconf_zname;
440: /* The type of the port. */
441: enum uuconf_porttype uuconf_ttype;
442: /* The list of protocols supported by the port. The name of each
443: protocol is a single character. May be NULL, in which case any
444: protocol is permitted. */
445: char *uuconf_zprotocols;
446: /* Array of protocol parameters. Ends in an entry with a
447: uuconf_bproto field of '\0'. May be NULL. */
448: struct uuconf_proto_param *uuconf_qproto_params;
449: /* The set of reliability bits. */
450: int uuconf_ireliable;
451: /* The lock file name to use. */
452: char *uuconf_zlockname;
453: /* Memory allocation block for the port. */
454: UUCONF_POINTER uuconf_palloc;
455: /* The type specific information. */
456: union
457: {
458: struct uuconf_stdin_port uuconf_sstdin;
459: struct uuconf_modem_port uuconf_smodem;
460: struct uuconf_direct_port uuconf_sdirect;
461: struct uuconf_tcp_port uuconf_stcp;
462: struct uuconf_tli_port uuconf_stli;
463: } uuconf_u;
464: };
465:
466: /* Information kept about a dialer. */
467:
468: struct uuconf_dialer
469: {
470: /* The name of the dialer. */
471: char *uuconf_zname;
472: /* The chat script to use when dialing out. */
473: struct uuconf_chat uuconf_schat;
474: /* The string to send when a `=' appears in the phone number. */
475: char *uuconf_zdialtone;
476: /* The string to send when a `-' appears in the phone number. */
477: char *uuconf_zpause;
478: /* Non-zero if the dialer supports carrier detect. */
479: int uuconf_fcarrier;
480: /* The number of seconds to wait for carrier after the chat script
481: is complete. Only used if fcarrier is non-zero. Only supported
482: on some systems. */
483: int uuconf_ccarrier_wait;
484: /* If non-zero, DTR should be toggled before dialing. Only
485: supported on some systems. */
486: int uuconf_fdtr_toggle;
487: /* If non-zero, sleep for 1 second after toggling DTR. Ignored if
488: fdtr_toggle is zero. */
489: int uuconf_fdtr_toggle_wait;
490: /* The chat script to use when a call is complete. */
491: struct uuconf_chat uuconf_scomplete;
492: /* The chat script to use when a call is aborted. */
493: struct uuconf_chat uuconf_sabort;
494: /* Array of protocol parameters. Ends in an entry with a
495: uuconf_bproto field of '\0'. May be NULL. */
496: struct uuconf_proto_param *uuconf_qproto_params;
497: /* The set of reliability bits. */
498: int uuconf_ireliable;
499: /* Memory allocation block for the dialer. */
500: UUCONF_POINTER uuconf_palloc;
501: };
502:
503: /* Reliability bits for the ireliable field of ports and dialers.
504: These bits are used to decide which protocol to run. A given
505: protocol will have a set of these bits, and each of them must be
506: turned on for the port before we will permit that protocol to be
507: used. This will be overridden by the zprotocols field. */
508:
509: /* Whether a set of reliability bits is given. If this bit is not
510: set, then there is no reliability information. */
511: #define UUCONF_RELIABLE_SPECIFIED (01)
512:
513: /* Set if the connection is eight bit transparent. */
514: #define UUCONF_RELIABLE_EIGHT (02)
515:
516: /* Set if the connection is error-free. */
517: #define UUCONF_RELIABLE_RELIABLE (04)
518:
519: /* Set if the connection is end-to-end reliable (e.g. TCP). */
520: #define UUCONF_RELIABLE_ENDTOEND (010)
521:
522: /* Set if the connection is full-duplex; that is, no time consuming
523: line turnaround is required before sending data in the reverse
524: direction. If the connection is truly half-duplex, in the sense
525: that communication can only flow in one direction, UUCP can not be
526: used. */
527: #define UUCONF_RELIABLE_FULLDUPLEX (020)
528:
529: /* UUCP grades range from 0 to 9, A to Z, a to z in order from highest
530: to lowest (work of higher grades is done before work of lower
531: grades). */
532:
533: /* The highest grade. */
534: #define UUCONF_GRADE_HIGH ('0')
535:
536: /* The lowest grade. */
537: #define UUCONF_GRADE_LOW ('z')
538:
539: /* Whether a character is a legal grade (requires <ctype.h>). */
540: #define UUCONF_GRADE_LEGAL(b) (isalnum ((unsigned) (b)))
541:
542: /* Return < 0 if the first grade should be done before the second
543: grade, == 0 if they are the same, or > 0 if the first grade should
544: be done after the second grade. On an ASCII system, this can just
545: be b1 - b2. */
546: #define UUCONF_GRADE_CMP(b1, b2) (uuconf_grade_cmp ((b1), (b2)))
547:
548: /* Most of the uuconf functions returns an error code. A value of
549: zero (UUCONF_SUCCESS) indicates success. */
550:
551: /* If this bit is set in the returned error code, then the
552: uuconf_errno function may be used to obtain the errno value as set
553: by the function which caused the failure. */
554: #define UUCONF_ERROR_ERRNO (0x100)
555:
556: /* If this bit is set in the returned error code, then the
557: uuconf_filename function may be used to get the name of a file
558: associated with the error. */
559: #define UUCONF_ERROR_FILENAME (0x200)
560:
561: /* If this bit is set in the returned error code, then the
562: uuconf_lineno function may be used to get a line number associated
563: with the error; normally if this is set UUCONF_ERROR_FILENAME will
564: also be set. */
565: #define UUCONF_ERROR_LINENO (0x400)
566:
567: /* There are two UUCONF_CMDTABRET bits that may be set in the return
568: value of uuconf_cmd_line or uuconf_cmd_args, described below. They
569: do not indicate an error, but instead give instructions to the
570: calling function, often uuconf_cmd_file. They may also be set in
571: the return value of a user function listed in a uuconf_cmdtab
572: table, in which case they will be honored by uuconf_cmd_file. */
573:
574: /* This bit means that the memory occupied by the arguments passed to
575: the function should be preserved, and not overwritten or freed. It
576: refers only to the contents of the arguments; the contents of the
577: argv array itself may always be destroyed. If this bit is set in
578: the return value of uuconf_cmd_line or uuconf_cmd_args, it must be
579: honored. It will be honored by uuconf_cmd_file. This may be
580: combined with an error code or with UUCONF_CMDTABRET_EXIT, although
581: neither uuconf_cmd_file or uuconf_cmd_line will do so. */
582: #define UUCONF_CMDTABRET_KEEP (0x800)
583:
584: /* This bit means that uuconf_cmd_file should exit, rather than go on
585: to read and process the next line. If uuconf_cmd_line or
586: uuconf_cmd_args encounter an error, the return value will have this
587: bit set along with the error code. A user function may set this
588: bit with or without an error; the return value of the user function
589: will be returned by uuconf_cmd_file, except that the
590: UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT bits will be
591: cleared. */
592: #define UUCONF_CMDTABRET_EXIT (0x1000)
593:
594: /* This macro may be used to extract the specific error value. */
595: #define UUCONF_ERROR_VALUE(i) ((i) & 0xff)
596:
597: /* UUCONF_ERROR_VALUE will return one of the following values. */
598:
599: /* Function succeeded. */
600: #define UUCONF_SUCCESS (0)
601: /* Named item not found. */
602: #define UUCONF_NOT_FOUND (1)
603: /* A call to fopen failed. */
604: #define UUCONF_FOPEN_FAILED (2)
605: /* A call to fseek failed. */
606: #define UUCONF_FSEEK_FAILED (3)
607: /* A call to malloc or realloc failed. */
608: #define UUCONF_MALLOC_FAILED (4)
609: /* Syntax error in file. */
610: #define UUCONF_SYNTAX_ERROR (5)
611: /* Unknown command. */
612: #define UUCONF_UNKNOWN_COMMAND (6)
613:
614: #if UUCONF_ANSI_C
615:
616: /* For each type of configuration file (Taylor, V2, HDB), there are
617: separate routines to read various sorts of information. There are
618: also generic routines, which call on the appropriate type specific
619: routines. The library can be compiled to read any desired
620: combination of the configuration file types. This affects only the
621: generic routines, as it determines which type specific routines
622: they call. Thus, on a system which, for example, does not have any
623: V2 configuration files, there is no need to include the overhead of
624: the code to parse the files and the time to look for them.
625: However, a program which specifically wants to be able to parse
626: them can call the V2 specific routines.
627:
628: The uuconf functions all take as an argument a pointer to uuconf
629: global information. This must be initialized by any the
630: initialization routines (the generic one and the three file type
631: specific ones) before any of the other uuconf functions may be
632: called. */
633:
634: /* Initialize the configuration file reading routines. The ppglobal
635: argument should point to a generic pointer (a void *, or, on older
636: compilers, a char *) which will be initialized and may then be
637: passed to the other uuconf routines. The zprogram argument is the
638: name of the program for which files should be read. A NULL is
639: taken as "uucp", and reads the standard UUCP configuration files.
640: The only other common argument is "cu", but any string is
641: permitted. The zname argument is the name of the Taylor UUCP
642: config file; if it is NULL, the default config file will be read.
643: If not reading Taylor UUCP configuration information, the argument
644: is ignored. This function must be called before any of the other
645: uuconf functions.
646:
647: Note that if the zname argument is obtained from the user running
648: the program, the program should be careful to revoke any special
649: privileges it may have (e.g. on Unix call setuid (getuid ()) and
650: setgid (getgid ())). Otherwise various sorts of spoofing become
651: possible. */
652: extern int uuconf_init (void **uuconf_ppglobal,
653: const char *uuconf_zprogram,
654: const char *uuconf_zname);
655:
656: /* Adjust the configuration file global pointer for a new thread. The
657: library is fully reentrant (with the exception of the function
658: uuconf_error_string, which calls strerror, which on some systems is
659: not reentrant), provided that each new thread that wishes to call
660: the library calls this function and uses the new global pointer
661: value. The ppglobal argument should be set to the address of the
662: global pointer set by any of the init functions; it will be
663: modified to become a new global pointer. */
664: extern int uuconf_init_thread (void **uuconf_ppglobal);
665:
666: /* Get the names of all known systems. This sets sets *ppzsystems to
667: point to an array of system names. The list of names is NULL
668: terminated. The array is allocated using malloc, as is each
669: element of the array, and they may all be passed to free when they
670: are no longer needed. If the falias argument is 0, the list will
671: not include any aliases; otherwise, it will. */
672: extern int uuconf_system_names (void *uuconf_pglobal,
673: char ***uuconf_ppzsystems,
674: int uuconf_falias);
675:
676: /* Get the information for the system zsystem. This sets the fields
677: in *qsys. This will work whether zsystem is the official name of
678: the system or merely an alias. */
679: extern int uuconf_system_info (void *uuconf_pglobal,
680: const char *uuconf_zsystem,
681: struct uuconf_system *uuconf_qsys);
682:
683: /* Get information for an unknown (anonymous) system. The
684: uuconf_zname field of the returned system information will be NULL.
685: If no information is available for unknown systems, this will
686: return UUCONF_NOT_FOUND. This does not run the HDB remote.unknown
687: shell script. */
688: extern int uuconf_system_unknown (void *uuconf_pglobal,
689: struct uuconf_system *uuconf_qsys);
690:
691: /* Get information for the local system. Normally the local system
692: name should first be looked up using uuconf_system_info. If that
693: returns UUCONF_NOT_FOUND, this function may be used to get an
694: appropriate set of defaults. The uuconf_zname field of the
695: returned system information may be NULL. */
696: extern int uuconf_system_local (void *uuconf_pglobal,
697: struct uuconf_system *uuconf_qsys);
698:
699: /* Free the memory occupied by system information returned by
700: uuconf_system_info, uuconf_system_unknown, uuconf_system_local, or
701: any of the configuration file type specific routines described
702: below. After this is called, the contents of the structure shall
703: not be referred to. */
704: extern int uuconf_system_free (void *uuconf_pglobal,
705: struct uuconf_system *uuconf_qsys);
706:
707: #ifdef __OPTIMIZE__
708: #define uuconf_system_free(qglob, q) \
709: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
710: #endif
711:
712: /* Find a matching port. This will consider each port in turn.
713:
714: If the zname argument is not NULL, the port's uuconf_zname field
715: must match it.
716:
717: If the ibaud argument is not zero and the ihighbaud argument is
718: zero, the port's baud rate, if defined, must be the same (if the
719: port has a range of baud rates, ibaud must be within the range).
720: If ibaud and ihighbaud are both not zero, the port's baud rate, if
721: defined, must be between ibaud and ihighbaud inclusive (if the port
722: has a range of baud rates, the ranges must intersect). If the port
723: has no baud rate, either because it is a type of port for which
724: baud rate is not defined (e.g. a TCP port) or because the
725: uuconf_ibaud field is 0, the ibaud and ihighbaud arguments are
726: ignored.
727:
728: If the pifn argument is not NULL, the port is passed to pifn, along
729: with the pinfo argument (which is otherwise ignored). If pifn
730: returns UUCONF_SUCCESS, the port matches. If pifn returns
731: UUCONF_NOT_FOUND, a new port is sought. Otherwise the return value
732: of pifn is returned from uuconf_find_port. The pifn function may
733: be used to further restrict the port, such as by modem class or
734: device name. It may also be used to lock the port, if appropriate;
735: in this case, if the lock fails, pifn may return UUCONF_NOT_FOUND
736: to force uuconf_find_port to continue searching for a port.
737:
738: If the port matches, the information is set into uuconf_qport, and
739: uuconf_find_port returns UUCONF_SUCCESS. */
740: extern int uuconf_find_port (void *uuconf_pglobal,
741: const char *uuconf_zname,
742: long uuconf_ibaud,
743: long uuconf_ihighbaud,
744: int (*uuconf_pifn) (struct uuconf_port *,
745: void *uuconf_pinfo),
746: void *uuconf_pinfo,
747: struct uuconf_port *uuconf_qport);
748:
749: /* Free the memory occupied by system information returned by
750: uuconf_find_port (or any of the configuration file specific
751: routines described below). After this is called, the contents of
752: the structure shall not be referred to. */
753: extern int uuconf_port_free (void *uuconf_pglobal,
754: struct uuconf_port *uuconf_qport);
755:
756: #ifdef __OPTIMIZE__
757: #define uuconf_port_free(qglob, q) \
758: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
759: #endif
760:
761: /* Get the names of all known dialers. This sets sets *ppzdialers to
762: point to an array of dialer names. The list of names is NULL
763: terminated. The array is allocated using malloc, as is each
764: element of the array, and they may all be passed to free when they
765: are no longer needed. */
766: extern int uuconf_dialer_names (void *uuconf_pglobal,
767: char ***uuconf_ppzdialers);
768:
769: /* Get the information for the dialer zdialer. This sets the fields
770: in *qdialer. */
771: extern int uuconf_dialer_info (void *uuconf_pglobal,
772: const char *uuconf_zdialer,
773: struct uuconf_dialer *uuconf_qdialer);
774:
775: /* Free the memory occupied by system information returned by
776: uuconf_dialer_info (or any of the configuration file specific
777: routines described below). After this is called, the contents of
778: the structure shall not be referred to. */
779: extern int uuconf_dialer_free (void *uuconf_pglobal,
780: struct uuconf_dialer *uuconf_qsys);
781:
782: #ifdef __OPTIMIZE__
783: #define uuconf_dialer_free(qglob, q) \
784: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
785: #endif
786:
787: /* Get the local node name. If the node name is not specified
788: (because no ``nodename'' command appeared in the config file) this
789: will return UUCONF_NOT_FOUND, and some system dependent function
790: must be used to determine the node name. Otherwise it will return
791: a pointer to a constant string, which should not be freed. */
792: extern int uuconf_localname (void *uuconf_pglobal,
793: const char **pzname);
794:
795: /* Get the local node name that should be used, given a login name.
796: This function will check for any special local name that may be
797: associated with the login name zlogin (as set by the ``myname''
798: command in a Taylor configuration file, or the MYNAME field in a
799: Permissions entry). This will set *pzname to the node name. If no
800: node name can be determined, *pzname will be set to NULL and the
801: function will return UUCONF_NOT_FOUND; in this case some system
802: dependent function must be used to determine the node name. If the
803: function returns UUCONF_SUCCESS, *pzname will be point to an
804: malloced buffer. */
805: extern int uuconf_login_localname (void *uuconf_pglobal,
806: const char *uuconf_zlogin,
807: char **pzname);
808:
809: /* Get the name of the UUCP spool directory. This will set *pzspool
810: to a constant string, which should not be freed. */
811: extern int uuconf_spooldir (void *uuconf_pglobal,
812: const char **uuconf_pzspool);
813:
814: /* Get the name of the default UUCP public directory. This will set
815: *pzpub to a constant string, which should not be freed. Note that
816: particular systems may use a different public directory. */
817: extern int uuconf_pubdir (void *uuconf_pglobal,
818: const char **uuconf_pzpub);
819:
820: /* Get the name of the UUCP lock directory. This will set *pzlock to
821: a constant string, which should not be freed. */
822: extern int uuconf_lockdir (void *uuconf_pglobal,
823: const char **uuconf_pzlock);
824:
825: /* Get the name of the UUCP log file. This will set *pzlog to a
826: constant string, which should not be freed. */
827: extern int uuconf_logfile (void *uuconf_pglobal,
828: const char **uuconf_pzlog);
829:
830: /* Get the name of the UUCP statistics file. This will set *pzstats
831: to a constant string, which should not be freed. */
832: extern int uuconf_statsfile (void *uuconf_pglobal,
833: const char **uuconf_pzstats);
834:
835: /* Get the name of the UUCP debugging file. This will set *pzdebug to
836: a constant string, which should not be freed. */
837: extern int uuconf_debugfile (void *uuconf_pglobal,
838: const char **uuconf_pzdebug);
839:
840: /* Get the default debugging level to use. This basically gets the
841: argument of the ``debug'' command from the Taylor UUCP config file.
842: It will set *pzdebug to a constant string, which should not be
843: freed. */
844: extern int uuconf_debuglevel (void *uuconf_pglobal,
845: const char **uuconf_pzdebug);
846:
847: /* Get the maximum number of simultaneous uuxqt executions. This will
848: set *pcmaxuuxqt to the number. Zero indicates no maximum. */
849: extern int uuconf_maxuuxqts (void *uuconf_pglobal,
850: int *uuconf_pcmaxuuxqt);
851:
852: /* Check a login name and password. This checks the Taylor UUCP
853: password file (not /etc/passwd). It will work even if
854: uuconf_taylor_init was not called. If the login name exists and
855: the password is correct, this returns UUCONF_SUCCESS. If the login
856: does not exist, or the password is wrong, this returns
857: UUCONF_NOT_FOUND. Other errors are also possible. */
858: extern int uuconf_callin (void *uuconf_pglobal,
859: const char *uuconf_zlogin,
860: const char *uuconf_zpassword);
861:
862: /* Get the callout login name and password for a system. This will
863: set both *pzlog and *pzpass to a string allocated by malloc, or to
864: NULL if the value is not found. If neither value is found, the
865: function will return UUCONF_NOT_FOUND. */
866: extern int uuconf_callout (void *uuconf_pglobal,
867: const struct uuconf_system *uuconf_qsys,
868: char **uuconf_pzlog,
869: char **uuconf_pzpass);
870:
871: /* See if a login name is permitted for a system. This will return
872: UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
873: invalid. This simply calls uuconf_taylor_validate or returns
874: UUCONF_SUCCESS, depending on the value of HAVE_TAYLOR_CONFIG. */
875: extern int uuconf_validate (void *uuconf_pglobal,
876: const struct uuconf_system *uuconf_qsys,
877: const char *uuconf_zlogin);
878:
879: /* Get the name of the HDB remote.unknown shell script, if using
880: HAVE_HDB_CONFIG. This does not actually run the shell script. If
881: the function returns UUCONF_SUCCESS, the name will be in *pzname,
882: which will point to an malloced buffer. If it returns
883: UUCONF_NOT_FOUND, then there is no script to run. */
884: extern int uuconf_remote_unknown (void *uuconf_pglobal,
885: char **pzname);
886:
887: /* Translate a dial code. This sets *pznum to an malloced string.
888: This will look up the entire zdial string in the dialcode file, so
889: for normal use the alphabetic prefix should be separated. */
890: extern int uuconf_dialcode (void *uuconf_pglobal,
891: const char *uuconf_zdial,
892: char **uuconf_pznum);
893:
894: /* Compare two grades, returning < 0 if b1 should be executed before
895: b2, == 0 if they are the same, or > 0 if b1 should be executed
896: after b2. This can not fail, and does not return a standard uuconf
897: error code; it is normally called via the macro UUCONF_GRADE_CMP,
898: defined above. */
899: extern int uuconf_grade_cmp (int uuconf_b1, int uuconf_b2);
900:
901: #else /* ! UUCONF_ANSI_C */
902:
903: extern int uuconf_init ();
904: extern int uuconf_init_thread ();
905: extern int uuconf_system_names ();
906: extern int uuconf_system_info ();
907: extern int uuconf_system_unknown ();
908: extern int uuconf_system_local ();
909: extern int uuconf_system_free ();
910: extern int uuconf_find_port ();
911: extern int uuconf_port_free ();
912: extern int uuconf_dialer_names ();
913: extern int uuconf_dialer_info ();
914: extern int uuconf_dialer_free ();
915: extern int uuconf_localname ();
916: extern int uuconf_login_localname ();
917: extern int uuconf_spooldir ();
918: extern int uuconf_lockdir ();
919: extern int uuconf_pubdir ();
920: extern int uuconf_logfile ();
921: extern int uuconf_statsfile ();
922: extern int uuconf_debugfile ();
923: extern int uuconf_debuglevel ();
924: extern int uuconf_maxuuxqts ();
925: extern int uuconf_callin ();
926: extern int uuconf_callout ();
927: extern int uuconf_remote_unknown ();
928: extern int uuconf_validate ();
929: extern int uuconf_grade_cmp ();
930:
931: #ifdef __OPTIMIZE__
932: #define uuconf_system_free(qglob, q) \
933: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
934: #define uuconf_port_free(qglob, q) \
935: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
936: #define uuconf_dialer_free(qglob, q) \
937: (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
938: #endif
939:
940: #endif /* ! UUCONF_ANSI_C */
941:
942: #if UUCONF_ANSI_C
943:
944: /* Initialize the Taylor UUCP configuration file reading routines.
945: This must be called before calling any of the Taylor UUCP
946: configuration file specific routines. The ppglobal argument should
947: point to a generic pointer. Moreover, before calling this function
948: the pointer either must be set to NULL, or must have been passed to
949: one of the other uuconf init routines. The zprogram argument is
950: the name of the program for which files should be read. If NULL,
951: it is taken as "uucp", which means to read the standard UUCP files.
952: The zname argument is the name of the config file. If it is NULL,
953: the default config file will be used.
954:
955: Note that if the zname argument is obtained from the user running
956: the program, the program should be careful to revoke any special
957: privileges it may have (e.g. on Unix call setuid (getuid ()) and
958: setgid (getgid ())). Otherwise various sorts of spoofing become
959: possible. */
960: extern int uuconf_taylor_init (void **uuconf_pglobal,
961: const char *uuconf_zprogram,
962: const char *uuconf_zname);
963:
964: /* Get the names of all systems listed in the Taylor UUCP
965: configuration files. This sets *ppzsystems to point to an array of
966: system names. The list of names is NULL terminated. The array is
967: allocated using malloc, as is each element of the array. If the
968: falias argument is 0, the list will not include any aliases;
969: otherwise, it will. */
970: extern int uuconf_taylor_system_names (void *uuconf_pglobal,
971: char ***uuconf_ppzsystems,
972: int uuconf_falias);
973:
974: /* Get the information for system zsystem from the Taylor UUCP
975: configuration files. This will set *qsys. */
976: extern int uuconf_taylor_system_info (void *uuconf_pglobal,
977: const char *uuconf_zsystem,
978: struct uuconf_system *uuconf_qsys);
979:
980: /* Get information for an unknown (anonymous) system. This returns
981: the values set by the ``unknown'' command in the main configuration
982: file. If the ``unknown'' command was not used, this will return
983: UUCONF_NOT_FOUND. */
984: extern int uuconf_taylor_system_unknown (void *uuconf_pglobal,
985: struct uuconf_system *uuconf_qsys);
986:
987: /* Find a port from the Taylor UUCP configuration files. The
988: arguments and return values are identical to those of
989: uuconf_find_port. */
990: extern int uuconf_taylor_find_port (void *uuconf_pglobal,
991: const char *uuconf_zname,
992: long uuconf_ibaud,
993: long uuconf_ihighbaud,
994: int (*uuconf_pifn) (struct uuconf_port *,
995: void *uuconf_pinfo),
996: void *uuconf_pinfo,
997: struct uuconf_port *uuconf_qport);
998:
999: /* Get the names of all dialers listed in the Taylor UUCP
1000: configuration files. This sets *ppzdialers to point to an array of
1001: dialer names. The list of names is NULL terminated. The array is
1002: allocated using malloc, as is each element of the array. */
1003: extern int uuconf_taylor_dialer_names (void *uuconf_pglobal,
1004: char ***uuconf_ppzdialers);
1005:
1006: /* Get the information for the dialer zdialer from the Taylor UUCP
1007: configuration files. This sets the fields in *qdialer. */
1008: extern int uuconf_taylor_dialer_info (void *uuconf_pglobal,
1009: const char *uuconf_zdialer,
1010: struct uuconf_dialer *uuconf_qdialer);
1011:
1012: /* Get the local node name that should be used, given a login name,
1013: considering only the ``myname'' command in the Taylor UUCP
1014: configuration files. If the function returns UUCONF_SUCCESS,
1015: *pzname will point to an malloced buffer. */
1016: extern int uuconf_taylor_login_localname (void *uuconf_pglobal,
1017: const char *uuconf_zlogin,
1018: char **pzname);
1019:
1020: /* Get the callout login name and password for a system from the
1021: Taylor UUCP configuration files. This will set both *pzlog and
1022: *pzpass to a string allocated by malloc, or to NULL if the value is
1023: not found. If neither value is found, the function will return
1024: UUCONF_NOT_FOUND. */
1025: extern int uuconf_taylor_callout (void *uuconf_pglobal,
1026: const struct uuconf_system *uuconf_qsys,
1027: char **uuconf_pzlog,
1028: char **uuconf_pzpass);
1029:
1030: /* See if a login name is permitted for a system. This will return
1031: UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
1032: invalid. This checks whether the login name appears in a
1033: called-login command with a list of system which does not include
1034: the system qsys. */
1035: extern int uuconf_taylor_validate (void *uuconf_pglobal,
1036: const struct uuconf_system *uuconf_qsys,
1037: const char *uuconf_zlogin);
1038:
1039: #else /* ! UUCONF_ANSI_C */
1040:
1041: extern int uuconf_taylor_init ();
1042: extern int uuconf_taylor_system_names ();
1043: extern int uuconf_taylor_system_info ();
1044: extern int uuconf_taylor_system_unknown ();
1045: extern int uuconf_taylor_find_port ();
1046: extern int uuconf_taylor_dialer_names ();
1047: extern int uuconf_taylor_dialer_info ();
1048: extern int uuconf_taylor_login_localname ();
1049: extern int uuconf_taylor_callout ();
1050: extern int uuconf_taylor_validate ();
1051:
1052: #endif /* ! UUCONF_ANSI_C */
1053:
1054: #if UUCONF_ANSI_C
1055:
1056: /* Initialize the V2 configuration file reading routines. This must
1057: be called before any of the other V2 routines are called. The
1058: ppglobal argument should point to a generic pointer. Moreover,
1059: before calling this function the pointer either must be set to
1060: NULL, or must have been passed to one of the other uuconf init
1061: routines. */
1062: extern int uuconf_v2_init (void **uuconf_ppglobal);
1063:
1064: /* Get the names of all systems listed in the V2 configuration files.
1065: This sets *ppzsystems to point to an array of system names. The
1066: list of names is NULL terminated. The array is allocated using
1067: malloc, as is each element of the array. If the falias argument is
1068: 0, the list will not include any aliases; otherwise, it will. */
1069: extern int uuconf_v2_system_names (void *uuconf_pglobal,
1070: char ***uuconf_ppzsystems,
1071: int uuconf_falias);
1072:
1073: /* Get the information for system zsystem from the V2 configuration
1074: files. This will set *qsys. */
1075: extern int uuconf_v2_system_info (void *uuconf_pglobal,
1076: const char *uuconf_zsystem,
1077: struct uuconf_system *uuconf_qsys);
1078:
1079: /* Find a port from the V2 configuration files. The arguments and
1080: return values are identical to those of uuconf_find_port. */
1081: extern int uuconf_v2_find_port (void *uuconf_pglobal,
1082: const char *uuconf_zname,
1083: long uuconf_ibaud,
1084: long uuconf_ihighbaud,
1085: int (*uuconf_pifn) (struct uuconf_port *,
1086: void *uuconf_pinfo),
1087: void *uuconf_pinfo,
1088: struct uuconf_port *uuconf_qport);
1089:
1090: #else /* ! UUCONF_ANSI_C */
1091:
1092: extern int uuconf_v2_init ();
1093: extern int uuconf_v2_system_names ();
1094: extern int uuconf_v2_system_info ();
1095: extern int uuconf_v2_find_port ();
1096:
1097: #endif /* ! UUCONF_ANSI_C */
1098:
1099: #if UUCONF_ANSI_C
1100:
1101: /* Initialize the HDB configuration file reading routines. This
1102: should be called before any of the other HDB routines are called.
1103: The ppglobal argument should point to a generic pointer. Moreover,
1104: before calling this function the pointer either must be set to
1105: NULL, or must have been passed to one of the other uuconf init
1106: routines. The zprogram argument is used to match against a
1107: "services" string in Sysfiles. A NULL or "uucp" argument is taken
1108: as "uucico". */
1109: extern int uuconf_hdb_init (void **uuconf_ppglobal,
1110: const char *uuconf_zprogram);
1111:
1112: /* Get the names of all systems listed in the HDB configuration files.
1113: This sets *ppzsystems to point to an array of system names. The
1114: list of names is NULL terminated. The array is allocated using
1115: malloc, as is each element of the array. If the falias argument is
1116: 0, the list will not include any aliases; otherwise, it will (an
1117: alias is created by using the ALIAS= keyword in the Permissions
1118: file). */
1119: extern int uuconf_hdb_system_names (void *uuconf_pglobal,
1120: char ***uuconf_ppzsystems,
1121: int uuconf_falias);
1122:
1123: /* Get the information for system zsystem from the HDB configuration
1124: files. This will set *qsys. */
1125: extern int uuconf_hdb_system_info (void *uuconf_pglobal,
1126: const char *uuconf_zsystem,
1127: struct uuconf_system *uuconf_qsys);
1128:
1129:
1130: /* Get information for an unknown (anonymous) system. If no
1131: information is available for unknown systems, this will return
1132: UUCONF_NOT_FOUND. This does not run the remote.unknown shell
1133: script. */
1134: extern int uuconf_hdb_system_unknown (void *uuconf_pglobal,
1135: struct uuconf_system *uuconf_qsys);
1136:
1137: /* Find a port from the HDB configuration files. The arguments and
1138: return values are identical to those of uuconf_find_port. */
1139: extern int uuconf_hdb_find_port (void *uuconf_pglobal,
1140: const char *uuconf_zname,
1141: long uuconf_ibaud,
1142: long uuconf_ihighbaud,
1143: int (*uuconf_pifn) (struct uuconf_port *,
1144: void *uuconf_pinfo),
1145: void *uuconf_pinfo,
1146: struct uuconf_port *uuconf_qport);
1147:
1148: /* Get the names of all dialers listed in the HDB configuration files.
1149: This sets *ppzdialers to point to an array of dialer names. The
1150: list of names is NULL terminated. The array is allocated using
1151: malloc, as is each element of the array. */
1152: extern int uuconf_hdb_dialer_names (void *uuconf_pglobal,
1153: char ***uuconf_ppzdialers);
1154:
1155: /* Get the information for the dialer zdialer from the HDB
1156: configuration files. This sets the fields in *qdialer. */
1157: extern int uuconf_hdb_dialer_info (void *uuconf_pglobal,
1158: const char *uuconf_zdialer,
1159: struct uuconf_dialer *uuconf_qdialer);
1160:
1161: /* Get the local node name that should be used, given a login name,
1162: considering only the MYNAME field in the HDB Permissions file. If
1163: the function returns UUCONF_SUCCESS, *pzname will point to an
1164: malloced buffer. */
1165: extern int uuconf_hdb_login_localname (void *uuconf_pglobal,
1166: const char *uuconf_zlogin,
1167: char **pzname);
1168:
1169: /* Get the name of the HDB remote.unknown shell script. This does not
1170: actually run the shell script. If the function returns
1171: UUCONF_SUCCESS, the name will be in *pzname, which will point to an
1172: malloced buffer. */
1173: extern int uuconf_hdb_remote_unknown (void *uuconf_pglobal,
1174: char **pzname);
1175:
1176: #else /* ! UUCONF_ANSI_C */
1177:
1178: extern int uuconf_hdb_init ();
1179: extern int uuconf_hdb_system_names ();
1180: extern int uuconf_hdb_system_info ();
1181: extern int uuconf_hdb_system_unknown ();
1182: extern int uuconf_hdb_find_port ();
1183: extern int uuconf_hdb_dialer_names ();
1184: extern int uuconf_hdb_dialer_info ();
1185: extern int uuconf_hdb_localname ();
1186: extern int uuconf_hdb_remote_unknown ();
1187:
1188: #endif /* ! UUCONF_ANSI_C */
1189:
1190: #if UUCONF_ANSI_C
1191:
1192: /* This function will set an appropriate error message into the buffer
1193: zbuf, given a uuconf error code. The buffer will always be null
1194: terminated, and will never be accessed beyond the length cbuf.
1195: This function will return the number of characters needed for the
1196: complete message, including the null byte. If this is less than
1197: the cbytes argument, the buffer holds a truncated string. */
1198: extern int uuconf_error_string (void *uuconf_pglobal, int ierror,
1199: char *zbuf, UUCONF_SIZE_T cbuf);
1200:
1201: /* If UUCONF_ERROR_ERRNO is set in a return value, this function may
1202: be used to retrieve the errno value. This will be the value of
1203: errno as set by the system function which failed. However, some
1204: system functions, notably some stdio routines, may not set errno,
1205: in which case the value will be meaningless. This function does
1206: not return a uuconf error code, and it cannot fail. */
1207: extern int uuconf_error_errno (void *uuconf_pglobal);
1208:
1209: /* If UUCONF_ERROR_FILENAME is set in a return value, this function
1210: may be used to retrieve the file name. This function does not
1211: return a uuconf error code, and it cannot fail. The string that it
1212: returns a pointer to is not guaranteed to remain allocated across
1213: the next call to a uuconf function (other than one of the three
1214: error retrieving functions). */
1215: extern const char *uuconf_error_filename (void *uuconf_pglobal);
1216:
1217: /* If UUCONF_ERROR_LINENO is set in a return value, this function may
1218: be used to retrieve the line number. This function does not return
1219: a uuconf error code, and it cannot fail. */
1220: extern int uuconf_error_lineno (void *uuconf_pglobal);
1221:
1222: #else /* ! UUCONF_ANSI_C */
1223:
1224: extern int uuconf_error_string ();
1225: extern int uuconf_error_errno ();
1226: extern UUCONF_CONST char *uuconf_error_filename ();
1227: extern int uuconf_error_lineno ();
1228:
1229: #endif /* ! UUCONF_ANSI_C */
1230:
1231: /* The uuconf package also provides a few functions which can accept
1232: commands and parcel them out according to a table. These are
1233: publically visible, partially in the hopes that they will be
1234: useful, but mostly because the rest of the Taylor UUCP package uses
1235: them. */
1236:
1237: /* The types of entries allowed in a command table (struct
1238: uuconf_cmdtab). Each type defines how a particular command is
1239: interpreted. Each type will either assign a value to a variable or
1240: call a function. In all cases, a line of input is parsed into
1241: separate fields, separated by whitespace; comments beginning with
1242: '#' are discarded, except that a '#' preceeded by a backslash is
1243: retained. The first field is taken as the command to execute, and
1244: the remaining fields are its arguments. */
1245:
1246: /* A boolean value. Used for a command which accepts a single
1247: argument, which must begin with 'y', 'Y', 't', or 'T' for true (1)
1248: or 'n', 'N', 'f', or 'F' for false (0). The corresponding variable
1249: must be an int. */
1250: #define UUCONF_CMDTABTYPE_BOOLEAN (0x12)
1251:
1252: /* An integer value. Used for a command which accepts a single
1253: argument, which must be an integer. The corresponding variable
1254: must be an int. */
1255: #define UUCONF_CMDTABTYPE_INT (0x22)
1256:
1257: /* A long value. Used for a command which accepts a single value,
1258: which must be an integer. The corresponding variable must be a
1259: long. */
1260: #define UUCONF_CMDTABTYPE_LONG (0x32)
1261:
1262: /* A string value. Used for a command which accepts a string
1263: argument. If there is no argument, the variable will be set to
1264: point to a zero byte. Otherwise the variable will be set to point
1265: to the string. The corresponding variable must be a char *. The
1266: memory pointed to by the variable after it is set must not be
1267: modified. */
1268: #define UUCONF_CMDTABTYPE_STRING (0x40)
1269:
1270: /* A full string value. Used for a command which accepts a series of
1271: string arguments separated by whitespace. The corresponding
1272: variable must be a char **. It will be set to an NULL terminated
1273: array of the arguments. The memory occupied by the array itself,
1274: and by the strings within it, must not be modified. */
1275: #define UUCONF_CMDTABTYPE_FULLSTRING (0x50)
1276:
1277: /* A function. If this command is encountered, the command and its
1278: arguments are passed to the corresponding function. They are
1279: passed as an array of strings, in which the first string is the
1280: command itself, along with a count of strings. This value may be
1281: or'red with a specific number of required arguments;
1282: UUCONF_CMDTABTYPE_FN | 1 accepts no additional arguments besides
1283: the command itself, UUCONF_CMDTABTYPE_FN | 2 accepts 1 argument,
1284: etc. UUCONF_CMDTABTYPE_FN | 0, accepts any number of additional
1285: arguments. */
1286: #define UUCONF_CMDTABTYPE_FN (0x60)
1287:
1288: /* A prefix function. The string in the table is a prefix; if a
1289: command is encountered with the same prefix, the corresponding
1290: function will be called as for UUCONF_CMDTABTYPE_FN. The number of
1291: arguments may be or'red in as with UUCONF_CMDTABTYPE_FN. */
1292: #define UUCONF_CMDTABTYPE_PREFIX (0x70)
1293:
1294: /* This macro will return the particular type of a CMDTABTYPE. */
1295: #define UUCONF_TTYPE_CMDTABTYPE(i) ((i) & 0x70)
1296:
1297: /* This macro will return the required number of arguments of a
1298: CMDTABTYPE. If it is zero, there is no restriction. */
1299: #define UUCONF_CARGS_CMDTABTYPE(i) ((i) & 0x0f)
1300:
1301: /* When a function is called via UUCONF_CMDTABTYPE_FN or
1302: UUCONF_CMDTABTYPE_PREFIX, it may return any uuconf error code (see
1303: above). However, it will normally return one of the following:
1304:
1305: UUCONF_CMDTABRET_CONTINUE: Take no special action. In particular,
1306: the arguments passed to the function may be overwritten or freed.
1307:
1308: UUCONF_CMDTABRET_KEEP: The memory occupied by the arguments passed
1309: to the function must be preserved. Continue processing commands.
1310:
1311: UUCONF_CMDTABRET_EXIT: If reading commands from a file, stop
1312: processing. The arguments passed to the function may be
1313: overwritten or freed.
1314:
1315: UUCONF_CMDTABRET_KEEP_AND_EXIT: Stop processing any file. The
1316: memory occupied by the arguments passed to the function must be
1317: preserved.
1318:
1319: These values are interpreted by uuconf_cmd_file. The
1320: uuconf_cmd_line and uuconf_cmd_args functions may return
1321: UUCONF_CMDTABRET_KEEP. It they get an error, they will return an
1322: error code with UUCONF_CMDTABRET_EXIT set. Also, of course, they
1323: may return any value that is returned by one of the user functions
1324: in the uuconf_cmdtab table. */
1325:
1326: /* UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT are defined above,
1327: with the error codes. */
1328:
1329: #define UUCONF_CMDTABRET_CONTINUE UUCONF_SUCCESS
1330: #define UUCONF_CMDTABRET_KEEP_AND_EXIT \
1331: (UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT)
1332:
1333: /* When a function is called via CMDTABTYPE_FN or CMDTABTYPE_PREFIX,
1334: it is passed five arguments. This is the type of a pointer to such
1335: a function. The uuconf global information structure is passed in
1336: for convenience in calling another uuconf function. The arguments
1337: to the command are passed in (the command itself is the first
1338: argument) along with a count and the value of the pvar field from
1339: the uuconf_cmdtab structure in which the function pointer was
1340: found. The pinfo argument to the function is taken from the
1341: argument to uuconf_cmd_*. */
1342:
1343: #if UUCONF_ANSI_C
1344: typedef int (*uuconf_cmdtabfn) (void *uuconf_pglobal,
1345: int uuconf_argc,
1346: char **uuconf_argv,
1347: void *uuconf_pvar,
1348: void *uuconf_pinfo);
1349: #else
1350: typedef int (*uuconf_cmdtabfn) ();
1351: #endif
1352:
1353: /* A table of commands is an array of the following structures. The
1354: final element of the table should have uuconf_zcmd == NULL. */
1355:
1356: struct uuconf_cmdtab
1357: {
1358: /* Command name. */
1359: UUCONF_CONST char *uuconf_zcmd;
1360: /* Command type (one of CMDTABTYPE_*). */
1361: int uuconf_itype;
1362: /* If not CMDTABTYPE_FN or CMDTABTYPE_PREFIX, the address of the
1363: associated variable. Otherwise, a pointer value to pass to the
1364: function pifn. */
1365: UUCONF_POINTER uuconf_pvar;
1366: /* The function to call if CMDTABTYPE_FN or CMDTABTYPE_PREFIX. */
1367: uuconf_cmdtabfn uuconf_pifn;
1368: };
1369:
1370: /* Bit flags to pass to uuconf_processcmds. */
1371:
1372: /* If set, case is significant when checking commands. Normally case
1373: is ignored. */
1374: #define UUCONF_CMDTABFLAG_CASE (0x1)
1375:
1376: /* If set, a backslash at the end of a line may be used to include the
1377: next physical line in the logical line. */
1378: #define UUCONF_CMDTABFLAG_BACKSLASH (0x2)
1379:
1380: #if UUCONF_ANSI_C
1381:
1382: /* Read commands from a file, look them up in a table, and take the
1383: appropriate action. This continues reading lines from the file
1384: until EOF, or until a function returns with UUCONF_CMDTABRET_EXIT
1385: set, or until an error occurs. The qtab argument must point to a
1386: table of struct uuconf_cmdtab; the last element in the table should
1387: have uuconf_zcmd == NULL. When a UUCONF_CMDTABTYPE_FN or
1388: UUCONF_CMDTABTYPE_PREFIX command is found, the pinfo argument will
1389: be passed to the called function. If an a command is found that is
1390: not in the table, then if pfiunknownfn is NULL the unknown command
1391: is ignored; otherwise it is passed to pfiunknownfn, which should
1392: return a uuconf return code which is handled as for any other
1393: function (the pvar argument to pfiunknownfn will always be NULL).
1394: The iflags argument is any combination of the above
1395: UUCONF_CMDTABFLAG bits. The pblock argument may also be a memory
1396: block, as returned by uuconf_malloc_block (described below), in
1397: which case all memory preserved because of UUCONF_CMDTABRET_KEEP
1398: will be added to the block so that it may be freed later; it may
1399: also be NULL, in which case any such memory is permanently lost.
1400:
1401: This function initially sets the internal line number to 0, and
1402: then increments it as each line is read. It is permitted for any
1403: called function to use the uuconf_lineno function to obtain it. If
1404: this function is called when not at the start of a file, the value
1405: returned by uuconf_lineno (which is, in any case, only valid if an
1406: error code with UUCONF_ERROR_LINENO set is returned) must be
1407: adjusted by the caller.
1408:
1409: This returns a normal uuconf return value, as described above. */
1410: extern int uuconf_cmd_file (void *uuconf_pglobal,
1411: FILE *uuconf_e,
1412: const struct uuconf_cmdtab *uuconf_qtab,
1413: void *uuconf_pinfo,
1414: uuconf_cmdtabfn uuconf_pfiunknownfn,
1415: int uuconf_iflags,
1416: void *pblock);
1417:
1418: /* This utility function is just like uuconf_cmd_file, except that it
1419: only operates on a single string. If a function is called via
1420: qtab, its return value will be the return value of this function.
1421: UUCONF_CMDTABFLAG_BACKSLASH is ignored in iflags. The string z is
1422: modified in place. The return value may include the
1423: UUCONF_CMDTABRET_KEEP and, on error, the UUCONF_CMDTABRET_EXIT
1424: bits, which should be honored by the calling code. */
1425: extern int uuconf_cmd_line (void *uuconf_pglobal,
1426: char *uuconf_z,
1427: const struct uuconf_cmdtab *uuconf_qtab,
1428: void *uuconf_pinfo,
1429: uuconf_cmdtabfn uuconf_pfiunknownfn,
1430: int uuconf_iflags,
1431: void *pblock);
1432:
1433: /* This utility function is just like uuconf_cmd_line, except it is
1434: given a list of already parsed arguments. */
1435: extern int uuconf_cmd_args (void *uuconf_pglobal,
1436: int uuconf_cargs,
1437: char **uuconf_pzargs,
1438: const struct uuconf_cmdtab *uuconf_qtab,
1439: void *uuconf_pinfo,
1440: uuconf_cmdtabfn uuconf_pfiunknownfn,
1441: int uuconf_iflags,
1442: void *pblock);
1443:
1444: #else /* ! UUCONF_ANSI_C */
1445:
1446: extern int uuconf_cmd_file ();
1447: extern int uuconf_cmd_line ();
1448: extern int uuconf_cmd_args ();
1449:
1450: #endif /* ! UUCONF_ANSI_C */
1451:
1452: #if UUCONF_ANSI_C
1453:
1454: /* The uuconf_cmd_file function may allocate memory permanently, as
1455: for setting a UUCONF_CMDTABTYPE_STRING value, in ways which are
1456: difficult to free up. A memory block may be used to record all
1457: allocated memory, so that it can all be freed up at once at some
1458: later time. These functions do not take a uuconf global pointer,
1459: and are independent of the rest of the uuconf library. */
1460:
1461: /* Allocate a block of memory. If this returns NULL, then malloc
1462: returned NULL, and errno is whatever malloc set it to. */
1463: extern void *uuconf_malloc_block (void);
1464:
1465: /* Allocate memory within a memory block. If this returns NULL, then
1466: malloc returned NULL, and errno is whatever malloc set it to. */
1467: extern void *uuconf_malloc (void *uuconf_pblock,
1468: UUCONF_SIZE_T uuconf_cbytes);
1469:
1470: /* Add a block returned by the generic malloc routine to a memory
1471: block. This returns zero on success, non-zero on failure. If this
1472: fails (returns non-zero), then malloc returned NULL, and errno is
1473: whatever malloc set it to. */
1474: extern int uuconf_add_block (void *uuconf_pblock, void *uuconf_padd);
1475:
1476: /* Free a value returned by uuconf_malloc from a memory block. In the
1477: current implementation, this will normally not do anything, but it
1478: doesn't hurt. No errors can occur. */
1479: extern void uuconf_free (void *uuconf_pblock, void *uuconf_pfree);
1480:
1481: /* Free an entire memory block, including all values returned by
1482: uuconf_malloc from it and all values added to it with
1483: uuconf_add_block. No errors can occur. */
1484: extern void uuconf_free_block (void *uuconf_pblock);
1485:
1486: #else /* ! UUCONF_ANSI_C */
1487:
1488: extern UUCONF_POINTER uuconf_malloc_block ();
1489: extern UUCONF_POINTER uuconf_malloc ();
1490: extern int uuconf_add_block ();
1491: extern /* void */ uuconf_free ();
1492: extern /* void */ uuconf_free_block ();
1493:
1494: #endif /* ! UUCONF_ANSI_C */
1495:
1496: #endif /* ! defined (UUCONF_H) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.