unstrip-downed Class 2 error messages table
[efax.git] / efaxos.h
1 #ifndef _EFAXOS_H
2 #define _EFAXOS_H
3
4 #include <time.h>
5 #include <stdlib.h>
6
7 #include "efaxlib.h"
8
9 /* signals to be caught */
10
11 #define ANSISIGS  SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM
12 #define UNIXSIGS  SIGHUP, SIGQUIT, SIGIOT, SIGALRM
13 #define CATCHSIGS ANSISIGS, UNIXSIGS
14
15 typedef enum ttymodes           /* serial port modes:  */
16 {
17     COMMAND,                    /*   19200 8N1, no f/c, DTR high */
18     SEND,                       /*   19200 send-only XON/XOFF f/c */
19     VOICECOMMAND,               /*   38400 8N1, no f/c, DTR high */
20     VOICESEND,                  /*   38400 send-only XON/XOFF f/c*/
21     DROPDTR,                    /*   ", DTR low */
22     ORIGINAL                    /*   restore original settings */
23 } ttymodes ;
24
25 /* OS-specific i/o & delay functions */
26
27 /* We define new stream i/o macros because it's not possible to
28    do non-blocking reads/writes with C stream i/o [UNIX select()
29    gives the status of the file, not the stream buffer].*/
30
31 #define IBUFSIZE 1024       /* read up to this many bytes at a time from fax */
32 #define OBUFSIZE 1024       /* maximum bytes to write at a time to fax */
33
34 typedef struct tfilestruct {
35   int fd ;
36   unsigned char *ip, *iq ;
37   unsigned char ibuf [ IBUFSIZE ] ;
38   unsigned char *ibitorder, *obitorder ;
39   int bytes, pad, lines ;
40   int hwfc ;
41   time_t start ;
42   long mstart ;
43   int rd_state ;
44 } TFILE ;
45
46 /* tgetc() is a macro like getc().  It evaluates to the next
47    character from the fax device or EOF after idle time t. */
48
49 #define tgetc(f,t) ( (f)->ip >= (f)->iq && tundrflw(f,t) == EOF ? EOF : \
50                     *(unsigned char*)(f)->ip++ )
51
52 int tundrflw ( TFILE *f, int t ) ;
53 int tgetd ( TFILE *f, int t ) ;
54 int tput ( TFILE *f, unsigned char *p, int n ) ;
55 int tdata ( TFILE *f, int t ) ;
56 int ttyopen ( TFILE *f, char *fname, int reverse, int hwfc ) ;
57 int ttymode ( TFILE *f, ttymodes mode ) ;
58 void msleep ( int t ) ;
59 long proc_ms ( void ) ;
60 int time_ms ( void ) ;
61
62 /* POSIX execl */
63
64 extern int execl ( const char *path, const char *arg , ... ) ;
65
66 /* UUCP-style device locks */
67
68 #define BINLKFLAG '#'           /* prefix to force binary lock files */
69
70                                 /* [un]lock serial port using named files */
71 int lockall ( char **lkfiles, int log ) ;
72 int unlockall ( char **lkfiles ) ;
73
74 /* extract program name to be used in messages from argv0 */  
75
76 char *efaxbasename ( char *p ) ;
77
78 /* default fax modem device */
79
80 #define FAXFILE "/dev/modem"
81
82 #endif