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