xref: /illumos-gate/usr/src/cmd/lp/include/lp.h (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2245916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
287c478bd9Sstevel@tonic-gate 
29ace1a5f1Sdp #ifndef _LP_LP_H
30ace1a5f1Sdp #define	_LP_LP_H
317c478bd9Sstevel@tonic-gate 
32ace1a5f1Sdp #ifdef __cplusplus
33ace1a5f1Sdp extern "C" {
34ace1a5f1Sdp #endif
357c478bd9Sstevel@tonic-gate 
36ace1a5f1Sdp #include <errno.h>
37ace1a5f1Sdp #include <fcntl.h>
38ace1a5f1Sdp #include <sys/types.h>
39ace1a5f1Sdp #include <sys/stat.h>
40ace1a5f1Sdp #include <stdio.h>
41ace1a5f1Sdp #include <dirent.h>
427c478bd9Sstevel@tonic-gate 
431d4c48c4SToomas Soome /*
441d4c48c4SToomas Soome  * Types:
451d4c48c4SToomas Soome  */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate typedef struct SCALED {
487c478bd9Sstevel@tonic-gate 	float	val;	/* value of number, scaled according to "sc" */
497c478bd9Sstevel@tonic-gate 	char	sc;	/* 'i' inches, 'c' centimeters, ' ' lines/cols */
507c478bd9Sstevel@tonic-gate }			SCALED;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate typedef struct FALERT {
537c478bd9Sstevel@tonic-gate 	char	*shcmd;	/* shell command used to perform the alert */
547c478bd9Sstevel@tonic-gate 	int	Q;	/* # requests queued to activate alert */
557c478bd9Sstevel@tonic-gate 	int	W;	/* alert is sent every "W" minutes */
567c478bd9Sstevel@tonic-gate } FALERT;
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	LP_USE_PAPI_ATTR 1	/* use PAPI attributes for printing */
607c478bd9Sstevel@tonic-gate 				/* TODO: is this best place for this ? */
617c478bd9Sstevel@tonic-gate 
621d4c48c4SToomas Soome /*
631d4c48c4SToomas Soome  * Places:
641d4c48c4SToomas Soome  */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * These functions no longer exist.  The defines take care
687c478bd9Sstevel@tonic-gate  * of recompiling code that expects these and the null functions
697c478bd9Sstevel@tonic-gate  * in getpaths.c take care of relinking objects that expect these.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate #define	getpaths()
727c478bd9Sstevel@tonic-gate #define	getadminpaths(x)
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #define	LPDIR		"/usr/lib/lp"
757c478bd9Sstevel@tonic-gate #define	ETCDIR		"/etc/lp"
767c478bd9Sstevel@tonic-gate #define	SPOOLDIR	"/var/spool/lp"
777c478bd9Sstevel@tonic-gate #define	LOGDIR		"/var/lp/logs"
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #define	TERMINFO	"/usr/share/lib/terminfo"
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate #define	LPUSER		"lp"
827c478bd9Sstevel@tonic-gate #define	ROOTUSER	"root"
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	BANG_S		"!"
857c478bd9Sstevel@tonic-gate #define	BANG_C		'!'
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	LOCAL_LPUSER	BANG_S LPUSER
887c478bd9Sstevel@tonic-gate #define	LOCAL_ROOTUSER	BANG_S ROOTUSER
897c478bd9Sstevel@tonic-gate #define	ALL_BANG_ALL	NAME_ALL BANG_S NAME_ALL
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /* #define	ADMINSDIR	"admins"  */
927c478bd9Sstevel@tonic-gate /* # define CLASSESDIR	"classes" */
937c478bd9Sstevel@tonic-gate /* # define FORMSDIR	"forms" */
947c478bd9Sstevel@tonic-gate /* # define INTERFACESDIR	"interfaces" */
957c478bd9Sstevel@tonic-gate /* # define PRINTERSDIR	"printers" */
967c478bd9Sstevel@tonic-gate /* # define PRINTWHEELSDIR	"pwheels" */
977c478bd9Sstevel@tonic-gate /* #define BINDIR		"bin" */
987c478bd9Sstevel@tonic-gate /* #define LOGSDIR		"logs" */
997c478bd9Sstevel@tonic-gate /* #define MODELSDIR	"model" */
1007c478bd9Sstevel@tonic-gate /* #define NETWORKDIR	"network" */
1017c478bd9Sstevel@tonic-gate #define	FIFOSDIR	"fifos"
1027c478bd9Sstevel@tonic-gate /* # define PRIVFIFODIR	"private" */
1037c478bd9Sstevel@tonic-gate /* # define PUBFIFODIR	"public" */
1047c478bd9Sstevel@tonic-gate /* #define REQUESTSDIR	"requests" */
1057c478bd9Sstevel@tonic-gate /* #define SYSTEMDIR	"system" */
1067c478bd9Sstevel@tonic-gate /* #define TEMPDIR		"temp" */
1077c478bd9Sstevel@tonic-gate /* #define TMPDIR		"tmp" */
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /* #define SCHEDLOCK	"SCHEDLOCK" */
1107c478bd9Sstevel@tonic-gate /* #define FIFO		"FIFO" */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #define	FILTERTABLE	"filter.table"
1137c478bd9Sstevel@tonic-gate #define	FILTERTABLE_I	"filter.table.i"
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /* #define DESCRIBEFILE	"describe" */
1167c478bd9Sstevel@tonic-gate /* #define ALIGNFILE	"align_ptrn" */
1177c478bd9Sstevel@tonic-gate #define	COMMENTFILE	"comment"
1187c478bd9Sstevel@tonic-gate #define	ALLOWFILE	"allow"
1197c478bd9Sstevel@tonic-gate #define	DENYFILE	"deny"
1207c478bd9Sstevel@tonic-gate #define	ALERTSHFILE	"alert.sh"
1217c478bd9Sstevel@tonic-gate #define	ALERTVARSFILE	"alert.vars"
1227c478bd9Sstevel@tonic-gate #define	ALERTPROTOFILE	"alert.proto"
1237c478bd9Sstevel@tonic-gate #define	CONFIGFILE	"configuration"
1247c478bd9Sstevel@tonic-gate #define	FACCESSPREFIX	"forms."
1257c478bd9Sstevel@tonic-gate #define	PACCESSPREFIX	"paper."
1267c478bd9Sstevel@tonic-gate #define	UACCESSPREFIX	"users."
1277c478bd9Sstevel@tonic-gate #define	FALLOWFILE	FACCESSPREFIX ALLOWFILE
1287c478bd9Sstevel@tonic-gate #define	FDENYFILE	FACCESSPREFIX DENYFILE
1297c478bd9Sstevel@tonic-gate #define	UALLOWFILE	UACCESSPREFIX ALLOWFILE
1307c478bd9Sstevel@tonic-gate #define	UDENYFILE	UACCESSPREFIX DENYFILE
1317c478bd9Sstevel@tonic-gate /* #define DEFAULTFILE	"default" */
1327c478bd9Sstevel@tonic-gate #define	STATUSFILE	"status"
1337c478bd9Sstevel@tonic-gate /* #define USERSFILE	"users" */
1347c478bd9Sstevel@tonic-gate /* #define NAMEFILE	"name" */
1357c478bd9Sstevel@tonic-gate /* #define XFERFILE	"transfer" */
1367c478bd9Sstevel@tonic-gate /* #define EXECFILE	"execute" */
1377c478bd9Sstevel@tonic-gate #define	PSTATUSFILE	"pstatus"
1387c478bd9Sstevel@tonic-gate #define	CSTATUSFILE	"cstatus"
1397c478bd9Sstevel@tonic-gate /* #define REQLOGFILE	"requests" */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #define	STANDARD	"standard"
1427c478bd9Sstevel@tonic-gate /* #define SLOWFILTER	"slow.filter" */
1437c478bd9Sstevel@tonic-gate #define	FAULTMESSAGEFILE "faultMessage"
1447c478bd9Sstevel@tonic-gate #define	FORMMESSAGEFILE "formMessage"
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #define	LPNET		"/usr/lib/lp/lpNet"
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR
1497c478bd9Sstevel@tonic-gate #define	STANDARD_FOOMATIC	"standard_foomatic"
1507c478bd9Sstevel@tonic-gate 	/*
1517c478bd9Sstevel@tonic-gate 	 * The default model interface script to use if a printer is configured
1527c478bd9Sstevel@tonic-gate 	 * with a PPD (PostScript Printer Definition) file.
1537c478bd9Sstevel@tonic-gate 	 */
1547c478bd9Sstevel@tonic-gate #define	LP_PAPIATTRNAME "attributes"
1557c478bd9Sstevel@tonic-gate 	/*
1567c478bd9Sstevel@tonic-gate 	 * Job attributes filename extension,
1577c478bd9Sstevel@tonic-gate 	 * eg. /var/spool/lp/temp/123-attributes
1587c478bd9Sstevel@tonic-gate 	 */
1597c478bd9Sstevel@tonic-gate #endif
1607c478bd9Sstevel@tonic-gate 
1611d4c48c4SToomas Soome /*
1621d4c48c4SToomas Soome  * Names and phrases:
1631d4c48c4SToomas Soome  */
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * If you change these from macros to defined (char *) strings,
1677c478bd9Sstevel@tonic-gate  * be aware that in several places the lengths of the strings
1687c478bd9Sstevel@tonic-gate  * are computed using "sizeof()", not "strlen()"!
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate #define	NAME_ALL	"all"
1717c478bd9Sstevel@tonic-gate #define	NAME_ANY	"any"
1727c478bd9Sstevel@tonic-gate #define	NAME_NONE	"none"
1737c478bd9Sstevel@tonic-gate #define	NAME_TERMINFO	"terminfo"
1747c478bd9Sstevel@tonic-gate #define	NAME_SIMPLE	"simple"
1757c478bd9Sstevel@tonic-gate #define	NAME_HOLD	"hold"
1767c478bd9Sstevel@tonic-gate #define	NAME_RESUME	"resume"
1777c478bd9Sstevel@tonic-gate #define	NAME_IMMEDIATE	"immediate"
1787c478bd9Sstevel@tonic-gate #define	NAME_CONTINUE	"continue"
1797c478bd9Sstevel@tonic-gate #define	NAME_BEGINNING	"beginning"
1807c478bd9Sstevel@tonic-gate #define	NAME_WAIT	"wait"
1817c478bd9Sstevel@tonic-gate #define	NAME_MAIL	"mail"
1827c478bd9Sstevel@tonic-gate #define	NAME_WRITE	"write"
1837c478bd9Sstevel@tonic-gate #define	NAME_QUIET	"quiet"
1847c478bd9Sstevel@tonic-gate #define	NAME_LIST	"list"
1857c478bd9Sstevel@tonic-gate #define	NAME_ON		"on"
1867c478bd9Sstevel@tonic-gate #define	NAME_OFF	"off"
1877c478bd9Sstevel@tonic-gate #define	NAME_OPTIONAL	"optional"
1887c478bd9Sstevel@tonic-gate #define	NAME_ALWAYS	"Always"
1897c478bd9Sstevel@tonic-gate #define	NAME_UNKNOWN	"unknown"
1907c478bd9Sstevel@tonic-gate #define	NAME_REJECTING	"rejecting"
1917c478bd9Sstevel@tonic-gate #define	NAME_ACCEPTING	"accepting"
1927c478bd9Sstevel@tonic-gate #define	NAME_DISABLED	"disabled"
1937c478bd9Sstevel@tonic-gate #define	NAME_ENABLED	"enabled"
1947c478bd9Sstevel@tonic-gate #define	NAME_DIRECT	"direct"
1957c478bd9Sstevel@tonic-gate #define	NAME_PICA	"pica"
1967c478bd9Sstevel@tonic-gate #define	NAME_ELITE	"elite"
1977c478bd9Sstevel@tonic-gate #define	NAME_COMPRESSED	"compressed"
1987c478bd9Sstevel@tonic-gate #define	NAME_ALLOW	"allow"
1997c478bd9Sstevel@tonic-gate #define	NAME_DENY	"deny"
2007c478bd9Sstevel@tonic-gate #define	NAME_ONCE	"once"
2017c478bd9Sstevel@tonic-gate #define	NAME_DEFAULT	"default"
2027c478bd9Sstevel@tonic-gate #define	NAME_KEEP	"keep"
2037c478bd9Sstevel@tonic-gate 
2041d4c48c4SToomas Soome /*
2051d4c48c4SToomas Soome  * Common messages:
2061d4c48c4SToomas Soome  */
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate #define	CUZ_NEW_PRINTER		"new printer"
2097c478bd9Sstevel@tonic-gate #define	CUZ_NEW_DEST		"new destination"
2107c478bd9Sstevel@tonic-gate #define	CUZ_STOPPED		"stopped with printer fault"
2117c478bd9Sstevel@tonic-gate #define	CUZ_FAULT		"printer fault"
2127c478bd9Sstevel@tonic-gate #define	CUZ_LOGIN_PRINTER	"disabled by Spooler: login terminal"
2137c478bd9Sstevel@tonic-gate #define	CUZ_MOUNTING		"mounting a form"
2147c478bd9Sstevel@tonic-gate #define	CUZ_NOFORK		"can't fork"
2157c478bd9Sstevel@tonic-gate #define	CUZ_PRINTING_OK		"ready and printing"
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate #define	TIMEOUT_FAULT \
2187c478bd9Sstevel@tonic-gate "Timed-out trying to open the printer port.\n"
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate #define	OPEN_FAULT \
2217c478bd9Sstevel@tonic-gate "Failed to open the printer port.\n"
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate #define	PUSH_FAULT \
2247c478bd9Sstevel@tonic-gate "Failed to push module(s) onto the printer port stream.\n"
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate  * When the Spooler detected the hangup, this message is used.
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate #define	HANGUP_FAULT \
2307c478bd9Sstevel@tonic-gate "The connection to the printer dropped; perhaps the printer went off-line!\n"
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate  * When lp.cat detected the hangup, this message is used.
2347c478bd9Sstevel@tonic-gate  */
2357c478bd9Sstevel@tonic-gate #define	HANGUP_FAULT_LPCAT \
2367c478bd9Sstevel@tonic-gate "The connection to the printer dropped; perhaps the printer went off-line.\n"
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate #define	INTERRUPT_FAULT	\
2391d4c48c4SToomas Soome "Received an interrupt from the printer. The reason is unknown,\n\
2401d4c48c4SToomas Soome although a common cause is that the printer's buffer capacity\n\
2411d4c48c4SToomas Soome was exceeded. Using XON/XOFF flow control, adding carriage-return\n\
2421d4c48c4SToomas Soome delays, or lowering the baud rate may fix the problem.\n\
243*bbf21555SRichard Lowe See stty(1) and lpadmin(8) man-pages for help in doing this.\n"
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate #define	PIPE_FAULT \
2467c478bd9Sstevel@tonic-gate "The output ``port'', a FIFO, was closed before all output was written.\n"
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate #define	EXIT_FAULT \
2497c478bd9Sstevel@tonic-gate "The interface program returned with a reserved exit code.\n"
2507c478bd9Sstevel@tonic-gate 
2511d4c48c4SToomas Soome /*
2521d4c48c4SToomas Soome  * Lp-errno #defines, etc.
2531d4c48c4SToomas Soome  */
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate #define	LP_EBADSDN	1
2567c478bd9Sstevel@tonic-gate #define	LP_EBADINT	2
2577c478bd9Sstevel@tonic-gate #define	LP_EBADNAME	3
2587c478bd9Sstevel@tonic-gate #define	LP_EBADARG	4
2597c478bd9Sstevel@tonic-gate #define	LP_ETRAILIN	5
2607c478bd9Sstevel@tonic-gate #define	LP_ENOCMT	6
2617c478bd9Sstevel@tonic-gate #define	LP_EBADCTYPE	7
2627c478bd9Sstevel@tonic-gate #define	LP_ENOALP	8
2637c478bd9Sstevel@tonic-gate #define	LP_ENULLPTR	9
2647c478bd9Sstevel@tonic-gate #define	LP_EBADHDR	10
2657c478bd9Sstevel@tonic-gate #define	LP_ETEMPLATE	11
2667c478bd9Sstevel@tonic-gate #define	LP_EKEYWORD	12
2677c478bd9Sstevel@tonic-gate #define	LP_EPATTERN	13
2687c478bd9Sstevel@tonic-gate #define	LP_ERESULT	14
269*bbf21555SRichard Lowe #define	LP_EREGEX	15  /* and see extern int regerrno, regexpr(3GEN) */
2707c478bd9Sstevel@tonic-gate #define	LP_ENOMEM	99
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate extern int		lp_errno;
2737c478bd9Sstevel@tonic-gate 
2741d4c48c4SToomas Soome /*
2751d4c48c4SToomas Soome  * Misc. Macros
2761d4c48c4SToomas Soome  */
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate #define	LP_WS		" "	/* Whitespace (also list separator) */
2797c478bd9Sstevel@tonic-gate #define	LP_SEP		","	/* List separator */
2807c478bd9Sstevel@tonic-gate #define	LP_QUOTES	"'\""
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate #define	MAIL		"mail"
2837c478bd9Sstevel@tonic-gate #define	WRITE		"write"
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate #define	STATUS_BREAK	"=========="
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate #define	STREQU(A, B)	((!(A) || !(B)) ? 0 : (strcmp((A), (B)) == 0))
2887c478bd9Sstevel@tonic-gate #define	STRNEQU(A, B, N) ((!(A) || !(B)) ? 0 : (strncmp((A), (B), (N)) == 0))
2897c478bd9Sstevel@tonic-gate #define	CS_STREQU(A, B)	(cs_strcmp((A), (B)) == 0)
2907c478bd9Sstevel@tonic-gate #define	CS_STRNEQU(A, B, N) (cs_strncmp((A), (B), (N)) == 0)
2917c478bd9Sstevel@tonic-gate #define	STRSIZE(X)	(sizeof (X) - 1)
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate /*
2947c478bd9Sstevel@tonic-gate  * Almost STREQU but compares null pointers as equal, too.
2957c478bd9Sstevel@tonic-gate  */
2967c478bd9Sstevel@tonic-gate #define	SAME(A, B)	((A) == (B) || (A) && (B) && STREQU((A), (B)))
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate #define	PRINTF		(void)printf
2997c478bd9Sstevel@tonic-gate #define	SPRINTF		(void)sprintf
3007c478bd9Sstevel@tonic-gate #define	FPRINTF		(void)fprintf
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate #define	NB(X)		(X? X : "")
3037c478bd9Sstevel@tonic-gate 
304ace1a5f1Sdp #define	PERROR		strerror(errno)
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate /*
3077c478bd9Sstevel@tonic-gate  * Largest number we'll ever expect to get from doing %ld in printf,
3087c478bd9Sstevel@tonic-gate  * as a string and number. ULONG_MAX from limits.h gives us the number,
3097c478bd9Sstevel@tonic-gate  * but I can't figure out how to get that into a string.
3107c478bd9Sstevel@tonic-gate  */
3117c478bd9Sstevel@tonic-gate #define	BIGGEST_NUMBER		ULONG_MAX
3127c478bd9Sstevel@tonic-gate #define	BIGGEST_NUMBER_S	"4294967295"
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate  * Largest request ID (numerical part), as string and number.
3167c478bd9Sstevel@tonic-gate  * See comment above.
3177c478bd9Sstevel@tonic-gate  */
3187c478bd9Sstevel@tonic-gate #define	BIGGEST_REQID		999999
3197c478bd9Sstevel@tonic-gate #define	BIGGEST_REQID_S		"999999"
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate /*
3227c478bd9Sstevel@tonic-gate  * Maximum number of files queued per request, as string and number.
3237c478bd9Sstevel@tonic-gate  * See earlier comment above.
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate #define	MOST_FILES	999999
3267c478bd9Sstevel@tonic-gate #define	MOST_FILES_S	"999999"
3277c478bd9Sstevel@tonic-gate 
3281d4c48c4SToomas Soome /*
3291d4c48c4SToomas Soome  * Alert macros:
3301d4c48c4SToomas Soome  */
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate  * Type of alert to be S_QUIET'd
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate #define	QA_FORM		1
3367c478bd9Sstevel@tonic-gate #define	QA_PRINTER	2
3377c478bd9Sstevel@tonic-gate #define	QA_PRINTWHEEL	3
3387c478bd9Sstevel@tonic-gate 
3391d4c48c4SToomas Soome /*
3401d4c48c4SToomas Soome  * File modes:
3411d4c48c4SToomas Soome  * (The "NO" prefix is relative to ``others''.)
3421d4c48c4SToomas Soome  */
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate #define	MODE_READ	(mode_t)0664
3457c478bd9Sstevel@tonic-gate #define	MODE_NOREAD	(mode_t)0660
3467c478bd9Sstevel@tonic-gate #define	MODE_EXEC	(mode_t)0775
3477c478bd9Sstevel@tonic-gate #define	MODE_NOEXEC	(mode_t)0770
3487c478bd9Sstevel@tonic-gate #define	MODE_DIR	(mode_t)0775
3497c478bd9Sstevel@tonic-gate #define	MODE_NODIR	(mode_t)0770
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate extern int	printlist_qsep;
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate extern char	Lp_Spooldir[],
3547c478bd9Sstevel@tonic-gate 		Lp_Admins[],
3557c478bd9Sstevel@tonic-gate 		Lp_Bin[],
3567c478bd9Sstevel@tonic-gate 		Lp_FIFO[],
3577c478bd9Sstevel@tonic-gate 		Lp_Logs[],
3587c478bd9Sstevel@tonic-gate 		Lp_ReqLog[],
3597c478bd9Sstevel@tonic-gate 		Lp_Model[],
3607c478bd9Sstevel@tonic-gate 		Lp_Requests[],
3617c478bd9Sstevel@tonic-gate 		Lp_Secure[],
3627c478bd9Sstevel@tonic-gate 		Lp_Schedlock[],
3637c478bd9Sstevel@tonic-gate 		Lp_Slow_Filter[],
3647c478bd9Sstevel@tonic-gate 		Lp_System[],
3657c478bd9Sstevel@tonic-gate 		Lp_Temp[],
3667c478bd9Sstevel@tonic-gate 		Lp_Tmp[],
3677c478bd9Sstevel@tonic-gate 		Lp_Users[],
3687c478bd9Sstevel@tonic-gate 		Lp_A[],
3697c478bd9Sstevel@tonic-gate 		Lp_A_Classes[],
3707c478bd9Sstevel@tonic-gate 		Lp_A_Forms[],
3717c478bd9Sstevel@tonic-gate 		Lp_A_Interfaces[],
3727c478bd9Sstevel@tonic-gate 		Lp_A_Logs[],
3737c478bd9Sstevel@tonic-gate 		Lp_A_Printers[],
3747c478bd9Sstevel@tonic-gate 		Lp_A_PrintWheels[],
3757c478bd9Sstevel@tonic-gate 		Lp_A_Filters[],
3767c478bd9Sstevel@tonic-gate 		Lp_A_Systems[],
3777c478bd9Sstevel@tonic-gate 		Lp_Default[],
3787c478bd9Sstevel@tonic-gate 		Lp_A_Faults[];
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate /*
3817c478bd9Sstevel@tonic-gate  * File access:
3827c478bd9Sstevel@tonic-gate  */
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate extern int	open_locked(char *, char *, mode_t);
3857c478bd9Sstevel@tonic-gate extern char	*fdgets(char *, int, int);
3867c478bd9Sstevel@tonic-gate extern int	fdprintf(int, char *, ...);
3877c478bd9Sstevel@tonic-gate extern int	fdputs(char *, int);
3887c478bd9Sstevel@tonic-gate extern int	fdputc(char, int);
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate extern int	is_printer_uri(char *);
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate FILE		*open_lpfile(char *, char *, mode_t);
3937c478bd9Sstevel@tonic-gate int		close_lpfile(FILE *);
3941d4c48c4SToomas Soome int		chown_lppath(char *);
3951d4c48c4SToomas Soome int		mkdir_lpdir(char *, int);
3961d4c48c4SToomas Soome int		rmfile(char *);
3971d4c48c4SToomas Soome int		dumpstring(char *, char *);
3987c478bd9Sstevel@tonic-gate 
3991d4c48c4SToomas Soome char		*loadstring(char *);
4001d4c48c4SToomas Soome char		*loadline(char *);
4011d4c48c4SToomas Soome char		*sop_up_rest(int, char *);
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate /*
4047c478bd9Sstevel@tonic-gate  * List manipulation routines:
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate #define	emptylist(LP)	(!(LP) || !(LP)[0])
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate int		addlist(char ***, char *);
4107c478bd9Sstevel@tonic-gate int		addstring(char **, char *);
4117c478bd9Sstevel@tonic-gate int		appendlist(char ***, char *);
4127c478bd9Sstevel@tonic-gate int		dellist(char ***, char *);
4137c478bd9Sstevel@tonic-gate int		joinlist(char ***, char **);
4147c478bd9Sstevel@tonic-gate int		lenlist(char **);
4157c478bd9Sstevel@tonic-gate int		printlist(FILE *, char **);
4167c478bd9Sstevel@tonic-gate int		fdprintlist(int, char **);
4177c478bd9Sstevel@tonic-gate int		searchlist(char *, char **);
4187c478bd9Sstevel@tonic-gate int		searchlist_with_terminfo(char *, char **);
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate char		**duplist(char **);
4217c478bd9Sstevel@tonic-gate char		**getlist(char *, char *, char *);
4227c478bd9Sstevel@tonic-gate char		**dashos(char *);
4237c478bd9Sstevel@tonic-gate char		**wherelist(char *, char **);
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate char		*sprintlist(char **);
4267c478bd9Sstevel@tonic-gate char		*search_cslist(char *, char **);
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate void		freelist(char **);
4297c478bd9Sstevel@tonic-gate void		printlist_setup(char *, char *, char *, char *);
4307c478bd9Sstevel@tonic-gate void		printlist_unsetup(void);
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /*
4337c478bd9Sstevel@tonic-gate  * Scaled decimal number routines:
4347c478bd9Sstevel@tonic-gate  */
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate #define	getsdn(S)	_getsdn(S, (char **)0, 0)
4377c478bd9Sstevel@tonic-gate #define	getcpi(S)	_getsdn(S, (char **)0, 1)
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate #define	N_COMPRESSED	9999
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate void		printsdn(FILE *, SCALED);
4427c478bd9Sstevel@tonic-gate void		fdprintsdn(int, SCALED);
4437c478bd9Sstevel@tonic-gate void		printsdn_setup(char *, char *, char *);
4447c478bd9Sstevel@tonic-gate void		printsdn_unsetup(void);
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate SCALED		_getsdn(char *, char **, int);
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate /*
4497c478bd9Sstevel@tonic-gate  * File name routines:
4507c478bd9Sstevel@tonic-gate  */
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate char		*makepath(char *, ...);
4537c478bd9Sstevel@tonic-gate char		*getspooldir(void);
4547c478bd9Sstevel@tonic-gate char		*getrequestfile(char *);
4557c478bd9Sstevel@tonic-gate char		*getprinterfile(char *, char *);
4567c478bd9Sstevel@tonic-gate char		*getsystemfile(char *, char *);
4577c478bd9Sstevel@tonic-gate char		*getclassfile(char *);
4587c478bd9Sstevel@tonic-gate char		*getfilterfile(char *);
4597c478bd9Sstevel@tonic-gate char		*getformfile(char *, char *);
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate /*
4627c478bd9Sstevel@tonic-gate  * Additional string manipulation routines:
4637c478bd9Sstevel@tonic-gate  */
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate int		cs_strcmp(char *, char *);
4667c478bd9Sstevel@tonic-gate int		cs_strncmp(char *, char *, int);
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate /*
4697c478bd9Sstevel@tonic-gate  * Syntax checking routines:
4707c478bd9Sstevel@tonic-gate  */
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate int		syn_name(char *);
4737c478bd9Sstevel@tonic-gate int		syn_text(char *);
4747c478bd9Sstevel@tonic-gate int		syn_comment(char *);
4757c478bd9Sstevel@tonic-gate int		syn_machine_name(char *);
4767c478bd9Sstevel@tonic-gate int		syn_option(char *);
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate /*
4797c478bd9Sstevel@tonic-gate  * Alert management routines:
4807c478bd9Sstevel@tonic-gate  */
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate int		putalert(char *, char *, FALERT *);
4837c478bd9Sstevel@tonic-gate int		delalert(char *, char *);
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate FALERT		*getalert(char *, char *);
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate void		printalert(FILE *, FALERT *, int);
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate /*
4907c478bd9Sstevel@tonic-gate  * Terminfo Database Inquiry Tool
4917c478bd9Sstevel@tonic-gate  */
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate int		tidbit(char *, char *, ...);
4947c478bd9Sstevel@tonic-gate void		untidbit(char *);
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate /*
4977c478bd9Sstevel@tonic-gate  * Auto-restarting and other system calls:
4987c478bd9Sstevel@tonic-gate  * The two versions are here to reduce the chance of colliding
4997c478bd9Sstevel@tonic-gate  * with similar names in standard libraries (e.g. dial(3C) uses
5007c478bd9Sstevel@tonic-gate  * Read/Write).
5017c478bd9Sstevel@tonic-gate  */
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate #define	Access	_Access
5047c478bd9Sstevel@tonic-gate #define	Chdir	_Chdir
5057c478bd9Sstevel@tonic-gate #define	Chmod	_Chmod
5067c478bd9Sstevel@tonic-gate #define	Chown	_Chown
5077c478bd9Sstevel@tonic-gate #define	Close	_Close
5087c478bd9Sstevel@tonic-gate #define	Creat	_Creat
5097c478bd9Sstevel@tonic-gate #define	Fcntl	_Fcntl
5107c478bd9Sstevel@tonic-gate #define	Fstat	_Fstat
5117c478bd9Sstevel@tonic-gate #define	Link	_Link
5127c478bd9Sstevel@tonic-gate #define	Lstat	_Lstat
5137c478bd9Sstevel@tonic-gate #define	Mknod	_Mknod
5147c478bd9Sstevel@tonic-gate #define	Open	_Open
5157c478bd9Sstevel@tonic-gate #define	Read	_Read
5167c478bd9Sstevel@tonic-gate #define	Readlink _Readlink
5177c478bd9Sstevel@tonic-gate #define	Rename	_Rename
5187c478bd9Sstevel@tonic-gate #define	Stat	_Stat
5197c478bd9Sstevel@tonic-gate #define	Symlink	_Symlink
5207c478bd9Sstevel@tonic-gate #define	Unlink	_Unlink
5217c478bd9Sstevel@tonic-gate #define	Wait	_Wait
5227c478bd9Sstevel@tonic-gate #define	Write	_Write
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate #define	Malloc(size)		_Malloc(size, __FILE__, __LINE__)
5257c478bd9Sstevel@tonic-gate #define	Realloc(ptr, size)	_Realloc(ptr, size, __FILE__, __LINE__)
5267c478bd9Sstevel@tonic-gate #define	Calloc(nelem, elsize)	_Calloc(nelem, elsize, __FILE__, __LINE__)
5277c478bd9Sstevel@tonic-gate #define	Strdup(s)		_Strdup(s, __FILE__, __LINE__)
5287c478bd9Sstevel@tonic-gate #define	Free(ptr)		_Free(ptr, __FILE__, __LINE__)
5297c478bd9Sstevel@tonic-gate 
5307c478bd9Sstevel@tonic-gate int		_Access(char *, int);
5317c478bd9Sstevel@tonic-gate int		_Chdir(char *);
5327c478bd9Sstevel@tonic-gate int		_Chmod(char *, int);
5337c478bd9Sstevel@tonic-gate int		_Chown(char *, int, int);
5347c478bd9Sstevel@tonic-gate int		_Close(int);
5357c478bd9Sstevel@tonic-gate int		_Creat(char *, int);
5367c478bd9Sstevel@tonic-gate int		_Fcntl(int, int, ...);
5377c478bd9Sstevel@tonic-gate int		_Fstat(int, struct stat *);
5387c478bd9Sstevel@tonic-gate int		_Link(char *, char *);
5397c478bd9Sstevel@tonic-gate int		_Lstat(char *, struct stat *);
5407c478bd9Sstevel@tonic-gate int		_Mknod(char *, int, int);
5417c478bd9Sstevel@tonic-gate int		_Mkpipe(char *, int, int);
5427c478bd9Sstevel@tonic-gate int		_Open(char *, int, ... /* mode_t */);
5437c478bd9Sstevel@tonic-gate int		_Read(int, char *, unsigned int);
5447c478bd9Sstevel@tonic-gate int		_Readlink(char *, char *, unsigned int);
5457c478bd9Sstevel@tonic-gate int		_Rename(char *, char *);
5467c478bd9Sstevel@tonic-gate int		_Symlink(char *, char *);
5477c478bd9Sstevel@tonic-gate int		_Stat(char *, struct stat *);
5487c478bd9Sstevel@tonic-gate int		_Unlink(char *);
5497c478bd9Sstevel@tonic-gate int		_Wait(int *);
5507c478bd9Sstevel@tonic-gate int		_Write(int, char *, unsigned int);
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate void		*_Malloc(size_t, const char *, int);
5537c478bd9Sstevel@tonic-gate void		*_Realloc(void *, size_t, const char *, int);
5547c478bd9Sstevel@tonic-gate void		*_Calloc(size_t, size_t, const char *, int);
5557c478bd9Sstevel@tonic-gate char		*_Strdup(const char *, const char *, int);
5567c478bd9Sstevel@tonic-gate void		_Free(void *, const char *, int);
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate /*
5597c478bd9Sstevel@tonic-gate  * Misc. routines:
5607c478bd9Sstevel@tonic-gate  */
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate int		isterminfo(char *);
5637c478bd9Sstevel@tonic-gate int		isprinter(char *);
5647c478bd9Sstevel@tonic-gate int		isrequest(char *);
5657c478bd9Sstevel@tonic-gate int		isnumber(char *);
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate char		*getname(void);
5687c478bd9Sstevel@tonic-gate char		*makestr(char *, ...);
5697c478bd9Sstevel@tonic-gate char		*strip(char *);
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate void		sendmail(char *, char *);
5727c478bd9Sstevel@tonic-gate 
5731d4c48c4SToomas Soome extern void	(*lp_alloc_fail_handler)(void);
5747c478bd9Sstevel@tonic-gate 
5757c478bd9Sstevel@tonic-gate /*
5767c478bd9Sstevel@tonic-gate  * Originally part of liblpfs.a and fs.h, now no longer needed
5777c478bd9Sstevel@tonic-gate  * since the code doesn't have to work on pre-SVR4.0.
5787c478bd9Sstevel@tonic-gate  */
5797c478bd9Sstevel@tonic-gate #define	Opendir		opendir
5807c478bd9Sstevel@tonic-gate #define	Telldir		telldir
5817c478bd9Sstevel@tonic-gate #define	Seekdir		seekdir
5827c478bd9Sstevel@tonic-gate #define	Rewinddir(dirp)	Seekdir(dirp, 0L)
5837c478bd9Sstevel@tonic-gate #define	Closedir	closedir
5847c478bd9Sstevel@tonic-gate #define	Readdir		readdir
5857c478bd9Sstevel@tonic-gate #define	Mkdir		mkdir
5867c478bd9Sstevel@tonic-gate #define	Rmdir		rmdir
5877c478bd9Sstevel@tonic-gate 
5887c478bd9Sstevel@tonic-gate #define	next_dir(base, ptr)	next_x(base, ptr, S_IFDIR)
5897c478bd9Sstevel@tonic-gate #define	next_file(base, ptr)	next_x(base, ptr, S_IFREG)
5907c478bd9Sstevel@tonic-gate 
5911d4c48c4SToomas Soome extern int chownmod(char *, uid_t, gid_t, mode_t);
592df1eb1adSjacobs 
593df1eb1adSjacobs 
5947c478bd9Sstevel@tonic-gate char		*next_x(char *, long *, unsigned int);
5957c478bd9Sstevel@tonic-gate 
59645916cd2Sjpk /*
59745916cd2Sjpk  * Stuff needed for Trusted Extensions
59845916cd2Sjpk  */
59945916cd2Sjpk 
60045916cd2Sjpk extern	char	*get_labeled_zonename(char *);
6011d4c48c4SToomas Soome extern int	get_peer_label(int, char **);
60245916cd2Sjpk 
60345916cd2Sjpk 
604ace1a5f1Sdp #ifdef __cplusplus
605ace1a5f1Sdp }
6067c478bd9Sstevel@tonic-gate #endif
607ace1a5f1Sdp 
608ace1a5f1Sdp #endif	/* _LP_LP_H */
609