1 #ifndef ___MGETTY_H 2 #define ___MGETTY_H 3 4 #ident "$Id: mgetty.h,v 4.29 2005/12/31 15:52:45 gert Exp $ Copyright (c) Gert Doering" 5 6 /* mgetty.h 7 * 8 * contains most of the constants and prototypes necessary for 9 * mgetty+sendfax (except some fax constants, they are in fax_lib.h) 10 * 11 * $Log: mgetty.h,v $ 12 * Revision 4.29 2005/12/31 15:52:45 gert 13 * move typedef...uch from class1.h to mgetty.h 14 * 15 * Revision 4.28 2005/11/26 13:48:16 gert 16 * GNU/kFreeBSD portability changes 17 * 18 * Revision 4.27 2005/04/25 15:29:20 gert 19 * proper prototype for rmlocks() 20 * set SIG_HDLR_ARGS correctly on AIX5 (needs -DAIX5 in CFLAGS) 21 * 22 */ 23 24 #include "ugly.h" 25 26 /* some generic, useful defines */ 27 28 #ifndef ERROR 29 #define ERROR -1 30 #define NOERROR 0 31 #endif 32 33 #ifndef TRUE 34 #define TRUE (1==1) 35 #define FALSE (1==0) 36 #endif 37 38 #define FAIL -1 39 #define SUCCESS 0 40 41 /* defines for FIDO mailers */ 42 43 #define TSYNC 0xae 44 #define YOOHOO 0xf1 45 46 /* defines for auto detection of incoming PPP calls (->PAP/CHAP) */ 47 48 #define PPP_FRAME 0x7e /* PPP Framing character */ 49 #define PPP_STATION 0xff /* "All Station" character */ 50 #define PPP_ESCAPE 0x7d /* Escape Character */ 51 #define PPP_CONTROL 0x03 /* PPP Control Field */ 52 #define PPP_LCP_HI 0xc0 /* LCP protocol - high byte */ 53 #define PPP_LCP_LOW 0x21 /* LCP protocol - low byte */ 54 #define PPP_UNESCAPE(c) ((c) ^ 0x20) /* un-escape character */ 55 56 /* stuff in logfile.c */ 57 58 #define L_FATAL 0 59 #define L_ERROR 1 60 #define L_AUDIT 2 61 #define L_WARN 3 62 #define L_MESG 4 63 #define L_NOISE 5 64 #define L_JUNK 6 65 66 void log_init_paths _PROTO(( char * program, char * path, char * infix )); 67 void log_set_llevel _PROTO(( int level )); 68 void log_close _PROTO((void)); 69 int lputc _PROTO(( int level, char ch )); 70 int lputs _PROTO(( int level, char * s )); 71 #ifdef USE_VARARGS 72 int lprintf _PROTO(()); 73 #else 74 int lprintf _PROTO((int level, const char *format, ...)); 75 #endif 76 77 /* various defines */ 78 79 /* bsd stuff */ 80 #if defined(__BSD_NET2__) || defined(__386BSD__) || \ 81 defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ 82 defined(__MACH__) 83 # include <sys/param.h> /* defines BSD, BSD4_3 and BSD4_4 */ 84 # ifndef BSD 85 # define BSD /* just in case... */ 86 # endif 87 # if defined(__FreeBSD__) && !defined(__FreeBSD_version) 88 # include <osreldate.h> /* FreeBSD version */ 89 # endif 90 #endif 91 92 /* some versions of BSD have their own variant of fgetline that 93 * behaves differently. Just change the name for now... 94 * FIXME. 95 */ 96 #ifdef BSD 97 # define fgetline mgetty_fgetline 98 #endif 99 100 /* define here what function to use for polling for characters 101 * Chose one of the following: USE_SELECT, USE_POLL, USE_READ 102 * I recommend USE_SELECT on all machines that have it, except SCO Unix, 103 * since the tv_usec timer is not exact at all on SCO. 104 * If your System has the "nap(S)" call, you can use this instead of 105 * select(S) or poll(S) for sleeping less than one second. 106 * Ditto for usleep(S), for systems having it. 107 */ 108 #if defined(linux) || defined(_AIX) 109 # define USE_USLEEP 110 #endif 111 112 #if !defined(USE_POLL) && !defined(USE_READ) 113 #define USE_SELECT 114 #endif 115 116 /* SunOS4 does not have memmove, but bcopy handles overlapping copies 117 * as well. Watch out for src/dst argument order! 118 */ 119 120 #if defined(sunos4) || defined(NEED_MEMMOVE) 121 # define memmove(dst, src, len) bcopy(src, dst, len) 122 #endif 123 124 /* these definitions specify the return value type and the arguments 125 * for signal handler functions - if your compiler barfs, change them 126 */ 127 typedef void RETSIGTYPE; 128 129 #if defined(_SCO_DS) || defined(AIX5) /* SCO OSR 5.0 */ 130 # define SIG_HDLR_ARGS int signo 131 #else 132 # define SIG_HDLR_ARGS 133 #endif 134 135 typedef char boolean; 136 typedef unsigned char uch; 137 138 /* the cpp directive "sun" isn't useful at all, since is defined on 139 * SunOS 4, Solaris 2, and even Solaris x86... 140 * So, you have to define -Dsunos4, -Dsolaris2, or -Dsolaris86. 141 * Otherwise: barf! 142 */ 143 #ifdef sun 144 # if !defined( sunos4 ) && !defined( solaris2 ) && !defined( solaris86 ) 145 # error "Please define -Dsunos4 or -Dsolaris2 or -Dsolaris86" 146 # endif 147 #endif 148 149 #ifdef solaris2 150 # define SVR4 151 # define SVR42 152 # ifndef sun 153 # define sun 154 # endif 155 #endif 156 157 /* SGI's are SVR4... (jwz@netscape.com) */ 158 #ifdef __sgi 159 # define SVR4 160 # define SVR42 161 #endif 162 163 /* assume that all BSD systems have the siginterrupt() function 164 * for GNU libc 2.x, we need it as well (default behaviour is now "restart") 165 */ 166 #if defined(BSD) || defined(sunos4) ||\ 167 ( defined(__GLIBC__) && __GLIBC__ >= 2 ) 168 # ifndef NO_SIGINTERRUPT 169 # define HAVE_SIGINTERRUPT 170 # endif 171 #endif 172 173 /* assume that some systems do not have long filenames... 174 */ 175 #if ( defined(m88k) && !defined(SVR4) ) 176 # ifndef SHORT_FILENAMES 177 # define SHORT_FILENAMES 178 # endif 179 #endif 180 181 /* On systems we know mmap() works, it will be used for reading G3 182 * files in the tools (g3topbm.c, g3cat.c), because it is a lot faster 183 */ 184 #if defined(linux) || defined(BSD) 185 # define HAVE_MMAP 186 #endif 187 188 /* recent systems have mkstemp(), and it's more secure than mktemp() 189 * SCO does not have it, though :-( 190 */ 191 #if !defined(M_UNIX) && !defined(_3B1_) 192 # define HAVE_MKSTEMP 193 #endif 194 195 /* On a ALPHA, the config routines won't work, unless we change the 196 * union to use "void *" and "long", instead of "int" (see config.h). 197 * Same for Sparc Ultra machines [at least with SparcLinux] 198 */ 199 #if defined(__alpha__) || defined(__sparc64__) || \ 200 defined(__ia64__) || defined(__s390x__) || defined(__x86_64__) || \ 201 defined(__powerpc64__) 202 # define PTR_IS_LONG 203 #endif 204 205 #define MAXLINE 1024 /* max. # chars in a line */ 206 #define MAXPATH MAXLINE 207 #define STDIN 0 208 209 typedef enum { 210 A_TIMOUT, A_FAIL, A_FAX, A_VCON, A_CONN, 211 A_RING1, A_RING2, A_RING3, A_RING4, A_RING5 212 } action_t; 213 214 typedef struct chat_actions { 215 char * expect; 216 action_t action; } chat_action_t ; 217 218 /* do_chat.c */ 219 int do_chat _PROTO(( int filedesc, char * expect_send[], 220 chat_action_t actions[], action_t * action, 221 int chat_timeout_time, boolean timeout_first )); 222 int do_chat_send _PROTO(( int filedesc, char * send_str_with_esc )); 223 int clean_line _PROTO(( int filedesc, int tenths )); 224 225 /* ring.c */ 226 int wait_for_ring _PROTO(( int filedesc, char ** msn_list, int timeout, 227 chat_action_t actions[], action_t * action, 228 int * dist_ring_number )); 229 230 /* do_stat.c */ 231 void get_statistics _PROTO(( int filedesc, char ** chat, char * file )); 232 233 /* goodies.c */ 234 char * get_basename _PROTO(( char * )); 235 char * mydup _PROTO(( char *s )); 236 char * get_ps_args _PROTO(( int pid )); 237 238 /* io.c */ 239 boolean check_for_input _PROTO (( int fd )); 240 boolean wait_for_input _PROTO (( int fd, int seconds )); 241 void delay _PROTO(( int waittime )); 242 243 /* locks.c */ 244 #define NO_LOCK 0 /* returned by checklock() if no lock found */ 245 int makelock _PROTO((char * device)); 246 int makelock_file _PROTO(( char * lockname )); 247 int checklock _PROTO((char * device)); 248 void rmlocks _PROTO ((void)); 249 int steal_lock _PROTO((char * device, int pid )); 250 251 /* fax stuff */ 252 void faxrec _PROTO(( char * spool_dir, unsigned int switchbd, 253 int uid, int gid, int mode, char * mail_to )); 254 char * fax_strerror _PROTO(( int fax_hangup_code )); 255 void faxlib_init _PROTO((void)); 256 extern int modem_quirks; 257 258 /* initialization stuff: mg_m_init.c */ 259 int mg_init_data _PROTO(( int fd, char * chat_seq[], 260 boolean need_dsr, char * force_seq[])); 261 int mg_init_fax _PROTO(( int fd, char * mclass, char * fax_id, 262 boolean fax_only, int fax_max_speed )); 263 int mg_init_voice _PROTO(( int fd )); 264 void faxpoll_server_init _PROTO(( int fd, char * fax_server_file )); 265 int mg_open_device _PROTO(( char * devname, boolean blocking )); 266 int mg_init_device _PROTO(( int fd, boolean toggle_dtr, 267 int toggle_dtr_waittime, 268 unsigned int portspeed )); 269 int mg_get_device _PROTO(( char * devname, boolean blocking, 270 boolean toggle_dtr, int toggle_dtr_waittime, 271 unsigned int portspeed )); 272 int mg_get_ctty _PROTO(( int fd, char * devname )); 273 int mg_drop_ctty _PROTO(( int fd )); 274 275 /* modem.c */ 276 int mdm_send _PROTO(( char * send, int fd )); 277 int mdm_read_byte _PROTO(( int fd, char * c )); 278 char * mdm_get_line _PROTO(( int fd )); 279 int mdm_command _PROTO(( char * send, int fd )); 280 char * mdm_get_idstring _PROTO(( char * send, int n, int fd )); 281 282 /* logname.c */ 283 char * ln_escape_prompt _PROTO(( char * prompt )); 284 void set_env_var _PROTO(( char * var, char * string )); 285 286 /* login stuff */ 287 void login_dispatch _PROTO(( char * user, boolean is_callback, char * cf)); 288 void setup_environment _PROTO(( void )); 289 290 /* how long should I wait for a string from modem */ 291 #define FAX_RESPONSE_TIMEOUT 120 292 /* how much time may pass while receiving a fax without getting data */ 293 #define FAX_PAGE_TIMEOUT 60 294 295 /* cnd.c */ 296 297 extern char *Connect; 298 extern char *CallerId; 299 extern char *CallTime; 300 extern char *CallName; 301 extern char *CalledNr; 302 303 void cndfind _PROTO((char *str)); 304 int cndlookup _PROTO((void)); 305 int cnd_call _PROTO((char *name, char *tty, int dist_ring )); 306 307 /* disk statistics retrieval in getdisk.c */ 308 309 struct mountinfo { 310 long mi_bsize; /* fundamental block size */ 311 long mi_blocks; /* number of blocks in file system */ 312 long mi_bfree; /* number of free blocks in file system */ 313 long mi_bavail; /* blocks available to non-super user */ 314 long mi_files; /* number of file nodes in file system */ 315 long mi_ffree; /* number of free nodes in fs */ 316 }; 317 318 typedef struct mountinfo mntinf; 319 320 extern long minfreespace; 321 322 int checkspace _PROTO((char *path)); 323 int getdiskstats _PROTO ((char *path, mntinf *mi)); 324 325 /********* system prototypes **************/ 326 extern char * mktemp _PROTO(( char * template )); 327 328 #if !defined(linux) && !defined(SVR4) && !defined(__hpux) && \ 329 !defined(BSD) && !defined(M_UNIX) && !defined(_AIX) && !defined(__GLIBC__) 330 extern int getopt _PROTO(( int, char **, char * )); 331 #endif 332 extern int optind; 333 extern char * optarg; 334 335 /* system specific stuff */ 336 #ifdef ISC 337 #define fileno(p) (p)->_file 338 # ifndef O_NDELAY 339 # define O_NDELAY O_NONBLOCK 340 # endif 341 #endif 342 343 #if defined(_3B1_) || defined(MEIBE) 344 typedef ushort uid_t; 345 typedef ushort gid_t; 346 #endif 347 348 #if defined(NeXT) 349 # define NEED_PUTENV 350 # define NEED_STRDUP 351 352 char * strdup _PROTO(( char *src )); 353 #endif 354 355 /* hardware handshake flags for tio.c/tio.h 356 * we have to define them here, because otherwise config.c would break 357 */ 358 #define FLOW_NONE 0x00 359 #define FLOW_HARD 0x01 /* rts/cts */ 360 #define FLOW_XON_IN 0x02 /* incoming data, send xon/xoff */ 361 #define FLOW_XON_OUT 0x04 /* send data, honor xon/xoff */ 362 #define FLOW_SOFT (FLOW_XON_IN | FLOW_XON_OUT) 363 #define FLOW_BOTH (FLOW_HARD | FLOW_SOFT ) 364 #define FLOW_XON_IXANY 0x08 /* set IXANY flag together with IXON */ 365 366 #endif /* ___MGETTY_H */ 367