10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1676Sjpk * Common Development and Distribution License (the "License"). 6*1676Sjpk * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1676Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 29634Sdp #ifndef _LP_LP_H 30634Sdp #define _LP_LP_H 310Sstevel@tonic-gate 320Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 330Sstevel@tonic-gate 34634Sdp #ifdef __cplusplus 35634Sdp extern "C" { 36634Sdp #endif 370Sstevel@tonic-gate 38634Sdp #include <errno.h> 39634Sdp #include <fcntl.h> 40634Sdp #include <sys/types.h> 41634Sdp #include <sys/stat.h> 42634Sdp #include <stdio.h> 43634Sdp #include <dirent.h> 440Sstevel@tonic-gate 450Sstevel@tonic-gate /** 460Sstevel@tonic-gate ** Types: 470Sstevel@tonic-gate **/ 480Sstevel@tonic-gate 490Sstevel@tonic-gate typedef struct SCALED { 500Sstevel@tonic-gate float val; /* value of number, scaled according to "sc" */ 510Sstevel@tonic-gate char sc; /* 'i' inches, 'c' centimeters, ' ' lines/cols */ 520Sstevel@tonic-gate } SCALED; 530Sstevel@tonic-gate 540Sstevel@tonic-gate typedef struct FALERT { 550Sstevel@tonic-gate char * shcmd; /* shell command used to perform the alert */ 560Sstevel@tonic-gate int Q; /* # requests queued to activate alert */ 570Sstevel@tonic-gate int W; /* alert is sent every "W" minutes */ 580Sstevel@tonic-gate } FALERT; 590Sstevel@tonic-gate 600Sstevel@tonic-gate 610Sstevel@tonic-gate #define LP_USE_PAPI_ATTR 1 /* use PAPI attributes for printing */ 620Sstevel@tonic-gate /* TODO: is this best place for this ? */ 630Sstevel@tonic-gate 640Sstevel@tonic-gate /** 650Sstevel@tonic-gate ** Places: 660Sstevel@tonic-gate **/ 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * These functions no longer exist. The defines take care 700Sstevel@tonic-gate * of recompiling code that expects these and the null functions 710Sstevel@tonic-gate * in getpaths.c take care of relinking objects that expect these. 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate #define getpaths() 740Sstevel@tonic-gate #define getadminpaths(x) 750Sstevel@tonic-gate 760Sstevel@tonic-gate #define LPDIR "/usr/lib/lp" 770Sstevel@tonic-gate #define ETCDIR "/etc/lp" 780Sstevel@tonic-gate #define SPOOLDIR "/var/spool/lp" 790Sstevel@tonic-gate #define LOGDIR "/var/lp/logs" 800Sstevel@tonic-gate 810Sstevel@tonic-gate #define TERMINFO "/usr/share/lib/terminfo" 820Sstevel@tonic-gate 830Sstevel@tonic-gate #define LPUSER "lp" 840Sstevel@tonic-gate #define ROOTUSER "root" 850Sstevel@tonic-gate 860Sstevel@tonic-gate #define BANG_S "!" 870Sstevel@tonic-gate #define BANG_C '!' 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define LOCAL_LPUSER BANG_S LPUSER 900Sstevel@tonic-gate #define LOCAL_ROOTUSER BANG_S ROOTUSER 910Sstevel@tonic-gate #define ALL_BANG_ALL NAME_ALL BANG_S NAME_ALL 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* #define ADMINSDIR "admins" */ 940Sstevel@tonic-gate /* # define CLASSESDIR "classes" */ 950Sstevel@tonic-gate /* # define FORMSDIR "forms" */ 960Sstevel@tonic-gate /* # define INTERFACESDIR "interfaces" */ 970Sstevel@tonic-gate /* # define PRINTERSDIR "printers" */ 980Sstevel@tonic-gate /* # define PRINTWHEELSDIR "pwheels" */ 990Sstevel@tonic-gate /* #define BINDIR "bin" */ 1000Sstevel@tonic-gate /* #define LOGSDIR "logs" */ 1010Sstevel@tonic-gate /* #define MODELSDIR "model" */ 1020Sstevel@tonic-gate /* #define NETWORKDIR "network" */ 1030Sstevel@tonic-gate #define FIFOSDIR "fifos" 1040Sstevel@tonic-gate /* # define PRIVFIFODIR "private" */ 1050Sstevel@tonic-gate /* # define PUBFIFODIR "public" */ 1060Sstevel@tonic-gate /* #define REQUESTSDIR "requests" */ 1070Sstevel@tonic-gate /* #define SYSTEMDIR "system" */ 1080Sstevel@tonic-gate /* #define TEMPDIR "temp" */ 1090Sstevel@tonic-gate /* #define TMPDIR "tmp" */ 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* #define SCHEDLOCK "SCHEDLOCK" */ 1120Sstevel@tonic-gate /* #define FIFO "FIFO" */ 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define FILTERTABLE "filter.table" 1150Sstevel@tonic-gate #define FILTERTABLE_I "filter.table.i" 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* #define DESCRIBEFILE "describe" */ 1180Sstevel@tonic-gate /* #define ALIGNFILE "align_ptrn" */ 1190Sstevel@tonic-gate #define COMMENTFILE "comment" 1200Sstevel@tonic-gate #define ALLOWFILE "allow" 1210Sstevel@tonic-gate #define DENYFILE "deny" 1220Sstevel@tonic-gate #define ALERTSHFILE "alert.sh" 1230Sstevel@tonic-gate #define ALERTVARSFILE "alert.vars" 1240Sstevel@tonic-gate #define ALERTPROTOFILE "alert.proto" 1250Sstevel@tonic-gate #define CONFIGFILE "configuration" 1260Sstevel@tonic-gate #define FACCESSPREFIX "forms." 1270Sstevel@tonic-gate #define PACCESSPREFIX "paper." 1280Sstevel@tonic-gate #define UACCESSPREFIX "users." 1290Sstevel@tonic-gate #define FALLOWFILE FACCESSPREFIX ALLOWFILE 1300Sstevel@tonic-gate #define FDENYFILE FACCESSPREFIX DENYFILE 1310Sstevel@tonic-gate #define UALLOWFILE UACCESSPREFIX ALLOWFILE 1320Sstevel@tonic-gate #define UDENYFILE UACCESSPREFIX DENYFILE 1330Sstevel@tonic-gate /* #define DEFAULTFILE "default" */ 1340Sstevel@tonic-gate #define STATUSFILE "status" 1350Sstevel@tonic-gate /* #define USERSFILE "users" */ 1360Sstevel@tonic-gate /* #define NAMEFILE "name" */ 1370Sstevel@tonic-gate /* #define XFERFILE "transfer" */ 1380Sstevel@tonic-gate /* #define EXECFILE "execute" */ 1390Sstevel@tonic-gate #define PSTATUSFILE "pstatus" 1400Sstevel@tonic-gate #define CSTATUSFILE "cstatus" 1410Sstevel@tonic-gate /* #define REQLOGFILE "requests" */ 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate #define STANDARD "standard" 1440Sstevel@tonic-gate /* #define SLOWFILTER "slow.filter" */ 1450Sstevel@tonic-gate #define FAULTMESSAGEFILE "faultMessage" 1460Sstevel@tonic-gate #define FORMMESSAGEFILE "formMessage" 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #define LPNET "/usr/lib/lp/lpNet" 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate #ifdef LP_USE_PAPI_ATTR 1510Sstevel@tonic-gate #define STANDARD_FOOMATIC "standard_foomatic" 1520Sstevel@tonic-gate /* 1530Sstevel@tonic-gate * The default model interface script to use if a printer is configured 1540Sstevel@tonic-gate * with a PPD (PostScript Printer Definition) file. 1550Sstevel@tonic-gate */ 1560Sstevel@tonic-gate #define LP_PAPIATTRNAME "attributes" 1570Sstevel@tonic-gate /* 1580Sstevel@tonic-gate * Job attributes filename extension, 1590Sstevel@tonic-gate * eg. /var/spool/lp/temp/123-attributes 1600Sstevel@tonic-gate */ 1610Sstevel@tonic-gate #endif 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /** 1640Sstevel@tonic-gate ** Names and phrases: 1650Sstevel@tonic-gate **/ 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate /* 1680Sstevel@tonic-gate * If you change these from macros to defined (char *) strings, 1690Sstevel@tonic-gate * be aware that in several places the lengths of the strings 1700Sstevel@tonic-gate * are computed using "sizeof()", not "strlen()"! 1710Sstevel@tonic-gate */ 1720Sstevel@tonic-gate #define NAME_ALL "all" 1730Sstevel@tonic-gate #define NAME_ANY "any" 1740Sstevel@tonic-gate #define NAME_NONE "none" 1750Sstevel@tonic-gate #define NAME_TERMINFO "terminfo" 1760Sstevel@tonic-gate #define NAME_SIMPLE "simple" 1770Sstevel@tonic-gate #define NAME_HOLD "hold" 1780Sstevel@tonic-gate #define NAME_RESUME "resume" 1790Sstevel@tonic-gate #define NAME_IMMEDIATE "immediate" 1800Sstevel@tonic-gate #define NAME_CONTINUE "continue" 1810Sstevel@tonic-gate #define NAME_BEGINNING "beginning" 1820Sstevel@tonic-gate #define NAME_WAIT "wait" 1830Sstevel@tonic-gate #define NAME_MAIL "mail" 1840Sstevel@tonic-gate #define NAME_WRITE "write" 1850Sstevel@tonic-gate #define NAME_QUIET "quiet" 1860Sstevel@tonic-gate #define NAME_LIST "list" 1870Sstevel@tonic-gate #define NAME_ON "on" 1880Sstevel@tonic-gate #define NAME_OFF "off" 1890Sstevel@tonic-gate #define NAME_OPTIONAL "optional" 1900Sstevel@tonic-gate #define NAME_ALWAYS "Always" 1910Sstevel@tonic-gate #define NAME_UNKNOWN "unknown" 1920Sstevel@tonic-gate #define NAME_REJECTING "rejecting" 1930Sstevel@tonic-gate #define NAME_ACCEPTING "accepting" 1940Sstevel@tonic-gate #define NAME_DISABLED "disabled" 1950Sstevel@tonic-gate #define NAME_ENABLED "enabled" 1960Sstevel@tonic-gate #define NAME_DIRECT "direct" 1970Sstevel@tonic-gate #define NAME_PICA "pica" 1980Sstevel@tonic-gate #define NAME_ELITE "elite" 1990Sstevel@tonic-gate #define NAME_COMPRESSED "compressed" 2000Sstevel@tonic-gate #define NAME_ALLOW "allow" 2010Sstevel@tonic-gate #define NAME_DENY "deny" 2020Sstevel@tonic-gate #define NAME_ONCE "once" 2030Sstevel@tonic-gate #define NAME_DEFAULT "default" 2040Sstevel@tonic-gate #define NAME_KEEP "keep" 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate /** 2070Sstevel@tonic-gate ** Common messages: 2080Sstevel@tonic-gate **/ 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate #define CUZ_NEW_PRINTER "new printer" 2110Sstevel@tonic-gate #define CUZ_NEW_DEST "new destination" 2120Sstevel@tonic-gate #define CUZ_STOPPED "stopped with printer fault" 2130Sstevel@tonic-gate #define CUZ_FAULT "printer fault" 2140Sstevel@tonic-gate #define CUZ_LOGIN_PRINTER "disabled by Spooler: login terminal" 2150Sstevel@tonic-gate #define CUZ_MOUNTING "mounting a form" 2160Sstevel@tonic-gate #define CUZ_NOFORK "can't fork" 2170Sstevel@tonic-gate #define CUZ_PRINTING_OK "ready and printing" 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate #define TIMEOUT_FAULT \ 2200Sstevel@tonic-gate "Timed-out trying to open the printer port.\n" 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate #define OPEN_FAULT \ 2230Sstevel@tonic-gate "Failed to open the printer port.\n" 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate #define PUSH_FAULT \ 2260Sstevel@tonic-gate "Failed to push module(s) onto the printer port stream.\n" 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * When the Spooler detected the hangup, this message is used. 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate #define HANGUP_FAULT \ 2320Sstevel@tonic-gate "The connection to the printer dropped; perhaps the printer went off-line!\n" 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate /* 2350Sstevel@tonic-gate * When lp.cat detected the hangup, this message is used. 2360Sstevel@tonic-gate */ 2370Sstevel@tonic-gate #define HANGUP_FAULT_LPCAT \ 2380Sstevel@tonic-gate "The connection to the printer dropped; perhaps the printer went off-line.\n" 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate #define INTERRUPT_FAULT \ 2410Sstevel@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" 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate #define PIPE_FAULT \ 2440Sstevel@tonic-gate "The output ``port'', a FIFO, was closed before all output was written.\n" 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate #define EXIT_FAULT \ 2470Sstevel@tonic-gate "The interface program returned with a reserved exit code.\n" 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /** 2500Sstevel@tonic-gate ** Lp-errno #defines, etc. 2510Sstevel@tonic-gate **/ 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate #define LP_EBADSDN 1 2540Sstevel@tonic-gate #define LP_EBADINT 2 2550Sstevel@tonic-gate #define LP_EBADNAME 3 2560Sstevel@tonic-gate #define LP_EBADARG 4 2570Sstevel@tonic-gate #define LP_ETRAILIN 5 2580Sstevel@tonic-gate #define LP_ENOCMT 6 2590Sstevel@tonic-gate #define LP_EBADCTYPE 7 2600Sstevel@tonic-gate #define LP_ENOALP 8 2610Sstevel@tonic-gate #define LP_ENULLPTR 9 2620Sstevel@tonic-gate #define LP_EBADHDR 10 2630Sstevel@tonic-gate #define LP_ETEMPLATE 11 2640Sstevel@tonic-gate #define LP_EKEYWORD 12 2650Sstevel@tonic-gate #define LP_EPATTERN 13 2660Sstevel@tonic-gate #define LP_ERESULT 14 2670Sstevel@tonic-gate #define LP_EREGEX 15 /* and see extern int regerrno, regexpr(3G) */ 2680Sstevel@tonic-gate #define LP_ENOMEM 99 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate extern int lp_errno; 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate /** 2730Sstevel@tonic-gate ** Misc. Macros 2740Sstevel@tonic-gate **/ 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate #define LP_WS " " /* Whitespace (also list separator) */ 2770Sstevel@tonic-gate #define LP_SEP "," /* List separator */ 2780Sstevel@tonic-gate #define LP_QUOTES "'\"" 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate #define MAIL "mail" 2810Sstevel@tonic-gate #define WRITE "write" 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate #define STATUS_BREAK "==========" 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate #define STREQU(A,B) ( (!(A) || !(B)) ? 0: (strcmp((A), (B)) == 0) ) 2860Sstevel@tonic-gate #define STRNEQU(A,B,N) ( (!(A) || !(B)) ? 0: (strncmp((A), (B), (N)) == 0) ) 2870Sstevel@tonic-gate #define CS_STREQU(A,B) (cs_strcmp((A), (B)) == 0) 2880Sstevel@tonic-gate #define CS_STRNEQU(A,B,N) (cs_strncmp((A), (B), (N)) == 0) 2890Sstevel@tonic-gate #define STRSIZE(X) (sizeof(X) - 1) 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate /* 2920Sstevel@tonic-gate * Almost STREQU but compares null pointers as equal, too. 2930Sstevel@tonic-gate */ 2940Sstevel@tonic-gate #define SAME(A,B) ((A) == (B) || (A) && (B) && STREQU((A), (B))) 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate #define PRINTF (void)printf 2970Sstevel@tonic-gate #define SPRINTF (void)sprintf 2980Sstevel@tonic-gate #define FPRINTF (void)fprintf 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate #define NB(X) (X? X : "") 3010Sstevel@tonic-gate 302634Sdp #define PERROR strerror(errno) 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* 3050Sstevel@tonic-gate * Largest number we'll ever expect to get from doing %ld in printf, 3060Sstevel@tonic-gate * as a string and number. ULONG_MAX from limits.h gives us the number, 3070Sstevel@tonic-gate * but I can't figure out how to get that into a string. 3080Sstevel@tonic-gate */ 3090Sstevel@tonic-gate #define BIGGEST_NUMBER ULONG_MAX 3100Sstevel@tonic-gate #define BIGGEST_NUMBER_S "4294967295" 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate /* 3130Sstevel@tonic-gate * Largest request ID (numerical part), as string and number. 3140Sstevel@tonic-gate * See comment above. 3150Sstevel@tonic-gate */ 3160Sstevel@tonic-gate #define BIGGEST_REQID 999999 3170Sstevel@tonic-gate #define BIGGEST_REQID_S "999999" 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate /* 3200Sstevel@tonic-gate * Maximum number of files queued per request, as string and number. 3210Sstevel@tonic-gate * See earlier comment above. 3220Sstevel@tonic-gate */ 3230Sstevel@tonic-gate #define MOST_FILES 999999 3240Sstevel@tonic-gate #define MOST_FILES_S "999999" 3250Sstevel@tonic-gate 3260Sstevel@tonic-gate /** 3270Sstevel@tonic-gate ** Alert macros: 3280Sstevel@tonic-gate **/ 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate /* 3310Sstevel@tonic-gate * Type of alert to be S_QUIET'd 3320Sstevel@tonic-gate */ 3330Sstevel@tonic-gate #define QA_FORM 1 3340Sstevel@tonic-gate #define QA_PRINTER 2 3350Sstevel@tonic-gate #define QA_PRINTWHEEL 3 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /** 3380Sstevel@tonic-gate ** File modes: 3390Sstevel@tonic-gate ** (The "NO" prefix is relative to ``others''.) 3400Sstevel@tonic-gate **/ 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate #define MODE_READ (mode_t)0664 3430Sstevel@tonic-gate #define MODE_NOREAD (mode_t)0660 3440Sstevel@tonic-gate #define MODE_EXEC (mode_t)0775 3450Sstevel@tonic-gate #define MODE_NOEXEC (mode_t)0770 3460Sstevel@tonic-gate #define MODE_DIR (mode_t)0775 3470Sstevel@tonic-gate #define MODE_NODIR (mode_t)0770 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate extern int printlist_qsep; 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate extern char Lp_Spooldir[], 3520Sstevel@tonic-gate Lp_Admins[], 3530Sstevel@tonic-gate Lp_Bin[], 3540Sstevel@tonic-gate Lp_FIFO[], 3550Sstevel@tonic-gate Lp_Logs[], 3560Sstevel@tonic-gate Lp_ReqLog[], 3570Sstevel@tonic-gate Lp_Model[], 3580Sstevel@tonic-gate Lp_Requests[], 3590Sstevel@tonic-gate Lp_Secure[], 3600Sstevel@tonic-gate Lp_Schedlock[], 3610Sstevel@tonic-gate Lp_Slow_Filter[], 3620Sstevel@tonic-gate Lp_System[], 3630Sstevel@tonic-gate Lp_Temp[], 3640Sstevel@tonic-gate Lp_Tmp[], 3650Sstevel@tonic-gate Lp_Users[], 3660Sstevel@tonic-gate Lp_A[], 3670Sstevel@tonic-gate Lp_A_Classes[], 3680Sstevel@tonic-gate Lp_A_Forms[], 3690Sstevel@tonic-gate Lp_A_Interfaces[], 3700Sstevel@tonic-gate Lp_A_Logs[], 3710Sstevel@tonic-gate Lp_A_Printers[], 3720Sstevel@tonic-gate Lp_A_PrintWheels[], 3730Sstevel@tonic-gate Lp_A_Filters[], 3740Sstevel@tonic-gate Lp_A_Systems[], 3750Sstevel@tonic-gate Lp_Default[], 3760Sstevel@tonic-gate Lp_A_Faults[]; 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate /* 3790Sstevel@tonic-gate * File access: 3800Sstevel@tonic-gate */ 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate extern int open_locked(char *, char *, mode_t); 3830Sstevel@tonic-gate extern char *fdgets(char *, int, int); 3840Sstevel@tonic-gate extern int fdprintf(int, char *, ...); 3850Sstevel@tonic-gate extern int fdputs(char *, int); 3860Sstevel@tonic-gate extern int fdputc(char, int); 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate extern int is_printer_uri(char *); 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate FILE *open_lpfile ( char * , char * , mode_t ); 3910Sstevel@tonic-gate int close_lpfile ( FILE * ); 3920Sstevel@tonic-gate int chown_lppath ( char * path ); 3930Sstevel@tonic-gate int mkdir_lpdir ( char * path , int mode ); 3940Sstevel@tonic-gate int rmfile ( char * path ); 3950Sstevel@tonic-gate int dumpstring ( char * path , char * str ); 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate char * loadstring ( char * path ); 3980Sstevel@tonic-gate char * loadline ( char * path ); 3990Sstevel@tonic-gate char * sop_up_rest (int, char * endsop ); 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate /* 4020Sstevel@tonic-gate * List manipulation routines: 4030Sstevel@tonic-gate */ 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate #define emptylist(LP) (!(LP) || !(LP)[0]) 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate int addlist ( char *** , char * ); 4080Sstevel@tonic-gate int addstring ( char ** , char * ); 4090Sstevel@tonic-gate int appendlist ( char *** , char * ); 4100Sstevel@tonic-gate int dellist ( char *** , char * ); 4110Sstevel@tonic-gate int joinlist ( char *** , char ** ); 4120Sstevel@tonic-gate int lenlist ( char ** ); 4130Sstevel@tonic-gate int printlist ( FILE * , char ** ); 4140Sstevel@tonic-gate int fdprintlist(int , char ** ); 4150Sstevel@tonic-gate int searchlist ( char *, char ** ); 4160Sstevel@tonic-gate int searchlist_with_terminfo ( char * , char ** ); 4170Sstevel@tonic-gate 4180Sstevel@tonic-gate char ** duplist ( char ** ); 4190Sstevel@tonic-gate char ** getlist ( char * , char * , char * ); 4200Sstevel@tonic-gate char ** dashos ( char * ); 4210Sstevel@tonic-gate char ** wherelist ( char * , char ** ); 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate char * sprintlist ( char ** ); 4240Sstevel@tonic-gate char * search_cslist ( char * , char ** ); 4250Sstevel@tonic-gate 4260Sstevel@tonic-gate void freelist ( char ** ); 4270Sstevel@tonic-gate void printlist_setup ( char * , char * , char * , char * ); 4280Sstevel@tonic-gate void printlist_unsetup ( void ); 4290Sstevel@tonic-gate 4300Sstevel@tonic-gate /* 4310Sstevel@tonic-gate * Scaled decimal number routines: 4320Sstevel@tonic-gate */ 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate #define getsdn(S) _getsdn(S, (char **)0, 0) 4350Sstevel@tonic-gate #define getcpi(S) _getsdn(S, (char **)0, 1) 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate #define N_COMPRESSED 9999 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate void printsdn ( FILE * , SCALED ); 4400Sstevel@tonic-gate void fdprintsdn ( int , SCALED ); 4410Sstevel@tonic-gate void printsdn_setup ( char * , char * , char * ); 4420Sstevel@tonic-gate void printsdn_unsetup ( void ); 4430Sstevel@tonic-gate 4440Sstevel@tonic-gate SCALED _getsdn ( char * , char ** , int ); 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate /* 4470Sstevel@tonic-gate * File name routines: 4480Sstevel@tonic-gate */ 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate char * makepath ( char * , ... ); 4510Sstevel@tonic-gate char * getspooldir ( void ); 4520Sstevel@tonic-gate char * getrequestfile ( char * ); 4530Sstevel@tonic-gate char * getprinterfile ( char * , char * ); 4540Sstevel@tonic-gate char * getsystemfile ( char * , char * ); 4550Sstevel@tonic-gate char * getclassfile ( char * ); 4560Sstevel@tonic-gate char * getfilterfile ( char * ); 4570Sstevel@tonic-gate char * getformfile ( char * , char * ); 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate /* 4600Sstevel@tonic-gate * Additional string manipulation routines: 4610Sstevel@tonic-gate */ 4620Sstevel@tonic-gate 4630Sstevel@tonic-gate int cs_strcmp ( char * , char * ); 4640Sstevel@tonic-gate int cs_strncmp ( char * , char * , int ); 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate /* 4670Sstevel@tonic-gate * Syntax checking routines: 4680Sstevel@tonic-gate */ 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate int syn_name ( char * ); 4710Sstevel@tonic-gate int syn_text ( char * ); 4720Sstevel@tonic-gate int syn_comment ( char * ); 4730Sstevel@tonic-gate int syn_machine_name ( char * ); 4740Sstevel@tonic-gate int syn_option ( char * ); 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate /* 4770Sstevel@tonic-gate * Alert management routines: 4780Sstevel@tonic-gate */ 4790Sstevel@tonic-gate 4800Sstevel@tonic-gate int putalert ( char * , char * , FALERT * ); 4810Sstevel@tonic-gate int delalert ( char * , char * ); 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate FALERT * getalert ( char * , char * ); 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate void printalert ( FILE * , FALERT * , int ); 4860Sstevel@tonic-gate 4870Sstevel@tonic-gate /* 4880Sstevel@tonic-gate * Terminfo Database Inquiry Tool 4890Sstevel@tonic-gate */ 4900Sstevel@tonic-gate 4910Sstevel@tonic-gate int tidbit ( char * , char * , ... ); 4920Sstevel@tonic-gate void untidbit ( char * ); 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate /* 4950Sstevel@tonic-gate * Auto-restarting and other system calls: 4960Sstevel@tonic-gate * The two versions are here to reduce the chance of colliding 4970Sstevel@tonic-gate * with similar names in standard libraries (e.g. dial(3C) uses 4980Sstevel@tonic-gate * Read/Write). 4990Sstevel@tonic-gate */ 5000Sstevel@tonic-gate 5010Sstevel@tonic-gate #define Access _Access 5020Sstevel@tonic-gate #define Chdir _Chdir 5030Sstevel@tonic-gate #define Chmod _Chmod 5040Sstevel@tonic-gate #define Chown _Chown 5050Sstevel@tonic-gate #define Close _Close 5060Sstevel@tonic-gate #define Creat _Creat 5070Sstevel@tonic-gate #define Fcntl _Fcntl 5080Sstevel@tonic-gate #define Fstat _Fstat 5090Sstevel@tonic-gate #define Link _Link 5100Sstevel@tonic-gate #define Lstat _Lstat 5110Sstevel@tonic-gate #define Mknod _Mknod 5120Sstevel@tonic-gate #define Open _Open 5130Sstevel@tonic-gate #define Read _Read 5140Sstevel@tonic-gate #define Readlink _Readlink 5150Sstevel@tonic-gate #define Rename _Rename 5160Sstevel@tonic-gate #define Stat _Stat 5170Sstevel@tonic-gate #define Symlink _Symlink 5180Sstevel@tonic-gate #define Unlink _Unlink 5190Sstevel@tonic-gate #define Wait _Wait 5200Sstevel@tonic-gate #define Write _Write 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate #define Malloc(size) _Malloc(size, __FILE__, __LINE__) 5230Sstevel@tonic-gate #define Realloc(ptr,size) _Realloc(ptr, size, __FILE__, __LINE__) 5240Sstevel@tonic-gate #define Calloc(nelem,elsize) _Calloc(nelem, elsize, __FILE__, __LINE__) 5250Sstevel@tonic-gate #define Strdup(s) _Strdup(s, __FILE__, __LINE__) 5260Sstevel@tonic-gate #define Free(ptr) _Free(ptr, __FILE__, __LINE__) 5270Sstevel@tonic-gate 5280Sstevel@tonic-gate int _Access ( char * , int ); 5290Sstevel@tonic-gate int _Chdir ( char * ); 5300Sstevel@tonic-gate int _Chmod ( char * , int ); 5310Sstevel@tonic-gate int _Chown ( char * , int , int ); 5320Sstevel@tonic-gate int _Close ( int ); 5330Sstevel@tonic-gate int _Creat ( char * , int ); 5340Sstevel@tonic-gate int _Fcntl ( int , int , ... ); 5350Sstevel@tonic-gate int _Fstat ( int , struct stat * ); 5360Sstevel@tonic-gate int _Link ( char * , char * ); 5370Sstevel@tonic-gate int _Lstat ( char * , struct stat * ); 5380Sstevel@tonic-gate int _Mknod ( char * , int , int ); 5390Sstevel@tonic-gate int _Mkpipe ( char * , int , int ); 5400Sstevel@tonic-gate int _Open ( char * , int , ... /* mode_t */ ); 5410Sstevel@tonic-gate int _Read ( int , char * , unsigned int ); 5420Sstevel@tonic-gate int _Readlink ( char * , char * , unsigned int ); 5430Sstevel@tonic-gate int _Rename ( char * , char * ); 5440Sstevel@tonic-gate int _Symlink ( char * , char * ); 5450Sstevel@tonic-gate int _Stat ( char * , struct stat * ); 5460Sstevel@tonic-gate int _Unlink ( char * ); 5470Sstevel@tonic-gate int _Wait ( int * ); 5480Sstevel@tonic-gate int _Write ( int , char * , unsigned int ); 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate void * _Malloc ( size_t , const char * , int ); 5510Sstevel@tonic-gate void * _Realloc ( void * , size_t , const char * , int ); 5520Sstevel@tonic-gate void * _Calloc ( size_t , size_t , const char * , int ); 5530Sstevel@tonic-gate char * _Strdup ( const char * , const char * , int ); 5540Sstevel@tonic-gate void _Free ( void * , const char * , int ); 5550Sstevel@tonic-gate 5560Sstevel@tonic-gate /* 5570Sstevel@tonic-gate * Misc. routines: 5580Sstevel@tonic-gate */ 5590Sstevel@tonic-gate 5600Sstevel@tonic-gate int isterminfo ( char * ); 5610Sstevel@tonic-gate int isprinter ( char * ); 5620Sstevel@tonic-gate int isrequest ( char * ); 5630Sstevel@tonic-gate int isnumber ( char * ); 5640Sstevel@tonic-gate 5650Sstevel@tonic-gate char * getname ( void ); 5660Sstevel@tonic-gate char * makestr ( char * , ... ); 5670Sstevel@tonic-gate char * strip ( char * ); 5680Sstevel@tonic-gate 5690Sstevel@tonic-gate void sendmail ( char * , char * ); 5700Sstevel@tonic-gate 5710Sstevel@tonic-gate void (*lp_alloc_fail_handler)( void ); 5720Sstevel@tonic-gate 5730Sstevel@tonic-gate /* 5740Sstevel@tonic-gate * Originally part of liblpfs.a and fs.h, now no longer needed 5750Sstevel@tonic-gate * since the code doesn't have to work on pre-SVR4.0. 5760Sstevel@tonic-gate */ 5770Sstevel@tonic-gate #define Opendir opendir 5780Sstevel@tonic-gate #define Telldir telldir 5790Sstevel@tonic-gate #define Seekdir seekdir 5800Sstevel@tonic-gate #define Rewinddir(dirp) Seekdir(dirp, 0L) 5810Sstevel@tonic-gate #define Closedir closedir 5820Sstevel@tonic-gate #define Readdir readdir 5830Sstevel@tonic-gate #define Mkdir mkdir 5840Sstevel@tonic-gate #define Rmdir rmdir 5850Sstevel@tonic-gate 5860Sstevel@tonic-gate #define next_dir(base, ptr) next_x(base, ptr, S_IFDIR) 5870Sstevel@tonic-gate #define next_file(base, ptr) next_x(base, ptr, S_IFREG) 5880Sstevel@tonic-gate 589547Sjacobs extern int chownmod(char *path, uid_t owner, gid_t group, mode_t mode); 590547Sjacobs 591547Sjacobs 5920Sstevel@tonic-gate char * next_x ( char * , long * , unsigned int ); 5930Sstevel@tonic-gate 594*1676Sjpk /* 595*1676Sjpk * Stuff needed for Trusted Extensions 596*1676Sjpk */ 597*1676Sjpk 598*1676Sjpk extern char *get_labeled_zonename(char *); 599*1676Sjpk extern int get_peer_label(int fd, char **slabel); 600*1676Sjpk 601*1676Sjpk 602634Sdp #ifdef __cplusplus 603634Sdp } 6040Sstevel@tonic-gate #endif 605634Sdp 606634Sdp #endif /* _LP_LP_H */ 607