hfaxd/FileSystem.c++
/*
 * This is used to identify a submitted document type when the client 
 * specified the default (Postscript) or did not make a specification.
 *
 * There is no sure-fire way to type all PCL files.  So this is a best-
 * guess approach on PCL.  It's best if the client specifies the type
 * with PCL.
 */
This is used to identify a submitted document type when the client
specified the default (Postscript) or did not make a specification.

There is no sure-fire way to type all PCL files.  So this is a best
guess approach on PCL.  It's best if the client specifies the type
with PCL.
This is used to identify a submitted document type when the client specified the default ( Postscript ) or did not make a specification . There is no sure - fire way to type all PCL files . So this is a best guess approach on PCL . It ' s best if the client specifies the type with PCL .
bool
HylaFAXServer::docType(const char* docname, FaxSendOp& op)
{
    op = FaxRequest::send_unknown;
    int fd = Sys::open(docname, O_RDONLY);
    if (fd >= 0) {
	struct stat sb;
	if (FileCache::lookup(docname, sb) && S_ISREG(sb.st_mode)) {
	    union {
		char buf[512];
		TIFFHEADER h;
	    } b;
	    ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b));
	    if (cc > 2 && b.buf[0] == '%' && b.buf[1] == '!')
		op = FaxRequest::send_postscript;
	    else if (cc > 2 && b.buf[0] == '%' && b.buf[1] == 'P') {
	    	logDebug("What we have here is a PDF file");
	    	op = FaxRequest::send_pdf;
	    } else if (cc > 2 && b.buf[0] == 0x1b && (b.buf[1] == 'E' || b.buf[1] == '%' || b.buf[1] == '&' || b.buf[1] == '*')) {
	    	logDebug("What we have here is a PCL file");
	    	op = FaxRequest::send_pcl;
	    } else if (cc > (ssize_t)sizeof (b.h) && isTIFF(b.h))
		op = FaxRequest::send_tiff;
	    else if (cc > 3 && b.buf[0] == '@' && b.buf[1] == 'P' && b.buf[2] == 'J' && b.buf[3] == 'L') {
	    	logDebug("PJL is unsupported");
	    	op = FaxRequest::send_unknown;
	    }
	    else
		op = FaxRequest::send_data;
	}
	Sys::close(fd);
    }
    if (op == FaxRequest::send_unknown)
    	    	logError("Don't know what file");
    return (op != FaxRequest::send_unknown);   
}
bool HylaFAXServer :: docType ( const char * docname , FaxSendOp & op ) { op = FaxRequest :: send_unknown ; int fd = Sys :: open ( docname , O_RDONLY ) ; if ( fd >= 0 ) { struct stat sb ; if ( FileCache :: lookup ( docname , sb ) && S_ISREG ( sb . st_mode ) ) { union { char buf [ 512 ] ; TIFFHEADER h ; } b ; ssize_t cc = Sys :: read ( fd , ( char * ) & b , sizeof ( b ) ) ; if ( cc > 2 && b . buf [ 0 ] == ' ' && b . buf [ 1 ] == ' ' ) op = FaxRequest :: send_postscript ; else if ( cc > 2 && b . buf [ 0 ] == ' ' && b . buf [ 1 ] == ' ' ) { logDebug ( " " ) ; op = FaxRequest :: send_pdf ; } else if ( cc > 2 && b . buf [ 0 ] == 0x1b && ( b . buf [ 1 ] == ' ' || b . buf [ 1 ] == ' ' || b . buf [ 1 ] == ' ' || b . buf [ 1 ] == ' ' ) ) { logDebug ( " " ) ; op = FaxRequest :: send_pcl ; } else if ( cc > ( ssize_t ) sizeof ( b . h ) && isTIFF ( b . h ) ) op = FaxRequest :: send_tiff ; else if ( cc > 3 && b . buf [ 0 ] == ' ' && b . buf [ 1 ] == ' ' && b . buf [ 2 ] == ' ' && b . buf [ 3 ] == ' ' ) { logDebug ( " " ) ; op = FaxRequest :: send_unknown ; } else op = FaxRequest :: send_data ; } Sys :: close ( fd ) ; } if ( op == FaxRequest :: send_unknown ) logError ( " " ) ; return ( op != FaxRequest :: send_unknown ) ; }
This is used to identify a submitted document type when the client
 specified the default (Postscript) or did not make a specification.
This is used to identify a submitted document type when the client specified the default ( Postscript ) or did not make a specification .