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