Changeset 135

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

move photo_put() into photo.c, move send() into cgi.c as cgi_send()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fastphoto/trunk/src/Makefile.am

    r131 r135  
    55bin_PROGRAMS = fastphoto 
    66 
    7 noinst_HEADERS = alloc_snprintf.h cache.h cgi.h header.h resize.h send.h 
     7noinst_HEADERS = alloc_snprintf.h cache.h cgi.h header.h photo.h resize.h 
    88 
    9 fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c header.c resize.c send.c 
     9fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c header.c photo.c resize.c 
    1010fastphoto_LDADD = $(EPEG_LIBS) 
  • fastphoto/trunk/src/cache.c

    r134 r135  
    88 
    99#include "fastphoto.h" 
     10#include "photo.h" 
    1011#include "alloc_snprintf.h" 
    1112 
     
    4445} 
    4546 
    46 int 
    47 file_check (photo_t * photo) 
    48 { 
    49     struct stat statbuf; 
    50  
    51     if (stat (photo->name, &statbuf) == -1) { 
    52         switch (errno) { 
    53             case ENOENT: 
    54                 return 0; 
    55             default: 
    56                 fprintf (stderr, "fastphoto: Error checking %s: %s\n", photo->name, strerror (errno)); 
    57                 return -1; 
    58         } 
    59     } 
    60  
    61     photo->mtime = statbuf.st_mtime; 
    62     photo->size = statbuf.st_size; 
    63  
    64     return 1; 
    65 } 
    66  
    6747static int 
    6848cache_check (fastphoto_t * params) 
     
    7050    int ret; 
    7151 
    72     if ((ret = file_check (&params->out)) != 1) { 
     52    if ((ret = photo_stat (&params->out)) != 1) { 
    7353        return ret; 
    7454    } 
    7555 
    76     if ((ret = file_check (&params->in)) != 1) { 
     56    if ((ret = photo_stat (&params->in)) != 1) { 
    7757        return ret; 
    7858    } 
  • fastphoto/trunk/src/cache.h

    r134 r135  
    77int memory_send (fastphoto_t * params); 
    88 
    9 int file_check (photo_t * photo); 
    10  
    11  
    129#endif /* __CACHE_H__ */ 
  • fastphoto/trunk/src/cgi.c

    r134 r135  
    77#include "fastphoto.h" 
    88#include "cache.h" 
    9  
    10 #define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n" 
    11  
    12 #define BUFSIZE 4096 
     9#include "header.h" 
     10#include "photo.h" 
    1311 
    1412static void 
     
    106104  return 1; 
    107105} 
     106 
     107size_t 
     108send_memory (fastphoto_t * params) 
     109{ 
     110    size_t n = fwrite (params->data, 1, params->data_size, stdout); 
     111    fflush (stdout); 
     112    return n; 
     113} 
     114 
     115int 
     116cgi_send (fastphoto_t * params) 
     117{ 
     118  header_content_length (params->out.size); 
     119  header_end(); 
     120 
     121  if (params->out.name) { 
     122    photo_put (&params->out); 
     123  } else { 
     124    fprintf (stderr, "fastphoto: Sending from memory ...\n"); 
     125    send_memory (params); 
     126  } 
     127 
     128  return 1; 
     129} 
  • fastphoto/trunk/src/cgi.h

    r131 r135  
    77int cgi_send (fastphoto_t * params); 
    88 
     9size_t send_memory (fastphoto_t * params); 
     10 
    911#endif /* __CGI_H__ */ 
  • fastphoto/trunk/src/main.c

    r134 r135  
    1212#include "header.h" 
    1313#include "resize.h" 
    14 #include "send.h" 
    1514 
    1615static void 
     
    173172    if (!err) { 
    174173      if (cgi) { 
    175         send (&params); 
     174        cgi_send (&params); 
    176175      } else if (!params.out.name) { 
    177176        send_memory (&params); 
  • fastphoto/trunk/src/resize.c

    r134 r135  
    33 
    44#include "fastphoto.h" 
    5 #include "cache.h" /* file_check() */ 
     5#include "photo.h" 
    66 
    77int 
     
    5959 
    6060  if (params->out.name) 
    61     file_check (&params->out); 
     61    photo_stat (&params->out); 
    6262  else 
    6363    params->out.size = (off_t)params->data_size;