/* fax.c - facsimileTelephoneNumber attribute */
static char *rcsid
= "$Header: /f/osi/dsap/common/RCS/fax.c,v 7.1 91/02/22 09:19:11 mrose Interim $";
* $Header: /f/osi/dsap/common/RCS/fax.c,v 7.1 91/02/22 09:19:11 mrose Interim $
* Revision 7.1 91/02/22 09:19:11 mrose
* Revision 7.0 89/11/23 21:42:12 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
fax ::= <printablestring> [ <parameters> ]
parameters ::= <parm> | <parm> $ <parameters>
<parm> ::= "twoDimensional" | "fineResolution" | "unlimitedLength" |
"b4Length" | "a3Width" | "b4Width" | "uncompressed"
123-4567 $ twoDimensional
#include "quipu/syntaxes.h"
static struct pair pairs
[] = {
static struct fax
*fax_cpy (a
)
f
= (struct fax
*) smalloc (sizeof *f
);
f
-> number
= strdup (a
-> number
);
f
-> bits
= a
-> bits
? pe_cpy (a
-> bits
) : NULLPE
;
static int fax_cmp (a
, b
)
if (a
== (struct fax
*) NULL
)
if (b
== (struct fax
*) NULL
)
if (i
= telcmp (a
-> number
, b
-> number
))
return pe_cmp (a
-> bits
, b
-> bits
);
static fax_print (ps
, f
, format
)
ps_printf (ps
, "%s", f
-> number
);
if ((pe
= f
-> bits
) && (i
= pe
-> pe_nbits
) > 0) {
if (bit_test (pe
, i
) > OK
) {
for (p
= pairs
; p
-> p_name
; p
++)
ps_printf (ps
, "%s %s", cp
, p
-> p_name
);
ps_printf (ps
, "%s %d", cp
, i
);
ps_printf (ps
, "%s", f
-> number
);
if ((pe
= f
-> bits
) && (i
= pe
-> pe_nbits
) > 0) {
if (bit_test (pe
, i
) > OK
) {
for (p
= pairs
; p
-> p_name
; p
++)
ps_printf (ps
, "%s %s", cp
, p
-> p_name
);
ps_printf (ps
, "%s %d", cp
, i
);
static struct fax
*str2fax (str
)
f
= (struct fax
*) smalloc (sizeof *f
);
if (ptr
= index (str
, '$'))
if (strlen (str
) > UB_TELEPHONE_NUMBER
) {
parse_error ("fax phone number too big",NULLCP
);
return ((struct fax
*) NULL
);
f
-> number
= TidyString (strdup (str
));
bzero ((char *) vec
, sizeof vec
);
(void) str2vec (ptr
, vec
);
for (ap
= vec
; *ap
; ap
++) {
if (sscanf (*ap
, "%d", &value
) == 1 && value
>= 0)
for (p
= pairs
; p
-> p_name
; p
++)
if (lexequ (p
-> p_name
, *ap
) == 0)
parse_error ("unknown G3fax non-basic parameter: '%s'", *ap
);
return ((struct fax
*) NULL
);
&& (f
-> bits
= prim2bit (pe_alloc (PE_CLASS_UNIV
,
|| bit_on (f
-> bits
, value
) == NOTOK
) {
parse_error ("unable to allocate G3fax non-basic parameter",NULLCP
);
if (bit2prim (f
-> bits
) == NULLPE
)
f
-> fax_bits
= bitstr2strb (f
-> bits
, & f
-> fax_len
);
(void) encode_SA_FacsimileTelephoneNumber (&pe
, 0, 0, NULLCP
, f
);
static struct fax
*fax_dec (pe
)
if (decode_SA_FacsimileTelephoneNumber (pe
, 1, NULLIP
, NULLVP
, &f
)
return ((struct fax
*) NULL
);
f
-> bits
= strb2bitstr ( f
-> fax_bits
, f
-> fax_len
,
PE_CLASS_UNIV
, PE_PRIM_BITS
);
(void) add_attribute_syntax ("FacsimileTelephoneNumber",
(IFP
) fax_enc
, (IFP
) fax_dec
,
(IFP
) str2fax
, fax_print
,