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