Changeset 101

Show
Ignore:
Timestamp:
02/05/06 00:27:39 (3 years ago)
Author:
conrad
Message:

add usage, basic cgi framework works

Files:

Legend:

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

    r100 r101  
    44#include "fastphoto.h" 
    55 
    6 #define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n\n
     6#define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n
    77 
    88#define BUFSIZE 4096 
  • fastphoto/trunk/src/main.c

    r100 r101  
     1#include "config.h" 
     2 
    13#include <stdio.h> 
    24#include <stdlib.h> 
     
    79#include "resize.h" 
    810 
     11static void 
     12usage (void) 
     13{ 
     14    printf ("FastPhoto " VERSION "\n"); 
     15    printf ("Usage: fastphoto infile outfile\n"); 
     16} 
     17 
    918int 
    1019main (int argc, char * argv[]) 
    1120{ 
    12   int cgi = 0;  
    13   fastphoto_t params; 
     21    int cgi = 0;  
     22    fastphoto_t params; 
     23   
     24    memset (&params, 0, sizeof (fastphoto_t)); 
     25   
     26    if (cgi_init(&params)) { 
     27        cgi = 1; 
     28        content_type_jpeg (); 
     29    } else { 
     30        if (argc < 3) { 
     31            usage (); 
     32            exit (1); 
     33        } 
    1434 
    15   memset (&params, 1, sizeof (fastphoto_t)); 
    16  
    17   if (cgi_init(&params)) { 
    18     cgi = 1; 
    19     content_type_jpeg (); 
    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); 
    28  
    29   if (cgi) { 
    30     cgi_send (&params); 
    31   } 
    32  
    33   return 0; 
     35        params.infile = argv[1]; 
     36        params.outfile = argv[2]; 
     37        params.x = 128; 
     38        params.y = 128; 
     39    } 
     40   
     41    resize (&params); 
     42   
     43    if (cgi) { 
     44        /* 
     45        puts ("Content-Type: text/plain\n\n"); 
     46        printf ("Infile: %s\n", params.infile); 
     47        printf ("Outfile: %s\n", params.outfile); 
     48        */ 
     49        cgi_send (&params); 
     50    } 
     51   
     52    return 0; 
    3453}