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