head	1.5;
access;
symbols
	OCT93:1.5;
locks;
comment	@ * @;


1.5
date	93.10.25.02.20.15;	author Rhialto;	state Exp;
branches;
next	1.4;

1.4
date	93.09.18.20.16.23;	author Rhialto;	state Exp;
branches;
next	1.3;

1.3
date	93.06.11.23.22.07;	author Rhialto;	state Exp;
branches;
next	1.2;

1.2
date	93.06.11.16.15.25;	author Rhialto;	state Exp;
branches;
next	1.1;

1.1
date	93.06.11.15.19.27;	author Rhialto;	state Exp;
branches;
next	;


desc
@Magic constants for class 2 fax commands
@


1.5
log
@Make +FBOR flexible.
@
text
@/* $Id: c2proto.h,v 1.4 1993/09/18 20:16:23 Rhialto Exp $
 * $Log: c2proto.h,v $
 * Revision 1.4  1993/09/18  20:16:23  Rhialto
 * Add BOR_*, FAX_F_FPOLL.
 *
 * Revision 1.3  1993/06/11  23:22:07  Rhialto
 * Add definition of DC2.
 *
 * Revision 1.2  1993/06/11  16:15:25  Rhialto
 * First real RCS checkin
 *
 */
/*
  c2proto.h

  (c) Copyright 1991 by David M. Siegel.
      All rights reserved.

  %W% %G% %U%
*/

#ifndef in_libfax_c2proto_h
#define in_libfax_c2proto_h 1

#define TRUE  1
#define FALSE 0

#define ETX  '\003'
#define DLE  '\020'
#define XON  '\021'     /* DC1 */
#define DC2  '\022'     /* DC2 */
#define XOFF '\023'     /* DC3 */
#define CAN  '\030'

/*
 * Various timeouts are defined here, in seconds:
 */
#define TIMEOUT_CONNECT     60	/* wait for a connection		*/
#define TIMEOUT_HANGUP	    5	/* wait for hangup to complete		*/
#define TIMEOUT_ANSWER	    15	/* wait for phone to be answered	*/
#define TIMEOUT_END_PAGE    120 /* wait for end of page to be acked	*/
#define TIMEOUT_END_XMIT    120 /* wait for end of xmit to be acked	*/
#define TIMEOUT_BIT_REVERSE 5	/* wait for bit reverse to be acked	*/
#define TIMEOUT_BYTE_ALIGN  5	/* wait for byte align to be acked	*/
#define TIMEOUT_SET_CAPABILITIES  5 /* wait for set capabilities ack	*/
#define TIMEOUT_SEND_PAGE   60	/* final send of page timeout		*/
#define TIMEOUT_RECV_PAGE   60	/* final recv page ack			*/
#define TIMEOUT_WANT_POLL   5	/* wait for +FSPL to be acked           */
#define TIMEOUT_FDT	    180 /* wait for begin of page negotiations  */

/*
 * Standard Hayes-style modem result codes:
 */
#define RESULT_OK		0
#define RESULT_CONNECT		1
#define RESULT_RING		2
#define RESULT_NO_CARRIER	3
#define RESULT_ERROR		4
#define RESULT_NO_DIALTONE	6
#define RESULT_BUSY		7
#define RESULT_NO_ANSWER	8

/*
 * Post page response codes:
 */
#define PPR_MCF 	1	/* page good				*/
#define PPR_RTN 	2	/* page bad; retrans requested		*/
#define PPR_RTP 	3	/* page good; retrans requested 	*/
#define PPR_PIN 	4	/* page bad; interrupt requested	*/
#define PPR_PIP 	5	/* page good; interrupt requested	*/

/* vertical resolution */
#define VR_NORMAL	0	/* 7.6/mm */
#define VR_FINE 	1	/* 3.8/mm */

/* baud rate */
#define BR_2400 	0
#define BR_4800 	1
#define BR_7200 	2
#define BR_9600 	3
#define BR_12000	4
#define BR_14400	5

/* width */
#define WD_1728 	0	/* in 215 mm 8/mm (A4 is 210 mm) */
#define WD_2048 	1	/* in 255 mm 8/mm */
#define WD_2432 	2	/* in 303 mm 8/mm */
#define WD_1216 	3	/* in 151 mm 8/mm */
#define WD_864		4	/* in 107 mm 8/mm */

/* page length */
#define LN_A4		0	/* 297 mm */
#define LN_B4		1	/* 364 mm */
#define LN_UNLIMITED	2

/* data format */
#define DF_1DHUFFMAN	0	/* 1-D modified Huffman */
#define DF_2DMREAD	1	/* 2-D modified Read */
#define DF_2DUNCOMP	2	/* 2-D uncompressed mode */
#define DF_2DMREAD2	3	/* 2-D modified Read ?? */

/* error correction */
#define EC_DA_ECM	0	/* Disabled */
#define EC_EN_ECM_64	1
#define EC_EN_ECM_256	2

/* binary file */
#define BF_DISABLED	0
#define BF_ENABLED	1

/* scan time */
#define ST_0		0
#define ST_1		1
#define ST_2		2
#define ST_3		3
#define ST_4		4
#define ST_5		5
#define ST_6		6
#define ST_7		7

typedef struct _T30params {
    int vr;			/* vertical resolution		*/
    int br;			/* bit rate			*/
    int wd;			/* page width			*/
    int ln;			/* page length			*/
    int df;			/* data compression format	*/
    int ec;			/* error correction		*/
    int bf;			/* binary file transfer 	*/
    int st;			/* scan time			*/
} T30params;

/* bit order +FBOR=n 
 * Direct bit order is LSB first, but for practical purposes
 * people like their bit strings packed MSB first into bytes.
 */
#define BOR_C_DIR	0	/* phase C direct               */
#define BOR_C_REV	1	/* phase C reversed             */
#define BOR_C		0x1
#define BOR_BD_DIR	(0<<1)	/* phase B/D direct             */
#define BOR_BD_REV	(1<<1)	/* phase B/D reversed           */
#define BOR_BD		0x2

/* The bit order we use */
#define BOR_VALUE	BOR_C_DIR

/*
  Fax flags:
*/
#define FAX_F_SYNC	0000001 /* modem is in sync		*/
#define FAX_F_FCON	0000002 /* modem is connected		*/
#define FAX_F_FDCS	0000004 /* recved neg session params	*/
#define FAX_F_FDIS	0000010 /* recved remote capabilities	*/
#define FAX_F_FHNG	0000020 /* recved hangup code		*/
#define FAX_F_FNSF	0000040 /* recved nsf frame FAX 	*/
#define FAX_F_FPTS	0000100 /* recved post page resp (ppr)  */
#define FAX_F_FET	0000200 /* recved post page msg (ppm)   */
#define FAX_F_FTSI	0000400 /* recved remote TSI string	*/
#define FAX_F_FCSI	0001000 /* recved remote CSI string	*/
#define FAX_F_FCIG	0002000 /* recved remote CIG string	*/
#define FAX_F_CANCELED	0004000 /* the remote end canceled	*/
#define FAX_F_RETRIES	0010000 /* too many retries sending page*/
#define FAX_F_FCFR	0020000 /* recved fcfr response 	*/
#define FAX_F_CONNECT	0040000 /* recved connect response	*/
#define FAX_F_FPOLL	0100000 /* recved pollable doc. avail.  */

/*
  Modem error conditions.  When get_modem_response returns -1,
  one of these error conditions will result.  This are hard
  errors, that may not be possible to recover from.  The idea
  is for protocol errors to be reported in the above flags.
*/
typedef enum {
    MODEM_STATUS_OK,		/* all ok			*/
    MODEM_STATUS_FAILED,	/* a system called failed	*/
    MODEM_STATUS_TIMEOUT,	/* the modem timed out		*/
} modem_status;

/*
  Page reception codes.  Returned by faxmodem_recv_page().
*/
typedef enum {
    RECV_OK,
    RECV_DONE,
    RECV_FAILED,
} recv_code;

#define MAX_ID_LEN	64

/*
  This structure holds the current state of the faxmodem.  Various
  fields are filled at different times in a fax session.  Not all
  fields are valid at all times.  Check flags to see what field
  currently hold valid information.
*/
typedef struct _fax_modem {
    int fd;			/* fd of the fax modem		*/
    modem_status status;	/* status for last modem op	*/
    int flags;			/* fax modem flags (see above)  */
    int result; 		/* last numeric result code	*/
    int dialer_code;		/* result from last ATDT op	*/
    int hangup_code;		/* +FHNG code; See table 8.3	*/
    int ppr_code;		/* +FPTS code; See table 8.2	*/
    int ppm_code;		/* +FET  code; See table 8.1	*/
    char ftsi_id[MAX_ID_LEN];	/* +FTSI id string		*/
    char fcsi_id[MAX_ID_LEN];	/* +FCSI id string		*/
    char fcig_id[MAX_ID_LEN];	/* +FCIG id string		*/
    T30params fdcs_params;	/* current session params	*/
    T30params fdis_params;	/* remote identification params */
    T30params fdtc_params;	/* request for polling params	*/
} FaxModem;

#define FAX_ISSET(x,y)   (((x)->flags)&y)
#define FAX_CONNECTED(x) (FAX_ISSET((x),FAX_F_FCON) && \
			  !FAX_ISSET((x),FAX_F_FHNG))

#endif
@


1.4
log
@Add BOR_*, FAX_F_FPOLL.
@
text
@d1 1
a1 1
/* $Id: c2proto.h,v 1.3 1993/06/11 23:22:07 Rhialto Exp $
d3 3
d49 1
d144 1
a144 1
#define BOR_VALUE	BOR_C_REV
@


1.3
log
@Add definition of DC2.
@
text
@d1 1
a1 1
/* $Id: c2proto.h,v 1.2 1993/06/11 16:15:25 Rhialto Exp $
d3 3
d45 1
d128 14
d160 1
@


1.2
log
@First real RCS checkin
@
text
@d1 5
a5 2
/* $Id$
 * $Log$
d25 1
@


1.1
log
@Initial revision
@
text
@d1 3
@
