|
| 1 | +/* |
| 2 | +** ~ppr/src/include/global_defines.h |
| 3 | +** Copyright 1995, Trinity College Computing Center. |
| 4 | +** Written by David Chappell. |
| 5 | +** |
| 6 | +** Permission to use, copy, modify, and distribute this software and its |
| 7 | +** documentation for any purpose and without fee is hereby granted, provided |
| 8 | +** that the above copyright notice appear in all copies and that both that |
| 9 | +** copyright notice and this permission notice appear in supporting |
| 10 | +** documentation. This software and documentation are provided "as is" without |
| 11 | +** express or implied warranty. |
| 12 | +** |
| 13 | +** The PPR project was begun 28 December 1992. |
| 14 | +** |
| 15 | +** There are many things in this file you may want to change. This file |
| 16 | +** should be the first include file. It is the header file for the whole |
| 17 | +** project. |
| 18 | +** |
| 19 | +** This file was last modified 22 December 1995. |
| 20 | +*/ |
| 21 | + |
| 22 | +#include <stdio.h> |
| 23 | +#include <sys/types.h> |
| 24 | +#include <sys/stat.h> |
| 25 | +#include <stdarg.h> |
| 26 | + |
| 27 | +#define mode_t int |
| 28 | +/* |
| 29 | +** Define if we should include code to make GNU-C happy. |
| 30 | +** This generaly means initializing a variable to zero |
| 31 | +** in order to supress incorrect warnings about possibly |
| 32 | +** uninitialized variables. |
| 33 | +*/ |
| 34 | +#define GNUC_HAPPY 1 |
| 35 | + |
| 36 | +/* |
| 37 | +** Define if we want the spooler to keep superseeded |
| 38 | +** PostScript code as comments. These comments can be |
| 39 | +** useful in debuging. |
| 40 | +*/ |
| 41 | +#define KEEP_OLD_CODE 1 |
| 42 | + |
| 43 | +/* |
| 44 | +** Define various file names. |
| 45 | +** Those not begining with "/" origionate in HOMEDIR. |
| 46 | +** |
| 47 | +** Some of the names are defined only if they have not been defined |
| 48 | +** already. This is because one can make limited changes to PPR's |
| 49 | +** directory layout by editing the top of globak.mk. If you |
| 50 | +** do, the C compiler will be invoked with command line switches |
| 51 | +** which override the definitions here. |
| 52 | +*/ |
| 53 | +#ifndef HOMEDIR |
| 54 | +#define HOMEDIR "/usr/ppr" /* directory for most permanent files */ |
| 55 | +#endif |
| 56 | +#ifndef CONFDIR |
| 57 | +#define CONFDIR "/etc/ppr" /* top directory for all configuration files (must be absolute) */ |
| 58 | +#endif |
| 59 | +#ifndef VAR_SPOOL_PPR |
| 60 | +#define VAR_SPOOL_PPR "/var/spool/ppr" /* are for fixed path things */ |
| 61 | +#endif |
| 62 | +#ifndef TEMPDIR |
| 63 | +#define TEMPDIR "/tmp" /* for ordinary temporary files */ |
| 64 | +#endif |
| 65 | + |
| 66 | +#define NEXTIDFILE VAR_SPOOL_PPR"/nextid" /* file with next queue id number */ |
| 67 | +#define QUEUEDIR VAR_SPOOL_PPR"/queue" /* queue directory */ |
| 68 | +#define DATADIR VAR_SPOOL_PPR"/jobs" /* date directory */ |
| 69 | +#define FIFO_NAME VAR_SPOOL_PPR"/PIPE" /* name of pipe between ppr & pprd */ |
| 70 | +#define LOCKFILE VAR_SPOOL_PPR"/pprd.lock" /* created and locked by pprd */ |
| 71 | +#define ALERTDIR VAR_SPOOL_PPR"/alerts" /* directory for alert files */ |
| 72 | +#define LOGDIR VAR_SPOOL_PPR"/logs" /* directory for log files */ |
| 73 | +#define INTDIR "interfaces" /* directory for interface programs */ |
| 74 | +#define COMDIR "commentators" /* directory for commentator programs */ |
| 75 | +#define PRE_CACHEDIR "cache" /* pre-loaded cache files */ |
| 76 | +#define CACHEDIR VAR_SPOOL_PPR"/cache" /* directory for cache files */ |
| 77 | +#define RESPONDERDIR "responders" /* responder programs */ |
| 78 | +#define PPDDIR "PPDFiles" /* our PPD file library */ |
| 79 | +#define MOUNTEDDIR CONFDIR"/mounted" /* directory for media mounted files */ |
| 80 | +#define PRCONF CONFDIR"/printers" /* printer configuration files */ |
| 81 | +#define GRCONF CONFDIR"/groups" /* group configuration files */ |
| 82 | +#define DBNAME CONFDIR"/charge_users" /* users database file name */ |
| 83 | +#define DEFFILTOPTS CONFDIR"/deffiltopts" /* directory for default filter options */ |
| 84 | +#define GROUPSPPD CONFDIR"/groups.ppd" /* directory for auto-generated group PPD files */ |
| 85 | +#define FONTSUB CONFDIR"/fontsub" /* font substitution database */ |
| 86 | +#define MEDIAFILE CONFDIR"/media" /* media definitions */ |
| 87 | +#define PRINTLOG "printlog" /* needed so that pprd won't delete */ |
| 88 | +#define PRINTLOG_PATH LOGDIR"/"PRINTLOG /* log of jobs printed */ |
| 89 | + |
| 90 | +/* The paths of various programs which must be invoked. */ |
| 91 | +#define PPRDRV_PATH "lib/pprdrv" |
| 92 | +#define PPOP_PATH "bin/ppop" |
| 93 | +#define PPR_PATH "bin/ppr" |
| 94 | + |
| 95 | +/* |
| 96 | +** These are rather system dependent, so sysdep.h |
| 97 | +** may redefine many of these. We define them here |
| 98 | +** rather than waiting to defined them conditionally |
| 99 | +** after including sysdep.h for philisophical reasons. |
| 100 | +** We want to make it plain that these values will |
| 101 | +** apply to the vast majority of systems. |
| 102 | +*/ |
| 103 | +#define SHORT_INT short int /* a 16 bit number */ |
| 104 | +#define MAILPATH "/usr/lib/sendmail" /* mail program for alerting */ |
| 105 | +#define SHORT_PATH "/bin:/usr/bin" /* Secure path */ |
| 106 | + |
| 107 | +/* |
| 108 | +** Include system dependent modifications to the stuff above |
| 109 | +** and special defines necessary to compile on particular systems. |
| 110 | +*/ |
| 111 | + |
| 112 | +/* |
| 113 | +** some practical limits |
| 114 | +*/ |
| 115 | +#define MAX_LINE 1024 /* 8192 */ /* maximum PostScript input line length (now pretty meaningless) */ |
| 116 | +#define MAX_CONT 32 /* maximum segment represented by "%%+" */ |
| 117 | +#define MAX_TOKENIZED 512 /* longest line we may pass to tokenize() */ |
| 118 | +#define MAX_PATH 128 /* space to reserve for building a file name */ |
| 119 | +#define MAX_TOKENS 20 /* limit on words per comment line */ |
| 120 | + |
| 121 | +#define MAX_BINNAME 16 /* max chars in name of input bin */ |
| 122 | +#define MAX_MEDIANAME 16 /* max chars in media name */ |
| 123 | +#define MAX_COLOURNAME 16 /* max chars in colour name */ |
| 124 | +#define MAX_TYPENAME 16 /* max chars media type name */ |
| 125 | + |
| 126 | +#define MAX_DOCMEDIA 4 /* max media types per job */ |
| 127 | + |
| 128 | +#define QUEUE_SIZE 2000 /* 2000 entry queue */ |
| 129 | +#define MAX_DESTNAME 16 /* max length of destination name */ |
| 130 | +#define MAX_PRINTERS 150 /* no more than 150 printers */ |
| 131 | +#define MAX_BINS 4 /* max bins per printer */ |
| 132 | +#define MAX_GROUPS 150 /* no more than this may groups */ |
| 133 | +#define MAX_GROUPSIZE 8 /* no more than 8 printers per group */ |
| 134 | + |
| 135 | +#define MAX_QFLINE 150 /* Max length of queue file line (exclusive of newline and NULL) */ |
| 136 | +#define MAX_RESPONSE_METHOD 16 /* Max length of method name (responder name) */ |
| 137 | +#define MAX_RESPONSE_ADDRESS 256 /* Max length of address to pass to responder */ |
| 138 | + |
| 139 | +#define MAX_CONFLINE 255 /* Max length of config file line (exclusive of newline and NULL) */ |
| 140 | + |
| 141 | +/* |
| 142 | +** True/False values |
| 143 | +*/ |
| 144 | +#define APPLE_QUOTE 1 /* allow non-standard quote mark quoting */ |
| 145 | + |
| 146 | +/*=========================================================================*/ |
| 147 | +/* End of values you might want to change. */ |
| 148 | +/*=========================================================================*/ |
| 149 | + |
| 150 | +/*--------------------------------------------------- |
| 151 | +** external functions in libppr.a |
| 152 | +---------------------------------------------------*/ |
| 153 | +void *myalloc(size_t number, size_t size); |
| 154 | +void *myrealloc(void *ptr, size_t size); |
| 155 | +char *mystrdup(const char *string); |
| 156 | +void myfree(void *ptr); |
| 157 | +char *datestamp(void); |
| 158 | +void tokenize(void); |
| 159 | +extern char *tokens[]; |
| 160 | +void ASCIIZ_to_padded(char *padded, const char *asciiz, int len); |
| 161 | +void padded_to_ASCIIZ(char *asciiz, const char *padded, int len); |
| 162 | +int padded_cmp(const char *padded1, const char *padded2, int len); |
| 163 | +int ppr_sscanf(const char *string, const char *pattern, ...); |
| 164 | +void daemon(void); |
| 165 | +void valert(const char printername[], int dateflag, const char string[], va_list args); |
| 166 | +void alert(const char printername[], int dateflag, const char string[], ...); |
| 167 | +char *quote(const char *); |
| 168 | +double getdouble(const char *); |
| 169 | +char *dtostr(double); |
| 170 | +int torf(const char *s); |
| 171 | +int destination_protected(const char *destname); |
| 172 | +int icmp(const char *s1, const char *s2); |
| 173 | +int icmpn(const char *s1, const char *s2, int n); |
| 174 | +int lock_exclusive(int filenum, int waitmode); |
| 175 | +char *money(int amount_times_ten); |
| 176 | +char *jobid(const char *destname, int qid, int subid); |
| 177 | +int pagesize(const char *keyword, int *width, int *length, int *envelope); |
| 178 | +int disk_space(const char *path, int *free_blocks, int *free_files); |
| 179 | +char *noalloc_find_cached_resource(const char *res_type, const char *res_name, double version, int revision, int *new_revision, mode_t *mode); |
| 180 | +char *find_cached_resource(const char *res_type, const char *res_name, double version, int revision, int *new_revision, mode_t *mode); |
| 181 | +void wrap_string(char *target, const char *source, int width); |
| 182 | +int get_responder_width(const char *name); |
| 183 | +void options_start(const char *options_str); |
| 184 | +int options_get_one(char *name, int maxnamelen, char *value, int maxvaluelen); |
| 185 | +extern const char *options_string; |
| 186 | +extern const char *options_error; |
| 187 | +extern int options_error_context_index; |
| 188 | +extern int options_error_index; |
| 189 | +double convert_dimension(const char *string); |
| 190 | +void filter_option_error(int exlevel, const char *format, ...) __attribute__ ((noreturn)); |
| 191 | +const char *pap_strerror(int err); |
| 192 | +const char *nbp_strerror(int err); |
| 193 | +const char *pap_look_string(int n); |
| 194 | + |
| 195 | +/* NEEDS_STRSIGNAL may be defined in sysdep.h */ |
| 196 | +#ifdef NEEDS_STRSIGNAL |
| 197 | +const char *strsignal(int signum); |
| 198 | +#endif |
| 199 | + |
| 200 | +/* |
| 201 | +** Functions and constant which library callers must provide if they |
| 202 | +** call certain library functions. |
| 203 | +*/ |
| 204 | +void fatal(int exitval, const char *string, ...) __attribute__ ((noreturn)); |
| 205 | +void error(const char *string, ...); |
| 206 | +extern const int memory_exit; |
| 207 | + |
| 208 | +/* |
| 209 | +** Characters which are not allowed in printer |
| 210 | +** and group names. |
| 211 | +*/ |
| 212 | +#define DEST_DISALLOWED "/~.-" |
| 213 | + |
| 214 | +/* |
| 215 | +** TRUE and FALSE |
| 216 | +** The code makes liberal use of these macros. |
| 217 | +*/ |
| 218 | +#if !defined(FALSE) |
| 219 | +#define FALSE 0 |
| 220 | +#endif |
| 221 | +#if !defined(TRUE) |
| 222 | +#define TRUE !FALSE |
| 223 | +#endif |
| 224 | + |
| 225 | +/* |
| 226 | +** Define unix permission 755. We do this because just saying |
| 227 | +** 0755 is at least theoretically non-portable and because |
| 228 | +** this portable expression is long and unsightly. |
| 229 | +*/ |
| 230 | +#define UNIX_755 (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) |
| 231 | + |
| 232 | +/* |
| 233 | +** Values for torf(), a function which examines a string |
| 234 | +** and tries to determine whether it represents a true or |
| 235 | +** a false value. |
| 236 | +*/ |
| 237 | +#define ANSWER_UNKNOWN -1 |
| 238 | +#define ANSWER_FALSE 0 |
| 239 | +#define ANSWER_TRUE 1 |
| 240 | + |
| 241 | +/* |
| 242 | +** Types of PostScript langauge extensions: |
| 243 | +*/ |
| 244 | +#define EXTENSION_DPS 1 |
| 245 | +#define EXTENSION_CMYK 2 |
| 246 | +#define EXTENSION_Composite 4 |
| 247 | +#define EXTENSION_FileSystem 8 |
| 248 | + |
| 249 | +/* |
| 250 | +** Types of fax support: |
| 251 | +*/ |
| 252 | +#define FAXSUPPORT_NONE 0 |
| 253 | +#define FAXSUPPORT_Base 1 |
| 254 | + |
| 255 | +/* |
| 256 | +** "%%PageOrder:" settings |
| 257 | +*/ |
| 258 | +#define PAGEORDER_ASCEND 1 |
| 259 | +#define PAGEORDER_DESCEND -1 |
| 260 | +#define PAGEORDER_SPECIAL 0 |
| 261 | + |
| 262 | +/* |
| 263 | +** Valid banner and trailer options. |
| 264 | +*/ |
| 265 | +#define BANNER_DONTCARE 0 /* ppr submits the job with one */ |
| 266 | +#define BANNER_YESPLEASE 1 /* of these */ |
| 267 | +#define BANNER_NOTHANKYOU 2 |
| 268 | + |
| 269 | +#define BANNER_FORBIDDEN 0 /* the printer configuration includes one */ |
| 270 | +#define BANNER_DISCOURAGED 1 /* of these */ |
| 271 | +#define BANNER_ENCOURAGED 2 |
| 272 | +#define BANNER_REQUIRED 3 |
| 273 | +#define BANNER_INVALID 4 /* used to indicate invalid user input in ppad(8) */ |
| 274 | + |
| 275 | +/* |
| 276 | +** Job status values. |
| 277 | +** A positive value is the ID of a printer which |
| 278 | +** is currently printing the job. |
| 279 | +*/ |
| 280 | +#define STATUS_WAITING -1 /* waiting for printer */ |
| 281 | +#define STATUS_HELD -2 /* put on hold by user */ |
| 282 | +#define STATUS_WAITING4MEDIA -3 /* proper media not mounted */ |
| 283 | +#define STATUS_ARRESTED -4 /* auto put on hold because of job error */ |
| 284 | +#define STATUS_CANCEL -5 /* being canceled */ |
| 285 | + |
| 286 | +/* |
| 287 | +** Printer status values. |
| 288 | +*/ |
| 289 | +#define PRNSTATUS_IDLE 0 /* idle but ready to print */ |
| 290 | +#define PRNSTATUS_PRINTING 1 /* printing right now */ |
| 291 | +#define PRNSTATUS_CANCELING 2 /* canceling a job */ |
| 292 | +#define PRNSTATUS_FAULT 3 /* waiting for auto retry */ |
| 293 | +#define PRNSTATUS_ENGAGED 4 /* printer is printing for another computer */ |
| 294 | +#define PRNSTATUS_STARVED 5 /* starved for system resources */ |
| 295 | +#define PRNSTATUS_STOPT 6 /* stopt by user */ |
| 296 | +#define PRNSTATUS_STOPPING 7 /* will go to PRNSTATUS_STOPT at job end */ |
| 297 | +#define PRNSTATUS_HALTING 8 /* pprdrv being killed */ |
| 298 | +#define PRNSTATUS_DELETED 9 /* printer has been deleted */ |
| 299 | +#define PRNSTATUS_DELIBERATELY_DOWN 6 /* 1st non-printing value (stopt) */ |
| 300 | + |
| 301 | +/* |
| 302 | +** "%%ProofMode:" values. |
| 303 | +*/ |
| 304 | +#define PROOFMODE_NOTIFYME -1 |
| 305 | +#define PROOFMODE_SUBSTITUTE 0 /* default mode */ |
| 306 | +#define PROOFMODE_TRUSTME 1 |
| 307 | + |
| 308 | +/* |
| 309 | +** Signiture part values. |
| 310 | +*/ |
| 311 | +#define SIG_FRONTS 1 |
| 312 | +#define SIG_BACKS -1 |
| 313 | +#define SIG_BOTH 0 |
| 314 | + |
| 315 | +/* |
| 316 | +** Flags stored in the unix file permissions of a font: |
| 317 | +*/ |
| 318 | +#define FONT_MACTRUETYPE S_IXUSR /* Is a Macintosh TrueType font in PostScript form */ |
| 319 | +#define FONT_TYPE1 S_IXGRP /* Type 1 components present */ |
| 320 | +#define FONT_TYPE42 S_IXOTH /* Type 42 components present */ |
| 321 | + |
| 322 | +/* |
| 323 | +** Valid TrueType rasterizer settings. |
| 324 | +*/ |
| 325 | +#define TT_UNKNOWN 0 |
| 326 | +#define TT_NONE 1 |
| 327 | +#define TT_ACCEPT68K 2 |
| 328 | +#define TT_TYPE42 3 |
| 329 | + |
| 330 | + |
| 331 | +/* end of file */ |
0 commit comments