ciao a tutti
spero perdonerete la mancanza di indentazione nel codice ma il mio browser non mi permette di editarlo diversamente
#include <stdio.h>
#include <string.h>
#define MAX_GET 1024
#define MAX_KEYS 100
#define MAX_VALUES 100
static char *keys[MAX_KEYS], *values[MAX_VALUES];
int isMethod(char *m);
void getPostParams(void);
void getGetParams(void);
int main(int argc, char *argv[]){
printf("%s\n\n", "Content-Type: text/html");
if(isMethod("GET")) getGetParams();
return(0);
}
int isMethod(char *m){
if(strcmp(getenv("REQUEST_METHOD"), m) != 0) return 0;
return 1;
}
void getGetParams(){
int i, j;
char *query_string, *tmp, *params[100];
query_string = getenv("QUERY_STRING");
tmp = query_string;
for(i = 0; i < MAX_GET; ++i){
if(tmp == NULL) break;
tmp = strtok(tmp, "&");
params[i] = tmp;
tmp = strtok(NULL, "&");
}
for(j = 0; j <= i; ++j){
tmp = params[j];
if(tmp == NULL) break;
tmp = strtok(tmp, "=");
keys[j] = tmp;
tmp = strtok(NULL, "=");
values[j] = tmp;
}
return;
}
quando compilo mi vengono restituiti i seguenti warning
cgilib.c: In function `isMethod':
cgilib.c:21: warning: passing arg 1 of `strcmp' makes pointer from integer withut a cast
cgilib.c: In function `getGetParams':
cgilib.c:28: warning: assignment makes pointer from integer without a cast
ma il programma funziona senza problemi. Non è molto che programmo e vorrei capire come risolverli
grazie
ciao

Rispondi quotando

