aboutsummaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libuuconf/syshdr.h
blob: b5a759fd1a6c790e5cf8d945f60607e25883251f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* syshdr.unx -*- C -*-
   Unix system header for the uuconf library.

   Copyright (C) 1992, 1993 Ian Lance Taylor

   This file is part of the Taylor UUCP uuconf library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License
   as published by the Free Software Foundation; either version 2 of
   the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   The author of the program may be contacted at ian@airs.com or
   c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
   */

/* The root directory (used when setting local-send and local-receive
   values).  */
#define ZROOTDIR "/"

/* The current directory (used by uuconv as a prefix for the newly
   created file names).  */
#define ZCURDIR "."

/* The names of the Taylor UUCP configuration files.  These are
   appended to NEWCONFIGLIB which is defined in Makefile.  */
#define CONFIGFILE "/config"
#define SYSFILE "/sys"
#define PORTFILE "/port"
#define DIALFILE "/dial"
#define CALLFILE "/call"
#define PASSWDFILE "/passwd"
#define DIALCODEFILE "/dialcode"

/* The names of the various V2 configuration files.  These are
   appended to OLDCONFIGLIB which is defined in Makefile.  */
#define V2_SYSTEMS "/L.sys"
#define V2_DEVICES "/L-devices"
#define V2_USERFILE "/USERFILE"
#define V2_CMDS "/L.cmds"
#define V2_DIALCODES "/L-dialcodes"

/* The names of the HDB configuration files.  These are appended to
   OLDCONFIGLIB which is defined in Makefile.  */
#define HDB_SYSFILES "/Sysfiles"
#define HDB_SYSTEMS "/Systems"
#define HDB_PERMISSIONS "/Permissions"
#define HDB_DEVICES "/Devices"
#define HDB_DIALERS "/Dialers"
#define HDB_DIALCODES "/Dialcodes"
#define HDB_MAXUUXQTS "/Maxuuxqts"
#define HDB_REMOTE_UNKNOWN "/remote.unknown"

/* A string which is inserted between the value of OLDCONFIGLIB
   (defined in the Makefile) and any names specified in the HDB
   Sysfiles file.  */
#define HDB_SEPARATOR "/"

/* A macro to check whether fopen failed because the file did not
   exist.  */
#define FNO_SUCH_FILE() (errno == ENOENT)

#if ! HAVE_STRERROR

/* We need a definition for strerror; normally the function in the
   unix directory is used, but we want to be independent of that
   library.  This macro evaluates its argument multiple times.  */
extern int sys_nerr;
extern char *sys_errlist[];

#define strerror(ierr) \
  ((ierr) >= 0 && (ierr) < sys_nerr ? sys_errlist[ierr] : "unknown error")

#endif /* ! HAVE_STRERROR */

/* This macro is used to make a filename found in a configuration file
   into an absolute path.  The zdir argument is the directory to put it
   in.  The zset argument is set to the new string.  The fallocated
   argument is set to TRUE if the new string was allocated.  */
#define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \
  do \
    { \
      if (*(zfile) == '/') \
	{ \
	  (zset) = (zfile); \
	  (fallocated) = FALSE; \
	} \
      else \
	{ \
	  size_t abs_cdir, abs_cfile; \
	  char *abs_zret; \
\
	  abs_cdir = strlen (zdir); \
	  abs_cfile = strlen (zfile); \
	  abs_zret = (char *) uuconf_malloc ((pblock), \
					     abs_cdir + abs_cfile + 2); \
	  (zset) = abs_zret; \
	  (fallocated) = TRUE; \
	  if (abs_zret != NULL) \
	    { \
	      memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \
	      abs_zret[abs_cdir] = '/'; \
	      memcpy ((pointer) (abs_zret + abs_cdir + 1), \
		      (pointer) (zfile), abs_cfile + 1); \
	    } \
	} \
    } \
  while (0)

/* We want to be able to mark the Taylor UUCP system files as close on
   exec.  */
#if HAVE_FCNTL_H
#include <fcntl.h>
#else
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#endif

#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif

#define CLOSE_ON_EXEC(e) \
  do \
    { \
      int cle_i = fileno (e); \
 \
      fcntl (cle_i, F_SETFD, fcntl (cle_i, F_GETFD, 0) | FD_CLOEXEC); \
    } \
  while (0)