1/* syshdr.h -*- C -*- 2 Unix system header for the uuconf library. 3 4 Copyright (C) 1992, 1993, 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 author of the program may be contacted at ian@airs.com. 23 */ 24 25/* The root directory (used when setting local-send and local-receive 26 values). */ 27#define ZROOTDIR "/" 28 29/* The current directory (used by uuconv as a prefix for the newly 30 created file names). */ 31#define ZCURDIR "." 32 33/* The names of the Taylor UUCP configuration files. These are 34 appended to NEWCONFIGLIB which is defined in Makefile. */ 35#define CONFIGFILE "/config" 36#define SYSFILE "/sys" 37#define PORTFILE "/port" 38#define DIALFILE "/dial" 39#define CALLFILE "/call" 40#define PASSWDFILE "/passwd" 41#define DIALCODEFILE "/dialcode" 42 43/* The names of the various V2 configuration files. These are 44 appended to OLDCONFIGLIB which is defined in Makefile. */ 45#define V2_SYSTEMS "/L.sys" 46#define V2_DEVICES "/L-devices" 47#define V2_USERFILE "/USERFILE" 48#define V2_CMDS "/L.cmds" 49#define V2_DIALCODES "/L-dialcodes" 50 51/* The names of the HDB configuration files. These are appended to 52 OLDCONFIGLIB which is defined in Makefile. */ 53#define HDB_SYSFILES "/Sysfiles" 54#define HDB_SYSTEMS "/Systems" 55#define HDB_PERMISSIONS "/Permissions" 56#define HDB_DEVICES "/Devices" 57#define HDB_DIALERS "/Dialers" 58#define HDB_DIALCODES "/Dialcodes" 59#define HDB_MAXUUXQTS "/Maxuuxqts" 60#define HDB_REMOTE_UNKNOWN "/remote.unknown" 61 62/* A string which is inserted between the value of OLDCONFIGLIB 63 (defined in the Makefile) and any names specified in the HDB 64 Sysfiles file. */ 65#define HDB_SEPARATOR "/" 66 67/* A macro to check whether fopen failed because the file did not 68 exist. */ 69#define FNO_SUCH_FILE() (errno == ENOENT) 70 71#if ! HAVE_STRERROR 72 73/* We need a definition for strerror; normally the function in the 74 unix directory is used, but we want to be independent of that 75 library. This macro evaluates its argument multiple times. */ 76extern int sys_nerr; 77extern char *sys_errlist[]; 78 79#define strerror(ierr) \ 80 ((ierr) >= 0 && (ierr) < sys_nerr ? sys_errlist[ierr] : "unknown error") 81 82#endif /* ! HAVE_STRERROR */ 83 84/* This macro is used to make a filename found in a configuration file 85 into an absolute path. The zdir argument is the directory to put it 86 in. The zset argument is set to the new string. The fallocated 87 argument is set to TRUE if the new string was allocated. */ 88#define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \ 89 do \ 90 { \ 91 if (*(zfile) == '/') \ 92 { \ 93 (zset) = (zfile); \ 94 (fallocated) = FALSE; \ 95 } \ 96 else \ 97 { \ 98 size_t abs_cdir, abs_cfile; \ 99 char *abs_zret; \ 100\ 101 abs_cdir = strlen (zdir); \ 102 abs_cfile = strlen (zfile); \ 103 abs_zret = (char *) uuconf_malloc ((pblock), \ 104 abs_cdir + abs_cfile + 2); \ 105 (zset) = abs_zret; \ 106 (fallocated) = TRUE; \ 107 if (abs_zret != NULL) \ 108 { \ 109 memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \ 110 abs_zret[abs_cdir] = '/'; \ 111 memcpy ((pointer) (abs_zret + abs_cdir + 1), \ 112 (pointer) (zfile), abs_cfile + 1); \ 113 } \ 114 } \ 115 } \ 116 while (0) 117 118/* We want to be able to mark the Taylor UUCP system files as close on 119 exec. */ 120#if HAVE_FCNTL_H 121#include <fcntl.h> 122#else 123#if HAVE_SYS_FILE_H 124#include <sys/file.h> 125#endif 126#endif 127 128#ifndef FD_CLOEXEC 129#define FD_CLOEXEC 1 130#endif 131 132#define CLOSE_ON_EXEC(e) \ 133 do \ 134 { \ 135 int cle_i = fileno (e); \ 136 \ 137 fcntl (cle_i, F_SETFD, fcntl (cle_i, F_GETFD, 0) | FD_CLOEXEC); \ 138 } \ 139 while (0) 140