Changeset 42

Show
Ignore:
Timestamp:
01/13/2004 01:47:32 PM (5 years ago)
Author:
ckruse
Message:

updates...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/cfcgi.c

    r5 r42  
    2727 
    2828#include "hashlib.h" 
     29#include "utils.h" 
    2930#include "cfcgi.h" 
    30 #include "utils.h" 
    3131/* }}} */ 
    3232 
     
    5353 * \param value   the value of the parameter 
    5454 */ 
    55 int _cf_cgi_save_param(t_cf_hash *,u_char *,int,u_char *); 
    56  
    57 /** 
    58  * \fn cf_cgi_destroy_entry(void *data) 
     55int _cf_cgi_save_param(t_cf_hash *hash,u_char *name,int namlen,u_char *value); 
     56 
     57/** 
    5958 * \brief this function destroys a parameter list. 
    6059 * \ingroup cgi_privfuncs 
    6160 * \param data the given parameter list 
    6261 */ 
    63 void cf_cgi_destroy_entry(void *); 
     62void cf_cgi_destroy_entry(void *data); 
    6463/*\@}*/ 
    6564 
     
    7271 * 
    7372 */ 
    74 t_cf_hash *cf_cgi_new(void) { 
     73t_cf_hash *cf_cgi_new() { 
    7574  u_char *clen = getenv("CONTENT_LENGTH"),*rqmeth = getenv("REQUEST_METHOD"),*data; 
    7675  t_cf_hash *hash; 
     
    113112 
    114113  return NULL; 
     114} 
     115 
     116void cf_cgi_parse_path_info(t_array *ary) { 
     117  u_char *data = getenv("PATH_INFO"); 
     118  register u_char *ptr = (u_char *)data+1; 
     119  u_char *start = data,*name = NULL; 
     120 
     121  array_init(ary,sizeof(char **),NULL); 
     122 
     123  if(!data) return; 
     124 
     125  if(*ptr) { 
     126    for(;*ptr;ptr++) { 
     127      if(*ptr == '/') { 
     128        if(start) { 
     129          name = strndup(start+1,ptr-start); 
     130          array_push(ary,&name); 
     131          start = ptr; 
     132        } 
     133        else { 
     134          start = ptr; 
     135        } 
     136      } 
     137    } 
     138 
     139    name = strdup(start+1); 
     140    array_push(ary,&name); 
     141  } 
    115142} 
    116143 
  • src/cfcgi.h

    r5 r42  
    4141 * this function is the constructor for the CGI hash. It reads the CGI data 
    4242 * from the environment, parses it and decodes it. 
     43 * \param what CF_CGI_PATH_INFO or CF_CGI_QUERY 
    4344 * \return It returns NULL on error or the CGI hash on success. 
    4445 */ 
    45 t_cf_hash *cf_cgi_new(void); 
     46t_cf_hash *cf_cgi_new(); 
     47 
     48/** 
     49 * This function parses a query string 
     50 * \param ary A pointer to a array structure 
     51 */ 
     52void cf_cgi_parse_path_info(t_array *ary); 
    4653 
    4754/** 
  • src/fo_threadlookup.c

    r39 r42  
    8181  t_name_value *archive_path; 
    8282  u_char *port = getenv("SERVER_PORT"); 
     83  t_array infos; 
     84  size_t i; 
     85 
     86  cf_cgi_parse_path_info(&infos); 
    8387 
    8488  if((cfgfiles = get_conf_file((u_char **)argv,0)) == NULL) { 
     
    100104  } 
    101105 
    102   if((ctid = getenv("PATH_INFO")) == NULL) { 
     106  if(infos.elements != 2 && infos.elements != 4) { 
    103107    printf("Status: 404 Not Found\015\012"); 
    104108    return EXIT_FAILURE; 
    105109  } 
     110 
     111  ctid = *((char **)array_element_at(&infos,1)); 
    106112  if(is_tid(ctid) == -1) { 
    107113    printf("Status: 404 Not Found\015\012"); 
     
    146152 
    147153  if(!port || cf_strcmp(port,"80") == 0) { 
    148     printf("Location: http://%s%s%d/%d/%s/\015\012\015\012",getenv("SERVER_NAME"),archive_path->values[0],idx->year,idx->month,ctid); 
     154    if(infos.elements == 4) { 
     155      printf("Location: http://%s%s%d/%d/%s/#m%s\015\012\015\012",getenv("SERVER_NAME"),archive_path->values[0],idx->year,idx->month,ctid,*((char **)array_element_at(&infos,3))); 
     156    } 
     157    else { 
     158      printf("Location: http://%s%s%d/%d/%s/\015\012\015\012",getenv("SERVER_NAME"),archive_path->values[0],idx->year,idx->month,ctid); 
     159    } 
    149160  } 
    150161  else { 
    151     printf("Location: http://%s:%s%s%d/%d/%s/\015\012\015\012",getenv("SERVER_NAME"),getenv("SERVER_PORT"),archive_path->values[0],idx->year,idx->month,ctid); 
     162    if(infos.elements == 4) { 
     163      printf("Location: http://%s:%s%s%d/%d/%s/#m%s\015\012\015\012",getenv("SERVER_NAME"),getenv("SERVER_PORT"),archive_path->values[0],idx->year,idx->month,ctid,*((char **)array_element_at(&infos,3))); 
     164    } 
     165    else { 
     166      printf("Location: http://%s:%s%s%d/%d/%s/\015\012\015\012",getenv("SERVER_NAME"),getenv("SERVER_PORT"),archive_path->values[0],idx->year,idx->month,ctid); 
     167    } 
    152168  } 
    153169