1 #ident "$Id: fax_lib.h,v 4.19 2007/05/16 15:24:46 gert Exp $ Copyright (c) Gert Doering"
2 
3 
4 /* fax_lib.h
5  *
6  * declare protopes for all the fax functions in faxrec.c and faxlib.c
7  * declare global variables set by functions in faxlib.c
8  * declare all the constants required for Class 2 faxing
9  */
10 
11 /* data types + variables */
12 
13 typedef enum { Mt_unknown, Mt_data,
14 		Mt_class1,	/* TIA/EIA 578 standard */
15 		Mt_class1_0,	/* ITU T.31 standard */
16 		Mt_class2, 	/* SP-2388 / EIA 592 drafts */
17 		Mt_class2_0,	/* TIA/EIA 592 standard */
18 		Mt_class2_1	/* ITU T.32 standard */
19 		} Modem_type;
20 extern Modem_type modem_type;
21 
22 typedef enum { pp_mps, pp_eom, pp_eop,
23 	       pp_pri_mps, pp_pri_eom, pp_pri_eop } Post_page_messages;
24 
25 extern unsigned char fax_send_swaptable[], fax_recv_swaptable[];
26 
27 /* function prototypes */
28 
29 int fax_send _PROTO(( char * s, int fd ));	/* write to fd, with logging */
30                                          /* expect string, handle fax msgs */
31 int fax_wait_for _PROTO(( char * s, int fd ));
32 int fax_command _PROTO(( char * send, char * expect, int fd ));
33 
34 void fax_find_directory _PROTO(( char * dirlist, char * directory, int size ));
35 int fax_get_pages _PROTO(( int fd, int * pagenum, char * directory,
36 			   int uid, int gid, int mode ));
37 int fax_get_page_data _PROTO(( int modem_fd, int pagenum, char * directory,
38 			       int uid, int gid, int file_mode ));
39 
40 int fax_set_l_id _PROTO(( int fd, char * fax_id ));
41 int fax_set_fdcc _PROTO(( int fd, int fine, int maxsp, int minsp ));
42 int fax_set_bor  _PROTO(( int fd, int bit_order ));
43 int fax_set_flowcontrol _PROTO(( int fd, int hw_flow ));
44 int mdm_identify _PROTO(( int fd ));
45 void fax2_incoming_nsf _PROTO(( char * nsf_hex ));
46 void fax1_incoming_nsf _PROTO(( uch * nsf_bin, int len ));
47 void hylafax_nsf_decode _PROTO(( uch * nsf, int nsfSize ));
48 
49 #ifdef __TIO_H__
50 int fax_send_page _PROTO(( char * g3_file, int * bytes_sent, TIO * tio,
51 			   Post_page_messages ppm, int fd ));
52 int fax_send_ppm  _PROTO(( int fd, TIO *tio, Post_page_messages ppm ));
53 #endif
54 
55 Modem_type fax_get_modem_type _PROTO(( int fd, char * mclass ));
56 
57 typedef	struct	{ short vr, br, wd, ln, df, ec, bf, st; } fax_param_t;
58 
59 #ifdef CLASS1
60 /* prototypes for class 1 functions */
61 int fax1_dial_and_phase_AB _PROTO(( char * dial_cmd, int fd ));
62 int fax1_highlevel_receive _PROTO(( int fd, int * pagenum, char * dirlist,
63 		                    int uid, int gid, int mode));
64 int fax1_set_l_id _PROTO(( int fd, char * fax_id ));
65 int fax1_set_fdcc _PROTO(( int fd, int fine, int max, int min ));
66 extern boolean fax1_receive_have_connect;
67 #endif
68 
69 /* g3file.c */
70 typedef int (in_func_t)(char *, int);
71 in_func_t g3_rf_chunk;
72 
73 int g3_open_read _PROTO(( char * filename ));
74 void g3_close _PROTO((void));
75 int g3_send_file _PROTO((in_func_t * in_func, int out_fd, int is_device,
76 			 int escape_dle, int pad_bytes, int fax_res ));
77 
78 extern	char	fax_remote_id[];		/* remote FAX id +FTSI */
79 extern	char	fax_param[];			/* transm. parameters +FDCS */
80 extern	char	fax_hangup;
81 extern	int	fax_hangup_code;
82 extern	int	fax_page_tx_status;
83 extern	fax_param_t	fax_par_d;
84 extern	boolean	fax_to_poll;			/* there's something */
85 						/* to poll */
86 extern	boolean	fax_poll_req;			/* caller wants to poll */
87 
88 extern	boolean	fhs_details;			/* +FHS:x,lc info avail.*/
89 extern	int	fhs_lc, fhs_blc, fhs_cblc, fhs_lbc;	/* details */
90 
91 extern	int	modem_quirks;			/* modem specials */
92 
93 
94 /* fax_hangup_code gives the reason for failure, normally it's a positive
95  * number returned by the faxmodem in the "+FHNG:iii" response. If the
96  * modem returned BUSY or NO_CARRIER or ERROR, we use negative numbers to
97  * signal what has happened. "-5" means something toally unexpeced.
98  */
99 
100 #define	FHUP_BUSY	-2
101 #define FHUP_NODIAL	-3
102 #define FHUP_ERROR	-4
103 #define FHUP_UNKNOWN	-5
104 #define FHUP_TIMEOUT    -6
105 
106 #define ETX	003
107 #define DLE	020
108 #define SUB	032
109 #define DC2	022
110 #define XON	021
111 #define XOFF	023
112 #define CAN	030		/* ctrl-x, abort */
113 
114 #ifndef ERROR
115 #define	ERROR	-1
116 #define NOERROR	0
117 #endif
118 
119 /* modem_quirks specifies some details in this modem's implementation
120  * that are just *different* from the usual...
121  */
122 
123 #define MQ_NEED2	0x01	/* must be in +FCLASS=2 for +FAA=1 to work */
124 #define MQ_FBOR_OK	0x02	/* +FBOR implemented correctly (Multitech) */
125 #define MQ_NO_LQC	0x04	/* +FPS:x,lc,blc can't be trusted */
126 #define MQ_NO_XON	0x08	/* do not wait for XON char when sending */
127 #define MQ_NEED_SP_PAD	0x10	/* modem needs 0-padding before start of page */
128 #define MQ_USR_FMINSP	0x20	/* USR: +FCC=1,<max> sets MIN speed instead */
129 #define MQ_SHOW_NSF	0x40	/* set AT+FNR=1,1,1,1 (with NSFs) */
130 #define MQ_FPS_NOT_HEX	0x80	/* +FPS:<status>,<lc> reported as decimal */
131 
132 /* note: 0x100 and 0x200 currently used for teergrubing - faxrecp.c */
133 
134 #define MQ_C1_NO_V17	0x400	/* class1: don't use V.17, even if adv. */
135