File: common.h

package info (click to toggle)
cti-ifhp 2.1.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 932 kB
  • ctags: 845
  • sloc: ansic: 6,036; sh: 1,524; makefile: 318
file content (249 lines) | stat: -rw-r--r-- 7,530 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/**************************************************************************
 * LPRng IFHP Filter
 * Copyright 1994-1997 Patrick Powell, San Diego, CA <papowell@sdsu.edu>
 *
 * Based on the CTI printer filters.
 *  See COPYRIGHT for details.
 *
 * $Id: common.h,v 2.2 1997/01/06 21:59:47 papowell Exp $
*/


/****************************************************************************
 * Modification History:
 *  Extracted from ifhp4.c
 *
 * 	Revision 1.11	95/08/22	15:01:07
 *		 Version 1.2 initiated and Porting to Solaris.
 *
 */

#ifndef _COMMON_H
#define _COMMON_H 1
#ifdef EXTERN
# undef EXTERN
# undef DEFINE
# define EXTERN
# define DEFINE(X) X
#else
# undef EXTERN
# undef DEFINE
# define EXTERN extern
# define DEFINE(X)
#endif

#ifndef OFF
#	define OFF	0
#endif
#ifndef ON
#	define ON	1
#endif

#ifndef FALSE
#	define FALSE	0
#endif
#ifndef TRUE
#	define TRUE	1
#endif

#include "errorcodes.h"

#define	FILTSUCC	(plp_compat?0:JSUCC)
#define	FILTRETRY	(plp_compat?1:JFAIL)
#define	FILTABORT	(plp_compat?2:JABORT)

#define	PCL		1
#define	POSTSCRIPT	2
#define	LITERAL	3

#define IV          0
#define III         1
#define IIID        2
#define IIISi       3
#define C5M         4


#define	DIE		1

EXTERN char *name;		/* name of filter */

EXTERN char	*zopts, *class, *job, *login, *accntname, *host, *fqdnhost,
		*accntfile, *bantitle, *format, *filename, 
		*date, *username, *seq_number, *controlfile,
		*device,	/* Patrick Powell Thu Aug 24 21:01:04 PDT 1995 */
		*pr_commnt, *statusfile,
		*stty_args, *model_name, *summaryfile;
EXTERN char *printer DEFINE( = "IFHPfilter" );
EXTERN int	width, length, xwidth, ylength, debug, literal, indent, version;
EXTERN int logall;	/* log all data back from printer */ 
EXTERN int Accounting_fd;

EXTERN char *Upperopts[26];
EXTERN char *Loweropts[26];


extern char *copyright[];

EXTERN int bnr DEFINE(= 1),		/* generate a banner */
    errorcode, 	   /* status the errlog funcs exit with */
    mode,     	   /* PCL or Postscript */
    npages,        /* number of pages printed from device */
	initialpagecount,	/* initial pagecount */
    alrmflag,       /* Set by ALARM signal handling funcs */
    monitpid DEFINE( = -1),       /* pid of the port monitoring child */
	filterpid,		/* pid of the filter */
    printer_ok,
    interrupted,    /* Set when signal received */
    job_started,    /* Flag for the successful initiation of the job */
    job_ended,      /* Flag for the successful termination of the job */
	cartridge DEFINE(= 1),		/* PS cartridge */
	model,			/* model of printer */
	plp_compat,		/* PLP compatible return codes */
	of_filter,		/* OF filter */
	resourcesave,	/* resource saved */
	trace,			/* open a trace file */
	wrap,			/* wrap */
	autodetect,	    /* autodetect to determine job type */
	pagecount DEFINE( =1), /* use PJL INFO PAGECOUNT to get page counter */
#ifdef QUIET
	quiet DEFINE(=1),			/* do not report status messages */
#else
	quiet DEFINE(=0),			/* report status messages */
#endif
	get_status DEFINE( =1 ),	/* get status from printer */
	sync_printer DEFINE( =1 ),	/* synchronize with printer */
	forcepagecount DEFINE( =0 ),	/* force pagecount using PS */
	infostatus DEFINE( =1 );	/* send infostatus request */

EXTERN char    *query[10];          /* Holds the every time pjl commands
                     * sent to the printer port */
EXTERN char **Envp;	/* envp pointer */

EXTERN int wait_time DEFINE(= 30),   /* Time to wait between two retries
                       (secs) */
        retries DEFINE(= 0);    /* Number of retries if printer comes
                       off-line 0 means for ever */
EXTERN char null_str[1024];
EXTERN char *Accounting_script DEFINE( = ACCNTSH ); 
EXTERN char *default_font
# if defined(DEFLTFONT)
		DEFINE( = DEFLTFONT )
# endif
; 

#define MAXLINE	1024
EXTERN char    sendline[MAXLINE+1];
EXTERN char    readprin[MAXLINE+1];
EXTERN char    job_start[100];
EXTERN char    job_end[100];

EXTERN int Status_fd;
EXTERN int Max_status_size DEFINE( = 2 );
EXTERN int Min_status_size;

#define STDOUT	fileno(stdout)
			
#define INTV 0
#define STRV 1
#define FLGV 2
struct parm {
	int flag;
	char **var;
	int kind;
};

struct value{
	char *flag;
	char **var;
	int kind;
};


#undef _PARMS__
#ifdef __STDC__
#define _PARMS__(X) X
#else
#define _PARMS__(X) ()
#endif

void sendjob _PARMS__( (int fc, int sockfd) );
void do_of_stream _PARMS__( (FILE *fp, int sockfd) );
void Out_line _PARMS__( ( char *str ) );
int writecn _PARMS__( ( int fd, char *ptr, int nbytes ) );
void cleanup _PARMS__( ( int sig ) );
void wake_up _PARMS__( ( void ) );
void setpcl_on _PARMS__( ( void ) );
void setps_on _PARMS__( ( void ) );
void eofprinter _PARMS__( ( void ) );
void resetprinter _PARMS__( ( void ) );
void pclresetprinter _PARMS__( ( void ) );
int port_readline _PARMS__( ( int fd, char *ptr, int maxlen, int timeout ) );
int file_readline _PARMS__( ( int fd, char *ptr, int maxlen ) );
void doaccnt _PARMS__( ( int start ) );
int readpipe _PARMS__( ( int *inptr, int timeout ) );
int readpspipe _PARMS__( ( int *inptr, int timeout ) );
int get_num _PARMS__( ( char *s ) );
void forkport _PARMS__( ( void ) );
void monitorport _PARMS__( ( void ) );
void slay _PARMS__( ( int sig ) );
void nochildren _PARMS__( ( int sig ) );
void pr_late _PARMS__( ( int sig ) );
void pr_query _PARMS__( ( int fd, int n ) );
int pr_synch _PARMS__( ( int fd, int timeout ) );
int pr_status _PARMS__( ( int fd ) );
int pr_pagecount _PARMS__( ( int fd ) );
int pr_pspagecount _PARMS__( ( int fd ) );
void pr_timed _PARMS__( ( int fd ) );
void pr_ustatusoff _PARMS__( ( int fd ) );
void pr_ustatus _PARMS__( ( int fd, char *pjlstr ) );
void pr_startjob _PARMS__( ( int fd ) );
void check_job_end _PARMS__( ( void ) );
void getpjlargs _PARMS__( ( void ) );
void fexit _PARMS__( ( int i ) );
int check_code _PARMS__( ( int cd ) );
void wait_printer _PARMS__( (int i) );
void write_check _PARMS__( (int fd,char *str,char *msg,int flg) );
void get_retries _PARMS__( ( void ) );
char *getcrstr _PARMS__( ( char *s, char *match, int len ) );
void updaccnt _PARMS__( ( int i ) );
void wrap_set _PARMS__( ( void ) );
void job_page_set _PARMS__( ( void ) );
void page_set _PARMS__( ( void ) );
int sendfont _PARMS__( ( char *font ) );
void selectfont _PARMS__( ( void ) );
char *fnt_scan _PARMS__( (char *mchn) );
void newfont _PARMS__( ( char *fontname) );
void open_device _PARMS__( (void) );
void do_monitor _PARMS__( (void) );
void check_pages _PARMS__( (void) );
int open_trace _PARMS__( (void) );
void set_mode _PARMS__( (int m) );
void pr_duplex _PARMS__( (void) );
void getargs _PARMS__( (int argc, char **argv) );
void get_info _PARMS__( (void) );
void setstatus _PARMS__((char *msg ) );
void newstatus _PARMS__(( void ) );
void header_info _PARMS__(( void ) );
int setvalue _PARMS__((char *arg, char *value, struct value *v, int l));

#if defined(HAVE_STDARGS)
void log _PARMS__( (int kind, char *msg,...) );
void fatal _PARMS__( ( char *msg,...) );
void logerr _PARMS__( (int kind, char *msg,...) );
void logerr_die _PARMS__( (int kind, char *msg,...) );
int plp_snprintf (char *str, size_t count, const char *fmt, ...);
int vplp_snprintf (char *str, size_t count, const char *fmt, va_list arg);
#else
void log _PARMS__( (void) );
void fatal _PARMS__( (void) );
void logerr _PARMS__( (void) );
void logerr_die _PARMS__( (void) );
int plp_snprintf ();
int vplp_snprintf ();
#endif

const char *Errormsg _PARMS__( (int err ) );
char *Time_str _PARMS__( (void) );
const char *Sigstr _PARMS__ ((int n));

#endif /* _COMMON_H */