File: efaxos.h

package info (click to toggle)
efax 08a-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 352 kB
  • ctags: 532
  • sloc: ansic: 4,161; sh: 624; makefile: 79
file content (119 lines) | stat: -rw-r--r-- 3,342 bytes parent folder | download | duplicates (2)
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
#ifndef _EFAXOS_H
#define _EFAXOS_H

#ifdef DEBIAN
#include <time.h>
#endif

#ifndef PATH_MAX
#ifdef FILENAME_MAX
#define PATH_MAX FILENAME_MAX
#else
#define PATH_MAX 255
#endif
#endif

/* signals to be caught */

#define ANSISIGS  SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM
#define UNIXSIGS  SIGHUP, SIGQUIT, SIGIOT, SIGALRM
#define CATCHSIGS ANSISIGS, UNIXSIGS

/* Bit order reversal table. */

extern unsigned char normalbits [ ] ;

typedef enum ttymodes		/* serial port modes:  */
{
    COMMAND,			/*   19200 8N1, no f/c, DTR high */
    SEND,			/*   19200 send-only XON/XOFF f/c */
    VOICECOMMAND,		/*   38400 8N1, no f/c, DTR high */
    VOICESEND,			/*   38400 send-only XON/XOFF f/c*/
    DROPDTR,			/*   ", DTR low */
    ORIGINAL			/*   restore original settings */
} ttymodes ;

/* OS-specific i/o & delay functions */

/* We define new stream i/o macros because it's not possible to
   do non-blocking reads/writes with C stream i/o [UNIX select()
   gives the status of the file, not the stream buffer].*/

#define IBUFSIZE 1024	    /* read up to this many bytes at a time from fax */
#define OBUFSIZE 1024	    /* maximum bytes to write at a time to fax */

typedef struct tfilestruct {
  int fd ;
  unsigned char *ip, *iq, *op, *oq ;
  unsigned char ibuf [ IBUFSIZE ], obuf[ OBUFSIZE ] ;
  unsigned char *ibitorder, *obitorder ;
  int bytes, pad, lines ;
  time_t start ;
  long mstart ;
} TFILE ;

/* tgetc() is a macro like getc().  It evaluates to the next
   character from the fax device or EOF after idle time t. */

#define tgetc(f,t) ( (f)->ip >= (f)->iq && tundrflw(f,t) == EOF ? EOF : \
		    *(unsigned char*)(f)->ip++ )

/* tgetd() also removes DLE escapes, detects DLE-ETX terminators
   and fixes bit order. Evaluates to the next character, EOF on
   error/timeout, or -2 on DLE-ETX.  */

#define IBUFC(f) ( ((unsigned char*)(f)->ip)[-1] )

#define tgetd(f,t) ( tgetc(f,t) < 0 ? EOF : \
       IBUFC(f) != DLE ? (f)->ibitorder[ IBUFC(f) ] : \
       tgetc(f,t) == ETX ? -2 : \
       ( IBUFC(f) == DLE || IBUFC(f) == SUB ) ? (f)->ibitorder [ DLE ] : \
       msg ( "W0invalid escape sequence (DLE-%s) in data", \
	    cname ( IBUFC(f) ) ) )

/* tputc() is a macro like putc().  It evaluates to the character
   written or EOF on error. */

#define tputc(c,f,t) ( (f)->op >= (f)->oq && tflush(f,t) == EOF ? EOF : \
		    (unsigned char) ( *(f)->op++ = (c) ) )

/* tobytes() evaluates to the number of bytes in the output
   buffer */

#define tobytes(f) ( (f)->op - (f)->obuf ) 

int tundrflw ( TFILE *f, int t ) ;
int tflush   ( TFILE *f, int t ) ;
int toclear ( TFILE *f ) ;

int tdata    ( TFILE *f, int t ) ;
void tinit ( TFILE *f, int fd, int reverse ) ;
int ttyopen  ( TFILE *f, char *fname, int reverse ) ;
int ttymode  ( TFILE *f, ttymodes mode ) ;
void msleep  ( int t ) ;
long proc_ms ( void ) ;
int time_ms ( void ) ;

/* POSIX execl */

extern int execl ( const char *path, const char *arg , ... ) ;

/* UUCP-style device locks */

#define HDBLKFLAG '#'		/* prefix to force HDB (text) lock files */

				/* [un]lock serial port using named files */
int lockall ( char **lkfiles, int log ) ;
int unlockall ( char **lkfiles ) ;

/* extract program name to be used in messages from argv0 */  

char *efaxbasename ( char *p ) ;

/* default fax modem device */

#define FAXFILE "/dev/fax"



#endif