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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _LP_LP_H
#define _LP_LP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <dirent.h>
/*
* Types:
*/
typedef struct SCALED {
float val; /* value of number, scaled according to "sc" */
char sc; /* 'i' inches, 'c' centimeters, ' ' lines/cols */
} SCALED;
typedef struct FALERT {
char *shcmd; /* shell command used to perform the alert */
int Q; /* # requests queued to activate alert */
int W; /* alert is sent every "W" minutes */
} FALERT;
#define LP_USE_PAPI_ATTR 1 /* use PAPI attributes for printing */
/* TODO: is this best place for this ? */
/*
* Places:
*/
/*
* These functions no longer exist. The defines take care
* of recompiling code that expects these and the null functions
* in getpaths.c take care of relinking objects that expect these.
*/
#define getpaths()
#define getadminpaths(x)
#define LPDIR "/usr/lib/lp"
#define ETCDIR "/etc/lp"
#define SPOOLDIR "/var/spool/lp"
#define LOGDIR "/var/lp/logs"
#define TERMINFO "/usr/share/lib/terminfo"
#define LPUSER "lp"
#define ROOTUSER "root"
#define BANG_S "!"
#define BANG_C '!'
#define LOCAL_LPUSER BANG_S LPUSER
#define LOCAL_ROOTUSER BANG_S ROOTUSER
#define ALL_BANG_ALL NAME_ALL BANG_S NAME_ALL
/* #define ADMINSDIR "admins" */
/* # define CLASSESDIR "classes" */
/* # define FORMSDIR "forms" */
/* # define INTERFACESDIR "interfaces" */
/* # define PRINTERSDIR "printers" */
/* # define PRINTWHEELSDIR "pwheels" */
/* #define BINDIR "bin" */
/* #define LOGSDIR "logs" */
/* #define MODELSDIR "model" */
/* #define NETWORKDIR "network" */
#define FIFOSDIR "fifos"
/* # define PRIVFIFODIR "private" */
/* # define PUBFIFODIR "public" */
/* #define REQUESTSDIR "requests" */
/* #define SYSTEMDIR "system" */
/* #define TEMPDIR "temp" */
/* #define TMPDIR "tmp" */
/* #define SCHEDLOCK "SCHEDLOCK" */
/* #define FIFO "FIFO" */
#define FILTERTABLE "filter.table"
#define FILTERTABLE_I "filter.table.i"
/* #define DESCRIBEFILE "describe" */
/* #define ALIGNFILE "align_ptrn" */
#define COMMENTFILE "comment"
#define ALLOWFILE "allow"
#define DENYFILE "deny"
#define ALERTSHFILE "alert.sh"
#define ALERTVARSFILE "alert.vars"
#define ALERTPROTOFILE "alert.proto"
#define CONFIGFILE "configuration"
#define FACCESSPREFIX "forms."
#define PACCESSPREFIX "paper."
#define UACCESSPREFIX "users."
#define FALLOWFILE FACCESSPREFIX ALLOWFILE
#define FDENYFILE FACCESSPREFIX DENYFILE
#define UALLOWFILE UACCESSPREFIX ALLOWFILE
#define UDENYFILE UACCESSPREFIX DENYFILE
/* #define DEFAULTFILE "default" */
#define STATUSFILE "status"
/* #define USERSFILE "users" */
/* #define NAMEFILE "name" */
/* #define XFERFILE "transfer" */
/* #define EXECFILE "execute" */
#define PSTATUSFILE "pstatus"
#define CSTATUSFILE "cstatus"
/* #define REQLOGFILE "requests" */
#define STANDARD "standard"
/* #define SLOWFILTER "slow.filter" */
#define FAULTMESSAGEFILE "faultMessage"
#define FORMMESSAGEFILE "formMessage"
#define LPNET "/usr/lib/lp/lpNet"
#ifdef LP_USE_PAPI_ATTR
#define STANDARD_FOOMATIC "standard_foomatic"
/*
* The default model interface script to use if a printer is configured
* with a PPD (PostScript Printer Definition) file.
*/
#define LP_PAPIATTRNAME "attributes"
/*
* Job attributes filename extension,
* eg. /var/spool/lp/temp/123-attributes
*/
#endif
/*
* Names and phrases:
*/
/*
* If you change these from macros to defined (char *) strings,
* be aware that in several places the lengths of the strings
* are computed using "sizeof()", not "strlen()"!
*/
#define NAME_ALL "all"
#define NAME_ANY "any"
#define NAME_NONE "none"
#define NAME_TERMINFO "terminfo"
#define NAME_SIMPLE "simple"
#define NAME_HOLD "hold"
#define NAME_RESUME "resume"
#define NAME_IMMEDIATE "immediate"
#define NAME_CONTINUE "continue"
#define NAME_BEGINNING "beginning"
#define NAME_WAIT "wait"
#define NAME_MAIL "mail"
#define NAME_WRITE "write"
#define NAME_QUIET "quiet"
#define NAME_LIST "list"
#define NAME_ON "on"
#define NAME_OFF "off"
#define NAME_OPTIONAL "optional"
#define NAME_ALWAYS "Always"
#define NAME_UNKNOWN "unknown"
#define NAME_REJECTING "rejecting"
#define NAME_ACCEPTING "accepting"
#define NAME_DISABLED "disabled"
#define NAME_ENABLED "enabled"
#define NAME_DIRECT "direct"
#define NAME_PICA "pica"
#define NAME_ELITE "elite"
#define NAME_COMPRESSED "compressed"
#define NAME_ALLOW "allow"
#define NAME_DENY "deny"
#define NAME_ONCE "once"
#define NAME_DEFAULT "default"
#define NAME_KEEP "keep"
/*
* Common messages:
*/
#define CUZ_NEW_PRINTER "new printer"
#define CUZ_NEW_DEST "new destination"
#define CUZ_STOPPED "stopped with printer fault"
#define CUZ_FAULT "printer fault"
#define CUZ_LOGIN_PRINTER "disabled by Spooler: login terminal"
#define CUZ_MOUNTING "mounting a form"
#define CUZ_NOFORK "can't fork"
#define CUZ_PRINTING_OK "ready and printing"
#define TIMEOUT_FAULT \
"Timed-out trying to open the printer port.\n"
#define OPEN_FAULT \
"Failed to open the printer port.\n"
#define PUSH_FAULT \
"Failed to push module(s) onto the printer port stream.\n"
/*
* When the Spooler detected the hangup, this message is used.
*/
#define HANGUP_FAULT \
"The connection to the printer dropped; perhaps the printer went off-line!\n"
/*
* When lp.cat detected the hangup, this message is used.
*/
#define HANGUP_FAULT_LPCAT \
"The connection to the printer dropped; perhaps the printer went off-line.\n"
#define INTERRUPT_FAULT \
"Received an interrupt from the printer. The reason is unknown,\n\
although a common cause is that the printer's buffer capacity\n\
was exceeded. Using XON/XOFF flow control, adding carriage-return\n\
delays, or lowering the baud rate may fix the problem.\n\
See stty(1) and lpadmin(8) man-pages for help in doing this.\n"
#define PIPE_FAULT \
"The output ``port'', a FIFO, was closed before all output was written.\n"
#define EXIT_FAULT \
"The interface program returned with a reserved exit code.\n"
/*
* Lp-errno #defines, etc.
*/
#define LP_EBADSDN 1
#define LP_EBADINT 2
#define LP_EBADNAME 3
#define LP_EBADARG 4
#define LP_ETRAILIN 5
#define LP_ENOCMT 6
#define LP_EBADCTYPE 7
#define LP_ENOALP 8
#define LP_ENULLPTR 9
#define LP_EBADHDR 10
#define LP_ETEMPLATE 11
#define LP_EKEYWORD 12
#define LP_EPATTERN 13
#define LP_ERESULT 14
#define LP_EREGEX 15 /* and see extern int regerrno, regexpr(3GEN) */
#define LP_ENOMEM 99
extern int lp_errno;
/*
* Misc. Macros
*/
#define LP_WS " " /* Whitespace (also list separator) */
#define LP_SEP "," /* List separator */
#define LP_QUOTES "'\""
#define MAIL "mail"
#define WRITE "write"
#define STATUS_BREAK "=========="
#define STREQU(A, B) ((!(A) || !(B)) ? 0 : (strcmp((A), (B)) == 0))
#define STRNEQU(A, B, N) ((!(A) || !(B)) ? 0 : (strncmp((A), (B), (N)) == 0))
#define CS_STREQU(A, B) (cs_strcmp((A), (B)) == 0)
#define CS_STRNEQU(A, B, N) (cs_strncmp((A), (B), (N)) == 0)
#define STRSIZE(X) (sizeof (X) - 1)
/*
* Almost STREQU but compares null pointers as equal, too.
*/
#define SAME(A, B) ((A) == (B) || (A) && (B) && STREQU((A), (B)))
#define PRINTF (void)printf
#define SPRINTF (void)sprintf
#define FPRINTF (void)fprintf
#define NB(X) (X? X : "")
#define PERROR strerror(errno)
/*
* Largest number we'll ever expect to get from doing %ld in printf,
* as a string and number. ULONG_MAX from limits.h gives us the number,
* but I can't figure out how to get that into a string.
*/
#define BIGGEST_NUMBER ULONG_MAX
#define BIGGEST_NUMBER_S "4294967295"
/*
* Largest request ID (numerical part), as string and number.
* See comment above.
*/
#define BIGGEST_REQID 999999
#define BIGGEST_REQID_S "999999"
/*
* Maximum number of files queued per request, as string and number.
* See earlier comment above.
*/
#define MOST_FILES 999999
#define MOST_FILES_S "999999"
/*
* Alert macros:
*/
/*
* Type of alert to be S_QUIET'd
*/
#define QA_FORM 1
#define QA_PRINTER 2
#define QA_PRINTWHEEL 3
/*
* File modes:
* (The "NO" prefix is relative to ``others''.)
*/
#define MODE_READ (mode_t)0664
#define MODE_NOREAD (mode_t)0660
#define MODE_EXEC (mode_t)0775
#define MODE_NOEXEC (mode_t)0770
#define MODE_DIR (mode_t)0775
#define MODE_NODIR (mode_t)0770
extern int printlist_qsep;
extern char Lp_Spooldir[],
Lp_Admins[],
Lp_Bin[],
Lp_FIFO[],
Lp_Logs[],
Lp_ReqLog[],
Lp_Model[],
Lp_Requests[],
Lp_Secure[],
Lp_Schedlock[],
Lp_Slow_Filter[],
Lp_System[],
Lp_Temp[],
Lp_Tmp[],
Lp_Users[],
Lp_A[],
Lp_A_Classes[],
Lp_A_Forms[],
Lp_A_Interfaces[],
Lp_A_Logs[],
Lp_A_Printers[],
Lp_A_PrintWheels[],
Lp_A_Filters[],
Lp_A_Systems[],
Lp_Default[],
Lp_A_Faults[];
/*
* File access:
*/
extern int open_locked(char *, char *, mode_t);
extern char *fdgets(char *, int, int);
extern int fdprintf(int, char *, ...);
extern int fdputs(char *, int);
extern int fdputc(char, int);
extern int is_printer_uri(char *);
FILE *open_lpfile(char *, char *, mode_t);
int close_lpfile(FILE *);
int chown_lppath(char *);
int mkdir_lpdir(char *, int);
int rmfile(char *);
int dumpstring(char *, char *);
char *loadstring(char *);
char *loadline(char *);
char *sop_up_rest(int, char *);
/*
* List manipulation routines:
*/
#define emptylist(LP) (!(LP) || !(LP)[0])
int addlist(char ***, char *);
int addstring(char **, char *);
int appendlist(char ***, char *);
int dellist(char ***, char *);
int joinlist(char ***, char **);
int lenlist(char **);
int printlist(FILE *, char **);
int fdprintlist(int, char **);
int searchlist(char *, char **);
int searchlist_with_terminfo(char *, char **);
char **duplist(char **);
char **getlist(char *, char *, char *);
char **dashos(char *);
char **wherelist(char *, char **);
char *sprintlist(char **);
char *search_cslist(char *, char **);
void freelist(char **);
void printlist_setup(char *, char *, char *, char *);
void printlist_unsetup(void);
/*
* Scaled decimal number routines:
*/
#define getsdn(S) _getsdn(S, (char **)0, 0)
#define getcpi(S) _getsdn(S, (char **)0, 1)
#define N_COMPRESSED 9999
void printsdn(FILE *, SCALED);
void fdprintsdn(int, SCALED);
void printsdn_setup(char *, char *, char *);
void printsdn_unsetup(void);
SCALED _getsdn(char *, char **, int);
/*
* File name routines:
*/
char *makepath(char *, ...);
char *getspooldir(void);
char *getrequestfile(char *);
char *getprinterfile(char *, char *);
char *getsystemfile(char *, char *);
char *getclassfile(char *);
char *getfilterfile(char *);
char *getformfile(char *, char *);
/*
* Additional string manipulation routines:
*/
int cs_strcmp(char *, char *);
int cs_strncmp(char *, char *, int);
/*
* Syntax checking routines:
*/
int syn_name(char *);
int syn_text(char *);
int syn_comment(char *);
int syn_machine_name(char *);
int syn_option(char *);
/*
* Alert management routines:
*/
int putalert(char *, char *, FALERT *);
int delalert(char *, char *);
FALERT *getalert(char *, char *);
void printalert(FILE *, FALERT *, int);
/*
* Terminfo Database Inquiry Tool
*/
int tidbit(char *, char *, ...);
void untidbit(char *);
/*
* Auto-restarting and other system calls:
* The two versions are here to reduce the chance of colliding
* with similar names in standard libraries (e.g. dial(3C) uses
* Read/Write).
*/
#define Access _Access
#define Chdir _Chdir
#define Chmod _Chmod
#define Chown _Chown
#define Close _Close
#define Creat _Creat
#define Fcntl _Fcntl
#define Fstat _Fstat
#define Link _Link
#define Lstat _Lstat
#define Mknod _Mknod
#define Open _Open
#define Read _Read
#define Readlink _Readlink
#define Rename _Rename
#define Stat _Stat
#define Symlink _Symlink
#define Unlink _Unlink
#define Wait _Wait
#define Write _Write
#define Malloc(size) _Malloc(size, __FILE__, __LINE__)
#define Realloc(ptr, size) _Realloc(ptr, size, __FILE__, __LINE__)
#define Calloc(nelem, elsize) _Calloc(nelem, elsize, __FILE__, __LINE__)
#define Strdup(s) _Strdup(s, __FILE__, __LINE__)
#define Free(ptr) _Free(ptr, __FILE__, __LINE__)
int _Access(char *, int);
int _Chdir(char *);
int _Chmod(char *, int);
int _Chown(char *, int, int);
int _Close(int);
int _Creat(char *, int);
int _Fcntl(int, int, ...);
int _Fstat(int, struct stat *);
int _Link(char *, char *);
int _Lstat(char *, struct stat *);
int _Mknod(char *, int, int);
int _Mkpipe(char *, int, int);
int _Open(char *, int, ... /* mode_t */);
int _Read(int, char *, unsigned int);
int _Readlink(char *, char *, unsigned int);
int _Rename(char *, char *);
int _Symlink(char *, char *);
int _Stat(char *, struct stat *);
int _Unlink(char *);
int _Wait(int *);
int _Write(int, char *, unsigned int);
void *_Malloc(size_t, const char *, int);
void *_Realloc(void *, size_t, const char *, int);
void *_Calloc(size_t, size_t, const char *, int);
char *_Strdup(const char *, const char *, int);
void _Free(void *, const char *, int);
/*
* Misc. routines:
*/
int isterminfo(char *);
int isprinter(char *);
int isrequest(char *);
int isnumber(char *);
char *getname(void);
char *makestr(char *, ...);
char *strip(char *);
void sendmail(char *, char *);
extern void (*lp_alloc_fail_handler)(void);
/*
* Originally part of liblpfs.a and fs.h, now no longer needed
* since the code doesn't have to work on pre-SVR4.0.
*/
#define Opendir opendir
#define Telldir telldir
#define Seekdir seekdir
#define Rewinddir(dirp) Seekdir(dirp, 0L)
#define Closedir closedir
#define Readdir readdir
#define Mkdir mkdir
#define Rmdir rmdir
#define next_dir(base, ptr) next_x(base, ptr, S_IFDIR)
#define next_file(base, ptr) next_x(base, ptr, S_IFREG)
extern int chownmod(char *, uid_t, gid_t, mode_t);
char *next_x(char *, long *, unsigned int);
/*
* Stuff needed for Trusted Extensions
*/
extern char *get_labeled_zonename(char *);
extern int get_peer_label(int, char **);
#ifdef __cplusplus
}
#endif
#endif /* _LP_LP_H */
|