Annotation of coherent/g/usr/lib/uucp/tay104/sysh.unx, revision 1.1.1.1

1.1       root        1: /* sysh.unx -*- C -*-
                      2:    The header file for the UNIX system dependent routines.
                      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: #ifndef SYSH_UNX_H
                     27: 
                     28: #define SYSH_UNX_H
                     29: 
                     30: #if ANSI_C
                     31: /* These structures are used in prototypes but are not defined in this
                     32:    header file.  */
                     33: struct uuconf_system;
                     34: struct sconnection;
                     35: #endif
                     36: 
                     37: /* Make sure the defines do not conflict.  These are in this file
                     38:    because they are Unix dependent.  */
                     39: #if HAVE_V2_LOCKFILES + HAVE_HDB_LOCKFILES + HAVE_SCO_LOCKFILES + HAVE_SVR4_LOCKFILES + HAVE_COHERENT_LOCKFILES != 1
                     40:  #error LOCKFILES define not set or duplicated
                     41: #endif
                     42: 
                     43: /* SCO and SVR4 lockfiles are basically just like HDB lockfiles.  */
                     44: #if HAVE_SCO_LOCKFILES || HAVE_SVR4_LOCKFILES
                     45: #undef HAVE_HDB_LOCKFILES
                     46: #define HAVE_HDB_LOCKFILES 1
                     47: #endif
                     48: 
                     49: #if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS != 1
                     50:  #error Terminal driver define not set or duplicated
                     51: #endif
                     52: 
                     53: #if SPOOLDIR_V2 + SPOOLDIR_BSD42 + SPOOLDIR_BSD43 + SPOOLDIR_HDB + SPOOLDIR_ULTRIX + SPOOLDIR_SVR4 + SPOOLDIR_TAYLOR != 1
                     54:  #error Spool directory define not set or duplicated
                     55: #endif
                     56: 
                     57: /* If setreuid is broken, don't use it.  */
                     58: #if HAVE_BROKEN_SETREUID
                     59: #undef HAVE_SETREUID
                     60: #define HAVE_SETREUID 0
                     61: #endif
                     62: 
                     63: /* Get some standard types from the configuration header file.  */
                     64: /*
                     65: #ifdef PID_T
                     66: typedef PID_T pid_t;
                     67: #endif
                     68: 
                     69: #ifdef UID_T
                     70: typedef UID_T uid_t;
                     71: #endif
                     72: 
                     73: #ifdef GID_T
                     74: typedef GID_T gid_t;
                     75: #endif
                     76: 
                     77: #ifdef OFF_T
                     78: typedef OFF_T off_t;
                     79: #endif
                     80: 
                     81: */
                     82: 
                     83: /* On Unix, binary files are the same as text files.  */
                     84: #define BINREAD "r"
                     85: #define BINWRITE "w"
                     86: 
                     87: /* If we have sigaction, we can force system calls to not be
                     88:    restarted.  */
                     89: #if HAVE_SIGACTION
                     90: #undef HAVE_RESTARTABLE_SYSCALLS
                     91: #define HAVE_RESTARTABLE_SYSCALLS 0
                     92: #endif
                     93: 
                     94: /* If we have sigvec, and we have HAVE_SIGVEC_SV_FLAGS, and
                     95:    SV_INTERRUPT is defined, we can force system calls to not be
                     96:    restarted (signal.h is included by uucp.h before this point, so
                     97:    SV_INTERRUPT will be defined by now if it it ever is).  */
                     98: #if HAVE_SIGVEC && HAVE_SIGVEC_SV_FLAGS
                     99: #ifdef SV_INTERRUPT
                    100: #undef HAVE_RESTARTABLE_SYSCALLS
                    101: #define HAVE_RESTARTABLE_SYSCALLS 0
                    102: #endif
                    103: #endif
                    104: 
                    105: /* If we were cross-configured, we will have a value of -1 for
                    106:    HAVE_RESTARTABLE_SYSCALLS.  In this case, we try to guess what the
                    107:    correct value should be.  Yuck.  If we have sigvec, but neither of
                    108:    the above cases applied (which we know because they would have
                    109:    changed HAVE_RESTARTABLE_SYSCALLS) then we are probably on 4.2BSD
                    110:    and system calls are automatically restarted.  Otherwise, assume
                    111:    that they are not.  */
                    112: #if HAVE_RESTARTABLE_SYSCALLS == -1
                    113: #undef HAVE_RESTARTABLE_SYSCALLS
                    114: #if HAVE_SIGVEC
                    115: #define HAVE_RESTARTABLE_SYSCALLS 1
                    116: #else
                    117: #define HAVE_RESTARTABLE_SYSCALLS 0
                    118: #endif
                    119: #endif /* HAVE_RESTARTABLE_SYSCALLS == -1 */
                    120: 
                    121: /* We don't handle sigset in combination with restartable system
                    122:    calls, so we check for it although this combination will never
                    123:    happen.  */
                    124: #if ! HAVE_SIGACTION && ! HAVE_SIGVEC && HAVE_SIGSET
                    125: #if HAVE_RESTARTABLE_SYSCALLS
                    126: #undef HAVE_SIGSET
                    127: #define HAVE_SIGSET 0
                    128: #endif
                    129: #endif
                    130: 
                    131: /* If we don't have restartable system calls, we can ignore
                    132:    fsysdep_catch, usysdep_start_catch and usysdep_end_catch.
                    133:    Otherwise fsysdep_catch has to do a setjmp.  */
                    134: 
                    135: #if ! HAVE_RESTARTABLE_SYSCALLS
                    136: 
                    137: #define fsysdep_catch() (TRUE)
                    138: #define usysdep_start_catch()
                    139: #define usysdep_end_catch()
                    140: #define CATCH_PROTECT
                    141: 
                    142: #else /* HAVE_RESTARTABLE_SYSCALLS */
                    143: 
                    144: #if HAVE_SETRET && ! HAVE_SIGSETJMP
                    145: #include <setret.h>
                    146: #define setjmp setret
                    147: #define longjmp longret
                    148: #define jmp_buf ret_buf
                    149: #else /* ! HAVE_SETRET || HAVE_SIGSETJMP */
                    150: #include <setjmp.h>
                    151: #if HAVE_SIGSETJMP
                    152: #undef setjmp
                    153: #undef longjmp
                    154: #undef jmp_buf
                    155: #define setjmp(s) sigsetjmp ((s), TRUE)
                    156: #define longjmp siglongjmp
                    157: #define jmp_buf sigjmp_buf
                    158: #endif /* HAVE_SIGSETJMP */
                    159: #endif /* ! HAVE_SETRET || HAVE_SIGSETJMP */
                    160: 
                    161: extern volatile sig_atomic_t fSjmp;
                    162: extern volatile jmp_buf sSjmp_buf;
                    163: 
                    164: #define fsysdep_catch() (setjmp (sSjmp_buf) == 0)
                    165: 
                    166: #define usysdep_start_catch() (fSjmp = TRUE)
                    167: 
                    168: #define usysdep_end_catch() (fSjmp = FALSE)
                    169: 
                    170: #define CATCH_PROTECT volatile
                    171: 
                    172: #endif /* HAVE_RESTARTABLE_SYSCALLS */
                    173: 
                    174: /* Get definitions for the terminal driver.  */
                    175: 
                    176: #if HAVE_BSD_TTY
                    177: #include <sgtty.h>
                    178: struct sbsd_terminal
                    179: {
                    180:   struct sgttyb stty;
                    181:   struct tchars stchars;
                    182:   struct ltchars sltchars;
                    183: };
                    184: typedef struct sbsd_terminal sterminal;
                    185: #define fgetterminfo(o, q) \
                    186:   (ioctl ((o), TIOCGETP, &(q)->stty) == 0 \
                    187:    && ioctl ((o), TIOCGETC, &(q)->stchars) == 0 \
                    188:    && ioctl ((o), TIOCGLTC, &(q)->sltchars) == 0)
                    189: #define fsetterminfo(o, q) \
                    190:   (ioctl ((o), TIOCSETN, &(q)->stty) == 0 \
                    191:    && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
                    192:    && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
                    193: #define fsetterminfodrain(o, q) \
                    194:   (ioctl ((o), TIOCSETP, &(q)->stty) == 0 \
                    195:    && ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
                    196:    && ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
                    197: #endif /* HAVE_BSD_TTY */
                    198: 
                    199: #if HAVE_SYSV_TERMIO
                    200: #include <termio.h>
                    201: typedef struct termio sterminal;
                    202: #define fgetterminfo(o, q) (ioctl ((o), TCGETA, (q)) == 0)
                    203: #define fsetterminfo(o, q) (ioctl ((o), TCSETA, (q)) == 0)
                    204: #define fsetterminfodrain(o, q) (ioctl ((o), TCSETAW, (q)) == 0)
                    205: #endif /* HAVE_SYSV_TERMIO */
                    206: 
                    207: #if HAVE_POSIX_TERMIOS
                    208: #include <termios.h>
                    209: typedef struct termios sterminal;
                    210: #define fgetterminfo(o, q) (tcgetattr ((o), (q)) == 0)
                    211: #define fsetterminfo(o, q) (tcsetattr ((o), TCSANOW, (q)) == 0)
                    212: #define fsetterminfodrain(o, q) (tcsetattr ((o), TCSADRAIN, (q)) == 0)
                    213: 
                    214: /* On some systems it is not possible to include both <sys/ioctl.h>
                    215:    and <termios.h> in the same source files; I don't really know why.
                    216:    On such systems, we pretend that we don't have <sys/ioctl.h>.  */
                    217: #if ! HAVE_TERMIOS_AND_SYS_IOCTL_H
                    218: #undef HAVE_SYS_IOCTL_H
                    219: #define HAVE_SYS_IOCTL_H 0
                    220: #endif
                    221: 
                    222: #endif /* HAVE_POSIX_TERMIOS */
                    223: 
                    224: /* The root directory (this is needed by the system independent stuff
                    225:    as the default for local-send).  */
                    226: #define ZROOTDIR "/"
                    227: 
                    228: /* The name of the execution directory within the spool directory
                    229:    (this is need by the system independent uuxqt.c).  */
                    230: #define XQTDIR ".Xqtdir"
                    231: 
                    232: /* The name of the directory in which we preserve file transfers that
                    233:    failed.  */
                    234: #define PRESERVEDIR ".Preserve"
                    235: 
                    236: /* The length of the sequence number used in a file name.  */
                    237: #define CSEQLEN (4)
                    238: 
                    239: /* Get some standard definitions.  Avoid including the files more than
                    240:    once--some might have been included by uucp.h.  */
                    241: #if USE_STDIO && HAVE_UNISTD_H
                    242: #include <unistd.h>
                    243: #endif
                    244: #if ! USE_TYPES_H
                    245: #include <sys/types.h>
                    246: #endif
                    247: #include <sys/stat.h>
                    248: 
                    249: /* Get definitions for the file permission bits.  */
                    250: 
                    251: #ifndef S_IRWXU
                    252: #define S_IRWXU 0700
                    253: #endif
                    254: #ifndef S_IRUSR
                    255: #define S_IRUSR 0400
                    256: #endif
                    257: #ifndef S_IWUSR
                    258: #define S_IWUSR 0200
                    259: #endif
                    260: #ifndef S_IXUSR
                    261: #define S_IXUSR 0100
                    262: #endif
                    263: 
                    264: #ifndef S_IRWXG
                    265: #define S_IRWXG 0070
                    266: #endif
                    267: #ifndef S_IRGRP
                    268: #define S_IRGRP 0040
                    269: #endif
                    270: #ifndef S_IWGRP
                    271: #define S_IWGRP 0020
                    272: #endif
                    273: #ifndef S_IXGRP
                    274: #define S_IXGRP 0010
                    275: #endif
                    276: 
                    277: #ifndef S_IRWXO
                    278: #define S_IRWXO 0007
                    279: #endif
                    280: #ifndef S_IROTH
                    281: #define S_IROTH 0004
                    282: #endif
                    283: #ifndef S_IWOTH
                    284: #define S_IWOTH 0002
                    285: #endif
                    286: #ifndef S_IXOTH
                    287: #define S_IXOTH 0001
                    288: #endif
                    289: 
                    290: #ifndef S_ISDIR
                    291: #ifdef S_IFDIR
                    292: #define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR)
                    293: #else /* ! defined (S_IFDIR) */
                    294: #define S_ISDIR(i) (((i) & 0170000) == 040000)
                    295: #endif /* ! defined (S_IFDIR) */
                    296: #endif /* ! defined (S_ISDIR) */
                    297: 
                    298: /* We need the access macros.  */
                    299: #ifndef R_OK
                    300: #define R_OK 4
                    301: #define W_OK 2
                    302: #define X_OK 1
                    303: #define F_OK 0
                    304: #endif /* ! defined (R_OK) */
                    305: 
                    306: /* We create files with these modes (should this be configurable?).  */
                    307: #define IPRIVATE_FILE_MODE (S_IRUSR | S_IWUSR)
                    308: #define IPUBLIC_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
                    309: 
                    310: /* We create directories with this mode (should this be configurable?).  */
                    311: #define IDIRECTORY_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
                    312: #define IPUBLIC_DIRECTORY_MODE (S_IRWXU | S_IRWXG | S_IRWXO)
                    313: 
                    314: #if ! HAVE_OPENDIR
                    315: 
                    316: /* Define some structures to use if we don't have opendir, etc.  These
                    317:    will only work if we have the old Unix filesystem, with a 2 byte
                    318:    inode and a 14 byte filename.  */
                    319: 
                    320: #include <sys/dir.h>
                    321: 
                    322: struct dirent
                    323: {
                    324:   char d_name[DIRSIZ + 1];
                    325: };
                    326: 
                    327: typedef struct
                    328: {
                    329:   int o;
                    330:   struct dirent s;
                    331: } DIR;
                    332: 
                    333: extern DIR *opendir P((const char *zdir));
                    334: extern struct dirent *readdir P((DIR *));
                    335: extern int closedir P((DIR *));
                    336: 
                    337: #endif /* ! HAVE_OPENDIR */
                    338: 
                    339: #if ! HAVE_FTW_H
                    340: 
                    341: /* If there is no <ftw.h>, define the ftw constants.  */
                    342: 
                    343: #define FTW_F (0)
                    344: #define FTW_D (1)
                    345: #define FTW_DNR (2)
                    346: #define FTW_NS (3)
                    347: 
                    348: #endif /* ! HAVE_FTW_H */
                    349: 
                    350: /* This structure holds the system dependent information we keep for a
                    351:    connection.  This is used by the TCP and TLI code.  */
                    352: 
                    353: struct ssysdep_conn
                    354: {
                    355:   /* File descriptor.  */
                    356:   int o;
                    357:   /* Device name.  */
                    358:   char *zdevice;
                    359:   /* File status flags.  */
                    360:   int iflags;
                    361:   /* File status flags for descriptor 1 (-1 if not standard input).  */
                    362:   int istdout_flags;
                    363:   /* Hold the real descriptor when using a dialer device.  */
                    364:   int ohold;
                    365:   /* TRUE if this is a terminal and the remaining fields are valid.  */
                    366:   boolean fterminal;
                    367:   /* TRUE if this is a TLI descriptor.  */
                    368:   boolean ftli;
                    369:   /* Baud rate.  */
                    370:   long ibaud;
                    371:   /* Original terminal settings.  */
                    372:   sterminal sorig;
                    373:   /* Current terminal settings.  */
                    374:   sterminal snew;
                    375: #if HAVE_COHERENT_LOCKFILES
                    376:   /* On Coherent we need to hold on to the real port name which will
                    377:      be used to enable the port.  Ick.  */
                    378:   char *zenable;
                    379: #endif
                    380: };
                    381: 
                    382: /* These functions do I/O and chat scripts to a port.  They are called
                    383:    by the TCP and TLI routines.  */
                    384: extern boolean fsysdep_conn_read P((struct sconnection *qconn,
                    385:                                    char *zbuf, size_t *pclen,
                    386:                                    size_t cmin, int ctimeout,
                    387:                                    boolean freport));
                    388: extern boolean fsysdep_conn_write P((struct sconnection *qconn,
                    389:                                     const char *zbuf, size_t clen));
                    390: extern boolean fsysdep_conn_io P((struct sconnection *qconn,
                    391:                                  const char *zwrite, size_t *pcwrite,
                    392:                                  char *zread, size_t *pcread));
                    393: extern boolean fsysdep_conn_chat P((struct sconnection *qconn,
                    394:                                    char **pzprog));
                    395: 
                    396: /* Set a signal handler.  */
                    397: extern void usset_signal P((int isig, RETSIGTYPE (*pfn) P((int)),
                    398:                            boolean fforce, boolean *pfignored));
                    399: 
                    400: /* Default signal handler.  This sets the appropriate element of the
                    401:    afSignal array.  If system calls are automatically restarted, it
                    402:    may do a longjmp to an fsysdep_catch.  */
                    403: extern RETSIGTYPE ussignal P((int isig));
                    404: 
                    405: /* Try to fork, repeating several times.  */
                    406: extern pid_t ixsfork P((void));
                    407: 
                    408: /* Spawn a job.  Returns the process ID of the spawned job or -1 on
                    409:    error.  The following macros may be passed in aidescs.  */
                    410: 
                    411: /* Set descriptor to /dev/null.  */
                    412: #define SPAWN_NULL (-1)
                    413: /* Set element of aidescs to a pipe for caller to read from.  */
                    414: #define SPAWN_READ_PIPE (-2)
                    415: /* Set element of aidescs to a pipe for caller to write to.  */
                    416: #define SPAWN_WRITE_PIPE (-3)
                    417: 
                    418: extern pid_t ixsspawn P((const char **pazargs, int *aidescs,
                    419:                         boolean fkeepuid, boolean fkeepenv,
                    420:                         const char *zchdir, boolean fnosigs,
                    421:                         boolean fshell, const char *zpath,
                    422:                         const char *zuu_machine,
                    423:                         const char *zuu_user));
                    424: 
                    425: /* Do a form of popen using ixsspawn.  */
                    426: extern FILE *espopen P((const char **pazargs, boolean frd,
                    427:                        pid_t *pipid));
                    428: 
                    429: /* Wait for a particular process to finish, returning the exit status.
                    430:    The process ID should be pid_t, but we can't put that in a
                    431:    prototype.  */
                    432: extern int ixswait P((unsigned long ipid, const char *zreport));
                    433: 
                    434: /* Find a spool file in the spool directory.  For a local file, the
                    435:    bgrade argument is the grade of the file.  This is needed for
                    436:    SPOOLDIR_SVR4.  */
                    437: extern char *zsfind_file P((const char *zsimple, const char *zsystem,
                    438:                            int bgrade));
                    439: 
                    440: /* Return the grade given a sequence number.  */
                    441: extern char bsgrade P((pointer pseq));
                    442: 
                    443: /* Lock a string.  */
                    444: extern boolean fsdo_lock P((const char *, boolean fspooldir,
                    445:                            boolean *pferr));
                    446: 
                    447: /* Unlock a string.  */
                    448: extern boolean fsdo_unlock P((const char *, boolean fspooldir));
                    449: 
                    450: /* Check access for a particular user name, or NULL to check access
                    451:    for any user.  */
                    452: extern boolean fsuser_access P((const struct stat *, int imode,
                    453:                                const char *zuser));
                    454: 
                    455: /* Stick two directories and a file name together.  */
                    456: extern char *zsappend3 P((const char *zdir1, const char *zdir2,
                    457:                          const char *zfile));
                    458: 
                    459: /* Stick three directories and a file name together.  */
                    460: extern char *zsappend4 P((const char *zdir1, const char *zdir2,
                    461:                          const char *zdir3, const char *zfile));
                    462: 
                    463: /* Get a temporary file name.  */
                    464: extern char *zstemp_file P((const struct uuconf_system *qsys));
                    465: 
                    466: /* Get a command file name.  */
                    467: extern char *zscmd_file P((const struct uuconf_system *qsys, int bgrade));
                    468: 
                    469: /* Get a jobid from a system, a file name, and a grade.  */
                    470: extern char *zsfile_to_jobid P((const struct uuconf_system *qsys,
                    471:                                const char *zfile,
                    472:                                int bgrade));
                    473: 
                    474: /* Get a file name from a jobid.  This also returns the associated system
                    475:    in *pzsystem and the grade in *pbgrade.  */
                    476: extern char *zsjobid_to_file P((const char *zid, char **pzsystem,
                    477:                                char *pbgrade));
                    478: 
                    479: /* See whether there is a spool directory for a system when using
                    480:    SPOOLDIR_ULTRIX.  */
                    481: extern boolean fsultrix_has_spool P((const char *zsystem));
                    482: 
                    483: #if HAVE_COHERENT_LOCKFILES
                    484: /* Lock a coherent tty.  */
                    485: extern boolean lockttyexist P((const char *z));
                    486: extern boolean fscoherent_disable_tty P((const char *zdevice,
                    487:                                         char **pzenable));
                    488: #endif
                    489: 
                    490: /* Some replacements for standard Unix functions.  */
                    491: 
                    492: #if ! HAVE_DUP2
                    493: extern int dup2 P((int oold, int onew));
                    494: #endif
                    495: 
                    496: #if ! HAVE_FTW
                    497: extern int ftw P((const char *zdir,
                    498:                  int (*pfn) P((const char *zfile,
                    499:                                const struct stat *qstat,
                    500:                                int iflag)),
                    501:                  int cdescriptors));
                    502: #endif
                    503: 
                    504: #if ! HAVE_GETCWD && ! HAVE_GETWD
                    505: extern char *getcwd P((char *zbuf, size_t cbuf));
                    506: #endif
                    507: 
                    508: #if ! HAVE_MKDIR
                    509: extern int mkdir P((const char *zdir, int imode));
                    510: #endif
                    511: 
                    512: #if ! HAVE_RENAME
                    513: extern int rename P((const char *zold, const char *znew));
                    514: #endif
                    515: 
                    516: #if ! HAVE_RMDIR
                    517: extern int rmdir P((const char *zdir));
                    518: #endif
                    519: 
                    520: /* The working directory from which the program was run (this is set
                    521:    by usysdep_initialize if called with INIT_GETCWD).  */
                    522: extern char *zScwd;
                    523: 
                    524: /* The spool directory name.  */
                    525: extern const char *zSspooldir;
                    526: 
                    527: /* The lock directory name.  */
                    528: extern const char *zSlockdir;
                    529: 
                    530: /* The local UUCP name (needed for some spool directory stuff).  */
                    531: extern const char *zSlocalname;
                    532: 
                    533: #endif /* ! defined (SYSH_UNX_H) */

unix.superglobalmegacorp.com

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