lpsched.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9.1.11 */
#include "stdio.h"
#include "memory.h"
#include "string.h"
#include "pwd.h"
#include "fcntl.h"
#include "errno.h"
#include "signal.h"
#include "unistd.h"
#include "stdlib.h"
#include "lp.h"
#include "access.h"
#include "form.h"
#include "requests.h"
#include "filters.h"
#include "printers.h"
#include "class.h"
#include "users.h"
#include "systems.h"
#include "secure.h"
#include "msgs.h"
#include "nodes.h"
/**
** Defines:
**/
/*
* These are the fields in the PSTATUS and CSTATUS files,
* found in the SYSTEM directory.
*/
#define PST_MAX 8
# define PST_BRK 0
# define PST_NAME 1
# define PST_STATUS 2
# define PST_DATE 3
# define PST_DISREAS 4
# define PST_REJREAS 5
# define PST_PWHEEL 6
# define PST_FORM 7
#define CST_MAX 5
# define CST_BRK 0
# define CST_NAME 1
# define CST_STATUS 2
# define CST_DATE 3
# define CST_REJREAS 4
/*
* Exit codes from child processes:
*
* 0 <= exit <= 0177 (127) are reserved for ``normal'' exits.
* 0200 <= exit <= 0377 (255) are reserved for special failures.
*
* If bit 0200 is set, then we have three sets of special error
* codes available, with 32 values in each set (except the first):
*
* 0201 - 0237 Printer faults
* 0240 - 0277 Dial problems
* 0300 - 0337 Port problems
* 0340 - 0377 Exec problems
*
* 0200 Interface received SIGTERM
*/
#define EXEC_EXIT_OKAY 0 /* success */
/*
* If killed, return signal, else 0.
*/
/*
* If exited, return exit code, else -1.
*/
/*
* Events that can be scheduled:
*/
#define EV_SLOWF 1
#define EV_INTERF 2
#define EV_NOTIFY 3
#define EV_LATER 4
#define EV_ALARM 5
#define EV_MESSAGE 6
#define EV_CHECKCHILD 7
#define EV_SYSTEM 8
#define EV_ENABLE 9
#define EV_POLLBSDSYSTEMS 10
#define EV_FORM_MESSAGE 11
#define EV_STATUS 12
/*
* How long to wait before retrying an event:
* (For best results, make CLOCK_TICK a factor of 60.)
*/
/*
* Alert types:
*/
#define A_PRINTER 1
#define A_PWHEEL 2
#define A_FORM 3
/*
* How to handle active requests when disabling a printer:
*/
#define DISABLE_STOP 0
#define DISABLE_FINISH 1
#define DISABLE_CANCEL 2
/*
* validate_request() - VERIFY REQUEST CAN BE PRINTED
* evaluate_request() - TRY REQUEST ON A PARTICULAR PRINTER
* reevaluate_request() - TRY TO MOVE REQUEST TO ANOTHER PRINTER
*/
/*
* Request is ready to be slow-filtered:
*/
#define NEEDS_FILTERING(PRS) \
/*
* Where requests are handled:
*/
/*
* Misc:
*/
#define makereqerr(PRS) \
makepath( \
Lp_Tmp, \
(char *)0 \
)
#define EVER ;;
#define DEFAULT_SHELL "/bin/sh"
#if defined(MLISTENDEL_WORKS)
mlistendel (MD); \
mdisconnect (MD); \
} else /*EMPTY*/
#else
} else /*EMPTY*/
#endif
/**
** External routines:
**/
typedef int (*qchk_fnc_type)( RSTATUS * );
CSTATUS * search_ctable ( char * );
CSTATUS * walk_ctable ( int );
FSTATUS * search_fptable(register char *);
FSTATUS * search_ftable ( char * );
FSTATUS * walk_ftable ( int );
PRINTER * Getprinter ( char * );
PSTATUS * search_ptable ( char * );
PSTATUS * walk_ptable ( int );
PWSTATUS * search_pwtable ( char * );
PWSTATUS * walk_pwtable ( int );
REQUEST * Getrequest ( char * );
RSTATUS * request_by_id ( char * );
RSTATUS * request_by_id_num ( long );
RSTATUS * request_by_jobid ( char * , char * );
char * dispatchName(int);
char * statusName(int);
char * getreqno ( char * );
int Loadfilters ( char * );
int exec ( int , ... );
int one_printer_with_charsets ( RSTATUS * );
int open_dialup ( char * , PRINTER * );
int open_direct ( char * , PRINTER * );
int qchk_filter ( RSTATUS * );
int qchk_pwheel ( RSTATUS * );
int qchk_waiting ( RSTATUS * );
long getkey ( void );
long _alloc_req_id ( void );
void add_flt_act ( MESG * , ... );
void alert ( int , ... );
void cancel_alert ( int , ... );
void check_children ( void );
void check_request ( RSTATUS * );
void del_flt_act ( MESG * , ... );
void dowait ( void );
void dump_cstatus ( void );
void dump_fault_status(PSTATUS *);
void dump_pstatus ( void );
void dump_status ( void );
void execlog ( char * , ... );
void fail ( char * , ... );
void freerstatus ( register RSTATUS * );
void init_memory ( void );
void init_messages ( void );
void load_status ( void );
void load_str ( char ** , char * );
void lp_endpwent ( void );
void lp_setpwent ( void );
void lpfsck ( void );
void lpshut ( int );
void mallocfail ( void );
void maybe_schedule ( RSTATUS * );
void note ( char * , ... );
void clear_printer_fault ( PSTATUS * , char * );
void putjobfiles ( RSTATUS * );
void queue_check ( int (*)( RSTATUS * ) );
void queue_pwheel ( RSTATUS * , char * );
void schedule ( int , ... );
void take_message ( void );
void unload_list ( char *** );
void unload_str ( char ** );
void unqueue_form ( RSTATUS * );
void unqueue_pwheel ( RSTATUS * );
void update_req ( char * , long );
/*
* Things that can't be passed as parameters:
*/
extern FSTATUS *form_in_question;
extern char *pwheel_in_question;
/**
** External tables, lists:
**/
*Exec_Notify; /* First notification exec */
extern int CT_Size, /* Size of class table */
ET_Size, /* Size of exec table */
ET_SlowSize, /* Number of filter execs */
ET_NotifySize, /* Number of notify execs */
FT_Size, /* Size of form table */
PT_Size, /* Size of printer table */
PWT_Size, /* Size of print wheel table */
ST_Size, /* Size of system status table */
ST_Count; /* No. active entries in above */
#if defined(DEBUG)
#define DB_EXEC 0x00000001
#define DB_DONE 0x00000002
#define DB_INIT 0x00000004
#define DB_ABORT 0x00000008
#define DB_SCHEDLOG 0x00000010
#define DB_SDB 0x00000020
#define DB_MESSAGES 0x00000040
#define DB_MALLOC 0x00000080
#define DB_ALL 0xFFFFFFFF
extern unsigned long debug;
#endif
extern char *Local_System, /* Node name of local system */
*SHELL; /* value of $SHELL, or default */
extern int lock_fd;
extern int Starting,
extern unsigned long chkprinter_result;
#if defined(MDL)
#include "mdl.h"
#endif