2 Header file for UUCP configuration routines.
4 Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor
6 This file is part of the Taylor UUCP uuconf library.
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.
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.
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.
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).
28 The author of the program may be contacted at ian@airs.com or
29 c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
38 /* The macro UUCONF_ANSI_C may be used to override __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) */
48 #define UUCONF_CONST const
49 typedef void *UUCONF_POINTER;
51 typedef size_t UUCONF_SIZE_T;
54 typedef char *UUCONF_POINTER;
55 typedef unsigned int UUCONF_SIZE_T;
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.
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
75 /* The information which is kept for a chat script. */
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). */
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
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. */
97 /* Non-zero if incoming characters should be stripped to seven bits
98 (by anding with 0x7f). */
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.
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.
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
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. */
130 struct uuconf_timespan
132 /* Next element in list. */
133 struct uuconf_timespan *uuconf_qnext;
134 /* Starting minute (-1 at the end of the array). */
138 /* Value for this span (lowest grade or largest file that may be
139 transferred at this time). */
145 /* The information which is kept for protocol parameters. Protocol
146 parameter information is stored as an array of the following
149 struct uuconf_proto_param
151 /* The name of the protocol to which this entry applies. This is
152 '\0' for the last element of the array. */
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;
159 /* Each particular protocol parameter entry is one of the following
162 struct uuconf_proto_param_entry
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. */
168 /* The actual arguments to the ``protocol-parameter'' command; this
169 is an array with cargs entries. */
170 char **uuconf_pzargs;
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). */
180 /* The name of the system. */
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. */
194 /* If non-zero, this alternate may be used for accepting a call. */
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
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 times at which to allow a particular grade of work to be
210 transferred to the system, when it calls in. The ival field of
211 each uuconf_timespan structure is the lowest grade which should
212 be transferred at that time. May be NULL, in which case there
213 are no grade restrictions. */
214 struct uuconf_timespan *uuconf_qcalledtimegrade;
215 /* The maximum number of times to retry calling this system. If
216 this is 0, there is no limit. */
217 int uuconf_cmax_retries;
218 /* The number of minutes to wait between successful calls to a
220 int uuconf_csuccess_wait;
221 /* The size restrictions by time for local requests during a locally
222 placed call. The ival field of each uuconf_timespan structure is
223 the size in bytes of the largest file which may be transferred at
224 that time. May be NULL, in which case there are no size
226 struct uuconf_timespan *uuconf_qcall_local_size;
227 /* The size restrictions by time for remote requests during a
228 locally placed call. May be NULL. */
229 struct uuconf_timespan *uuconf_qcall_remote_size;
230 /* The size restrictions by time for local requests during a
231 remotely placed call. May be NULL. */
232 struct uuconf_timespan *uuconf_qcalled_local_size;
233 /* The size restrictions by time for remote requests during a
234 remotely placed call. May be NULL. */
235 struct uuconf_timespan *uuconf_qcalled_remote_size;
236 /* Baud rate, or speed. Zero means any baud rate. If ihighbaud is
237 non-zero, this is the low baud rate of a range. */
239 /* If non-zero, ibaud is the low baud rate of a range and ihighbaud
240 is the high baud rate. */
241 long uuconf_ihighbaud;
242 /* Port name to use. May be NULL. If an HDB configuration file
243 contains a modem class (alphabetic characters preceeding the baud
244 rate), the class is appended to the port name. */
246 /* Specific port information, if the system entry includes port
247 information. May be NULL. */
248 struct uuconf_port *uuconf_qport;
249 /* Phone number to call, or address to use for a TCP connection.
250 May be NULL, in which case a dialer script may not use \D or \T
251 for this system, and a TCP port will use the system name. */
253 /* Chat script to use when logging in to the system. */
254 struct uuconf_chat uuconf_schat;
255 /* Login name to use for \L in the login chat script. This should
256 normally be accessed via uuconf_callout. If it is "*",
257 uuconf_callout will look it up in the call out file. This may be
258 NULL, in which case the login script may not use \L. */
259 char *uuconf_zcall_login;
260 /* Password to use for \P in the login chat script. This should
261 normally be accessed via uuconf_callout. If it is "*",
262 uuconf_callout will look it up in the call out file. This may be
263 NULL, in which case the login script may not use \P. */
264 char *uuconf_zcall_password;
265 /* The login name this system must use when calling in. This may be
266 different for different alternates. This should only be examined
267 if uuconf_fcalled is TRUE. If this is NULL or "ANY" then
268 uuconf_validate must be called to make sure that whatever login
269 name was used is permitted for this machine. */
270 char *uuconf_zcalled_login;
271 /* If non-zero, then when this system calls in the call should not
272 be allowed to proceed and the system should be called back. */
273 int uuconf_fcallback;
274 /* If non-zero, then conversation sequence numbers should be used
276 int uuconf_fsequence;
277 /* A list of protocols to use with this system. Each protocol has a
278 single character name. May be NULL, in which case any known
279 protocol may be used. */
280 char *uuconf_zprotocols;
281 /* Array of protocol parameters. Ends in an entry with a
282 uuconf_bproto field of '\0'. May be NULL. */
283 struct uuconf_proto_param *uuconf_qproto_params;
284 /* Chat script to run when called by this system. */
285 struct uuconf_chat uuconf_scalled_chat;
286 /* Debugging level to set during a conversation. May be NULL. */
288 /* Maximum remote debugging level this system may request. May be
290 char *uuconf_zmax_remote_debug;
291 /* Non-zero if the remote system may request us to send files from
292 the local system to the remote. */
293 int uuconf_fsend_request;
294 /* Non-zero if the remote system may request us to receive files
295 from the remote system to the local. */
296 int uuconf_frec_request;
297 /* Non-zero if local requests are permitted when calling this
299 int uuconf_fcall_transfer;
300 /* Non-zero if local requests are permitted when this system calls
302 int uuconf_fcalled_transfer;
303 /* NULL terminated list of directories from which files may be sent
305 char **uuconf_pzlocal_send;
306 /* NULL terminated list of directories from which files may be sent
307 by remote request. */
308 char **uuconf_pzremote_send;
309 /* NULL terminated list of directories into which files may be
310 received by local request. */
311 char **uuconf_pzlocal_receive;
312 /* NULL terminated list of directories into which files may be
313 received by remote request. */
314 char **uuconf_pzremote_receive;
315 /* Path to use for command execution. This is a NULL terminated
316 list of directories. */
317 char **uuconf_pzpath;
318 /* NULL terminated List of commands that may be executed. */
319 char **uuconf_pzcmds;
320 /* Amount of free space to leave when accepting a file from this
322 long uuconf_cfree_space;
323 /* NULL terminated list of systems that this system may forward
324 from. May be NULL if there are no systems from which files may
325 be forwarded. The list may include "ANY". */
326 char **uuconf_pzforward_from;
327 /* NULL terminated list of systems that this system may forward to.
328 May be NULL if there are no systems to which files may be
329 forwarded. The list may include "ANY". */
330 char **uuconf_pzforward_to;
331 /* The public directory to use for this sytem. */
332 const char *uuconf_zpubdir;
333 /* The local name to use for this remote system. May be NULL if the
334 usual local name should be used. */
335 char *uuconf_zlocalname;
336 /* Memory allocation block for the system. */
337 UUCONF_POINTER uuconf_palloc;
340 /* Types of ports. */
344 /* Unknown port type. A port of this type should never be returned
345 by the uuconf functions. */
346 UUCONF_PORTTYPE_UNKNOWN,
347 /* Read from standard input and write to standard output. Not
349 UUCONF_PORTTYPE_STDIN,
351 UUCONF_PORTTYPE_MODEM,
352 /* A direct connect port. */
353 UUCONF_PORTTYPE_DIRECT,
354 /* A TCP port. Not supported on all systems. */
356 /* A TLI port. Not supported on all systems. */
358 /* A pipe port. Not supported on all systems. */
362 /* Additional information for a stdin port (there is none). */
364 struct uuconf_stdin_port
369 /* Additional information for a modem port. */
371 struct uuconf_modem_port
373 /* The device name. May be NULL, in which case the port name is
375 char *uuconf_zdevice;
376 /* The device name to send the dialer chat script to. May be NULL,
377 in which case the chat script is sent to the usual device. */
378 char *uuconf_zdial_device;
379 /* The default baud rate (speed). If zero, there is no default. */
381 /* The low baud rate, if a range is used. If zero, a range is not
382 used and ihighbaud should be ignored. */
383 long uuconf_ilowbaud;
384 /* The high baud rate, if ilowbaud is non-zero. */
385 long uuconf_ihighbaud;
386 /* Non-zero if the port supports carrier detect. */
388 /* Non-zero if the port supports hardware flow control. */
389 int uuconf_fhardflow;
390 /* A NULL terminated sequence of dialer/token pairs (element 0 is a
391 dialer name, element 1 is a token, etc.) May be NULL, in which
392 case qdialer should not be NULL. */
393 char **uuconf_pzdialer;
394 /* Specific dialer information. Only used if pzdialer is NULL. */
395 struct uuconf_dialer *uuconf_qdialer;
398 /* Additional information for a direct connect port. */
400 struct uuconf_direct_port
402 /* The device name. May be NULL, in which case the port name is
404 char *uuconf_zdevice;
405 /* The baud rate (speed). */
407 /* Non-zero if the port uses carrier detect. */
409 /* Non-zero if the port supports hardware flow control. */
410 int uuconf_fhardflow;
413 /* Additional information for a TCP port. */
415 struct uuconf_tcp_port
417 /* The TCP port number to use. May be a name or a number. May be
418 NULL, in which case "uucp" is looked up using getservbyname. */
420 /* A NULL terminated sequence of dialer/token pairs (element 0 is a
421 dialer name, element 1 is a token, etc.) May be NULL. */
422 char **uuconf_pzdialer;
425 /* Additional information for a TLI port. */
427 struct uuconf_tli_port
429 /* Device name to open. May be NULL, in which case the port name is
431 char *uuconf_zdevice;
432 /* Whether this port should be turned into a stream, permitting the
433 read and write calls instead of the t_rcv and t_send calls. */
435 /* A NULL terminated list of modules to push after making the
436 connection. May be NULL, in which case if fstream is non-zero,
437 then "tirdwr" is pushed onto the stream, and otherwise nothing is
439 char **uuconf_pzpush;
440 /* A NULL terminated sequence of dialer/token pairs (element 0 is a
441 dialer name, element 1 is a token, etc.) May be NULL. If
442 element 0 is TLI or TLIS, element 1 is used as the address to
443 connect to; otherwise uuconf_zphone from the system information
445 char **uuconf_pzdialer;
446 /* Address to use when operating as a server. This may contain
448 char *uuconf_zservaddr;
451 /* Additional information for a pipe port. */
453 struct uuconf_pipe_port
455 /* The command and its arguments. */
459 /* Information kept for a port. */
463 /* The name of the port. */
465 /* The type of the port. */
466 enum uuconf_porttype uuconf_ttype;
467 /* The list of protocols supported by the port. The name of each
468 protocol is a single character. May be NULL, in which case any
469 protocol is permitted. */
470 char *uuconf_zprotocols;
471 /* Array of protocol parameters. Ends in an entry with a
472 uuconf_bproto field of '\0'. May be NULL. */
473 struct uuconf_proto_param *uuconf_qproto_params;
474 /* The set of reliability bits. */
475 int uuconf_ireliable;
476 /* The lock file name to use. */
477 char *uuconf_zlockname;
478 /* Memory allocation block for the port. */
479 UUCONF_POINTER uuconf_palloc;
480 /* The type specific information. */
483 struct uuconf_stdin_port uuconf_sstdin;
484 struct uuconf_modem_port uuconf_smodem;
485 struct uuconf_direct_port uuconf_sdirect;
486 struct uuconf_tcp_port uuconf_stcp;
487 struct uuconf_tli_port uuconf_stli;
488 struct uuconf_pipe_port uuconf_spipe;
492 /* Information kept about a dialer. */
496 /* The name of the dialer. */
498 /* The chat script to use when dialing out. */
499 struct uuconf_chat uuconf_schat;
500 /* The string to send when a `=' appears in the phone number. */
501 char *uuconf_zdialtone;
502 /* The string to send when a `-' appears in the phone number. */
504 /* Non-zero if the dialer supports carrier detect. */
506 /* The number of seconds to wait for carrier after the chat script
507 is complete. Only used if fcarrier is non-zero. Only supported
509 int uuconf_ccarrier_wait;
510 /* If non-zero, DTR should be toggled before dialing. Only
511 supported on some systems. */
512 int uuconf_fdtr_toggle;
513 /* If non-zero, sleep for 1 second after toggling DTR. Ignored if
514 fdtr_toggle is zero. */
515 int uuconf_fdtr_toggle_wait;
516 /* The chat script to use when a call is complete. */
517 struct uuconf_chat uuconf_scomplete;
518 /* The chat script to use when a call is aborted. */
519 struct uuconf_chat uuconf_sabort;
520 /* Array of protocol parameters. Ends in an entry with a
521 uuconf_bproto field of '\0'. May be NULL. */
522 struct uuconf_proto_param *uuconf_qproto_params;
523 /* The set of reliability bits. */
524 int uuconf_ireliable;
525 /* Memory allocation block for the dialer. */
526 UUCONF_POINTER uuconf_palloc;
529 /* Reliability bits for the ireliable field of ports and dialers.
530 These bits are used to decide which protocol to run. A given
531 protocol will have a set of these bits, and each of them must be
532 turned on for the port before we will permit that protocol to be
533 used. This will be overridden by the zprotocols field. */
535 /* Whether a set of reliability bits is given. If this bit is not
536 set, then there is no reliability information. */
537 #define UUCONF_RELIABLE_SPECIFIED (01)
539 /* Set if the connection is eight bit transparent. */
540 #define UUCONF_RELIABLE_EIGHT (02)
542 /* Set if the connection is error-free. */
543 #define UUCONF_RELIABLE_RELIABLE (04)
545 /* Set if the connection is end-to-end reliable (e.g. TCP). */
546 #define UUCONF_RELIABLE_ENDTOEND (010)
548 /* Set if the connection is full-duplex; that is, no time consuming
549 line turnaround is required before sending data in the reverse
550 direction. If the connection is truly half-duplex, in the sense
551 that communication can only flow in one direction, UUCP can not be
553 #define UUCONF_RELIABLE_FULLDUPLEX (020)
555 /* UUCP grades range from 0 to 9, A to Z, a to z in order from highest
556 to lowest (work of higher grades is done before work of lower
559 /* The highest grade. */
560 #define UUCONF_GRADE_HIGH ('0')
562 /* The lowest grade. */
563 #define UUCONF_GRADE_LOW ('z')
565 /* Whether a character is a legal grade (requires <ctype.h>). */
566 #define UUCONF_GRADE_LEGAL(b) (isalnum (BUCHAR (b)))
568 /* Return < 0 if the first grade should be done before the second
569 grade, == 0 if they are the same, or > 0 if the first grade should
570 be done after the second grade. On an ASCII system, this can just
572 #define UUCONF_GRADE_CMP(b1, b2) (uuconf_grade_cmp ((b1), (b2)))
574 /* Definitions for bits returned by uuconf_strip. */
575 #define UUCONF_STRIP_LOGIN (01)
576 #define UUCONF_STRIP_PROTO (02)
578 /* uuconf_runuuxqt returns either a positive number (the number of
579 execution files to receive between uuxqt invocations) or one of
580 these constant values. */
581 #define UUCONF_RUNUUXQT_NEVER (0)
582 #define UUCONF_RUNUUXQT_ONCE (-1)
583 #define UUCONF_RUNUUXQT_PERCALL (-2)
585 /* Most of the uuconf functions returns an error code. A value of
586 zero (UUCONF_SUCCESS) indicates success. */
588 /* If this bit is set in the returned error code, then the
589 uuconf_errno function may be used to obtain the errno value as set
590 by the function which caused the failure. */
591 #define UUCONF_ERROR_ERRNO (0x100)
593 /* If this bit is set in the returned error code, then the
594 uuconf_filename function may be used to get the name of a file
595 associated with the error. */
596 #define UUCONF_ERROR_FILENAME (0x200)
598 /* If this bit is set in the returned error code, then the
599 uuconf_lineno function may be used to get a line number associated
600 with the error; normally if this is set UUCONF_ERROR_FILENAME will
602 #define UUCONF_ERROR_LINENO (0x400)
604 /* There are two UUCONF_CMDTABRET bits that may be set in the return
605 value of uuconf_cmd_line or uuconf_cmd_args, described below. They
606 do not indicate an error, but instead give instructions to the
607 calling function, often uuconf_cmd_file. They may also be set in
608 the return value of a user function listed in a uuconf_cmdtab
609 table, in which case they will be honored by uuconf_cmd_file. */
611 /* This bit means that the memory occupied by the arguments passed to
612 the function should be preserved, and not overwritten or freed. It
613 refers only to the contents of the arguments; the contents of the
614 argv array itself may always be destroyed. If this bit is set in
615 the return value of uuconf_cmd_line or uuconf_cmd_args, it must be
616 honored. It will be honored by uuconf_cmd_file. This may be
617 combined with an error code or with UUCONF_CMDTABRET_EXIT, although
618 neither uuconf_cmd_file or uuconf_cmd_line will do so. */
619 #define UUCONF_CMDTABRET_KEEP (0x800)
621 /* This bit means that uuconf_cmd_file should exit, rather than go on
622 to read and process the next line. If uuconf_cmd_line or
623 uuconf_cmd_args encounter an error, the return value will have this
624 bit set along with the error code. A user function may set this
625 bit with or without an error; the return value of the user function
626 will be returned by uuconf_cmd_file, except that the
627 UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT bits will be
629 #define UUCONF_CMDTABRET_EXIT (0x1000)
631 /* This macro may be used to extract the specific error value. */
632 #define UUCONF_ERROR_VALUE(i) ((i) & 0xff)
634 /* UUCONF_ERROR_VALUE will return one of the following values. */
636 /* Function succeeded. */
637 #define UUCONF_SUCCESS (0)
638 /* Named item not found. */
639 #define UUCONF_NOT_FOUND (1)
640 /* A call to fopen failed. */
641 #define UUCONF_FOPEN_FAILED (2)
642 /* A call to fseek failed. */
643 #define UUCONF_FSEEK_FAILED (3)
644 /* A call to malloc or realloc failed. */
645 #define UUCONF_MALLOC_FAILED (4)
646 /* Syntax error in file. */
647 #define UUCONF_SYNTAX_ERROR (5)
648 /* Unknown command. */
649 #define UUCONF_UNKNOWN_COMMAND (6)
653 /* For each type of configuration file (Taylor, V2, HDB), there are
654 separate routines to read various sorts of information. There are
655 also generic routines, which call on the appropriate type specific
656 routines. The library can be compiled to read any desired
657 combination of the configuration file types. This affects only the
658 generic routines, as it determines which type specific routines
659 they call. Thus, on a system which, for example, does not have any
660 V2 configuration files, there is no need to include the overhead of
661 the code to parse the files and the time to look for them.
662 However, a program which specifically wants to be able to parse
663 them can call the V2 specific routines.
665 The uuconf functions all take as an argument a pointer to uuconf
666 global information. This must be initialized by any the
667 initialization routines (the generic one and the three file type
668 specific ones) before any of the other uuconf functions may be
671 /* Initialize the configuration file reading routines. The ppglobal
672 argument should point to a generic pointer (a void *, or, on older
673 compilers, a char *) which will be initialized and may then be
674 passed to the other uuconf routines. The zprogram argument is the
675 name of the program for which files should be read. A NULL is
676 taken as "uucp", and reads the standard UUCP configuration files.
677 The only other common argument is "cu", but any string is
678 permitted. The zname argument is the name of the Taylor UUCP
679 config file; if it is NULL, the default config file will be read.
680 If not reading Taylor UUCP configuration information, the argument
681 is ignored. This function must be called before any of the other
684 Note that if the zname argument is obtained from the user running
685 the program, the program should be careful to revoke any special
686 privileges it may have (e.g. on Unix call setuid (getuid ()) and
687 setgid (getgid ())). Otherwise various sorts of spoofing become
689 extern int uuconf_init (void **uuconf_ppglobal,
690 const char *uuconf_zprogram,
691 const char *uuconf_zname);
693 /* Adjust the configuration file global pointer for a new thread. The
694 library is fully reentrant (with the exception of the function
695 uuconf_error_string, which calls strerror, which on some systems is
696 not reentrant), provided that each new thread that wishes to call
697 the library calls this function and uses the new global pointer
698 value. The ppglobal argument should be set to the address of the
699 global pointer set by any of the init functions; it will be
700 modified to become a new global pointer. */
701 extern int uuconf_init_thread (void **uuconf_ppglobal);
703 /* Get the names of all known systems. This sets sets *ppzsystems to
704 point to an array of system names. The list of names is NULL
705 terminated. The array is allocated using malloc, as is each
706 element of the array, and they may all be passed to free when they
707 are no longer needed. If the falias argument is 0, the list will
708 not include any aliases; otherwise, it will. */
709 extern int uuconf_system_names (void *uuconf_pglobal,
710 char ***uuconf_ppzsystems,
713 /* Get the information for the system zsystem. This sets the fields
714 in *qsys. This will work whether zsystem is the official name of
715 the system or merely an alias. */
716 extern int uuconf_system_info (void *uuconf_pglobal,
717 const char *uuconf_zsystem,
718 struct uuconf_system *uuconf_qsys);
720 /* Get information for an unknown (anonymous) system. The
721 uuconf_zname field of the returned system information will be NULL.
722 If no information is available for unknown systems, this will
723 return UUCONF_NOT_FOUND. This does not run the HDB remote.unknown
725 extern int uuconf_system_unknown (void *uuconf_pglobal,
726 struct uuconf_system *uuconf_qsys);
728 /* Get information for the local system. Normally the local system
729 name should first be looked up using uuconf_system_info. If that
730 returns UUCONF_NOT_FOUND, this function may be used to get an
731 appropriate set of defaults. The uuconf_zname field of the
732 returned system information may be NULL. */
733 extern int uuconf_system_local (void *uuconf_pglobal,
734 struct uuconf_system *uuconf_qsys);
736 /* Free the memory occupied by system information returned by
737 uuconf_system_info, uuconf_system_unknown, uuconf_system_local, or
738 any of the configuration file type specific routines described
739 below. After this is called, the contents of the structure shall
740 not be referred to. */
741 extern int uuconf_system_free (void *uuconf_pglobal,
742 struct uuconf_system *uuconf_qsys);
745 #define uuconf_system_free(qglob, q) \
746 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
749 /* Find a matching port. This will consider each port in turn.
751 If the zname argument is not NULL, the port's uuconf_zname field
754 If the ibaud argument is not zero and the ihighbaud argument is
755 zero, the port's baud rate, if defined, must be the same (if the
756 port has a range of baud rates, ibaud must be within the range).
757 If ibaud and ihighbaud are both not zero, the port's baud rate, if
758 defined, must be between ibaud and ihighbaud inclusive (if the port
759 has a range of baud rates, the ranges must intersect). If the port
760 has no baud rate, either because it is a type of port for which
761 baud rate is not defined (e.g. a TCP port) or because the
762 uuconf_ibaud field is 0, the ibaud and ihighbaud arguments are
765 If the pifn argument is not NULL, the port is passed to pifn, along
766 with the pinfo argument (which is otherwise ignored). If pifn
767 returns UUCONF_SUCCESS, the port matches. If pifn returns
768 UUCONF_NOT_FOUND, a new port is sought. Otherwise the return value
769 of pifn is returned from uuconf_find_port. The pifn function may
770 be used to further restrict the port, such as by modem class or
771 device name. It may also be used to lock the port, if appropriate;
772 in this case, if the lock fails, pifn may return UUCONF_NOT_FOUND
773 to force uuconf_find_port to continue searching for a port.
775 If the port matches, the information is set into uuconf_qport, and
776 uuconf_find_port returns UUCONF_SUCCESS. */
777 extern int uuconf_find_port (void *uuconf_pglobal,
778 const char *uuconf_zname,
780 long uuconf_ihighbaud,
781 int (*uuconf_pifn) (struct uuconf_port *,
784 struct uuconf_port *uuconf_qport);
786 /* Free the memory occupied by system information returned by
787 uuconf_find_port (or any of the configuration file specific
788 routines described below). After this is called, the contents of
789 the structure shall not be referred to. */
790 extern int uuconf_port_free (void *uuconf_pglobal,
791 struct uuconf_port *uuconf_qport);
794 #define uuconf_port_free(qglob, q) \
795 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
798 /* Get the names of all known dialers. This sets sets *ppzdialers to
799 point to an array of dialer names. The list of names is NULL
800 terminated. The array is allocated using malloc, as is each
801 element of the array, and they may all be passed to free when they
802 are no longer needed. */
803 extern int uuconf_dialer_names (void *uuconf_pglobal,
804 char ***uuconf_ppzdialers);
806 /* Get the information for the dialer zdialer. This sets the fields
808 extern int uuconf_dialer_info (void *uuconf_pglobal,
809 const char *uuconf_zdialer,
810 struct uuconf_dialer *uuconf_qdialer);
812 /* Free the memory occupied by system information returned by
813 uuconf_dialer_info (or any of the configuration file specific
814 routines described below). After this is called, the contents of
815 the structure shall not be referred to. */
816 extern int uuconf_dialer_free (void *uuconf_pglobal,
817 struct uuconf_dialer *uuconf_qsys);
820 #define uuconf_dialer_free(qglob, q) \
821 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
824 /* Get the local node name. If the node name is not specified
825 (because no ``nodename'' command appeared in the config file) this
826 will return UUCONF_NOT_FOUND, and some system dependent function
827 must be used to determine the node name. Otherwise it will return
828 a pointer to a constant string, which should not be freed. */
829 extern int uuconf_localname (void *uuconf_pglobal,
830 const char **pzname);
832 /* Get the local node name that should be used, given a login name.
833 This function will check for any special local name that may be
834 associated with the login name zlogin (as set by the ``myname''
835 command in a Taylor configuration file, or the MYNAME field in a
836 Permissions entry). This will set *pzname to the node name. If no
837 node name can be determined, *pzname will be set to NULL and the
838 function will return UUCONF_NOT_FOUND; in this case some system
839 dependent function must be used to determine the node name. If the
840 function returns UUCONF_SUCCESS, *pzname will be point to an
842 extern int uuconf_login_localname (void *uuconf_pglobal,
843 const char *uuconf_zlogin,
846 /* Get the name of the UUCP spool directory. This will set *pzspool
847 to a constant string, which should not be freed. */
848 extern int uuconf_spooldir (void *uuconf_pglobal,
849 const char **uuconf_pzspool);
851 /* Get the name of the default UUCP public directory. This will set
852 *pzpub to a constant string, which should not be freed. Note that
853 particular systems may use a different public directory. */
854 extern int uuconf_pubdir (void *uuconf_pglobal,
855 const char **uuconf_pzpub);
857 /* Get the name of the UUCP lock directory. This will set *pzlock to
858 a constant string, which should not be freed. */
859 extern int uuconf_lockdir (void *uuconf_pglobal,
860 const char **uuconf_pzlock);
862 /* Get the name of the UUCP log file. This will set *pzlog to a
863 constant string, which should not be freed. */
864 extern int uuconf_logfile (void *uuconf_pglobal,
865 const char **uuconf_pzlog);
867 /* Get the name of the UUCP statistics file. This will set *pzstats
868 to a constant string, which should not be freed. */
869 extern int uuconf_statsfile (void *uuconf_pglobal,
870 const char **uuconf_pzstats);
872 /* Get the name of the UUCP debugging file. This will set *pzdebug to
873 a constant string, which should not be freed. */
874 extern int uuconf_debugfile (void *uuconf_pglobal,
875 const char **uuconf_pzdebug);
877 /* Get the default debugging level to use. This basically gets the
878 argument of the ``debug'' command from the Taylor UUCP config file.
879 It will set *pzdebug to a constant string, which should not be
881 extern int uuconf_debuglevel (void *uuconf_pglobal,
882 const char **uuconf_pzdebug);
884 /* Get a combination of UUCONF_STRIP bits indicating what types of
885 global information should be stripped on input. */
886 extern int uuconf_strip (void *uuconf_pglobal,
887 int *uuconf_pistrip);
889 /* Get the maximum number of simultaneous uuxqt executions. This will
890 set *pcmaxuuxqt to the number. Zero indicates no maximum. */
891 extern int uuconf_maxuuxqts (void *uuconf_pglobal,
892 int *uuconf_pcmaxuuxqt);
894 /* Get the frequency with which to spawn a uuxqt process. This
895 returns an integer. A positive number is the number of execution
896 files that should be received between spawns. Other values are one
897 of the UUCONF_RUNUUXQT constants listed above. */
898 extern int uuconf_runuuxqt (void *uuconf_pglobal,
899 int *uuconf_pirunuuxqt);
901 /* Check a login name and password. This checks the Taylor UUCP
902 password file (not /etc/passwd). It will work even if
903 uuconf_taylor_init was not called. All comparisons are done via a
904 callback function. The first argument to the function will be zero
905 when comparing login names, non-zero when comparing passwords. The
906 second argument to the function will be the pinfo argument passed
907 to uuconf_callin. The third argument will be the login name or
908 password from the UUCP password file. The comparison function
909 should return non-zero for a match, or zero for a non-match. If
910 the login name is found and the password compares correctly,
911 uuconf_callin will return UUCONF_SUCCESS. If the login is not
912 found, or the password does not compare correctly, uuconf_callin
913 will return UUCONF_NOT_FOUND. Other errors are also possible. */
914 extern int uuconf_callin (void *uuconf_pglobal,
915 int (*uuconf_cmp) (int, void *, const char *),
918 /* Get the callout login name and password for a system. This will
919 set both *pzlog and *pzpass to a string allocated by malloc, or to
920 NULL if the value is not found. If neither value is found, the
921 function will return UUCONF_NOT_FOUND. */
922 extern int uuconf_callout (void *uuconf_pglobal,
923 const struct uuconf_system *uuconf_qsys,
925 char **uuconf_pzpass);
927 /* See if a login name is permitted for a system. This will return
928 UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
929 invalid. This simply calls uuconf_taylor_validate or returns
930 UUCONF_SUCCESS, depending on the value of HAVE_TAYLOR_CONFIG. */
931 extern int uuconf_validate (void *uuconf_pglobal,
932 const struct uuconf_system *uuconf_qsys,
933 const char *uuconf_zlogin);
935 /* Get the name of the HDB remote.unknown shell script, if using
936 HAVE_HDB_CONFIG. This does not actually run the shell script. If
937 the function returns UUCONF_SUCCESS, the name will be in *pzname,
938 which will point to an malloced buffer. If it returns
939 UUCONF_NOT_FOUND, then there is no script to run. */
940 extern int uuconf_remote_unknown (void *uuconf_pglobal,
943 /* Translate a dial code. This sets *pznum to an malloced string.
944 This will look up the entire zdial string in the dialcode file, so
945 for normal use the alphabetic prefix should be separated. */
946 extern int uuconf_dialcode (void *uuconf_pglobal,
947 const char *uuconf_zdial,
948 char **uuconf_pznum);
950 /* Compare two grades, returning < 0 if b1 should be executed before
951 b2, == 0 if they are the same, or > 0 if b1 should be executed
952 after b2. This can not fail, and does not return a standard uuconf
953 error code; it is normally called via the macro UUCONF_GRADE_CMP,
955 extern int uuconf_grade_cmp (int uuconf_b1, int uuconf_b2);
957 #else /* ! UUCONF_ANSI_C */
959 extern int uuconf_init ();
960 extern int uuconf_init_thread ();
961 extern int uuconf_system_names ();
962 extern int uuconf_system_info ();
963 extern int uuconf_system_unknown ();
964 extern int uuconf_system_local ();
965 extern int uuconf_system_free ();
966 extern int uuconf_find_port ();
967 extern int uuconf_port_free ();
968 extern int uuconf_dialer_names ();
969 extern int uuconf_dialer_info ();
970 extern int uuconf_dialer_free ();
971 extern int uuconf_localname ();
972 extern int uuconf_login_localname ();
973 extern int uuconf_spooldir ();
974 extern int uuconf_lockdir ();
975 extern int uuconf_pubdir ();
976 extern int uuconf_logfile ();
977 extern int uuconf_statsfile ();
978 extern int uuconf_debugfile ();
979 extern int uuconf_debuglevel ();
980 extern int uuconf_maxuuxqts ();
981 extern int uuconf_runuuxqt ();
982 extern int uuconf_callin ();
983 extern int uuconf_callout ();
984 extern int uuconf_remote_unknown ();
985 extern int uuconf_validate ();
986 extern int uuconf_grade_cmp ();
989 #define uuconf_system_free(qglob, q) \
990 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
991 #define uuconf_port_free(qglob, q) \
992 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
993 #define uuconf_dialer_free(qglob, q) \
994 (uuconf_free_block ((q)->uuconf_palloc), UUCONF_SUCCESS)
997 #endif /* ! UUCONF_ANSI_C */
1001 /* Initialize the Taylor UUCP configuration file reading routines.
1002 This must be called before calling any of the Taylor UUCP
1003 configuration file specific routines. The ppglobal argument should
1004 point to a generic pointer. Moreover, before calling this function
1005 the pointer either must be set to NULL, or must have been passed to
1006 one of the other uuconf init routines. The zprogram argument is
1007 the name of the program for which files should be read. If NULL,
1008 it is taken as "uucp", which means to read the standard UUCP files.
1009 The zname argument is the name of the config file. If it is NULL,
1010 the default config file will be used.
1012 Note that if the zname argument is obtained from the user running
1013 the program, the program should be careful to revoke any special
1014 privileges it may have (e.g. on Unix call setuid (getuid ()) and
1015 setgid (getgid ())). Otherwise various sorts of spoofing become
1017 extern int uuconf_taylor_init (void **uuconf_pglobal,
1018 const char *uuconf_zprogram,
1019 const char *uuconf_zname);
1021 /* Get the names of all systems listed in the Taylor UUCP
1022 configuration files. This sets *ppzsystems to point to an array of
1023 system names. The list of names is NULL terminated. The array is
1024 allocated using malloc, as is each element of the array. If the
1025 falias argument is 0, the list will not include any aliases;
1026 otherwise, it will. */
1027 extern int uuconf_taylor_system_names (void *uuconf_pglobal,
1028 char ***uuconf_ppzsystems,
1031 /* Get the information for system zsystem from the Taylor UUCP
1032 configuration files. This will set *qsys. */
1033 extern int uuconf_taylor_system_info (void *uuconf_pglobal,
1034 const char *uuconf_zsystem,
1035 struct uuconf_system *uuconf_qsys);
1037 /* Get information for an unknown (anonymous) system. This returns
1038 the values set by the ``unknown'' command in the main configuration
1039 file. If the ``unknown'' command was not used, this will return
1040 UUCONF_NOT_FOUND. */
1041 extern int uuconf_taylor_system_unknown (void *uuconf_pglobal,
1042 struct uuconf_system *uuconf_qsys);
1044 /* Find a port from the Taylor UUCP configuration files. The
1045 arguments and return values are identical to those of
1046 uuconf_find_port. */
1047 extern int uuconf_taylor_find_port (void *uuconf_pglobal,
1048 const char *uuconf_zname,
1050 long uuconf_ihighbaud,
1051 int (*uuconf_pifn) (struct uuconf_port *,
1052 void *uuconf_pinfo),
1054 struct uuconf_port *uuconf_qport);
1056 /* Get the names of all dialers listed in the Taylor UUCP
1057 configuration files. This sets *ppzdialers to point to an array of
1058 dialer names. The list of names is NULL terminated. The array is
1059 allocated using malloc, as is each element of the array. */
1060 extern int uuconf_taylor_dialer_names (void *uuconf_pglobal,
1061 char ***uuconf_ppzdialers);
1063 /* Get the information for the dialer zdialer from the Taylor UUCP
1064 configuration files. This sets the fields in *qdialer. */
1065 extern int uuconf_taylor_dialer_info (void *uuconf_pglobal,
1066 const char *uuconf_zdialer,
1067 struct uuconf_dialer *uuconf_qdialer);
1069 /* Get the local node name that should be used, given a login name,
1070 considering only the ``myname'' command in the Taylor UUCP
1071 configuration files. If the function returns UUCONF_SUCCESS,
1072 *pzname will point to an malloced buffer. */
1073 extern int uuconf_taylor_login_localname (void *uuconf_pglobal,
1074 const char *uuconf_zlogin,
1077 /* Get the callout login name and password for a system from the
1078 Taylor UUCP configuration files. This will set both *pzlog and
1079 *pzpass to a string allocated by malloc, or to NULL if the value is
1080 not found. If neither value is found, the function will return
1081 UUCONF_NOT_FOUND. */
1082 extern int uuconf_taylor_callout (void *uuconf_pglobal,
1083 const struct uuconf_system *uuconf_qsys,
1084 char **uuconf_pzlog,
1085 char **uuconf_pzpass);
1087 /* See if a login name is permitted for a system. This will return
1088 UUCONF_SUCCESS if it is permitted or UUCONF_NOT_FOUND if it is
1089 invalid. This checks whether the login name appears in a
1090 called-login command with a list of system which does not include
1092 extern int uuconf_taylor_validate (void *uuconf_pglobal,
1093 const struct uuconf_system *uuconf_qsys,
1094 const char *uuconf_zlogin);
1096 #else /* ! UUCONF_ANSI_C */
1098 extern int uuconf_taylor_init ();
1099 extern int uuconf_taylor_system_names ();
1100 extern int uuconf_taylor_system_info ();
1101 extern int uuconf_taylor_system_unknown ();
1102 extern int uuconf_taylor_find_port ();
1103 extern int uuconf_taylor_dialer_names ();
1104 extern int uuconf_taylor_dialer_info ();
1105 extern int uuconf_taylor_login_localname ();
1106 extern int uuconf_taylor_callout ();
1107 extern int uuconf_taylor_validate ();
1109 #endif /* ! UUCONF_ANSI_C */
1113 /* Initialize the V2 configuration file reading routines. This must
1114 be called before any of the other V2 routines are called. The
1115 ppglobal argument should point to a generic pointer. Moreover,
1116 before calling this function the pointer either must be set to
1117 NULL, or must have been passed to one of the other uuconf init
1119 extern int uuconf_v2_init (void **uuconf_ppglobal);
1121 /* Get the names of all systems listed in the V2 configuration files.
1122 This sets *ppzsystems to point to an array of system names. The
1123 list of names is NULL terminated. The array is allocated using
1124 malloc, as is each element of the array. If the falias argument is
1125 0, the list will not include any aliases; otherwise, it will. */
1126 extern int uuconf_v2_system_names (void *uuconf_pglobal,
1127 char ***uuconf_ppzsystems,
1130 /* Get the information for system zsystem from the V2 configuration
1131 files. This will set *qsys. */
1132 extern int uuconf_v2_system_info (void *uuconf_pglobal,
1133 const char *uuconf_zsystem,
1134 struct uuconf_system *uuconf_qsys);
1136 /* Find a port from the V2 configuration files. The arguments and
1137 return values are identical to those of uuconf_find_port. */
1138 extern int uuconf_v2_find_port (void *uuconf_pglobal,
1139 const char *uuconf_zname,
1141 long uuconf_ihighbaud,
1142 int (*uuconf_pifn) (struct uuconf_port *,
1143 void *uuconf_pinfo),
1145 struct uuconf_port *uuconf_qport);
1147 #else /* ! UUCONF_ANSI_C */
1149 extern int uuconf_v2_init ();
1150 extern int uuconf_v2_system_names ();
1151 extern int uuconf_v2_system_info ();
1152 extern int uuconf_v2_find_port ();
1154 #endif /* ! UUCONF_ANSI_C */
1158 /* Initialize the HDB configuration file reading routines. This
1159 should be called before any of the other HDB routines are called.
1160 The ppglobal argument should point to a generic pointer. Moreover,
1161 before calling this function the pointer either must be set to
1162 NULL, or must have been passed to one of the other uuconf init
1163 routines. The zprogram argument is used to match against a
1164 "services" string in Sysfiles. A NULL or "uucp" argument is taken
1166 extern int uuconf_hdb_init (void **uuconf_ppglobal,
1167 const char *uuconf_zprogram);
1169 /* Get the names of all systems listed in the HDB configuration files.
1170 This sets *ppzsystems to point to an array of system names. The
1171 list of names is NULL terminated. The array is allocated using
1172 malloc, as is each element of the array. If the falias argument is
1173 0, the list will not include any aliases; otherwise, it will (an
1174 alias is created by using the ALIAS= keyword in the Permissions
1176 extern int uuconf_hdb_system_names (void *uuconf_pglobal,
1177 char ***uuconf_ppzsystems,
1180 /* Get the information for system zsystem from the HDB configuration
1181 files. This will set *qsys. */
1182 extern int uuconf_hdb_system_info (void *uuconf_pglobal,
1183 const char *uuconf_zsystem,
1184 struct uuconf_system *uuconf_qsys);
1187 /* Get information for an unknown (anonymous) system. If no
1188 information is available for unknown systems, this will return
1189 UUCONF_NOT_FOUND. This does not run the remote.unknown shell
1191 extern int uuconf_hdb_system_unknown (void *uuconf_pglobal,
1192 struct uuconf_system *uuconf_qsys);
1194 /* Find a port from the HDB configuration files. The arguments and
1195 return values are identical to those of uuconf_find_port. */
1196 extern int uuconf_hdb_find_port (void *uuconf_pglobal,
1197 const char *uuconf_zname,
1199 long uuconf_ihighbaud,
1200 int (*uuconf_pifn) (struct uuconf_port *,
1201 void *uuconf_pinfo),
1203 struct uuconf_port *uuconf_qport);
1205 /* Get the names of all dialers listed in the HDB configuration files.
1206 This sets *ppzdialers to point to an array of dialer names. The
1207 list of names is NULL terminated. The array is allocated using
1208 malloc, as is each element of the array. */
1209 extern int uuconf_hdb_dialer_names (void *uuconf_pglobal,
1210 char ***uuconf_ppzdialers);
1212 /* Get the information for the dialer zdialer from the HDB
1213 configuration files. This sets the fields in *qdialer. */
1214 extern int uuconf_hdb_dialer_info (void *uuconf_pglobal,
1215 const char *uuconf_zdialer,
1216 struct uuconf_dialer *uuconf_qdialer);
1218 /* Get the local node name that should be used, given a login name,
1219 considering only the MYNAME field in the HDB Permissions file. If
1220 the function returns UUCONF_SUCCESS, *pzname will point to an
1222 extern int uuconf_hdb_login_localname (void *uuconf_pglobal,
1223 const char *uuconf_zlogin,
1226 /* Get the name of the HDB remote.unknown shell script. This does not
1227 actually run the shell script. If the function returns
1228 UUCONF_SUCCESS, the name will be in *pzname, which will point to an
1230 extern int uuconf_hdb_remote_unknown (void *uuconf_pglobal,
1233 #else /* ! UUCONF_ANSI_C */
1235 extern int uuconf_hdb_init ();
1236 extern int uuconf_hdb_system_names ();
1237 extern int uuconf_hdb_system_info ();
1238 extern int uuconf_hdb_system_unknown ();
1239 extern int uuconf_hdb_find_port ();
1240 extern int uuconf_hdb_dialer_names ();
1241 extern int uuconf_hdb_dialer_info ();
1242 extern int uuconf_hdb_localname ();
1243 extern int uuconf_hdb_remote_unknown ();
1245 #endif /* ! UUCONF_ANSI_C */
1249 /* This function will set an appropriate error message into the buffer
1250 zbuf, given a uuconf error code. The buffer will always be null
1251 terminated, and will never be accessed beyond the length cbuf.
1252 This function will return the number of characters needed for the
1253 complete message, including the null byte. If this is less than
1254 the cbytes argument, the buffer holds a truncated string. */
1255 extern int uuconf_error_string (void *uuconf_pglobal, int ierror,
1256 char *zbuf, UUCONF_SIZE_T cbuf);
1258 /* If UUCONF_ERROR_ERRNO is set in a return value, this function may
1259 be used to retrieve the errno value. This will be the value of
1260 errno as set by the system function which failed. However, some
1261 system functions, notably some stdio routines, may not set errno,
1262 in which case the value will be meaningless. This function does
1263 not return a uuconf error code, and it cannot fail. */
1264 extern int uuconf_error_errno (void *uuconf_pglobal);
1266 /* If UUCONF_ERROR_FILENAME is set in a return value, this function
1267 may be used to retrieve the file name. This function does not
1268 return a uuconf error code, and it cannot fail. The string that it
1269 returns a pointer to is not guaranteed to remain allocated across
1270 the next call to a uuconf function (other than one of the three
1271 error retrieving functions). */
1272 extern const char *uuconf_error_filename (void *uuconf_pglobal);
1274 /* If UUCONF_ERROR_LINENO is set in a return value, this function may
1275 be used to retrieve the line number. This function does not return
1276 a uuconf error code, and it cannot fail. */
1277 extern int uuconf_error_lineno (void *uuconf_pglobal);
1279 #else /* ! UUCONF_ANSI_C */
1281 extern int uuconf_error_string ();
1282 extern int uuconf_error_errno ();
1283 extern UUCONF_CONST char *uuconf_error_filename ();
1284 extern int uuconf_error_lineno ();
1286 #endif /* ! UUCONF_ANSI_C */
1288 /* The uuconf package also provides a few functions which can accept
1289 commands and parcel them out according to a table. These are
1290 publically visible, partially in the hopes that they will be
1291 useful, but mostly because the rest of the Taylor UUCP package uses
1294 /* The types of entries allowed in a command table (struct
1295 uuconf_cmdtab). Each type defines how a particular command is
1296 interpreted. Each type will either assign a value to a variable or
1297 call a function. In all cases, a line of input is parsed into
1298 separate fields, separated by whitespace; comments beginning with
1299 '#' are discarded, except that a '#' preceeded by a backslash is
1300 retained. The first field is taken as the command to execute, and
1301 the remaining fields are its arguments. */
1303 /* A boolean value. Used for a command which accepts a single
1304 argument, which must begin with 'y', 'Y', 't', or 'T' for true (1)
1305 or 'n', 'N', 'f', or 'F' for false (0). The corresponding variable
1307 #define UUCONF_CMDTABTYPE_BOOLEAN (0x12)
1309 /* An integer value. Used for a command which accepts a single
1310 argument, which must be an integer. The corresponding variable
1312 #define UUCONF_CMDTABTYPE_INT (0x22)
1314 /* A long value. Used for a command which accepts a single value,
1315 which must be an integer. The corresponding variable must be a
1317 #define UUCONF_CMDTABTYPE_LONG (0x32)
1319 /* A string value. Used for a command which accepts a string
1320 argument. If there is no argument, the variable will be set to
1321 point to a zero byte. Otherwise the variable will be set to point
1322 to the string. The corresponding variable must be a char *. The
1323 memory pointed to by the variable after it is set must not be
1325 #define UUCONF_CMDTABTYPE_STRING (0x40)
1327 /* A full string value. Used for a command which accepts a series of
1328 string arguments separated by whitespace. The corresponding
1329 variable must be a char **. It will be set to an NULL terminated
1330 array of the arguments. The memory occupied by the array itself,
1331 and by the strings within it, must not be modified. */
1332 #define UUCONF_CMDTABTYPE_FULLSTRING (0x50)
1334 /* A function. If this command is encountered, the command and its
1335 arguments are passed to the corresponding function. They are
1336 passed as an array of strings, in which the first string is the
1337 command itself, along with a count of strings. This value may be
1338 or'red with a specific number of required arguments;
1339 UUCONF_CMDTABTYPE_FN | 1 accepts no additional arguments besides
1340 the command itself, UUCONF_CMDTABTYPE_FN | 2 accepts 1 argument,
1341 etc. UUCONF_CMDTABTYPE_FN | 0, accepts any number of additional
1343 #define UUCONF_CMDTABTYPE_FN (0x60)
1345 /* A prefix function. The string in the table is a prefix; if a
1346 command is encountered with the same prefix, the corresponding
1347 function will be called as for UUCONF_CMDTABTYPE_FN. The number of
1348 arguments may be or'red in as with UUCONF_CMDTABTYPE_FN. */
1349 #define UUCONF_CMDTABTYPE_PREFIX (0x70)
1351 /* This macro will return the particular type of a CMDTABTYPE. */
1352 #define UUCONF_TTYPE_CMDTABTYPE(i) ((i) & 0x70)
1354 /* This macro will return the required number of arguments of a
1355 CMDTABTYPE. If it is zero, there is no restriction. */
1356 #define UUCONF_CARGS_CMDTABTYPE(i) ((i) & 0x0f)
1358 /* When a function is called via UUCONF_CMDTABTYPE_FN or
1359 UUCONF_CMDTABTYPE_PREFIX, it may return any uuconf error code (see
1360 above). However, it will normally return one of the following:
1362 UUCONF_CMDTABRET_CONTINUE: Take no special action. In particular,
1363 the arguments passed to the function may be overwritten or freed.
1365 UUCONF_CMDTABRET_KEEP: The memory occupied by the arguments passed
1366 to the function must be preserved. Continue processing commands.
1368 UUCONF_CMDTABRET_EXIT: If reading commands from a file, stop
1369 processing. The arguments passed to the function may be
1370 overwritten or freed.
1372 UUCONF_CMDTABRET_KEEP_AND_EXIT: Stop processing any file. The
1373 memory occupied by the arguments passed to the function must be
1376 These values are interpreted by uuconf_cmd_file. The
1377 uuconf_cmd_line and uuconf_cmd_args functions may return
1378 UUCONF_CMDTABRET_KEEP. It they get an error, they will return an
1379 error code with UUCONF_CMDTABRET_EXIT set. Also, of course, they
1380 may return any value that is returned by one of the user functions
1381 in the uuconf_cmdtab table. */
1383 /* UUCONF_CMDTABRET_KEEP and UUCONF_CMDTABRET_EXIT are defined above,
1384 with the error codes. */
1386 #define UUCONF_CMDTABRET_CONTINUE UUCONF_SUCCESS
1387 #define UUCONF_CMDTABRET_KEEP_AND_EXIT \
1388 (UUCONF_CMDTABRET_KEEP | UUCONF_CMDTABRET_EXIT)
1390 /* When a function is called via CMDTABTYPE_FN or CMDTABTYPE_PREFIX,
1391 it is passed five arguments. This is the type of a pointer to such
1392 a function. The uuconf global information structure is passed in
1393 for convenience in calling another uuconf function. The arguments
1394 to the command are passed in (the command itself is the first
1395 argument) along with a count and the value of the pvar field from
1396 the uuconf_cmdtab structure in which the function pointer was
1397 found. The pinfo argument to the function is taken from the
1398 argument to uuconf_cmd_*. */
1401 typedef int (*uuconf_cmdtabfn) (void *uuconf_pglobal,
1405 void *uuconf_pinfo);
1407 typedef int (*uuconf_cmdtabfn) ();
1410 /* A table of commands is an array of the following structures. The
1411 final element of the table should have uuconf_zcmd == NULL. */
1413 struct uuconf_cmdtab
1416 UUCONF_CONST char *uuconf_zcmd;
1417 /* Command type (one of CMDTABTYPE_*). */
1419 /* If not CMDTABTYPE_FN or CMDTABTYPE_PREFIX, the address of the
1420 associated variable. Otherwise, a pointer value to pass to the
1422 UUCONF_POINTER uuconf_pvar;
1423 /* The function to call if CMDTABTYPE_FN or CMDTABTYPE_PREFIX. */
1424 uuconf_cmdtabfn uuconf_pifn;
1427 /* Bit flags to pass to uuconf_processcmds. */
1429 /* If set, case is significant when checking commands. Normally case
1431 #define UUCONF_CMDTABFLAG_CASE (0x1)
1433 /* If set, a backslash at the end of a line may be used to include the
1434 next physical line in the logical line. */
1435 #define UUCONF_CMDTABFLAG_BACKSLASH (0x2)
1437 /* If set, the comment character (#) is treated as a normal character,
1438 rather than as starting a comment. */
1439 #define UUCONF_CMDTABFLAG_NOCOMMENTS (0x4)
1443 /* Read commands from a file, look them up in a table, and take the
1444 appropriate action. This continues reading lines from the file
1445 until EOF, or until a function returns with UUCONF_CMDTABRET_EXIT
1446 set, or until an error occurs. The qtab argument must point to a
1447 table of struct uuconf_cmdtab; the last element in the table should
1448 have uuconf_zcmd == NULL. When a UUCONF_CMDTABTYPE_FN or
1449 UUCONF_CMDTABTYPE_PREFIX command is found, the pinfo argument will
1450 be passed to the called function. If an a command is found that is
1451 not in the table, then if pfiunknownfn is NULL the unknown command
1452 is ignored; otherwise it is passed to pfiunknownfn, which should
1453 return a uuconf return code which is handled as for any other
1454 function (the pvar argument to pfiunknownfn will always be NULL).
1455 The iflags argument is any combination of the above
1456 UUCONF_CMDTABFLAG bits. The pblock argument may also be a memory
1457 block, as returned by uuconf_malloc_block (described below), in
1458 which case all memory preserved because of UUCONF_CMDTABRET_KEEP
1459 will be added to the block so that it may be freed later; it may
1460 also be NULL, in which case any such memory is permanently lost.
1462 This function initially sets the internal line number to 0, and
1463 then increments it as each line is read. It is permitted for any
1464 called function to use the uuconf_lineno function to obtain it. If
1465 this function is called when not at the start of a file, the value
1466 returned by uuconf_lineno (which is, in any case, only valid if an
1467 error code with UUCONF_ERROR_LINENO set is returned) must be
1468 adjusted by the caller.
1470 This returns a normal uuconf return value, as described above. */
1471 extern int uuconf_cmd_file (void *uuconf_pglobal,
1473 const struct uuconf_cmdtab *uuconf_qtab,
1475 uuconf_cmdtabfn uuconf_pfiunknownfn,
1479 /* This utility function is just like uuconf_cmd_file, except that it
1480 only operates on a single string. If a function is called via
1481 qtab, its return value will be the return value of this function.
1482 UUCONF_CMDTABFLAG_BACKSLASH is ignored in iflags. The string z is
1483 modified in place. The return value may include the
1484 UUCONF_CMDTABRET_KEEP and, on error, the UUCONF_CMDTABRET_EXIT
1485 bits, which should be honored by the calling code. */
1486 extern int uuconf_cmd_line (void *uuconf_pglobal,
1488 const struct uuconf_cmdtab *uuconf_qtab,
1490 uuconf_cmdtabfn uuconf_pfiunknownfn,
1494 /* This utility function is just like uuconf_cmd_line, except it is
1495 given a list of already parsed arguments. */
1496 extern int uuconf_cmd_args (void *uuconf_pglobal,
1498 char **uuconf_pzargs,
1499 const struct uuconf_cmdtab *uuconf_qtab,
1501 uuconf_cmdtabfn uuconf_pfiunknownfn,
1505 #else /* ! UUCONF_ANSI_C */
1507 extern int uuconf_cmd_file ();
1508 extern int uuconf_cmd_line ();
1509 extern int uuconf_cmd_args ();
1511 #endif /* ! UUCONF_ANSI_C */
1515 /* The uuconf_cmd_file function may allocate memory permanently, as
1516 for setting a UUCONF_CMDTABTYPE_STRING value, in ways which are
1517 difficult to free up. A memory block may be used to record all
1518 allocated memory, so that it can all be freed up at once at some
1519 later time. These functions do not take a uuconf global pointer,
1520 and are independent of the rest of the uuconf library. */
1522 /* Allocate a block of memory. If this returns NULL, then malloc
1523 returned NULL, and errno is whatever malloc set it to. */
1524 extern void *uuconf_malloc_block (void);
1526 /* Allocate memory within a memory block. If this returns NULL, then
1527 malloc returned NULL, and errno is whatever malloc set it to. */
1528 extern void *uuconf_malloc (void *uuconf_pblock,
1529 UUCONF_SIZE_T uuconf_cbytes);
1531 /* Add a block returned by the generic malloc routine to a memory
1532 block. This returns zero on success, non-zero on failure. If this
1533 fails (returns non-zero), then malloc returned NULL, and errno is
1534 whatever malloc set it to. */
1535 extern int uuconf_add_block (void *uuconf_pblock, void *uuconf_padd);
1537 /* Free a value returned by uuconf_malloc from a memory block. In the
1538 current implementation, this will normally not do anything, but it
1539 doesn't hurt. No errors can occur. */
1540 extern void uuconf_free (void *uuconf_pblock, void *uuconf_pfree);
1542 /* Free an entire memory block, including all values returned by
1543 uuconf_malloc from it and all values added to it with
1544 uuconf_add_block. No errors can occur. */
1545 extern void uuconf_free_block (void *uuconf_pblock);
1547 #else /* ! UUCONF_ANSI_C */
1549 extern UUCONF_POINTER uuconf_malloc_block ();
1550 extern UUCONF_POINTER uuconf_malloc ();
1551 extern int uuconf_add_block ();
1552 extern /* void */ uuconf_free ();
1553 extern /* void */ uuconf_free_block ();
1555 #endif /* ! UUCONF_ANSI_C */
1557 #endif /* ! defined (UUCONF_H) */