00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019 #include "defines.h"
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <time.h>
00024
00025 #include <string.h>
00026 #include <ctype.h>
00027 #include <sys/types.h>
00028
00029 #include "readline.h"
00030 #include "hashlib.h"
00031 #include "utils.h"
00032 #include "configparser.h"
00033 #include "cfcgi.h"
00034 #include "template.h"
00035 #include "clientlib.h"
00036 #include "charconvert.h"
00037
00038
00039
00040 struct {
00041 int ShowSig;
00042 int DoQuote;
00043 u_char *QuotingChars;
00044 u_char *ShowThread;
00045 u_char *Hi;
00046 u_char *Bye;
00047 u_char *Signature;
00048 u_char *link;
00049 u_char *TWidth;
00050 u_char *THeight;
00051 u_char *ActiveColorF;
00052 u_char *ActiveColorB;
00053 int Preview;
00054 int PreviewSwitchType;
00055 } Cfg = { 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0 };
00056
00057
00058
00059 u_char *convert(const u_char *in,size_t len,size_t *olen,const t_name_value *cs) {
00060 u_char *str = strndup(in,len);
00061 u_char *ret = htmlentities_charset_convert(str,"UTF-8",cs->values[0],olen,0);
00062 free(str);
00063 return ret;
00064 }
00065
00066
00067
00068 void replace_placeholders(const u_char *str,t_string *appender,t_cl_thread *thread) {
00069 register u_char *ptr = (u_char *)str;
00070 register u_char *ptr1;
00071
00072 for(ptr1 = thread->threadmsg->author;*ptr1;ptr1++) {
00073 if(!isalpha(*ptr1)) break;
00074 }
00075
00076 for(;*ptr;ptr++) {
00077 if(cf_strncmp(ptr,"\\n",2) == 0) {
00078 str_chars_append(appender,"\n",1);
00079 ptr += 1;
00080 }
00081 else if(cf_strncmp(ptr,"{$name}",7) == 0) {
00082 str_chars_append(appender,thread->threadmsg->author,thread->threadmsg->author_len);
00083 ptr += 6;
00084 }
00085 else if(cf_strncmp(ptr,"{$vname}",8) == 0) {
00086 str_chars_append(appender,thread->threadmsg->author,ptr1-thread->threadmsg->author);
00087 }
00088 else {
00089 str_chars_append(appender,ptr,1);
00090 }
00091 }
00092 }
00093
00094
00095
00096 t_message *get_parent_message(t_message *msgs,t_message *tmsg) {
00097 t_message *msg,*bmsg = NULL;
00098
00099 for(msg=msgs;msg;msg=msg->next) {
00100 if(msg->level == tmsg->level - 1) {
00101 bmsg = msg;
00102 }
00103
00104 if(msg->next && msg->next == tmsg) {
00105 return bmsg;
00106 }
00107 }
00108
00109 return NULL;
00110 }
00111
00112
00113
00114 int next_line_is_no_quote_line(const u_char *ptr) {
00115 int eq;
00116
00117 for(;*ptr && ((eq = cf_strncmp(ptr,"<br />",6)) == 0 || *ptr == ' ');ptr++) {
00118 if(eq == 0) ptr += 5;
00119 }
00120
00121 if(*ptr == (u_char)127) return 0;
00122 return 1;
00123 }
00124
00125
00126
00127 void msg_to_html(const u_char *msg,t_string *content,t_string *cite) {
00128 t_name_value *cs = cfg_get_value(&fo_default_conf,"ExternCharset");
00129 const u_char *ptr,*tmp;
00130 u_char *qchars;
00131 size_t qclen;
00132 int linebrk = 0,quotemode = 0,sig = 0,utf8 = cf_strcmp(cs->values[0],"UTF-8");
00133
00134 if(utf8 || (qchars = htmlentities_charset_convert(Cfg.QuotingChars,"UTF-8",cs->values[0],&qclen,0)) == NULL) {
00135 qchars = strdup(Cfg.QuotingChars);
00136 qclen = strlen(qchars);
00137 }
00138
00139 for(ptr=msg;*ptr;ptr++) {
00140 if(cf_strncmp(ptr,"<br />",6) == 0) {
00141 linebrk = 1;
00142
00143 str_chars_append(content,"<br />",6);
00144
00145 if(sig == 0 && cite) {
00146 str_chars_append(cite,"\n",1);
00147 str_chars_append(cite,qchars,qclen);
00148 }
00149
00150 if(quotemode && next_line_is_no_quote_line(ptr+6)) {
00151 str_chars_append(content,"</span>",7);
00152 quotemode = 0;
00153 }
00154
00155 ptr += 5;
00156 }
00157 else if(cf_strncmp(ptr,"<a href=\"",9) == 0) {
00158 ptr += 9;
00159 linebrk = 0;
00160 tmp = strstr(ptr,"\"");
00161
00162 if(tmp) {
00163 str_chars_append(content,"<a href=\"",9);
00164 str_chars_append(content,ptr,tmp-ptr);
00165
00166 if(Cfg.link) {
00167 str_chars_append(content,"\" target=\"",10);
00168 str_chars_append(content,Cfg.link,strlen(Cfg.link));
00169 }
00170
00171 str_chars_append(content,"\">",2);
00172 str_chars_append(content,ptr,tmp-ptr);
00173 str_chars_append(content,"</a>",4);
00174
00175 if(sig == 0 && cite) {
00176 str_chars_append(cite,"[link:",6);
00177 str_chars_append(cite,ptr,tmp-ptr);
00178 str_chars_append(cite,"]",1);
00179 }
00180
00181 for(;cf_strncmp(ptr+1,"</a>",4) != 0;ptr++);
00182 ptr += 4;
00183 }
00184 else {
00185 tmp -= 9;
00186 }
00187 }
00188 else if(cf_strncmp(ptr,"<img src=\"",10) == 0) {
00189 u_char *tmp;
00190
00191 ptr += 10;
00192 linebrk = 0;
00193
00194 tmp = strstr(ptr,"\"");
00195
00196 if(tmp) {
00197 str_chars_append(content,"<img src=\"",10);
00198
00199 str_chars_append(content,ptr,tmp-ptr);
00200 str_chars_append(content,"\" alt=\"Externes Bild\">",22);
00201
00202 if(sig == 0 && cite) {
00203 str_chars_append(cite,"[image:",7);
00204 str_chars_append(cite,ptr,tmp-ptr);
00205 str_chars_append(cite,"]",1);
00206 }
00207
00208 ptr = strstr(tmp,">");
00209 }
00210 else {
00211 ptr -= 10;
00212 }
00213 }
00214 else if(cf_strncmp(ptr,"[pref:",6) == 0) {
00215 ptr += 6;
00216 for(tmp=ptr;*tmp && (*tmp == 't' || *tmp == 'm' || *tmp == '=' || *tmp == '&' || isdigit(*tmp));tmp++) {
00217 if(cf_strncmp(tmp,"&",5) == 0) {
00218 tmp += 5;
00219 }
00220 }
00221
00222 if(sig == 0 && cite) {
00223 str_chars_append(cite,"[link:?",7);
00224 str_chars_append(cite,ptr,tmp-ptr);
00225 str_chars_append(cite,"]",1);
00226 }
00227
00228 str_chars_append(content,"<a href=\"?",10);
00229 str_chars_append(content,ptr,tmp-ptr);
00230
00231 if(Cfg.link) {
00232 str_chars_append(content,"\" target=\"",10);
00233 str_chars_append(content,Cfg.link,strlen(Cfg.link));
00234 }
00235
00236 str_chars_append(content,"\">?",3);
00237 str_chars_append(content,ptr,tmp-ptr);
00238 str_chars_append(content,"</a>",4);
00239
00240 ptr = tmp;
00241 }
00242 else if(cf_strncmp(ptr,"<iframe",7) == 0) {
00243 ptr += 13;
00244 tmp = ptr;
00245 ptr = strstr(ptr,"\"");
00246
00247 str_chars_append(content,"<iframe src=\"",13);
00248
00249 str_chars_append(content,tmp,ptr-tmp);
00250 str_chars_append(content,"\" width=\"90%\" height=\"90%\"><a href=\"",36);
00251 str_chars_append(content,tmp,ptr-tmp);
00252 str_chars_append(content,"\">",2);
00253 str_chars_append(content,tmp,ptr-tmp);
00254 str_chars_append(content,"</a></iframe>",13);
00255
00256 if(sig == 0 && cite) {
00257 str_chars_append(cite,"[iframe:",8);
00258 str_chars_append(cite,tmp,ptr-tmp);
00259 str_char_append(cite,']');
00260 }
00261
00262 ptr = strstr(ptr,"</iframe>");
00263 ptr += 9;
00264 }
00265 else if(*ptr == (u_char)127) {
00266 linebrk = 0;
00267
00268 if(!quotemode) {
00269 str_chars_append(content,"<span class=\"q\">",16);
00270 }
00271
00272 str_chars_append(content,qchars,qclen);
00273 quotemode = 1;
00274
00275 if(sig == 0 && cite) {
00276 str_chars_append(cite,qchars,qclen);
00277 }
00278 }
00279 else if(cf_strncmp(ptr,"_/_SIG_/_",9) == 0) {
00280
00281 if(!Cfg.ShowSig) break;
00282
00283 sig = 1;
00284
00285 str_chars_append(content,"<br /><span class=\"sig\">",24);
00286 str_chars_append(content,"-- <br />",9);
00287
00288 ptr += 8;
00289 }
00290 else {
00291 str_chars_append(content,ptr,1);
00292
00293 if(sig == 0 && cite) {
00294 str_chars_append(cite,ptr,1);
00295 }
00296 }
00297 }
00298
00299 if(quotemode || sig) {
00300 str_chars_append(content,"</span>",7);
00301 }
00302
00303 free(qchars);
00304
00305 }
00306
00307
00308
00309 int execute_filter(t_cf_hash *head,t_configuration *dc,t_configuration *vc,t_cl_thread *thread,t_cf_template *tpl) {
00310 t_string content,cite;
00311 u_char *ptr;
00312 t_name_value *ps = NULL;
00313 t_name_value *name = cfg_get_value(vc,"Name");
00314 t_name_value *email = cfg_get_value(vc,"EMail");
00315 t_name_value *hpurl = cfg_get_value(vc,"HomepageUrl");
00316 t_name_value *imgurl = cfg_get_value(vc,"ImageUrl");
00317 t_name_value *fbase = NULL;
00318 t_name_value *cs = cfg_get_value(dc,"ExternCharset");
00319 t_message *msg;
00320 u_char *UserName = cf_hash_get(GlobalValues,"UserName",8);
00321 int ShowInvisible = cf_hash_get(GlobalValues,"ShowInvisible",13) == NULL ? 0 : 1;
00322
00323 int utf8;
00324 int len = 0;
00325 u_char *tmp;
00326 u_char buff[50];
00327 u_char *date,*link,*qchars,*msgcnt;
00328 int rc = 0;
00329 size_t qclen,msgcntlen;
00330
00331 if(thread) {
00332 ptr = thread->threadmsg->content;
00333 tmp = get_time(vc,"DateFormatThreadView",&len,&thread->threadmsg->date);
00334 }
00335
00336 utf8 = cf_strcmp(cs->values[0],"UTF-8") == 0;
00337
00338 #ifdef CF_SHARED_MEM
00339
00340 if(thread) {
00341 if(thread->messages->invisible == 1 && !ShowInvisible) {
00342 str_error_message("E_FO_404",NULL,8);
00343 return FLT_EXIT;
00344 }
00345 }
00346 #endif
00347
00348 tpl_cf_setvar(tpl,"charset",cs->values[0],strlen(cs->values[0]),0);
00349
00350 if(UserName) {
00351 fbase = cfg_get_value(dc,"UBaseURL");
00352 ps = cfg_get_value(dc,"UPostScript");
00353 }
00354 else {
00355 fbase = cfg_get_value(dc,"BaseURL");
00356 ps = cfg_get_value(dc,"PostScript");
00357 }
00358
00359 cf_set_variable(tpl,cs,"forumbase",fbase->values[0],strlen(fbase->values[0]),1);
00360
00361 if(thread) {
00362 cf_set_variable(tpl,cs,"title",thread->threadmsg->subject,strlen(thread->threadmsg->subject),1);
00363 cf_set_variable(tpl,cs,"name",thread->threadmsg->author,strlen(thread->threadmsg->author),1);
00364 cf_set_variable(tpl,cs,"time",tmp,len,1);
00365 free(tmp);
00366 }
00367
00368 if(utf8 || (qchars = htmlentities_charset_convert(Cfg.QuotingChars,"UTF-8",cs->values[0],&qclen,0)) == NULL) {
00369 qchars = strdup(Cfg.QuotingChars);
00370 qclen = strlen(qchars);
00371 }
00372
00373 if(thread) {
00374 if(thread->threadmsg->email && *thread->threadmsg->email) {
00375 cf_set_variable(tpl,cs,"email",thread->threadmsg->email,strlen(thread->threadmsg->email),1);
00376 }
00377
00378 if(thread->threadmsg->category && *thread->threadmsg->category) {
00379 cf_set_variable(tpl,cs,"category",thread->threadmsg->category,strlen(thread->threadmsg->category),1);
00380 }
00381
00382 if(thread->threadmsg->hp && *thread->threadmsg->hp) {
00383 cf_set_variable(tpl,cs,"link",thread->threadmsg->hp,strlen(thread->threadmsg->hp),1);
00384 }
00385
00386 if(thread->threadmsg->img && *thread->threadmsg->img) {
00387 cf_set_variable(tpl,cs,"image",thread->threadmsg->img,strlen(thread->threadmsg->img),1);
00388 }
00389 }
00390
00391 if(Cfg.TWidth) {
00392 tpl_cf_setvar(tpl,"twidth",Cfg.TWidth,strlen(Cfg.TWidth),1);
00393 }
00394 if(Cfg.THeight) {
00395 tpl_cf_setvar(tpl,"theight",Cfg.THeight,strlen(Cfg.THeight),1);
00396 }
00397
00398 if(Cfg.Preview) {
00399 tpl_cf_setvar(tpl,"preview","1",1,0);
00400 }
00401 if(Cfg.PreviewSwitchType == 0) {
00402 tpl_cf_setvar(tpl,"previewswitchtype","checkbox",8,0);
00403 }
00404 else if(Cfg.PreviewSwitchType == 1) {
00405 tpl_cf_setvar(tpl,"previewswitchtype","button",6,0);
00406 }
00407
00408 if(Cfg.ActiveColorF && *Cfg.ActiveColorF) {
00409 cf_set_variable(tpl,cs,"activecolorf",Cfg.ActiveColorF,strlen(Cfg.ActiveColorF),1);
00410 }
00411 if(Cfg.ActiveColorB && *Cfg.ActiveColorB) {
00412 cf_set_variable(tpl,cs,"activecolorb",Cfg.ActiveColorB,strlen(Cfg.ActiveColorB),1);
00413 }
00414
00415
00416
00417
00418
00419 if(thread) {
00420 if(thread->threadmsg != thread->messages) {
00421 t_message *msg;
00422 if((msg = get_parent_message(thread->messages,thread->threadmsg)) != NULL) {
00423 tmp = get_time(vc,"DateFormatThreadView",&len,&msg->date);
00424
00425 tpl_cf_setvar(tpl,"messagebefore","1",1,0);
00426 cf_set_variable(tpl,cs,"b_name",msg->author,strlen(msg->author),1);
00427 cf_set_variable(tpl,cs,"b_title",msg->subject,strlen(msg->subject),1);
00428 cf_set_variable(tpl,cs,"b_time",tmp,len,1);
00429
00430 free(tmp);
00431
00432 tmp = get_link(thread->tid,msg->mid);
00433 cf_set_variable(tpl,cs,"b_link",tmp,strlen(tmp),1);
00434
00435 free(tmp);
00436
00437 if(msg->category) {
00438 cf_set_variable(tpl,cs,"b_category",msg->category,strlen(msg->category),1);
00439 }
00440 }
00441 }
00442 }
00443
00444
00445 if(name && *name->values[0]) {
00446 cf_set_variable(tpl,cs,"aname",name->values[0],strlen(name->values[0]),1);
00447 }
00448 if(email && *email->values[0]) {
00449 cf_set_variable(tpl,cs,"aemail",email->values[0],strlen(email->values[0]),1);
00450 }
00451 if(hpurl && *hpurl->values[0]) {
00452 cf_set_variable(tpl,cs,"aurl",hpurl->values[0],strlen(hpurl->values[0]),1);
00453 }
00454 if(imgurl && *imgurl->values[0]) {
00455 cf_set_variable(tpl,cs,"aimg",imgurl->values[0],strlen(imgurl->values[0]),1);
00456 }
00457
00458 tpl_cf_setvar(tpl,"qchar","ÿ",6,0);
00459 tpl_cf_appendvar(tpl,"qchar",qchars,qclen);
00460
00461 if(thread) {
00462 len = sprintf(buff,"%lld,%lld",thread->tid,thread->threadmsg->mid);
00463 tpl_cf_setvar(tpl,"fupto",buff,len,0);
00464 }
00465
00466 len = gen_unid(buff,50);
00467 tpl_cf_setvar(tpl,"unid",buff,len,1);
00468
00469 if(thread) str_init(&content);
00470 str_init(&cite);
00471
00472 if(thread) {
00473
00474 if(utf8 || (msgcnt = charset_convert_entities(thread->threadmsg->content,thread->threadmsg->content_len,"UTF-8",cs->values[0],&msgcntlen)) == NULL) {
00475 msgcnt = strdup(thread->threadmsg->content);
00476 msgcntlen = thread->threadmsg->content_len;
00477 }
00478 }
00479
00480
00481 if(Cfg.Hi) {
00482 replace_placeholders(Cfg.Hi,&cite,thread);
00483 }
00484
00485
00486 if(thread) {
00487 msg_to_html(msgcnt,&content,&cite);
00488 }
00489
00490
00491 if(Cfg.Bye && *Cfg.Bye) {
00492 replace_placeholders(Cfg.Bye,&cite,thread);
00493 }
00494
00495
00496 if(Cfg.Signature && *Cfg.Signature) {
00497 replace_placeholders(Cfg.Bye,&cite,thread);
00498 }
00499
00500 if(thread) cf_set_variable(tpl,cs,"message",content.content,content.len,0);
00501
00502 if(Cfg.DoQuote || !thread) cf_set_variable(tpl,cs,"cite",cite.content,cite.len,0);
00503
00504 cf_set_variable(tpl,cs,"action",ps->values[0],strlen(ps->values[0]),1);
00505
00506 str_cleanup(&cite);
00507 if(thread) str_cleanup(&content);
00508 if(thread) free(msgcnt);
00509 free(qchars);
00510
00511
00512 if(!thread) return FLT_OK;
00513
00514
00515
00516
00517 if(cf_strcmp(Cfg.ShowThread,"none") != 0) {
00518 int level = 0;
00519 int slvl = -1;
00520
00521 if(cf_strcmp(Cfg.ShowThread,"partitial") == 0) {
00522 t_message *msg;
00523 int level = 0;
00524
00525 for(msg=thread->messages;msg && msg->mid != thread->threadmsg->mid;msg=msg->next) {
00526 msg->may_show = 0;
00527 }
00528
00529 level = msg->level;
00530 msg->may_show = 0;
00531
00532 for(msg=msg->next;msg && msg->level > level;msg=msg->next);
00533
00534 for(;msg;msg=msg->next) {
00535 msg->may_show = 0;
00536 }
00537 }
00538 else {
00539 tpl_cf_setvar(&thread->threadmsg->tpl,"active","1",1,0);
00540 }
00541
00542 handle_thread(thread,head,1);
00543
00544 tpl_cf_setvar(tpl,"threadlist","",0,0);
00545 for(msg=thread->messages;msg;msg=msg->next) {
00546 if((msg->may_show && msg->invisible == 0) || ShowInvisible == 1) {
00547 rc = handle_thread_list_posting(msg,head,thread->tid,1);
00548 if(ShowInvisible == 0 && (rc == FLT_EXIT || msg->may_show == 0)) continue;
00549 else if(slvl == -1) slvl = msg->level;
00550
00551 date = get_time(vc,"DateFormatThreadList",&len,&msg->date);
00552 link = get_link(thread->tid,msg->mid);
00553 cf_set_variable(&msg->tpl,cs,"author",msg->author,strlen(msg->author),1);
00554 cf_set_variable(&msg->tpl,cs,"title",msg->subject,strlen(msg->subject),1);
00555
00556 if(msg->category) {
00557 cf_set_variable(&msg->tpl,cs,"category",msg->category,strlen(msg->category),1);
00558 }
00559
00560 if(date) {
00561 cf_set_variable(&msg->tpl,cs,"time",date,len,1);
00562 free(date);
00563 }
00564
00565 if(link) {
00566 cf_set_variable(&msg->tpl,cs,"link",link,strlen(link),1);
00567 free(link);
00568 }
00569
00570 if(msg->level < level) {
00571 for(;level>msg->level;level--) {
00572 tpl_cf_appendvar(tpl,"threadlist","</ul></li>",10);
00573 }
00574 }
00575
00576 level = msg->level;
00577
00578 if(msg->next && has_answers(msg)) {
00579 tpl_cf_appendvar(tpl,"threadlist","<li>",4);
00580
00581 tpl_cf_parse_to_mem(&msg->tpl);
00582 tpl_cf_appendvar(tpl,"threadlist",msg->tpl.parsed.content,msg->tpl.parsed.len-1);
00583
00584 tpl_cf_appendvar(tpl,"threadlist","<ul>",4);
00585 }
00586 else {
00587 tpl_cf_appendvar(tpl,"threadlist","<li>",4);
00588
00589 tpl_cf_parse_to_mem(&msg->tpl);
00590 tpl_cf_appendvar(tpl,"threadlist",msg->tpl.parsed.content,msg->tpl.parsed.len-1);
00591
00592 tpl_cf_appendvar(tpl,"threadlist","</li>",5);
00593 }
00594 }
00595 }
00596
00597 for(;level>slvl;level--) {
00598 tpl_cf_appendvar(tpl,"threadlist","</ul></li>",10);
00599 }
00600 }
00601
00602 return FLT_OK;
00603 }
00604
00605
00606
00607
00608 void *flt_posting_api_get_qchars(void *arg) {
00609 return (void *)Cfg.QuotingChars;
00610 }
00611
00612
00613
00614 void *flt_posting_api_msg_to_html(void *arg) {
00615 t_string *content,*cite;
00616 const u_char *msg;
00617
00618 msg = *((const u_char **)arg);
00619 arg += sizeof(const u_char *);
00620 content = *((t_string **)arg);
00621 arg += sizeof(t_string *);
00622 cite = *((t_string **)arg);
00623
00624 msg_to_html(msg,content,cite);
00625
00626 return NULL;
00627 }
00628
00629
00630
00631
00632
00633 int handle_q(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00634 if(cf_strcmp(opt->name,"DoQuote") == 0) {
00635 Cfg.DoQuote = cf_strcmp(args[0],"yes") == 0 ? 1 : 0;
00636 }
00637 else if(cf_strcmp(opt->name,"QuotingChars") == 0) {
00638 if(Cfg.QuotingChars) free(Cfg.QuotingChars);
00639 Cfg.QuotingChars = strdup(args[0]);
00640 }
00641
00642 return 0;
00643 }
00644
00645
00646
00647 int handle_st(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00648 if(Cfg.ShowThread) free(Cfg.ShowThread);
00649 Cfg.ShowThread = strdup(args[0]);
00650
00651 return 0;
00652 }
00653
00654
00655
00656 int handle_greet(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00657 u_char *tmp = strdup(args[0]);
00658
00659 if(cf_strcmp(opt->name,"Hi") == 0) {
00660 if(Cfg.Hi) free(Cfg.Hi);
00661 Cfg.Hi = tmp;
00662 }
00663 else if(cf_strcmp(opt->name,"Bye") == 0) {
00664 if(Cfg.Bye) free(Cfg.Bye);
00665 Cfg.Bye = tmp;
00666 }
00667 else if(cf_strcmp(opt->name,"Signature") == 0) {
00668 if(Cfg.Signature) free(Cfg.Signature);
00669 Cfg.Signature = tmp;
00670 }
00671
00672 return 0;
00673 }
00674
00675
00676
00677 int handle_link(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00678 if(Cfg.link) free(Cfg.link);
00679 Cfg.link = strdup(args[0]);
00680
00681 return 0;
00682 }
00683
00684
00685
00686 int handle_sig(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00687 Cfg.ShowSig = cf_strcmp(args[0],"yes") == 0 ? 1 : 0;
00688
00689 return 0;
00690 }
00691
00692
00693
00694 int handle_box(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00695 if(Cfg.TWidth) free(Cfg.TWidth);
00696 if(Cfg.THeight) free(Cfg.THeight);
00697
00698 Cfg.TWidth = strdup(args[0]);
00699 Cfg.THeight = strdup(args[1]);
00700
00701 return 0;
00702 }
00703
00704
00705
00706 int handle_prev(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00707 Cfg.Preview = cf_strcmp(args[0],"yes") == 0;
00708
00709 return 0;
00710 }
00711
00712
00713
00714 int handle_prevt(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00715 if(cf_strcmp(args[0],"button") == 0) {
00716 Cfg.PreviewSwitchType = 1;
00717 }
00718 else if(cf_strcmp(args[0],"checkbox") == 0) {
00719 Cfg.PreviewSwitchType = 0;
00720 }
00721 else {
00722 fprintf(stderr,"Error: wrong value for PreviewSwitchType\n");
00723 return 1;
00724 }
00725
00726 return 0;
00727 }
00728
00729
00730
00731 int handle_actpcol(t_configfile *cfile,t_conf_opt *opt,u_char **args,int argnum) {
00732 if(Cfg.ActiveColorF) free(Cfg.ActiveColorF);
00733 if(Cfg.ActiveColorB) free(Cfg.ActiveColorB);
00734
00735 Cfg.ActiveColorF = strdup(args[0]);
00736 Cfg.ActiveColorB = strdup(args[1]);
00737
00738 return 0;
00739 }
00740
00741
00742
00743 void cleanup(void) {
00744 if(Cfg.Hi) free(Cfg.Hi);
00745 if(Cfg.Bye) free(Cfg.Bye);
00746 if(Cfg.Signature) free(Cfg.Signature);
00747 if(Cfg.ShowThread) free(Cfg.ShowThread);
00748 if(Cfg.QuotingChars) free(Cfg.QuotingChars);
00749 if(Cfg.link) free(Cfg.link);
00750 if(Cfg.ActiveColorF) free(Cfg.ActiveColorF);
00751 if(Cfg.ActiveColorB) free(Cfg.ActiveColorB);
00752 }
00753
00754
00755
00756 int register_hooks(t_cf_hash *cgi,t_configuration *dc,t_configuration *vc) {
00757 cf_register_mod_api_ent("flt_posting","get_qchars",flt_posting_api_get_qchars);
00758 cf_register_mod_api_ent("flt_posting","msg_to_html",flt_posting_api_msg_to_html);
00759
00760 return FLT_OK;
00761 }
00762
00763
00764
00765 t_conf_opt config[] = {
00766 { "DoQuote", handle_q, NULL },
00767 { "QuotingChars", handle_q, NULL },
00768 { "ShowThread", handle_st, NULL },
00769 { "Hi", handle_greet, NULL },
00770 { "Bye", handle_greet, NULL },
00771 { "Signature", handle_greet, NULL },
00772 { "PostingLinkTarget", handle_link, NULL },
00773 { "ShowSig", handle_sig, NULL },
00774 { "TextBox", handle_box, NULL },
00775 { "GeneratePreview", handle_prev, NULL },
00776 { "PreviewSwitchType", handle_prevt, NULL },
00777 { "ActivePostingColor", handle_actpcol, NULL },
00778 { NULL, NULL, NULL }
00779 };
00780
00781
00782
00783 t_handler_config handlers[] = {
00784 { INIT_HANDLER, register_hooks },
00785 { POSTING_HANDLER, execute_filter },
00786 { 0, NULL }
00787 };
00788
00789
00790
00791 t_module_config flt_posting = {
00792 config,
00793 handlers,
00794 NULL,
00795 NULL,
00796 NULL,
00797 cleanup
00798 };
00799
00800
00801
00802