Changeset 125

Show
Ignore:
Timestamp:
02/08/06 20:02:37 (3 years ago)
Author:
conrad
Message:

use sendfile if available

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fastphoto/trunk/configure.ac

    r112 r125  
    3232# Checks for library functions. 
    3333AC_FUNC_REALLOC 
    34 AC_CHECK_FUNCS([memmove random]) 
     34AC_CHECK_FUNCS([sendfile]) 
    3535 
    3636# Check for valgrind 
  • fastphoto/trunk/src/Makefile.am

    r107 r125  
    66bin_PROGRAMS = fastphoto 
    77 
    8 noinst_HEADERS = alloc_snprintf.h cache.h cgi.h resize.h 
     8noinst_HEADERS = alloc_snprintf.h cache.h cgi.h resize.h send.h 
    99 
    10 fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c resize.c 
     10fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c resize.c send.c 
    1111fastphoto_LDADD = $(EPEG_LIBS) 
  • fastphoto/trunk/src/cache.c

    r124 r125  
    109109 
    110110int 
    111 memory_send (fastphoto_t * params) 
    112 { 
    113     fwrite (params->data, 1, params->data_size, stdout); 
    114 } 
    115  
    116 int 
    117111cache_init (fastphoto_t * params, char * path_info) 
    118112{ 
  • fastphoto/trunk/src/cgi.c

    r124 r125  
     1#include "config.h" 
     2 
    13#include <stdio.h> 
    24#include <stdlib.h> 
     
    108110content_type_jpeg () 
    109111{ 
    110     return puts (CONTENT_TYPE_JPEG); 
     112    puts (CONTENT_TYPE_JPEG); 
     113    fflush (stdout); 
     114    return 0; 
    111115} 
    112  
    113 int 
    114 cgi_send (fastphoto_t * params) 
    115 { 
    116     unsigned char buf[BUFSIZE]; 
    117     FILE * fd; 
    118     size_t n; 
    119  
    120     if (params->outfile) { 
    121       fd = fopen (params->outfile, "rb"); 
    122       while ((n = fread (buf, 1, BUFSIZE, fd)) > 0) { 
    123           fwrite (buf, 1, n, stdout); 
    124       } 
    125       fclose (fd); 
    126     } else { 
    127       fprintf (stderr, "fastphoto: Sending from memory ...\n"); 
    128       fwrite (params->data, 1, params->data_size, stdout); 
    129     } 
    130  
    131     return 1; 
    132 } 
    133  
  • fastphoto/trunk/src/main.c

    r121 r125  
    1111#include "cgi.h" 
    1212#include "resize.h" 
     13#include "send.h" 
    1314 
    1415static void 
     
    171172    if (!err) { 
    172173      if (cgi) { 
    173           cgi_send (&params); 
     174        send (&params); 
    174175      } else if (!params.outfile) { 
    175         memory_send (&params); 
     176        send_memory (&params); 
    176177      } 
    177178    }