hfaxd/FileTransfer.c++
/*
 * RETrieve one Page from a file.  For now the
 * file must be a TIFF image; we might try to
 * handle PostScript at a later time (but don't
 * hold your breath as there's not much reason).
 */
RETrieve one Page from a file.  For now the
file must be a TIFF image; we might try to
handle PostScript at a later time (but don't
hold your breath as there's not much reason).
RETrieve one Page from a file . For now the file must be a TIFF image ; we might try to handle PostScript at a later time ( but don ' t hold your breath as there ' s not much reason ) .
void
HylaFAXServer::retrievePageCmd(const char* name)
{
    TIFF* tif = cachedTIFF;
    if (tif != NULL && streq(name, TIFFFileName(tif))) {
	if (restart_point == 0)			
	    restart_point = TIFFCurrentDirectory(tif)+1;
    } else {
	if (tif)				
	    TIFFClose(tif), cachedTIFF = NULL;
	tif = openTIFF(name);
    }
    if (tif != NULL) {
	if (restart_point && !TIFFSetDirectory(tif, (tdir_t) restart_point)) {
	    reply(550, "%s: Unable to access directory %lu.",
		name, (u_long) restart_point);
	} else {
	    time_t start_time = Sys::now();
	    int code;
	    FILE* dout = openDataConn("w", code);
	    if (dout != NULL) {
		TIFFSTRIPBYTECOUNTS* sb;
		TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb);
		file_size = sizeof (DirTemplate) +
		    sizeof (TIFFHEADER) + sizeof (uint16);
		for (tstrip_t s = 0, ns = TIFFNumberOfStrips(tif); s < ns; s++)
		    file_size += sb[s];
		reply(code, "%s for %s (%lu bytes).",
		    dataConnMsg(code), name, (u_long) file_size);
		if (sendTIFFData(tif, dout))
		    reply(226, "Transfer complete.");
		if (TRACE(OUTXFERS) && xferfaxlog != -1) {
		    struct stat sb;
		    SpoolDir* sd = fileAccess(name, R_OK, sb);
		    logTransfer("o", *sd, name, start_time);
		}
		closeDataConn(dout);
	    }
	}
	cachedTIFF = tif;
    }
}
void HylaFAXServer :: retrievePageCmd ( const char * name ) { TIFF * tif = cachedTIFF ; if ( tif != NULL && streq ( name , TIFFFileName ( tif ) ) ) { if ( restart_point == 0 ) restart_point = TIFFCurrentDirectory ( tif ) + 1 ; } else { if ( tif ) TIFFClose ( tif ) , cachedTIFF = NULL ; tif = openTIFF ( name ) ; } if ( tif != NULL ) { if ( restart_point && ! TIFFSetDirectory ( tif , ( tdir_t ) restart_point ) ) { reply ( 550 , " " , name , ( u_long ) restart_point ) ; } else { time_t start_time = Sys :: now ( ) ; int code ; FILE * dout = openDataConn ( " " , code ) ; if ( dout != NULL ) { TIFFSTRIPBYTECOUNTS * sb ; TIFFGetField ( tif , TIFFTAG_STRIPBYTECOUNTS , & sb ) ; file_size = sizeof ( DirTemplate ) + sizeof ( TIFFHEADER ) + sizeof ( uint16 ) ; for ( tstrip_t s = 0 , ns = TIFFNumberOfStrips ( tif ) ; s < ns ; s ++ ) file_size += sb [ s ] ; reply ( code , " " , dataConnMsg ( code ) , name , ( u_long ) file_size ) ; if ( sendTIFFData ( tif , dout ) ) reply ( 226 , " " ) ; if ( TRACE ( OUTXFERS ) && xferfaxlog != -1 ) { struct stat sb ; SpoolDir * sd = fileAccess ( name , R_OK , sb ) ; logTransfer ( " " , * sd , name , start_time ) ; } closeDataConn ( dout ) ; } } cachedTIFF = tif ; } }
RETrieve one Page from a file.
RETrieve one Page from a file .
/*
	 * Reuse the cached open file.  If no directory
	 * has been specified with a REST command then
	 * return the next consecutive directory in the file.
	 */ // advance to next directory // close cached handle /*
		 * Calculate "file size" by totalling up the
		 * amount of image data and then adding in
		 * the expected data for the TIFF headers.
		 */