1 /***************************************************************************
2  * LPRng - An Extended Print Spooler System
3  *
4  * Copyright 1988-2003, Patrick Powell, San Diego, CA
5  *     papowell@lprng.com
6  * See LICENSE for conditions of use.
7  ***************************************************************************/
8 
9 
10 
11 #ifndef _UTILITIES_H_
12 #define _UTILITIES_H_ 1
13 
14 #include <setjmp.h>
15 
16 EXTERN volatile int Alarm_timed_out;      /* flag */
17 EXTERN volatile int Timeout_pending;
18 
19 #if defined(HAVE_SIGLONGJMP)
20 EXTERN sigjmp_buf Timeout_env;
21 #  define Set_timeout() (sigsetjmp(Timeout_env,1)==0)
22 #else
23 EXTERN jmp_buf Timeout_env;
24 #  define Set_timeout() (setjmp(Timeout_env)==0)
25 #endif
26 
27 /* PROTOTYPES */
28 char *Time_str(int shortform, time_t t);
29 char *Pretty_time( time_t t );
30 time_t Convert_to_time_t( char *str );
31 void Printlist( const char **m, int fd );
32 int Write_fd_len( int fd, const char *msg, int len );
33 int Write_fd_len_timeout( int timeout, int fd, const char *msg, int len );
34 int Write_fd_str( int fd, const char *msg );
35 int Write_fd_str_timeout( int timeout, int fd, const char *msg );
36 int Read_fd_len_timeout( int timeout, int fd, char *msg, int len );
37 plp_sigfunc_t plp_signal (int signo, plp_sigfunc_t func);
38 plp_sigfunc_t plp_signal_break (int signo, plp_sigfunc_t func);
39 void plp_block_all_signals ( plp_block_mask *oblock );
40 void plp_unblock_all_signals ( plp_block_mask *oblock );
41 void plp_set_signal_mask ( plp_block_mask *in, plp_block_mask *out );
42 void plp_unblock_one_signal ( int sig, plp_block_mask *oblock );
43 void plp_block_one_signal( int sig, plp_block_mask *oblock );
44 void plp_sigpause( void );
45 int safestrcasecmp (const char *s1, const char *s2);
46 int safestrncasecmp (const char *s1, const char *s2, int len );
47 int safestrcmp( const char *s1, const char *s2 );
48 int safestrlen( const char *s1 );
49 int safestrncmp( const char *s1, const char *s2, int len );
50 char *safestrchr( const char *s1, int c );
51 char *safestrrchr( const char *s1, int c );
52 char *safestrpbrk( const char *s1, const char *s2 );
53 int plp_usleep( int i );
54 int plp_sleep( int i );
55 int Get_max_servers( void );
56 int Get_max_fd( void );
57 char *Brk_check_size( void );
58 char *mystrncat( char *s1, const char *s2, int len );
59 char *mystrncpy( char *s1, const char *s2, int len );
60 int Get_nonblock_io( int fd );
61 int Set_nonblock_io( int fd );
62 int Set_block_io( int fd );
63 int Read_write_timeout(
64 	int readfd, char *inbuffer, int maxinlen, int *readlen,
65 	int writefd, char **outbuffer, int *outlen, int timeout );
66 void Set_timeout_signal_handler( int timeout, plp_sigfunc_t handler );
67 void Set_timeout_alarm( int timeout );
68 void Set_timeout_break( int timeout );
69 void Clear_timeout( void );
70 void Setup_uid(void);
71 int To_euid_root(void);
72 int To_daemon(void);
73 int To_user(void);
74 int To_ruid(int ruid);
75 int To_euid( int euid );
76 int setuid_wrapper(uid_t to);
77 int Full_daemon_perms(void);
78 int Full_root_perms(void);
79 int Full_user_perms(void);
80 int Getdaemon(void);
81 int Getdaemon_group(void);
82 int Set_full_group( int euid, int gid );
83 int Setdaemon_group(void);
84 void Reset_daemonuid(void);
85 double Space_avail( const char *pathname );
86 /* VARARGS2 */
87 #ifdef HAVE_STDARGS
88  int safefprintf (int fd, const char *format,...) PRINTFATTR(2,3)
89 #else
90  int safefprintf (va_alist) va_dcl
91 #endif
92 ;
93 #endif
94