... | ... |
@@ -29,9 +29,9 @@ typedef enum esection { |
29 | 29 |
newslconfig * |
30 | 30 |
newslconfig_init(char *configfile, char *deflogfile, char *defrootdir) |
31 | 31 |
{ |
32 |
- newslconfig *config; |
|
33 |
- FILE *f; |
|
34 |
- char line[MAXLINESIZE]; |
|
32 |
+ newslconfig *config; |
|
33 |
+ FILE *f; |
|
34 |
+ char line[MAXLINESIZE]; |
|
35 | 35 |
int len; |
36 | 36 |
char *ptr,*sep,*value; |
37 | 37 |
esection section; |
... | ... |
@@ -54,8 +54,8 @@ newslconfig_init(char *configfile, char *deflogfile, char *defrootdir) |
54 | 54 |
; |
55 | 55 |
len=strlen(line); |
56 | 56 |
while(len>0 && strchr("\n\t ",line[len-1])!=NULL) |
57 |
- line[len-1]='\0',len--; |
|
58 |
- for(ptr=line;*ptr!='\0' && strchr("\t ",*ptr)!=NULL;ptr++) |
|
57 |
+ line[len-1]='\0',len--; |
|
58 |
+ for(ptr=line;*ptr!='\0' && strchr("\t ",*ptr)!=NULL;ptr++) |
|
59 | 59 |
; |
60 | 60 |
len=strlen(ptr); |
61 | 61 |
/* ignore empty lines and comments */ |
... | ... |
@@ -82,12 +82,12 @@ newslconfig_init(char *configfile, char *deflogfile, char *defrootdir) |
82 | 82 |
/* trim value */ |
83 | 83 |
while(*value!='\0' && strchr(" \t",*value)!=NULL) |
84 | 84 |
value++; |
85 |
- /* sanity check */ |
|
85 |
+ /* sanity check */ |
|
86 | 86 |
if(*value=='\0') { |
87 |
- log_write("CONF","%s:%i: ignoring key without value; key:\"%s\"\n",configfile,lineno,ptr); |
|
87 |
+ log_write("CONF","%s:%i: ignoring key without value; key:\"%s\"\n",configfile,lineno,ptr); |
|
88 | 88 |
continue; |
89 | 89 |
} |
90 |
- /* assign value */ |
|
90 |
+ /* assign value */ |
|
91 | 91 |
if(section==section_none) { |
92 | 92 |
log_write("CONF","%s:%i: ignoring key-value pair in unknown section; key:\"%s\"\n",configfile,lineno,ptr); |
93 | 93 |
continue; |
... | ... |
@@ -98,13 +98,13 @@ newslconfig_init(char *configfile, char *deflogfile, char *defrootdir) |
98 | 98 |
configvalue=&(config->logfile); |
99 | 99 |
} else if(strcmp(ptr,"rootdir")==0) { |
100 | 100 |
configvalue=&(config->rootdir); |
101 |
- } else { |
|
101 |
+ } else { |
|
102 | 102 |
log_write("CONF","%s:%i: unknown key, ignoring key-value pair; key:\"%s\"\n",configfile,lineno,ptr); |
103 | 103 |
continue; |
104 | 104 |
} |
105 |
- } else |
|
105 |
+ } else |
|
106 | 106 |
continue; |
107 |
- /* store value */ |
|
107 |
+ /* store value */ |
|
108 | 108 |
if(*configvalue!=NULL) { |
109 | 109 |
log_write("CONF","%s:%i: duplicate key, ignoring key-value pair; key:\"%s\"\n",configfile,lineno,ptr); |
110 | 110 |
continue; |
... | ... |
@@ -121,11 +121,11 @@ newslconfig_init(char *configfile, char *deflogfile, char *defrootdir) |
121 | 121 |
} |
122 | 122 |
} |
123 | 123 |
fclose(f),f=NULL; |
124 |
- if((config->logfile==NULL && (config->logfile=strdup(deflogfile))==NULL) || |
|
125 |
- (config->rootdir==NULL && (config->rootdir=strdup(defrootdir))==NULL)) { |
|
126 |
- newslconfig_free(config),config=NULL; |
|
127 |
- return(NULL); |
|
128 |
- } |
|
124 |
+ if((config->logfile==NULL && (config->logfile=strdup(deflogfile))==NULL) || |
|
125 |
+ (config->rootdir==NULL && (config->rootdir=strdup(defrootdir))==NULL)) { |
|
126 |
+ newslconfig_free(config),config=NULL; |
|
127 |
+ return(NULL); |
|
128 |
+ } |
|
129 | 129 |
return(config); |
130 | 130 |
} |
131 | 131 |
|
... | ... |
@@ -196,21 +196,21 @@ callback_http(wk *web, int connid, wk_uri *uri, void *userptr) |
196 | 196 |
return(wkact_finished); |
197 | 197 |
} |
198 | 198 |
#warning TODO: do something with the email |
199 |
- { |
|
200 |
- FILE *f; |
|
201 |
- if((f=fopen("emails.txt","a"))==NULL) { |
|
202 |
- wk_serve_error(web,connid,wkerr_internal); |
|
203 |
- return(wkact_finished); |
|
204 |
- } |
|
205 |
- fprintf(f,"%s %s\n",language,email); |
|
206 |
- fclose(f); |
|
207 |
- } |
|
208 |
- if((res=res_find(resindexdata,"success.html"))!=NULL) { |
|
209 |
- wk_serve_buffer_as_file(web,connid,(char *) res->data,res->len,mime_getdefault(res->name,"application/octet-stream")); |
|
210 |
- } else { |
|
211 |
- char success[]={"The email has been saved.\n"}; |
|
212 |
- wk_serve_buffer_as_file(web,connid,success,strlen(success),"text/plain"); |
|
213 |
- } |
|
199 |
+ { |
|
200 |
+ FILE *f; |
|
201 |
+ if((f=fopen("emails.txt","a"))==NULL) { |
|
202 |
+ wk_serve_error(web,connid,wkerr_internal); |
|
203 |
+ return(wkact_finished); |
|
204 |
+ } |
|
205 |
+ fprintf(f,"%s %s\n",language,email); |
|
206 |
+ fclose(f); |
|
207 |
+ } |
|
208 |
+ if((res=res_find(resindexdata,"success.html"))!=NULL) { |
|
209 |
+ wk_serve_buffer_as_file(web,connid,(char *) res->data,res->len,mime_getdefault(res->name,"application/octet-stream")); |
|
210 |
+ } else { |
|
211 |
+ char success[]={"The email has been saved.\n"}; |
|
212 |
+ wk_serve_buffer_as_file(web,connid,success,strlen(success),"text/plain"); |
|
213 |
+ } |
|
214 | 214 |
return(wkact_finished); |
215 | 215 |
} |
216 | 216 |
wk_serve_error(web,connid,wkerr_notfound); |