Changeset 98

Show
Ignore:
Timestamp:
02/04/06 23:47:52 (3 years ago)
Author:
conrad
Message:

make a fastphoto_t type to hold parameters

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fastphoto/trunk/src/cgi.c

    r97 r98  
    22#include <stdlib.h> 
    33 
     4#include "fastphoto.h" 
     5 
    46#define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n\n" 
     7 
     8static char * path_translated; 
     9static char * query_string; 
     10 
     11int 
     12cgi_init (fastphoto_t * params) 
     13{ 
     14  char * gateway_interface; 
     15 
     16  gateway_interface = getenv ("GATEWAY_INTERFACE"); 
     17  if (gateway_interface == NULL) { 
     18    return 0; 
     19  } 
     20 
     21  path_translated = getenv ("PATH_TRANSLATED"); 
     22  query_string = getenv ("QUERY_STRING"); 
     23 
     24  params->infile = path_translated; 
     25  params->outfile = "/tmp/cache.jpg"; 
     26  params->x = 128; 
     27  params->y = 128; 
     28 
     29  return 1; 
     30} 
    531 
    632int 
  • fastphoto/trunk/src/cgi.h

    r97 r98  
    22#define __CGI_H__ 
    33 
     4#include "fastphoto.h" 
     5 
     6int cgi_init (fastphoto_t * params); 
    47int content_type_jpeg (void); 
    58 
  • fastphoto/trunk/src/fastphoto.c

    r97 r98  
    11#include <stdio.h> 
    22#include <stdlib.h> 
     3#include <string.h> 
    34 
     5#include "fastphoto.h" 
    46#include "cgi.h" 
    57#include "resize.h" 
     
    1012main (int argc, char * argv[]) 
    1113{ 
    12   char * infile, * outfile; 
    13   char * query_string; 
     14  fastphoto_t params; 
    1415 
    15   content_type_jpeg (); 
     16  memset (&params, 1, sizeof (fastphoto_t)); 
    1617 
    17   query_string = getenv ("QUERY_STRING"); 
     18  if (cgi_init(&params)) { 
    1819 
    19   infile = getenv ("PATH_TRANSLATED"); 
    20   outfile = "/tmp/cache.jpg"; 
    21   resize (infile, outfile, 128, 128); 
     20  } else { 
     21    params.infile = argv[1]; 
     22    params.outfile = argv[2]; 
     23    params.x = 128; 
     24    params.y = 128; 
     25  } 
     26 
     27  resize (&params); 
    2228 
    2329  return 0; 
  • fastphoto/trunk/src/resize.c

    r93 r98  
    11#include <Epeg.h> 
    22 
     3#include "fastphoto.h" 
     4 
    35void 
    4 resize (char * infile, char * outfile, int x, int y
     6resize (fastphoto_t * params
    57{ 
    68  Epeg_Image *im; 
     9  int x, y; 
    710 
    8   im = epeg_file_open(infile); 
     11  x = params->x; 
     12  y = params->y; 
     13 
     14  im = epeg_file_open(params->infile); 
    915  epeg_decode_size_set(im, x, y); 
    10   epeg_file_output_set(im, outfile); 
     16  epeg_file_output_set(im, params->outfile); 
    1117  epeg_encode(im); 
    1218  epeg_close(im); 
  • fastphoto/trunk/src/resize.h

    r93 r98  
    22#define __RESIZE_H__ 
    33 
    4 void resize (char * infile, char * outfile, int x, int y); 
     4#include "fastphoto.h" 
     5 
     6void resize (fastphoto_t * params); 
    57 
    68#endif /* __RESIZE_H__ */