Changeset 42
- Timestamp:
- 01/13/2004 01:47:32 PM (5 years ago)
- Files:
-
- src/cfcgi.c (modified) (4 diffs)
- src/cfcgi.h (modified) (1 diff)
- src/fo_threadlookup.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/cfcgi.c
r5 r42 27 27 28 28 #include "hashlib.h" 29 #include "utils.h" 29 30 #include "cfcgi.h" 30 #include "utils.h"31 31 /* }}} */ 32 32 … … 53 53 * \param value the value of the parameter 54 54 */ 55 int _cf_cgi_save_param(t_cf_hash *,u_char *,int,u_char *); 56 57 /** 58 * \fn cf_cgi_destroy_entry(void *data) 55 int _cf_cgi_save_param(t_cf_hash *hash,u_char *name,int namlen,u_char *value); 56 57 /** 59 58 * \brief this function destroys a parameter list. 60 59 * \ingroup cgi_privfuncs 61 60 * \param data the given parameter list 62 61 */ 63 void cf_cgi_destroy_entry(void * );62 void cf_cgi_destroy_entry(void *data); 64 63 /*\@}*/ 65 64 … … 72 71 * 73 72 */ 74 t_cf_hash *cf_cgi_new( void) {73 t_cf_hash *cf_cgi_new() { 75 74 u_char *clen = getenv("CONTENT_LENGTH"),*rqmeth = getenv("REQUEST_METHOD"),*data; 76 75 t_cf_hash *hash; … … 113 112 114 113 return NULL; 114 } 115 116 void 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 } 115 142 } 116 143 src/cfcgi.h
r5 r42 41 41 * this function is the constructor for the CGI hash. It reads the CGI data 42 42 * from the environment, parses it and decodes it. 43 * \param what CF_CGI_PATH_INFO or CF_CGI_QUERY 43 44 * \return It returns NULL on error or the CGI hash on success. 44 45 */ 45 t_cf_hash *cf_cgi_new(void); 46 t_cf_hash *cf_cgi_new(); 47 48 /** 49 * This function parses a query string 50 * \param ary A pointer to a array structure 51 */ 52 void cf_cgi_parse_path_info(t_array *ary); 46 53 47 54 /** src/fo_threadlookup.c
r39 r42 81 81 t_name_value *archive_path; 82 82 u_char *port = getenv("SERVER_PORT"); 83 t_array infos; 84 size_t i; 85 86 cf_cgi_parse_path_info(&infos); 83 87 84 88 if((cfgfiles = get_conf_file((u_char **)argv,0)) == NULL) { … … 100 104 } 101 105 102 if( (ctid = getenv("PATH_INFO")) == NULL) {106 if(infos.elements != 2 && infos.elements != 4) { 103 107 printf("Status: 404 Not Found\015\012"); 104 108 return EXIT_FAILURE; 105 109 } 110 111 ctid = *((char **)array_element_at(&infos,1)); 106 112 if(is_tid(ctid) == -1) { 107 113 printf("Status: 404 Not Found\015\012"); … … 146 152 147 153 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 } 149 160 } 150 161 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 } 152 168 } 153 169
