hfaxd/FileTransfer.c++
/*
 * Open a file that is expected to hold a TIFF image.
 */
Open a file that is expected to hold a TIFF image.
Open a file that is expected to hold a TIFF image .
TIFF*
HylaFAXServer::openTIFF(const char* name)
{
    struct stat sb;
    SpoolDir* sd = fileAccess(name, R_OK, sb);
    if (sd) {
	int fd = Sys::open(name, O_RDONLY);
	if (fd >= 0) {
	    union {
		char buf[512];
		TIFFHEADER h;
	    } b;
	    ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b));
	    if (cc > (ssize_t)sizeof (b.h) && b.h.tiff_version == TIFFVERSION &&
	      (b.h.tiff_magic == TIFF_BIGENDIAN ||
	       b.h.tiff_magic == TIFF_LITTLEENDIAN)) {
		(void) lseek(fd, 0L, SEEK_SET);		
		TIFF* tif = TIFFFdOpen(fd, name, "r");
		if (tif != NULL)
		    return (tif);
		else
		    reply(550, "%s: Incomplete or invalid TIFF file.", name);
	    } else
		reply(550, "%s: Not a TIFF file.", name);
	    Sys::close(fd);
	} else if (errno != 0)
	    perror_reply(550, name, errno);
	else
	    reply(550, "%s: Cannot open file.", name);
    }
    return (NULL);
}
TIFF * HylaFAXServer :: openTIFF ( const char * name ) { struct stat sb ; SpoolDir * sd = fileAccess ( name , R_OK , sb ) ; if ( sd ) { int fd = Sys :: open ( name , O_RDONLY ) ; if ( fd >= 0 ) { union { char buf [ 512 ] ; TIFFHEADER h ; } b ; ssize_t cc = Sys :: read ( fd , ( char * ) & b , sizeof ( b ) ) ; if ( cc > ( ssize_t ) sizeof ( b . h ) && b . h . tiff_version == TIFFVERSION && ( b . h . tiff_magic == TIFF_BIGENDIAN || b . h . tiff_magic == TIFF_LITTLEENDIAN ) ) { ( void ) lseek ( fd , 0L , SEEK_SET ) ; TIFF * tif = TIFFFdOpen ( fd , name , " " ) ; if ( tif != NULL ) return ( tif ) ; else reply ( 550 , " " , name ) ; } else reply ( 550 , " " , name ) ; Sys :: close ( fd ) ; } else if ( errno != 0 ) perror_reply ( 550 , name , errno ) ; else reply ( 550 , " " , name ) ; } return ( NULL ) ; }
Open a file that is expected to hold a TIFF image.
Open a file that is expected to hold a TIFF image .
// rewind