faxd/Class2.c++
/*
 * Parse a ``capabilities'' string from the modem and
 * return the values through the params parameter.
 */
Parse a ``capabilities'' string from the modem and
return the values through the params parameter.
Parse a ` ` capabilities ' ' string from the modem and return the values through the params parameter .
bool
Class2Modem::parseClass2Capabilities(const char* cap, Class2Params& params, bool isDIS)
{
    fxStr notation;
    if (conf.class2UseHex) {
	if (useJP) notation = "%X,%X,%X,%X,%X,%X,%X,%X,%X";
	else notation = "%X,%X,%X,%X,%X,%X,%X,%X";
    } else {
	if (useJP) notation = "%d,%d,%d,%d,%d,%d,%d,%d,%d";
	else notation = "%d,%d,%d,%d,%d,%d,%d,%d";
    }
    int n = 0;
    if (useJP) {
	n = sscanf(cap, notation,
	    &params.vr, &params.br, &params.wd, &params.ln,
	    &params.df, &params.ec, &params.bf, &params.st, &params.jp);
    } else {
	n = sscanf(cap, notation,
	    &params.vr, &params.br, &params.wd, &params.ln,
	    &params.df, &params.ec, &params.bf, &params.st);
	params.jp = 0;
    }
    if ((useJP && n == 9) || (n == 8)) {
	if (useJP && (n == 8)) {
	    params.jp = 0;
	}
	if (params.ec != EC_DISABLE && (conf.class2ECMType == ClassModem::ECMTYPE_CLASS20 ||
	   (conf.class2ECMType == ClassModem::ECMTYPE_UNSET && serviceType != SERVICE_CLASS2)))
	    params.ec += 1;		
	params.vr = params.vr & VR_ALL;
	params.br = fxmin(params.br, (u_int) BR_33600);
	params.wd = fxmin(params.wd, (u_int) WD_A3);
	params.ln = fxmin(params.ln, (u_int) LN_INF);
	if (useExtendedDF) {
	    u_int dfscan = params.df;
	    if (isDIS) {
		params.df = BIT(DF_1DMH);
		if (dfscan & 0x1) params.df |= BIT(DF_2DMR);
		if (dfscan & 0x2) params.df |= BIT(DF_2DMMR);	
		if (dfscan & 0x4) params.df |= BIT(DF_JBIG);	
		if (dfscan & 0x8) params.df |= BIT(DF_JBIG);
	    } else {
		params.df = DF_1DMH;
		if (dfscan == 0x3) params.df = DF_2DMMR;
		else if (dfscan & 0x1) params.df = DF_2DMR;
		else if (dfscan & 0x4) params.df = DF_JBIG;	
		else if (dfscan & 0x8) params.df = DF_JBIG;
	    }
	} else {
	    params.df = fxmin(params.df, (u_int) DF_2DMMR);
	    if (isDIS) {
		params.df = BIT(params.df) | BIT(DF_1DMH);
	    }
	}
	if (params.ec > EC_ECLFULL)		
	    params.ec = EC_DISABLE;
	if (params.bf > BF_ENABLE)
	    params.bf = BF_DISABLE;
	params.st = fxmin(params.st, (u_int) ST_40MS);
	int jpscan = params.jp;
	params.jp = 0;
	if (isDIS) {
	    if (jpscan & 0x1) params.jp |= BIT(JP_GREY);
	    if (jpscan & 0x2) params.jp |= BIT(JP_COLOR);
	} else {
	    if (jpscan == 0x1) params.jp = JP_GREY;
	    else if (jpscan & 0x2) params.jp = JP_COLOR;
	}
	return (true);
    } else {
	protoTrace("MODEM protocol botch, can not parse \"%s\"", cap);
	return (false);
    }
}
bool Class2Modem :: parseClass2Capabilities ( const char * cap , Class2Params & params , bool isDIS ) { fxStr notation ; if ( conf . class2UseHex ) { if ( useJP ) notation = " " ; else notation = " " ; } else { if ( useJP ) notation = " " ; else notation = " " ; } int n = 0 ; if ( useJP ) { n = sscanf ( cap , notation , & params . vr , & params . br , & params . wd , & params . ln , & params . df , & params . ec , & params . bf , & params . st , & params . jp ) ; } else { n = sscanf ( cap , notation , & params . vr , & params . br , & params . wd , & params . ln , & params . df , & params . ec , & params . bf , & params . st ) ; params . jp = 0 ; } if ( ( useJP && n == 9 ) || ( n == 8 ) ) { if ( useJP && ( n == 8 ) ) { params . jp = 0 ; } if ( params . ec != EC_DISABLE && ( conf . class2ECMType == ClassModem :: ECMTYPE_CLASS20 || ( conf . class2ECMType == ClassModem :: ECMTYPE_UNSET && serviceType != SERVICE_CLASS2 ) ) ) params . ec += 1 ; params . vr = params . vr & VR_ALL ; params . br = fxmin ( params . br , ( u_int ) BR_33600 ) ; params . wd = fxmin ( params . wd , ( u_int ) WD_A3 ) ; params . ln = fxmin ( params . ln , ( u_int ) LN_INF ) ; if ( useExtendedDF ) { u_int dfscan = params . df ; if ( isDIS ) { params . df = BIT ( DF_1DMH ) ; if ( dfscan & 0x1 ) params . df |= BIT ( DF_2DMR ) ; if ( dfscan & 0x2 ) params . df |= BIT ( DF_2DMMR ) ; if ( dfscan & 0x4 ) params . df |= BIT ( DF_JBIG ) ; if ( dfscan & 0x8 ) params . df |= BIT ( DF_JBIG ) ; } else { params . df = DF_1DMH ; if ( dfscan == 0x3 ) params . df = DF_2DMMR ; else if ( dfscan & 0x1 ) params . df = DF_2DMR ; else if ( dfscan & 0x4 ) params . df = DF_JBIG ; else if ( dfscan & 0x8 ) params . df = DF_JBIG ; } } else { params . df = fxmin ( params . df , ( u_int ) DF_2DMMR ) ; if ( isDIS ) { params . df = BIT ( params . df ) | BIT ( DF_1DMH ) ; } } if ( params . ec > EC_ECLFULL ) params . ec = EC_DISABLE ; if ( params . bf > BF_ENABLE ) params . bf = BF_DISABLE ; params . st = fxmin ( params . st , ( u_int ) ST_40MS ) ; int jpscan = params . jp ; params . jp = 0 ; if ( isDIS ) { if ( jpscan & 0x1 ) params . jp |= BIT ( JP_GREY ) ; if ( jpscan & 0x2 ) params . jp |= BIT ( JP_COLOR ) ; } else { if ( jpscan == 0x1 ) params . jp = JP_GREY ; else if ( jpscan & 0x2 ) params . jp = JP_COLOR ; } return ( true ) ; } else { protoTrace ( " \" \" " , cap ) ; return ( false ) ; } }
Parse a ``capabilities'' string from the modem and
 return the values through the params parameter.
Parse a ` ` capabilities ' ' string from the modem and return the values through the params parameter .
/*
     * Some modems report capabilities in hex values, others decimal.
     */ /*
	     * The modem was previously determined to support JP; however,
	     * this response does not include it.  So we just set it to zero.
	     */ // simple adjustment, drops EC_ENABLE64 /*
	 * Clamp values to insure modem doesn't feed us
	 * nonsense; should log bogus stuff also.
	 */ /*
	     * The T.32-A1 DF extension presents us with a bitmap-like presentation
	     * similar to VR here... but leaves 2D-MMR = 3 for backwards-compatibility.
	     *
	     * 0 = 1D-MH, 1 = 2D-MR, 3 = 2D-MMR, 4 = JBIG-L0, 8 = JBIG
	     */ // don't require MR for MMR // JBIG L0 is JBIG to us // Dex 855 is known to indicate MMR in addition to JBIG when sending JBIG (0x7). // Thus only interpret DF=MMR when 0x3. // JBIG L0 is JBIG to us /*
	     * Table 21 T.32 does not match Table 2 T.30 very well in some aspects.
	     * Data format is one of those things.  When dealing with DIS we use DF 
	     * as a bitmap to suit T.30, but a T.32-following modem will only report 
	     * one supported receiver format (and not all of them).  Thus when 
	     * parsing T.32 DIS we must convert the modem response to a bitmap.  
	     * However, due to the incongruency between T.30 and T.32 the bitmap will 
	     * only contain the the reported format and the required format.
	     */ // unknown, disable use