Annotation of coherent/g/usr/lib/uucp/tay104/uudefs.h, revision 1.1

1.1     ! root        1: /* uudefs.h
        !             2:    Miscellaneous definitions for the UUCP package.
        !             3: 
        !             4:    Copyright (C) 1991, 1992 Ian Lance Taylor
        !             5: 
        !             6:    This file is part of the Taylor UUCP package.
        !             7: 
        !             8:    This program is free software; you can redistribute it and/or
        !             9:    modify it under the terms of the GNU General Public License as
        !            10:    published by the Free Software Foundation; either version 2 of the
        !            11:    License, or (at your option) any later version.
        !            12: 
        !            13:    This program 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:    General Public License for more details.
        !            17: 
        !            18:    You should have received a copy of the GNU General Public License
        !            19:    along with this program; if not, write to the Free Software
        !            20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            21: 
        !            22:    The author of the program may be contacted at [email protected] or
        !            23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
        !            24:    */
        !            25: 
        !            26: #if ANSI_C
        !            27: /* These structures are used in prototypes but are not defined in this
        !            28:    header file.  */
        !            29: struct uuconf_system;
        !            30: struct uuconf_timespan;
        !            31: #endif
        !            32: 
        !            33: /* The tlog enumeration holds the different types of logging.  */
        !            34: enum tlog
        !            35: {
        !            36:   /* Normal log entry.  */
        !            37:   LOG_NORMAL,
        !            38:   /* Error log entry.  */
        !            39:   LOG_ERROR,
        !            40:   /* Fatal log entry.  */
        !            41:   LOG_FATAL
        !            42: #if DEBUG > 1
        !            43:     ,
        !            44:   /* Debugging log entry.  */
        !            45:   LOG_DEBUG,
        !            46:   /* Start debugging log entry.  */
        !            47:   LOG_DEBUG_START,
        !            48:   /* Continue debugging log entry.  */
        !            49:   LOG_DEBUG_CONTINUE,
        !            50:   /* End debugging log entry.  */
        !            51:   LOG_DEBUG_END
        !            52: #endif
        !            53: };
        !            54: 
        !            55: /* The tstatus_type enumeration holds the kinds of status information
        !            56:    we put in the status file.  The order of entries here corresponds
        !            57:    to the order of entries in the azStatus array.  */
        !            58: enum tstatus_type
        !            59: {
        !            60:   /* Conversation complete.  */
        !            61:   STATUS_COMPLETE,
        !            62:   /* Port unavailable.  */
        !            63:   STATUS_PORT_FAILED,
        !            64:   /* Dial failed.  */
        !            65:   STATUS_DIAL_FAILED,
        !            66:   /* Login failed.  */
        !            67:   STATUS_LOGIN_FAILED,
        !            68:   /* Handshake failed.  */
        !            69:   STATUS_HANDSHAKE_FAILED,
        !            70:   /* Failed after logging in.  */
        !            71:   STATUS_FAILED,
        !            72:   /* Talking to remote system.  */
        !            73:   STATUS_TALKING,
        !            74:   /* Wrong time to call.  */
        !            75:   STATUS_WRONG_TIME,
        !            76:   /* Number of status values.  */
        !            77:   STATUS_VALUES
        !            78: };
        !            79: 
        !            80: /* An array to convert status entries to strings.  If more status entries
        !            81:    are added, this array must be extended.  */
        !            82: extern const char *azStatus[];
        !            83: 
        !            84: /* The sstatus structure holds the contents of a system status file.  */
        !            85: struct sstatus
        !            86: {
        !            87:   /* Current status of conversation.  */
        !            88:   enum tstatus_type ttype;
        !            89:   /* Number of failed retries.  */
        !            90:   int cretries;
        !            91:   /* Time of last call in seconds since epoch (determined by
        !            92:      ixsysdep_time).  */
        !            93:   long ilast;
        !            94:   /* Number of seconds until a retry is permitted.  */
        !            95:   int cwait;
        !            96: };
        !            97: 
        !            98: /* How long we have to wait for the next call, given the number of retries
        !            99:    we have already made.  This should probably be configurable.  */
        !           100: #define CRETRY_WAIT(c) ((c) * 10 * 60)
        !           101: 
        !           102: /* The scmd structure holds a complete UUCP command.  */
        !           103: struct scmd
        !           104: {
        !           105:   /* Command ('S' for send, 'R' for receive, 'X' for execute, 'E' for
        !           106:      simple execution, 'H' for hangup, 'Y' for hangup confirm, 'N' for
        !           107:      hangup deny).  */
        !           108:   char bcmd;
        !           109:   /* At least one compiler needs an explicit padding byte here.  */
        !           110:   char bdummy;
        !           111:   /* Sequence handle for fsysdep_did_work.  */
        !           112:   pointer pseq;
        !           113:   /* File name to transfer from.  */
        !           114:   const char *zfrom;
        !           115:   /* File name to transfer to.  */
        !           116:   const char *zto;
        !           117:   /* User who requested transfer.  */
        !           118:   const char *zuser;
        !           119:   /* Options.  */
        !           120:   const char *zoptions;
        !           121:   /* Temporary file name ('S' and 'E').  */
        !           122:   const char *ztemp;
        !           123:   /* Mode to give newly created file ('S' and 'E').  */
        !           124:   unsigned int imode;
        !           125:   /* User to notify on remote system (optional; 'S' and 'E').  */
        !           126:   const char *znotify;
        !           127:   /* File size (-1 if not supplied) ('S', 'E' and 'R').  */
        !           128:   long cbytes;
        !           129:   /* Command to execute ('E').  */
        !           130:   const char *zcmd;
        !           131:   /* Position to restart from ('R').  */
        !           132:   long ipos;
        !           133: };
        !           134: 
        !           135: #if DEBUG > 1
        !           136: 
        !           137: /* We allow independent control over several different types of
        !           138:    debugging output, using a bit string with individual bits dedicated
        !           139:    to particular debugging types.  */
        !           140: 
        !           141: /* The bit string is stored in iDebug.  */
        !           142: extern int iDebug;
        !           143: 
        !           144: /* Debug abnormal events.  */
        !           145: #define DEBUG_ABNORMAL (01)
        !           146: /* Debug chat scripts.  */
        !           147: #define DEBUG_CHAT (02)
        !           148: /* Debug initial handshake.  */
        !           149: #define DEBUG_HANDSHAKE (04)
        !           150: /* Debug UUCP protocol.  */
        !           151: #define DEBUG_UUCP_PROTO (010)
        !           152: /* Debug protocols.  */
        !           153: #define DEBUG_PROTO (020)
        !           154: /* Debug port actions.  */
        !           155: #define DEBUG_PORT (040)
        !           156: /* Debug configuration files.  */
        !           157: #define DEBUG_CONFIG (0100)
        !           158: /* Debug spool directory actions.  */
        !           159: #define DEBUG_SPOOLDIR (0200)
        !           160: /* Debug executions.  */
        !           161: #define DEBUG_EXECUTE (0400)
        !           162: /* Debug incoming data.  */
        !           163: #define DEBUG_INCOMING (01000)
        !           164: /* Debug outgoing data.  */
        !           165: #define DEBUG_OUTGOING (02000)
        !           166: 
        !           167: /* Maximum possible value for iDebug.  */
        !           168: #define DEBUG_MAX (03777)
        !           169: 
        !           170: /* Intializer for array of debug names.  The index of the name in the
        !           171:    array is the corresponding bit position in iDebug.  We only check
        !           172:    for prefixes, so these names only need to be long enough to
        !           173:    distinguish each name from every other.  The last entry must be
        !           174:    NULL.  The string "all" is also recognized to turn on all
        !           175:    debugging.  */
        !           176: #define DEBUG_NAMES \
        !           177:   { "a", "ch", "h", "u", "pr", "po", "co", "s", "e", "i", "o", NULL }
        !           178: 
        !           179: /* The prefix to use to turn off all debugging.  */
        !           180: #define DEBUG_NONE "n"
        !           181: 
        !           182: /* Check whether a particular type of debugging is being done.  */
        !           183: #define FDEBUGGING(i) ((iDebug & (i)) != 0)
        !           184: 
        !           185: /* These macros are used to output debugging information.  I use
        !           186:    several different macros depending on the number of arguments
        !           187:    because no macro can take a variable number of arguments and I
        !           188:    don't want to use double parentheses.  */
        !           189: #define DEBUG_MESSAGE0(i, z) \
        !           190:   do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z)); } while (0)
        !           191: #define DEBUG_MESSAGE1(i, z, a1) \
        !           192:   do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1)); } while (0)
        !           193: #define DEBUG_MESSAGE2(i, z, a1, a2) \
        !           194:   do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1), (a2)); } while (0)
        !           195: #define DEBUG_MESSAGE3(i, z, a1, a2, a3) \
        !           196:   do \
        !           197:     { \
        !           198:       if (FDEBUGGING (i)) \
        !           199:        ulog (LOG_DEBUG, (z), (a1), (a2), (a3)); \
        !           200:     } \
        !           201:   while (0)
        !           202: #define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) \
        !           203:   do \
        !           204:     { \
        !           205:       if (FDEBUGGING (i)) \
        !           206:        ulog (LOG_DEBUG, (z), (a1), (a2), (a3), (a4)); \
        !           207:     } \
        !           208:   while (0)
        !           209: 
        !           210: #else /* DEBUG <= 1 */
        !           211: 
        !           212: /* If debugging information is not being compiled, provide versions of
        !           213:    the debugging macros which just disappear.  */
        !           214: #define DEBUG_MESSAGE0(i, z)
        !           215: #define DEBUG_MESSAGE1(i, z, a1)
        !           216: #define DEBUG_MESSAGE2(i, z, a1, a2)
        !           217: #define DEBUG_MESSAGE3(i, z, a1, a2, a3)
        !           218: #define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4)
        !           219: 
        !           220: #endif /* DEBUG <= 1 */
        !           221: 
        !           222: /* Functions.  */
        !           223: 
        !           224: /* Given an unknown system name, return information for an unknown
        !           225:    system.  If unknown systems are not permitted, this returns FALSE.
        !           226:    Otherwise, it translates the name as necessary for the spool
        !           227:    directory, and fills in *qsys.  */
        !           228: extern boolean funknown_system P((pointer puuconf, const char *zsystem,
        !           229:                                  struct uuconf_system *qsys));
        !           230: 
        !           231: /* See whether a file belongs in the spool directory.  */
        !           232: extern boolean fspool_file P((const char *zfile));
        !           233: 
        !           234: /* See if the current time matches a time span.  If not, return FALSE.
        !           235:    Otherwise, return TRUE and set *pival and *pcretry to the values
        !           236:    from the matching element of the span.  */
        !           237: extern boolean ftimespan_match P((const struct uuconf_timespan *qspan,
        !           238:                                  long *pival, int *pcretry));
        !           239: 
        !           240: /* Determine the maximum size that may ever be transferred, given a
        !           241:    timesize span.  If there are any time gaps larger than 1 hour not
        !           242:    described by the timesize span, this returns -1.  Otherwise it
        !           243:    returns the largest size that may be transferred at some time.  */
        !           244: extern long cmax_size_ever P((const struct uuconf_timespan *qtimesize));
        !           245: 
        !           246: /* Send mail about a file transfer.  */
        !           247: extern boolean fmail_transfer P((boolean fok, const char *zuser,
        !           248:                                 const char *zmail, const char *zwhy,
        !           249:                                 const char *zfrom, const char *zfromsys,
        !           250:                                 const char *zto, const char *ztosys,
        !           251:                                 const char *zsaved));
        !           252: 
        !           253: /* See whether a file is in one of a list of directories.  The zpubdir
        !           254:    argument is used to pass the directory names to zsysdep_local_file.
        !           255:    If fcheck is FALSE, this does not check accessibility.  Otherwise,
        !           256:    if freadable is TRUE, the user zuser must have read access to the
        !           257:    file and all appropriate directories; if freadable is FALSE zuser
        !           258:    must have write access to the appropriate directories.  The zuser
        !           259:    argument may be NULL, in which case all users must have the
        !           260:    appropriate access (this is used for a remote request).  */
        !           261: extern boolean fin_directory_list P((const char *zfile,
        !           262:                                     char **pzdirs,
        !           263:                                     const char *zpubdir,
        !           264:                                     boolean fcheck,
        !           265:                                     boolean freadable,
        !           266:                                     const char *zuser));
        !           267: 
        !           268: /* Parse a command string.  */
        !           269: extern boolean fparse_cmd P((char *zcmd, struct scmd *qcmd));
        !           270: 
        !           271: /* Make a log entry.  */
        !           272: #ifdef __GNUC__
        !           273: #define GNUC_VERSION __GNUC__
        !           274: #else
        !           275: #define GNUC_VERSION 0
        !           276: #endif
        !           277: 
        !           278: #if ANSI_C && HAVE_VFPRINTF
        !           279: extern void ulog P((enum tlog ttype, const char *zfmt, ...))
        !           280: #if GNUC_VERSION > 1
        !           281:      __attribute__ ((format (printf, 2, 3)))
        !           282: #endif
        !           283:      ;
        !           284: #else
        !           285: extern void ulog ();
        !           286: #endif
        !           287: 
        !           288: #undef GNUC_VERSION
        !           289: 
        !           290: /* Report an error returned by one of the uuconf routines.  */
        !           291: extern void ulog_uuconf P((enum tlog ttype, pointer puuconf,
        !           292:                           int iuuconf));
        !           293: 
        !           294: /* Set the function to call if a fatal error occurs.  */
        !           295: extern void ulog_fatal_fn P((void (*pfn) P((void))));
        !           296: 
        !           297: /* If ffile is TRUE, send log entries to the log file rather than to
        !           298:    stderr.  */
        !           299: extern void ulog_to_file P((pointer puuconf, boolean ffile));
        !           300: 
        !           301: /* Set the ID number used by the logging functions.  */
        !           302: extern void ulog_id P((int iid));
        !           303: 
        !           304: /* Set the system name used by the logging functions.  */
        !           305: extern void ulog_system P((const char *zsystem));
        !           306: 
        !           307: /* Set the system and user name used by the logging functions.  */
        !           308: extern void ulog_user P((const char *zuser));
        !           309: 
        !           310: /* Set the device name used by the logging functions.  */
        !           311: extern void ulog_device P((const char *zdevice));
        !           312: 
        !           313: /* Close the log file.  */
        !           314: extern void ulog_close P((void));
        !           315: 
        !           316: /* Make an entry in the statistics file.  */
        !           317: extern void ustats P((boolean fsucceeded, const char *zuser,
        !           318:                      const char *zsystem, boolean fsent,
        !           319:                      long cbytes, long csecs, long cmicros,
        !           320:                      boolean fmaster));
        !           321: 
        !           322: /* Close the statistics file.  */
        !           323: extern void ustats_close P((void));
        !           324: 
        !           325: #if DEBUG > 1
        !           326: /* A debugging routine to output a buffer.  This outputs zhdr, the
        !           327:    buffer length clen, and the contents of the buffer in quotation
        !           328:    marks.  */
        !           329: extern void udebug_buffer P((const char *zhdr, const char *zbuf,
        !           330:                             size_t clen));
        !           331: 
        !           332: /* A debugging routine to make a readable version of a character.
        !           333:    This takes a buffer at least 5 bytes long, and returns the length
        !           334:    of the string it put into it (not counting the null byte).  */
        !           335: extern size_t cdebug_char P((char *z, int ichar));
        !           336: 
        !           337: /* Parse a debugging option string.  This can either be a number or a
        !           338:    comma separated list of debugging names.  This returns a value for
        !           339:    iDebug.  */
        !           340: extern int idebug_parse P((const char *));
        !           341: 
        !           342: #endif /* DEBUG <= 1 */
        !           343: 
        !           344: /* Copy one file to another.  */
        !           345: extern boolean fcopy_file P((const char *zfrom, const char *zto,
        !           346:                             boolean fpublic, boolean fmkdirs));
        !           347: 
        !           348: /* Copy an open file to another.  */
        !           349: extern boolean fcopy_open_file P((openfile_t efrom, const char *zto,
        !           350:                                  boolean fpublic, boolean fmkdirs));
        !           351: 
        !           352: /* Translate escape sequences in a buffer, leaving the result in the
        !           353:    same buffer and returning the length.  */
        !           354: extern size_t cescape P((char *zbuf));
        !           355: 
        !           356: /* Get a buffer to hold a string of a given size.  The buffer should
        !           357:    be freed with ubuffree.  */
        !           358: extern char *zbufalc P((size_t csize));
        !           359: 
        !           360: /* Call zbufalc to allocate a buffer and copy a string into it.  */
        !           361: extern char *zbufcpy P((const char *z));
        !           362: 
        !           363: /* Free up a buffer returned by zbufalc or zbufcpy.  */
        !           364: extern void ubuffree P((char *z));
        !           365: 
        !           366: /* Allocate memory without fail.  */
        !           367: extern pointer xmalloc P((size_t));
        !           368: 
        !           369: /* Realloc memory without fail.  */
        !           370: extern pointer xrealloc P((pointer, size_t));
        !           371: 
        !           372: /* Free memory (accepts NULL pointers, which some libraries erroneously
        !           373:    do not).  */
        !           374: extern void xfree P((pointer));
        !           375: 
        !           376: /* Global variables.  */
        !           377: 
        !           378: /* The name of the program being run.  This is statically initialized,
        !           379:    although it should perhaps be set from argv[0].  */
        !           380: extern char abProgram[];
        !           381: 
        !           382: /* When a signal occurs, the signal handlers sets the appropriate
        !           383:    element of the arrays afSignal and afLog_signal to TRUE.  The
        !           384:    afSignal array is used to check whether a signal occurred.  The
        !           385:    afLog_signal array tells ulog to log the signal; ulog will clear
        !           386:    the element after logging it, which means that if a signal comes in
        !           387:    at just the right moment it will not be logged.  It will always be
        !           388:    recorded in afSignal, though.  At the moment we handle 5 signals:
        !           389:    SIGHUP, SIGINT, SIGQUIT, SIGTERM and SIGPIPE (the Unix code also
        !           390:    handles SIGALRM).  If we want to handle more, the afSignal array
        !           391:    must be extended; I see little point to handling any of the other
        !           392:    ANSI C or POSIX signals, as they are either unlikely to occur
        !           393:    (SIGABRT, SIGUSR1) or nearly impossible to handle cleanly (SIGILL,
        !           394:    SIGSEGV).  SIGHUP is only logged if fLog_sighup is TRUE.  */
        !           395: #define INDEXSIG_SIGHUP (0)
        !           396: #define INDEXSIG_SIGINT (1)
        !           397: #define INDEXSIG_SIGQUIT (2)
        !           398: #define INDEXSIG_SIGTERM (3)
        !           399: #define INDEXSIG_SIGPIPE (4)
        !           400: #define INDEXSIG_COUNT (5)
        !           401: 
        !           402: extern volatile sig_atomic_t afSignal[INDEXSIG_COUNT];
        !           403: extern volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT];
        !           404: extern boolean fLog_sighup;
        !           405: 
        !           406: /* The names of the signals to use in error messages, as an
        !           407:    initializer for an array.  */
        !           408: #define INDEXSIG_NAMES \
        !           409:   { "hangup", "interrupt", "quit", "termination", "SIGPIPE" }
        !           410: 
        !           411: /* Check to see whether we've received a signal.  It would be nice if
        !           412:    we could use a single variable for this, but we sometimes want to
        !           413:    clear our knowledge of a signal and that would cause race
        !           414:    conditions (clearing a single element of the array is not a race
        !           415:    assuming that we don't care about a particular signal, even if it
        !           416:    occurs after we've examined the array).  */
        !           417: #define FGOT_SIGNAL() \
        !           418:   (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGINT] \
        !           419:    || afSignal[INDEXSIG_SIGQUIT] || afSignal[INDEXSIG_SIGTERM] \
        !           420:    || afSignal[INDEXSIG_SIGPIPE])
        !           421: 
        !           422: /* If we get a SIGINT in uucico, we continue the current communication
        !           423:    session but don't start any new ones.  This macros checks for any
        !           424:    signal other than SIGINT, which means we should get out
        !           425:    immediately.  */
        !           426: #define FGOT_QUIT_SIGNAL() \
        !           427:   (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGQUIT] \
        !           428:    || afSignal[INDEXSIG_SIGTERM] || afSignal[INDEXSIG_SIGPIPE])
        !           429: 
        !           430: /* File being sent.  */
        !           431: extern openfile_t eSendfile;
        !           432: 
        !           433: /* File being received.  */
        !           434: extern openfile_t eRecfile;
        !           435: 
        !           436: /* Device name to log.  This is set by fconn_open.  It may be NULL.  */
        !           437: extern char *zLdevice;
        !           438: 
        !           439: /* If not NULL, ulog calls this function before outputting anything.
        !           440:    This is used to support cu.  */
        !           441: extern void (*pfLstart) P((void));
        !           442: 
        !           443: /* If not NULL, ulog calls this function after outputting everything.
        !           444:    This is used to support cu.  */
        !           445: extern void (*pfLend) P((void));

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.