return 1;
}
confpath = argv[i];
+ } else if(strcmp(argv[i], "--logfile") == 0 || strcmp(argv[i], "-l") == 0) {
+ i++;
+ if(argv[i] == NULL) {
+ fprintf(stderr, "Missing argument\n");
+ return 1;
+ }
+ if(logfile != NULL && logfile != stderr) {
+ fclose(logfile);
+ }
+ logfile = fopen(argv[i], "a");
+ if(logfile == NULL) {
+ fprintf(stderr, "Failed to open logfile\n");
+ return 1;
+ }
} else if(strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
printf("Tewi HTTPd Tewi/%s\n", tw_get_version());
printf("Under public domain.\n");
char* useragent = cm_strdup("");
int i;
- for(i = 0; req.headers[i] != NULL; i += 2){
- if(cm_strcaseequ(req.headers[i], "User-Agent")){
+ for(i = 0; req.headers[i] != NULL; i += 2) {
+ if(cm_strcaseequ(req.headers[i], "User-Agent")) {
free(useragent);
useragent = cm_strdup(req.headers[i + 1]);
}