Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 1 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 1 /* Copyright (C) 1995 NetWin, New Zealand, All rights reserved. */ 2 /* 3 What is quoted printable format, must detec 4 5 Content-Type: text/html; charset=ISO-8859-1 6 Content-Transfer-Encoding: quoted-printable 7 8 =3D --> = 9 = --> newline 10 11 12 13 Test on cern on hortnet. test turning logging off 14 */ 15 16 #include 338 #include 707 #include 846 #include 1075 #include 1665 #ifdef WIN32 X 1666 #include X 1667 #include X 1668 #else 1669 #include 1837 #include 1977 #endif 1978 #ifdef OS2 X 1979 #include X 1980 #endif 1981 #include 2022 #include "dnews.h" 2039 #include "conf.h" 2236 #include "lib.h" X 3071 #include "emsg.h" 3072 #include "nntp.h" 3104 #ifndef TRUE X 3105 #define FALSE 0 X 3106 #define TRUE (!FALSE) X 3107 #endif 3108 static int docache=FALSE; 3109 static int dodebug=FALSE; 3110 /* 3111 Commands that we need to support 3112 xover comp.os.vms [nnn-nnn] Default is last 20 messages in group 3113 article comp.os.vms nnn 3114 post message 3115 list comp.os.* Just show the ones at that level 3116 */ 3117 int decode_base64(char *buf, char *out); 3118 int decode_uu(char *line, char *out); 3119 static char tplname[BFSZ]; 3120 3121 void get_line_clear(void); 3122 void show_dline(char *s); 3123 void r_listall(void); 3124 void netwin_advert(void); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 2 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3125 void f_follow(int follow); 3126 char *xstrtok(char *line, char *in); 3127 char *towww(char *s); 3128 void r_find(void); /* from=nnn max=nnn*/ 3129 void f_find(void); 3130 void show_xsearch(void); 3131 void f_search(void); 3132 void r_search(void); 3133 void tpl_show_item_image(void); 3134 void f_post(void); 3135 void h_printf(char * arg_list, ...); 3136 void db_setscript(char *script); 3137 int show_headfile(char *type, char *title); 3138 void show_end(char *type); 3139 int show_top(char *type, char * arg_list, ...); 3140 void show_article2(void); 3141 char *lib_encode(char *s); 3142 char *value_encode(char *s); 3143 char *mygetenv(char *v); 3144 char *query_find(char *s); 3145 int query_get(void); 3146 void getword(char *word, char *line, char stop) ; 3147 char x2c(char *what) ; 3148 char *email_name(char *email); 3149 void unescape_url(char *url) ; 3150 void plustospace(char *str) ; 3151 void tpl_quote_body(void); 3152 int tpl_show_file(char *xfname); 3153 char *file_tpl(char *fname); 3154 3155 char *tpl_replace(char *bf); 3156 void tpl_init(void); 3157 char *tpl_replace_vars(char *orig); 3158 void tpl_replace_var(char *bf, int len, char *var); 3159 void tpl_show_list(void); 3160 void tpl_init_item(void); 3161 void tpl_show_item(void); 3162 void tpl_init_sbar(int from, int to, int total, char *key); 3163 3164 char *head_decode(char *s); 3165 3166 void tpl_show_group(void); 3167 void tpl_set_buttons(void); 3168 void tpl_show(char *xfname); 3169 3170 void var_set(char *var, char *val); 3171 char *var_find(char *var); 3172 3173 3174 void show_sbar(int from, int to, int total, char *key); 3175 void form_get(void); 3176 char *form_find(char *s); 3177 void show_article(void); 3178 int do_authent(void); 3179 3180 3181 static char path_script[BFSZ]; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 3 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3182 static char rootname[BFSZ]; 3183 int ini_read(char *s); 3184 int ini_find(char *s); 3185 char *ini_get(int x); 3186 void r_post(void); 3187 void zmsg(char * arg_list, ...); 3188 3189 void r_article(void); 3190 int read_lines(void); 3191 int read_status(void); 3192 int read_xover(void); 3193 void show_xover(void); 3194 void r_xover(void); /* from=nnn max=nnn*/ 3195 void r_list(void); 3196 char *mygetenv(char *s); 3197 3198 char *h_date_trim(char *instr); 3199 char *h_trim(char *s, int len); 3200 char *h_from_trim(char *s); 3201 #define MAX_ITEMS 4010 3202 3203 3204 #ifdef WIN32 X 3205 #define FIX_STDOUT TRUE X 3206 #endif 3207 3208 #ifdef OS2 X 3209 #define FIX_STDOUT TRUE X 3210 #define _setmode setmode X 3211 #endif 3212 3213 void xover_add(char *item, char *subject, char *from, char *lines, char *date, char *mid, char *ref); 3214 void xover_showord(void); 3215 3216 enum {I_HEADERS, I_XOVER_PRE, I_XOVER_POST, I_NEWSHOST, I_DEBUG, I_PAGESIZE 3217 , I_GROUPS, I_ALLOW, I_SORT, I_NOADVERT, I_SEARCH, I_CGI_PATH, I_TEMPLATES 3218 , I_POST_GROUPS, I_POST_USERS,I_LOG_FILE,I_SORT_REV,I_WRAP_POST,I_WRAP_TEXT 3219 , I_CONTENT_TYPE, I_ADD_MID, I_TELLNEWS_PASS, I_PRE_DISABLE 3220 }; 3221 char *ini_names[]={ 3222 "headers","xover_pre","xover_post","newshost", "debug", "pagesize" 3223 ,"groups", "allow" , "sort", "noadvert", "search", "cgi_path" 3224 ,"templates" 3225 ,"post_groups", "post_users","log_file" 3226 ,"sort_rev","wrap_post","wrap_text" 3227 ,"content_type", "add_mid", "tellnews_pass" 3228 ,"pre_disable" 3229 , NULL 3230 }; 3231 3232 #define PAGESIZE page_size() 3233 char *content_type(void); 3234 char *content_type(void) 3235 { 3236 static char bf[BFSZ]; 3237 strcpy(bf,ini_get(I_CONTENT_TYPE)); 3238 if (strlen(bf)==0) strcpy(bf,"text/html"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 4 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3239 return bf; 3240 } 3241 int page_size(void) 3242 { 3243 int i = atoi(ini_get(I_PAGESIZE)); 3244 if (i==0) i = 30; 3245 return i; 3246 } 3247 3248 static int done_content; 3249 static int x_item[MAX_ITEMS]; 3250 static char *x_score[MAX_ITEMS]; 3251 static char *x_group[MAX_ITEMS]; 3252 static double x_f[MAX_ITEMS]; 3253 static int x_fi[MAX_ITEMS]; 3254 static int x_depth[MAX_ITEMS]; 3255 static char *x_subject[MAX_ITEMS]; 3256 static char *x_subjectsrt[MAX_ITEMS]; 3257 static char *x_from[MAX_ITEMS]; 3258 static char *x_date[MAX_ITEMS]; 3259 static char *x_ref[MAX_ITEMS]; 3260 static char *x_lines[MAX_ITEMS]; 3261 static char *x_mid[MAX_ITEMS]; 3262 static int nitem; 3263 3264 void emsg_reset(void); 3265 3266 static int chan; 3267 static char thisuser[BFSZ]; 3268 static char group[BFSZ]; 3269 static int gfrom,gto,gmax,group_from,group_to; 3270 static int dosort; 3271 static char log_file[BFSZ]; 3272 static int search_result = FALSE; 3273 static int pre_disable=FALSE; 3274 int main(int argc, char *argv[]) 3275 { 3276 char method[BFSZ]; 3277 char cmd[BFSZ]; 3278 3279 #ifndef WIN32 3280 signal(SIGFPE,SIG_IGN); 3281 #endif 3282 strcpy(log_file,"dnewsweb.log"); 3283 db_setscript(mygetenv("SCRIPT_NAME")); 3284 sprintf(log_file,"%s.log",rootname); 3285 if (!ini_read(argv[0])) return 0; 3286 if (strlen(ini_get(I_CGI_PATH))>0) { 3287 strcpy(path_script,ini_get(I_CGI_PATH)); 3288 } 3289 if (strlen(ini_get(I_LOG_FILE))>0) { 3290 strcpy(log_file,ini_get(I_LOG_FILE)); 3291 } 3292 3293 if (strcmp("true",ini_get(I_DEBUG))==0) dodebug = TRUE; 3294 if (strcmp("true",ini_get(I_SORT))==0) dosort = TRUE; 3295 if (strcmp("true",ini_get(I_PRE_DISABLE))==0) pre_disable = TRUE; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 5 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3296 if (!dodebug) emsg_reset(); 3297 imsg("DNEWSWEB, Startup, Looking for winsock dll\n"); 3298 nntp_startup(); 3299 nntp_alwaysblock(); 3300 3301 strcpy(thisuser,mygetenv("REMOTE_USER")); 3302 strcpy(method,mygetenv("REQUEST_METHOD")); strlwr(method); 3303 query_get(); /* Get the ?xxx=yyy... parameters */ 3304 if (strcmp(method,"post")==0) { 3305 imsg("Processing POST\n"); 3306 if (docache) printf("Pragma: cache\n"); 3307 done_content = TRUE; 3308 printf("Content-type: %s\n\n",content_type()); 3309 chan = nntp_open(ini_get(I_NEWSHOST)); 3310 if (chan<0) { goto failed;} 3311 nntp_setblock(chan,TRUE); /* Set to blocking IO */ 3312 3313 form_get(); /* get any form fields */ 3314 strcpy(cmd,form_find("cmd")); 3315 if (strcmp(cmd,"post")==0) r_post(); 3316 } else { 3317 imsg("Processing command (%s)\n",query_find("cmd")); 3318 strcpy(cmd,query_find("cmd")); 3319 if (strcmp(cmd,"article")!=0) { 3320 if (docache) printf("Pragma: cache\n"); 3321 done_content = TRUE; 3322 printf("Content-type: %s\n\n",content_type()); 3323 } 3324 chan = nntp_open(ini_get(I_NEWSHOST)); 3325 if (chan<0) { goto failed;} 3326 nntp_setblock(chan,TRUE); /* Set to blocking IO */ 3327 3328 if (strcmp(cmd,"xover")==0) r_xover(); 3329 else if (strcmp(cmd,"list")==0) r_list(); 3330 else if (strcmp(cmd,"listall")==0) r_listall(); 3331 else if (strcmp(cmd,"article")==0) r_article(); 3332 else if (strcmp(cmd,"post")==0) f_post(); 3333 else if (strcmp(cmd,"search")==0) f_search(); 3334 else if (strcmp(cmd,"f_search")==0) f_search(); 3335 else if (strcmp(cmd,"r_search")==0) r_search(); 3336 else if (strcmp(cmd,"r_find")==0) r_find(); 3337 else if (strcmp(cmd,"xsearch")==0) r_find(); 3338 else if (strcmp(cmd,"f_find")==0) f_find(); 3339 else if (strcmp(cmd,"follow")==0) f_follow(TRUE); 3340 else r_list(); 3341 } 3342 imsg("Program finished ok\n"); 3343 return 0; 3344 failed: 3345 if (strcmp(cmd,"article")==0) { 3346 if (docache) printf("Pragma: cache\n"); 3347 done_content = TRUE; 3348 printf("Content-type: %s\n\n",content_type()); 3349 } 3350 printf("Could not open connection to your news server (%s). \n",ini_get(I_NEWSHOST)); 3351 printf("It may be down at the moment, in which case you could try\n"); 3352 printf("again later. Also check you have given the correct name in dnewsweb.ini\n"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 6 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3353 return 0; 3354 } 3355 3356 /* 3357 sprintf(bf,"group rec.humor\015\012"); nntp_write_s(c,bf,strlen(bf)); 3358 sprintf(bf,"article\015\012"); nntp_write_s(c,bf,strlen(bf)); 3359 sprintf(bf,"quit\015\012"); nntp_write_s(c,bf,strlen(bf)); 3360 n = nntp_read(c,out,1000); 3361 for (;n>=0;) { 3362 out[n] = 0; 3363 printf("%s",out); 3364 n = nntp_read(c,out,1000); 3365 3366 } 3367 return 0; 3368 */ 3369 3370 static String *instr; 3371 int read_lines(void) 3372 { 3373 int n; 3374 char bf[3000]; 3375 char *s; 3376 wantmore: 3377 n = nntp_read(chan,bf,2000); 3378 if (n<0) return FALSE; 3379 bf[n] = 0; 3380 str_addsn(instr,bf); 3381 3382 s = str_s(instr) + str_len(instr) - 1; 3383 dmsg("Last char {%d}\n",*s); 3384 if (*s != '\012') goto wantmore; 3385 return TRUE; 3386 } 3387 static char nntp_status[BFSZ]; 3388 int group_match(char *a, char *b); 3389 int group_allow(char *group) 3390 { 3391 char bf[BFSZ]; 3392 char g[BFSZ]; 3393 ncpy(g,group,BFSZ-1); 3394 ncpy(bf,ini_get(I_ALLOW),BFSZ-1); 3395 if (!group_match(bf,g)) { 3396 printf("Sorry, you are not permitted access to (%s) ",group); 3397 printf("via this DNEWSWEB gateway\n"); 3398 return FALSE; 3399 } 3400 return TRUE; 3401 } 3402 int read_status(void) 3403 { 3404 char *s,*s2; 3405 int slen; 3406 if (instr==NULL) instr = str_new(); 3407 get_line_clear(); 3408 str_copysn(instr,""); 3409 read_lines(); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 7 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3410 s = str_s(instr); 3411 s2 = strchr(s,'\012'); 3412 if (s2==NULL) return FALSE; 3413 *s2 = 0; 3414 ncpy(nntp_status,s,BFSZ-1); 3415 slen = s2-s+1; 3416 if (str_len(instr)>(slen)) { 3417 memmove(s,s2+1,str_len(instr)-slen+1); 3418 str_setlen(instr,str_len(instr)-slen); 3419 } else str_copysn(instr,""); 3420 if (nntp_status[0]=='2') return TRUE; 3421 if (nntp_status[0]=='3') return TRUE; 3422 return FALSE; 3423 } 3424 char *get_linex(String *instr) 3425 { 3426 static char bf[BFSZ]; 3427 char *s; 3428 char *s2; 3429 int slen; 3430 s = str_s(instr); 3431 if (s==NULL) return NULL; 3432 s2 = strchr(s,'\012'); 3433 if (s2==NULL) return NULL; 3434 *s2 = 0; 3435 ncpy(bf,s,BFSZ-1); 3436 slen = s2-s+1; 3437 if (str_len(instr)>(slen)) { 3438 memmove(s,s2+1,str_len(instr)-slen+1); 3439 str_setlen(instr,str_len(instr)-slen); 3440 } else str_copysn(instr,""); 3441 3442 return bf; 3443 } 3444 static int gupto; 3445 void get_line_clear(void) 3446 { 3447 gupto = 0; 3448 if (instr==NULL) return; 3449 str_copysn(instr,""); 3450 } 3451 char *get_line(String *instr) 3452 { 3453 static char bf[BFSZ]; 3454 char *s; 3455 int noskip = FALSE; 3456 char was; 3457 char *s2; 3458 int slen; 3459 if (instr==NULL) return NULL; 3460 s = str_s(instr); 3461 if (s==NULL) goto fail; 3462 s+=gupto; 3463 if (*s=='\r') {s++; gupto++;} 3464 if (*s=='\n') {s++; gupto++;} 3465 for (s2=s;*s2!=0;s2++) if ((*s2=='\n') || (*s2=='\r')) break; 3466 if (*s2==0) goto fail; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 8 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3467 if ((s2-s)>500) { 3468 /* Long line, wrap it on the last space if possible*/ 3469 s2 = strchr(s+500,' '); 3470 if (s2==NULL) {s2 = s+500; noskip = TRUE;} 3471 if (s2>(s+599)) {s2 = s+500; noskip = TRUE;} 3472 was = *s2; 3473 *s2 = 0; 3474 ncpy(bf,s,BFSZ-1); 3475 *s2 = was; 3476 gupto += s2-s+1; 3477 if (noskip) gupto--; 3478 } else { 3479 *s2 = 0; 3480 ncpy(bf,s,BFSZ-1); 3481 gupto += s2-s+1; 3482 } 3483 strcat(bf,"\r"); 3484 if (gupto==str_len(instr)) str_copysn(instr,""); 3485 return bf; 3486 fail: 3487 str_copysn(instr,""); 3488 return NULL; 3489 } 3490 int read_xover(void) 3491 { 3492 char *s; 3493 dmsg("inside read_xover\n"); 3494 if (instr==NULL) instr = str_new(); 3495 for (;TRUE;) { 3496 dmsg("inside read_xover\n"); 3497 if (str_len(instr)==3) if (strcmp(str_s(instr),".\015\012")==0) break; 3498 if (str_len(instr)>=5) { 3499 s = str_s(instr) + str_len(instr) - 5; 3500 if (strcmp(s,"\015\012.\015\012")==0) break; 3501 if (strcmp(s,"\015\012.\015\012")==0) break; 3502 } 3503 3504 read_lines(); 3505 } 3506 if (str_len(instr)>3) str_setlen(instr,str_len(instr)-3); 3507 return TRUE; 3508 } 3509 void show_xline(char *s); 3510 void show_xbar(void) 3511 { 3512 printf(""); 3513 printf(""); 3514 if (gfrom>group_from) { 3515 printf("
Previous Page",path_script,towww(group),gf 3515 rom-gmax); 3516 } 3517 if (gtoNext Page",path_script,towww(group),gto); 3519 printf("Recent Items",path_script,towww(group)); 3520 } 3521 printf("Standard Groups",path_script); 3522 printf("All Groups",path_script); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 9 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3523 printf("Post",path_script,towww(group)); 3524 printf("Search Group",path_script,towww(group)); 3525 printf("
\n"); 3526 } 3527 void tpl_init_sbar(int from, int to, int total, char *key) 3528 { 3529 char bf[BFSZ]; 3530 if (from>1) { 3531 sprintf(bf,"%s?cmd=r_search&key=%s&from=%d&to=%d",path_script,lib_encode(key),from-page_size(),from) 3531 ; 3532 var_set("b_prev",bf); 3533 } 3534 if (to"); 3546 printf(""); 3547 if (from>1) { 3548 printf("Previous Page %d-%d",path_script,li 3548 b_encode(key),from-page_size(),from,from-page_size(),from); 3549 } 3550 if (toNext Page %d-%d",path_script,lib_en 3551 code(key),to,to+page_size(),to,to+page_size()); 3552 } 3553 printf("Standard Groups",path_script); 3554 printf("All Groups",path_script); 3555 printf("Search Group",path_script,towww(group)); 3556 printf(" \n"); 3557 } 3558 void show_xover(void) 3559 { 3560 char *s; 3561 3562 3563 s = get_line(instr); 3564 for (;s!=NULL;) { 3565 dmsg("Show sxline %s\n",s); 3566 show_xline(s); 3567 s = get_line(instr); 3568 } 3569 } 3570 void show_search(void) 3571 { 3572 char *s; 3573 3574 s = get_line(instr); 3575 for (;s!=NULL;) { 3576 show_xline(s); /* decode xover information */ Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 10 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3577 s = get_line(instr); 3578 } 3579 show_xsearch(); 3580 } 3581 3582 3583 void show_xsearch(void) 3584 { 3585 int i; 3586 char bf[BFSZ]; 3587 char *s; 3588 printf("\n"); 3596 3597 } 3598 3599 3600 void show_dlist(void) 3601 { 3602 char *s; 3603 3604 3605 s = get_line(instr); 3606 for (;s!=NULL;) { 3607 show_dline(s); 3608 s = get_line(instr); 3609 } 3610 } 3611 void netwin_advert(void) 3612 { 3613 printf("
\n"); 3614 printf(" "); 3615 printf("DNEWSWEB %s Copyright © NetWin Ltd\n",DNEWS_VERSION); 3616 printf(" \n"); 3617 printf(" \n"); 3618 } 3619 int head_get(char *field, char *val, char *line) 3620 { 3621 char bf[BFSZ]; 3622 char bf2[BFSZ]; 3623 ncpy(bf,line,BFSZ-1); 3624 strlwr(bf); 3625 if (strncmp(bf,field,strlen(field))==0) { 3626 ncpy(bf2,line+strlen(field)+1,100); 3627 ncpy(val,head_decode(bf2),200); 3628 } 3629 return TRUE; 3630 } 3631 #define MAXIMG 500000 3632 void show_article_part(int wanted); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 11 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3633 void show_article_part(int wanted) 3634 { 3635 char *s; 3636 char *s2; 3637 int gothead; 3638 int n; 3639 char subject[BFSZ]; 3640 int isuu = FALSE; 3641 char from[BFSZ]; 3642 char tmp[BFSZ]; 3643 char date[BFSZ]; 3644 char boundary[BFSZ]; 3645 char content[BFSZ]; 3646 char newsgroups[BFSZ]; 3647 char *out; 3648 int nout; 3649 int findimage = FALSE; 3650 int item = atoi(query_find("item")); 3651 int related = item; 3652 int got=0; 3653 3654 if (wanted==200) {findimage = TRUE; gothead = TRUE;} 3655 if (wanted==99) wanted = 0; 3656 out = mymalloc(MAXIMG); 3657 strcpy(boundary,"none"); 3658 strcpy(subject,""); 3659 strcpy(from,""); 3660 strcpy(content,""); 3661 strcpy(date,""); 3662 strcpy(newsgroups,""); 3663 related = item ; 3664 if (related<1) related = 1; 3665 #ifdef FIX_STDOUT X 3666 _setmode(_fileno(stdout),_O_BINARY); X 3667 #endif 3668 /* printf("Content-type: text/html\n\n"); */ 3669 /* fopen 3670 printf("MIME-Version: 1.0\n"); */ 3671 3672 /* printf("Content-Type: image/x-xbitmap\n"); 3673 printf("\n"); 3674 printf("#define back_width 20\n"); 3675 printf("#define back_height 23\n"); 3676 printf("static char back_bits[] = {\n"); 3677 printf(" 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0f,0x00,0x80,0x0f, \n"); 3678 printf(" 0x00,0x80,0x0f,0x00,0x80,0x0f,0x00,0x80,0x0f,0x00,0x80,0x0f,0x60,0x80,0x0f, \n"); 3679 printf(" 0x70,0x80,0x0f,0x78,0x00,0x00,0xfc,0xff,0x0f,0xfe,0xff,0x07,0xff,0xff,0x03, \n"); 3680 printf(" 0xfe,0xff,0x01,0xfc,0xff,0x00,0x78,0x00,0x00,0x70,0x00,0x00,0x60,0x00,0x00, \n"); 3681 printf(" 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; \n"); 3682 return; 3683 printf("Content-type: image/jpeg; name=\"test.jpg\"\n"); 3684 f = fopen("test.jpg","rb"); 3685 if (f==NULL) {perror("test.jpg"); return;} 3686 n = fread(bf,1,100000,f); 3687 3688 printf("Content-length: %d\n",n); 3689 printf("\n"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 12 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3690 fwrite(bf,1,n,stdout); 3691 return; 3692 */ 3693 3694 3695 3696 3697 s = get_line(instr); 3698 for (;s!=NULL;) { 3699 s2 = strchr(s,'\015') ; 3700 if (s2!=NULL) *s2 = 0; 3701 s2 = strchr(s,'\012') ; 3702 if (s2!=NULL) *s2 = 0; 3703 if (strlen(s)==0) break; 3704 s2 = strstr(s,"boundary="); 3705 if (s2==NULL) s2 = strstr(s,"Boundary="); 3706 if (s2!=NULL) { 3707 s2 = strchr(s2,'"'); 3708 strcpy(boundary,"--"); 3709 if (s2!=NULL) ncpy(boundary+2,s2+1,BFSZ-10); 3710 s2 = strchr(boundary,'"'); 3711 if (s2!=NULL) *s2 = 0; 3712 head_get("content-type:",content,s); 3713 } 3714 /* head_get("subject:",subject,s); */ 3715 s = get_line(instr); 3716 } 3717 nout = 0; 3718 if (findimage) if (strlen(content)>0) wanted = 0; 3719 if (wanted==0) { 3720 emsg("Content-type: %s\n",content); 3721 printf("Content-type: image/jpeg; name=\"test.jpg\"\n"); 3722 gothead = TRUE; 3723 } 3724 for (;s!=NULL;) { 3725 s2 = strchr(s,'\015') ; 3726 if (s2!=NULL) *s2 = 0; 3727 s2 = strchr(s,'\012') ; 3728 if (s2!=NULL) *s2 = 0; 3729 3730 if (!isuu) { 3731 if (strncmp(s,"begin",5)==0) { 3732 isuu = TRUE; 3733 strlwr(s); 3734 3735 if (strstr(s,".gif")!=NULL) printf("Content-type: image/GIF\n"); 3736 else if (strstr(s,".zip")!=NULL) printf("Content-type: application/x-zip-compressed\n"); 3737 else if (strstr(s,".exe")!=NULL) printf("Content-type: application/octet-stream\n"); 3738 else if (strstr(s,".doc")!=NULL) printf("Content-type: application/octet-stream\n"); 3739 else if (strstr(s,".xls")!=NULL) printf("Content-type: application/octet-stream\n"); 3740 else if (strstr(s,".com")!=NULL) printf("Content-type: application/octet-stream\n"); 3741 else if (strstr(s,".txt")!=NULL) printf("Content-type: text/plain\n"); 3742 else if (strstr(s,".ini")!=NULL) printf("Content-type: text/plain\n"); 3743 else if (strstr(s,".jpg")!=NULL) printf("Content-type: image/JPEG\n"); 3744 /*else if (strstr(s,".avi")!=NULL) printf("Content-type: audio/avi\n"); 3745 else if (strstr(s,".mpg")!=NULL) printf("Content-type: video/mpeg\n"); 3746 else if (strstr(s,".mpeg")!=NULL) printf("Content-type: video/mpeg\n"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 13 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3747 */ 3748 else if (strstr(s,".htm")!=NULL) printf("Content-type: text/html\n"); 3749 else if (strstr(s,".html")!=NULL) printf("Content-type: text/html\n"); 3750 else if (strstr(s,".jpeg")!=NULL) printf("Content-type: image/JPEG\n"); 3751 else { 3752 printf("Content-type: image/JPEG\n"); 3753 } 3754 3755 } 3756 } else { 3757 if (isuu) { 3758 if (strncmp(s,"end",3)==0) break; 3759 if (strcmp(s,"`")==0) break; 3760 if (s[0]!=0) { 3761 n = decode_uu(s,out+nout); 3762 nout += n; 3763 } 3764 } 3765 } 3766 3767 if (!isuu) { 3768 3769 if (findimage) if (!gothead) { 3770 ncpy(tmp,s,BFSZ-1); 3771 strlwr(tmp); 3772 if ( (strstr(tmp,"jpeg")!=NULL) || 3773 (strstr(tmp,"jpg")!=NULL) || 3774 (strstr(tmp,"image")!=NULL) || 3775 (strstr(tmp,"gif")!=NULL) ) 3776 { 3777 wanted = got; 3778 goto showit; 3779 } 3780 if (strlen(s)==0) gothead = TRUE; 3781 } 3782 if (strstr(s,boundary)!=NULL) { 3783 gothead = FALSE; got++; 3784 } else if (got==wanted) { 3785 showit: if (strlen(s)==0) gothead = TRUE; 3786 else { 3787 if (!gothead) { 3788 /* {char *zz; 3789 zz = strchr(s,';'); 3790 if (zz!=NULL) *zz = 0; 3791 } 3792 */ 3793 printf("%s\n",s); 3794 imsg("Attach Head(%s)\n",s); 3795 3796 ncpy(tmp,s,BFSZ-1); 3797 strlwr(tmp); 3798 if (strstr(tmp,"x-uue")!=NULL) got = wanted+1; 3799 } else { 3800 n = decode_base64(s,out+nout); 3801 if (n<0) emsg("Base 64 encoding is corrupt {%s} \n",s); 3802 nout += n; 3803 } Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 14 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3804 } 3805 } 3806 if (nout<0) break; 3807 } 3808 s = get_line(instr); 3809 } 3810 3811 printf("Content-length: %d\n",nout); 3812 printf("\n"); 3813 fwrite(out,1,nout,stdout); 3814 return; 3815 } 3816 void show_article2(void) 3817 { 3818 char *s,*x; 3819 char subject[BFSZ]; 3820 static char from[BFSZ]; 3821 static char date[BFSZ]; 3822 static char mime[BFSZ]; 3823 static char content[BFSZ]; 3824 static char encoding[BFSZ]; 3825 char bf[BFSZ]; 3826 int isimage = FALSE; 3827 char *s2; 3828 int gothead = FALSE; 3829 int multi,got,istext; 3830 static char boundary[BFSZ]; 3831 char newsgroups[BFSZ]; 3832 int item = atoi(query_find("item")); 3833 int related = item; 3834 int part = atoi(query_find("part")); 3835 if (part>0) { show_article_part(part); return;} 3836 3837 multi = got = istext = FALSE; 3838 strcpy(subject,""); 3839 strcpy(from,""); 3840 strcpy(date,""); 3841 strcpy(newsgroups,""); 3842 related = item; 3843 3844 done_content = TRUE; 3845 if (docache) printf("Pragma: cache\n"); 3846 printf("Content-type: %s\n\n",content_type()); 3847 3848 show_top("article","Newsgroup Article %s:%s ",group,query_find("item")); 3849 printf("\n"); 3850 printf(" \n"); 3851 printf("
Related Items\n",path_script,towww(group),relat 3851 ed); 3852 printf("Recent Items\n",path_script,towww(group)); 3853 printf("Standard Groups\n",path_script); 3854 printf("All Groups\n",path_script); 3855 printf("Post Followup\n",path_script,towww(group),query_f 3855 ind("item")); 3856 printf("
\n"); 3857 3858 Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 15 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3859 3860 s = get_line(instr); 3861 for (;s!=NULL;) { 3862 if (strcmp(s,"\015")==0) break; 3863 head_get("subject:",subject,s); 3864 head_get("date:",date,s); 3865 head_get("from:",from,s); 3866 head_get("newsgroups:",newsgroups,s); 3867 head_get("mime-version:",mime,s); 3868 head_get("content-type:",content,s); 3869 head_get("content-transfer-encoding:",encoding,s); 3870 3871 s2 = strstr(s,"boundary="); 3872 if (s2==NULL) s2 = strstr(s,"Boundary="); 3873 if (s2!=NULL) { 3874 s2 = strchr(s2,'"'); 3875 strcpy(boundary,"--"); 3876 if (s2!=NULL) ncpy(boundary+2,s2+1,BFSZ-10); 3877 s2 = strchr(boundary,'"'); 3878 if (s2!=NULL) *s2 = 0; 3879 } 3880 3881 s = get_line(instr); 3882 } 3883 3884 printf(""); 3885 printf("
Subject:%s\n",value_encode(subject)); 3886 printf("
Date:%s\n",date); 3887 printf("
From:%s\n",value_encode(from)); 3888 printf("
Newsgroups:%s\n",newsgroups); 3889 printf("
\n"); 3890 3891 strlwr(encoding); 3892 multi = FALSE; 3893 if (strlen(mime)>0) if (strlen(boundary)>0) multi = TRUE; 3894 3895 if (!multi) if (strstr(encoding,"base64")!=NULL) { 3896 printf("
",path_script,towww(group),item); 3897 goto endbit; 3898 } 3899 got = 0; 3900 if (multi) { 3901 for (;s!=NULL;) { 3902 s2 = strchr(s,'\015') ; if (s2!=NULL) *s2 = 0; s2 = strchr(s,'\012') ; if (s2!=NULL) *s2 = 0; 3903 if (strstr(s,boundary)!=NULL) { 3904 if (!pre_disable) if (istext) printf("\n"); 3905 gothead = FALSE; istext = FALSE; got++; 3906 isimage = FALSE; 3907 } 3908 if (strlen(s)==0) { 3909 if (!pre_disable) if (istext) printf("
\n");
	   3910 			gothead = TRUE;
	   3911 			if (isimage) 
	   3912 			  printf("
",path_script,towww(group 3912 ),item,got); 3913 } 3914 else { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 16 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3915 if (!gothead) { 3916 /* printf("%s
\n",s);*/ 3917 strlwr(s); 3918 if (strstr(s,"text/")!=NULL) istext = TRUE; 3919 if (strstr(s,"image/")!=NULL) isimage = TRUE; 3920 } else { 3921 if (istext) { 3922 printf("%s",value_encode(s)); 3923 } 3924 } 3925 } 3926 s = get_line(instr); 3927 } 3928 goto endbit; 3929 } 3930 3931 if (!pre_disable) printf("
\n");
	   3932 	s = get_line(instr);
	   3933 	isimage = FALSE;
	   3934 	for (;s!=NULL;) {
	   3935 		if (strncmp(s,"begin ",6)==0) {
	   3936 			imsg("Found begin (%s) \n",s);
	   3937 			ncpy(bf,s,BFSZ-1);
	   3938 			x = strtok(bf," \012\015"); if (x==NULL) goto skip;
	   3939 			x = strtok(NULL," \012\015"); if (x==NULL) goto skip;
	   3940 			imsg("Found begin nn(%s) \n",x);
	   3941 			if (atoi(x)<100) goto skip;
	   3942 			x = strtok(NULL," \012\015"); if (x==NULL) goto skip;
	   3943 			strlwr(x);
	   3944 			imsg("Searching file name (%s) \n",x);
	   3945 			if (strstr(x,".jpg")!=NULL) goto isok;
	   3946 			if (strstr(x,".jpeg")!=NULL) goto isok;
	   3947 			if (strstr(x,".exe")!=NULL) goto isok;
	   3948 			if (strstr(x,".html")!=NULL) goto isok;
	   3949 			if (strstr(x,".htm")!=NULL) goto isok;
	   3950 			if (strstr(x,".mpg")!=NULL) goto isok;
	   3951 			if (strstr(x,".mpeg")!=NULL) goto isok;
	   3952 			if (strstr(x,".avi")!=NULL) goto isok;
	   3953 			if (strstr(x,".com")!=NULL) goto isok;
	   3954 			if (strstr(x,".zip")!=NULL) goto isok;
	   3955 			if (strstr(x,".doc")!=NULL) goto isok;
	   3956 			if (strstr(x,".xls")!=NULL) goto isok;
	   3957 			if (strstr(x,".gif")!=NULL) goto isok;
	   3958 			goto skip;
	   3959 isok:			isimage = TRUE;
	   3960 
	   3961 			printf("
",path_script,x,towww(g 3961 roup),item,got); 3962 } 3963 skip: if (!isimage) printf("%s",value_encode(s)); 3964 if (isimage) { 3965 if (strncmp(s,"end",3)==0) isimage = FALSE; 3966 } 3967 s = get_line(instr); 3968 } 3969 if (!pre_disable) printf("
\n"); 3970 Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 17 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 3971 endbit: 3972 printf("\n"); 3973 printf(""); 3974 printf(" "); 3975 printf("
Related Items\n",path_script,towww(group),relat 3975 ed); 3976 printf("Recent Items",path_script,towww(group)); 3977 printf("All Groups",path_script); 3978 printf("Post Followup",path_script,towww(group),query_fin 3978 d("item")); 3979 printf("
\n"); 3980 show_end("article"); 3981 } 3982 static char msgid[BFSZ]; 3983 static char subject[BFSZ]; 3984 static char from[BFSZ]; 3985 static char h_ref[BFSZ]; 3986 void show_article1(void) 3987 { 3988 char *s; 3989 char date[BFSZ]; 3990 char bf[4000]; 3991 char newsgroups[BFSZ]; 3992 strcpy(subject,""); 3993 strcpy(from,""); 3994 strcpy(date,""); 3995 strcpy(msgid,""); 3996 strcpy(newsgroups,""); 3997 3998 s = get_line(instr); 3999 for (;s!=NULL;) { 4000 if (strcmp(s,"\015")==0) break; 4001 head_get("subject:",subject,s); 4002 head_get("date:",date,s); 4003 head_get("from:",from,s); 4004 head_get("references:",h_ref,s); 4005 head_get("message-id:",msgid,s); 4006 head_get("newsgroups:",newsgroups,s); 4007 s = get_line(instr); 4008 } 4009 var_set("h_subject",value_encode(subject)); 4010 var_set("h_date",date); 4011 var_set("h_message-id",value_encode(msgid)); 4012 var_set("h_from",value_encode(from)); 4013 sprintf(bf,"%s %s",h_ref,msgid); 4014 var_set("h_references",value_encode(bf)); 4015 var_set("h_message-id",msgid); 4016 var_set("h_newsgroups",newsgroups); 4017 } 4018 void show_article3(void) 4019 { 4020 char *s; 4021 s = strchr(from,'\015'); 4022 if (s!=NULL) *s = 0; 4023 printf("%s wrote:",from); 4024 s = get_line(instr); 4025 for (;s!=NULL;) { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 18 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4026 printf(">%s",s); 4027 s = get_line(instr); 4028 } 4029 } 4030 void f_post(void) 4031 { 4032 f_follow(FALSE); 4033 } 4034 void f_postXX(void) 4035 { 4036 ncpy(group,query_find("group"),BFSZ-1); 4037 printf(" Post new item to group %s ",group); 4038 printf(""); 4039 printf("
\n",path_script); 4040 printf(" \n"); 4041 printf(" \n",group); 4042 printf("Newsgroup: %s
\n",group); 4043 printf("From: (Give EMail address)
\n"); 4044 printf("Subject (Required)
\n"); 4045 printf("Please enter your message text here: (press enter at the end of each line)
\n"); 4046 printf("
\n"); 4047 printf("\n"); 4048 printf("
\n"); 4049 netwin_advert(); 4050 printf(""); 4051 printf(""); 4052 } 4053 void f_search(void) 4054 { 4055 tpl_init(); 4056 tpl_show("search.tpl"); 4057 /* 4058 if (!show_top("fsearch","Search Entire News Database Using: DNEWS Full Text Search Engine")) 4059 printf("

Search All News Items

"); 4060 printf("
\n",path_script); 4061 printf(" \n"); 4062 printf(" \n"); 4063 printf(" \n"); 4064 printf("Key Words:
\n"); 4065 printf("\n"); 4066 printf("
\n"); 4067 printf("

\n"); 4068 printf("A higher weighting\n"); 4069 printf("is given to words early in your list of key words. \n"); 4070 printf("Some common words like 'and' may return '0' matches, this\n"); 4071 printf("is normal, these are not kept in the index as they have\n"); 4072 printf("no search value.
\n"); 4073 show_end("fsearch"); 4074 */ 4075 } 4076 void f_find(void) 4077 { 4078 tpl_init() ; 4079 tpl_show("xsearch.tpl"); 4080 } 4081 void f_find_xold(void) 4082 { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 19 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4083 if (!show_top("ffind","Search News Group Headers")) 4084 printf("

Search headers in %s

",query_find("group")); 4085 printf("
\n",path_script); 4086 printf(" \n"); 4087 printf(" \n",query_find("group")); 4088 printf("Search String:
\n"); 4089 printf("\n"); 4090 printf("
\n"); 4091 printf("

\n"); 4092 printf("The search is performed on the headers in the news group.\n"); 4093 printf("It is not case sensitive. If you give several words they\n"); 4094 printf("will only match if the same 'phrase' appears in the news headers
\n"); 4095 show_end("ffind"); 4096 } 4097 void r_search(void) /* from=nnn max=nnn*/ 4098 { 4099 char bf[BFSZ]; 4100 int from = atoi(query_find("from")); 4101 int to = atoi(query_find("to")); 4102 char key[BFSZ],xkey[BFSZ],zkey[BFSZ]; 4103 char *s; 4104 int total; 4105 int i; 4106 char *kw[100]; 4107 int nkw; 4108 int matches[100]; 4109 4110 strcpy(key,query_find("key")); 4111 strcpy(zkey,key); 4112 s = strtok(key,",+ \t\n"); 4113 strcpy(xkey,""); 4114 for (nkw=0;s!=NULL;) { 4115 strcat(xkey,s); 4116 kw[nkw++] = strdup(s); 4117 s = strtok(NULL,",+ \t\n"); 4118 if (s!=NULL) strcat(xkey,","); 4119 } 4120 4121 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4122 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4123 sprintf(bf,"xdsearch %d-%d %s\015\012",from,to,xkey); nntp_write_s(chan,bf,strlen(bf)); 4124 dmsg("Wait for dindex status\n"); 4125 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4126 4127 s = strchr(nntp_status,':'); 4128 if (s!=NULL) total = atoi(s+1); 4129 s = strchr(s+1,':'); 4130 if (s!=NULL) s = strtok(s,": \015\012"); 4131 for (i=0;(s!=NULL) && (i1800) return; 4305 x_item[nitem] = atoi(item); 4306 x_subject[nitem] = strdup(head_decode(subject)); 4307 x_subjectsrt[nitem] = strdup(lib_nore(subject)); 4308 x_from[nitem] = strdup(head_decode(from)); 4309 x_date[nitem] = strdup(date); 4310 x_lines[nitem] = strdup(lines); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 23 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4311 x_ref[nitem] = strdup(ref); 4312 x_mid[nitem] = strdup(mid); 4313 nitem++; 4314 } 4315 int xover_cmp(const void *a,const void *b) 4316 { 4317 int *aa = (int *) a; 4318 int *bb = (int *) b; 4319 if (x_f[*aa] < x_f[*bb]) return -1; 4320 if (x_f[*aa] > x_f[*bb]) return 1; 4321 return 0; 4322 } 4323 int xover_cmp_old(const void *a,const void *b) 4324 { 4325 int *aa = (int *) a; 4326 int *bb = (int *) b; 4327 return strcmp(x_subjectsrt[*aa],x_subjectsrt[*bb]); 4328 } 4329 void xover_showord(void) 4330 { 4331 int p[MAX_ITEMS]; 4332 int i,ii; 4333 for (i=0; i\n"); 4337 for (i=0; i",path_script,towww(group),x_item[ii]); 4340 printf("%s - %s (%s)
\n",value_encode(x_subject[ii]), email_name(x_from[ii]),x_lines[ii]); 4341 } 4342 printf("\n"); 4343 4344 } 4345 void r_find(void) /* from=nnn max=nnn*/ 4346 { 4347 char bf[BFSZ]; 4348 char find[BFSZ]; 4349 4350 ncpy(find,query_find("key"),BFSZ-1); 4351 ncpy(group,query_find("group"),BFSZ-1); 4352 if (!group_allow(group)) return; 4353 4354 if (!read_status()) {zmsg("News host not responding1: %s",nntp_status); return;} 4355 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4356 sprintf(bf,"group %s\015\012",group); nntp_write_s(chan,bf,strlen(bf)); 4357 if (!read_status()) {zmsg("News host not responding2: %s",nntp_status); return;} 4358 sprintf(bf,"xdfind 1- %s\015\012",lib_encode(find)); nntp_write_s(chan,bf,strlen(bf)); 4359 if (!read_status()) {zmsg("News host not responding3: %s",nntp_status); return;} 4360 read_xover(); 4361 show_xover(); 4362 4363 tpl_init(); 4364 tpl_set_buttons(); 4365 4366 var_set("keywords",find); 4367 tpl_show("xresults.tpl"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 24 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4368 /* 4369 if (!show_top("find"," Search results %s ",group)) 4370 printf("

Search Results: %s

",group); 4371 show_xbar(); 4372 4373 xover_showord(); 4374 show_xbar(); 4375 4376 show_end("find"); 4377 4378 */ 4379 sprintf(bf,"quit\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4380 read_status(); /* Wait for the channel to close */ 4381 } 4382 void r_xover(void) /* from=nnn max=nnn*/ 4383 { 4384 char bf[BFSZ]; 4385 char rsubject[BFSZ]; 4386 char rmsgid[BFSZ]; 4387 int from = atoi(query_find("from")); 4388 int max = atoi(query_find("max")); 4389 int to,xfrom,xto,lastfrom; 4390 char *s; 4391 int nloop = 0; 4392 int fwd = FALSE; 4393 int related; 4394 dmsg("called r_xover"); 4395 related = atoi(query_find("related")); 4396 if (strcmp(query_find("forward"),"TRUE")==0) fwd = TRUE; 4397 4398 ncpy(group,query_find("group"),BFSZ-1); 4399 if (!group_allow(group)) return; 4400 4401 if (max==0) max = PAGESIZE; 4402 if (max>1000) max = 1000; 4403 gmax = max; 4404 4405 dmsg("Wait for hello\n"); 4406 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4407 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4408 sprintf(bf,"group %s\015\012",group); nntp_write_s(chan,bf,strlen(bf)); 4409 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4410 if (related>0) { 4411 sprintf(bf,"xover %d\015\012",related); nntp_write_s(chan,bf,strlen(bf)); 4412 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4413 read_xover(); 4414 4415 s = get_line(instr); 4416 s = xstrtok(s,"\t"); 4417 if (s!=NULL) s = xstrtok(NULL,"\t"); 4418 if (s!=NULL) { 4419 strlwr(s); 4420 if (strncmp(s,"re:",3)==0) s += 3; 4421 if (*s == ' ') s++; 4422 ncpy(rsubject,s,BFSZ-1); 4423 } 4424 if (s!=NULL) s = xstrtok(NULL,"\t"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 25 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4425 if (s!=NULL) s = xstrtok(NULL,"\t"); 4426 if (s!=NULL) s = xstrtok(NULL,"\t"); 4427 if (s!=NULL) ncpy(rmsgid,s,BFSZ-1); 4428 4429 str_clear(instr); 4430 sprintf(bf,"xdfind 1- %s %s\015\012",lib_encode(rsubject),lib_encode(rmsgid)); nntp_write_s(chan,bf, 4430 strlen(bf)); 4431 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4432 } else { 4433 group_from = xfrom = atoi(get_word(nntp_status,2)); 4434 group_to = xto = atoi(get_word(nntp_status,3)); 4435 if (strlen(query_find("from"))==0) if (from==0) from = xto-max; 4436 if (fromgroup_from) gfrom -=max; 4454 if (gfrom0) sprintf(bf,"Related items in %s",group); 4461 else sprintf(bf,"Items in %s",group); 4462 4463 tpl_set_buttons(); 4464 tpl_show("items.tpl"); 4465 sprintf(bf,"quit\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4466 read_status(); /* Wait for the channel to close */ 4467 } 4468 void r_listall(void) /* from=nnn max=nnn*/ 4469 { 4470 char bf[BFSZ]; 4471 ncpy(group,query_find("group"),BFSZ-1); 4472 4473 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4474 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4475 sprintf(bf,"xdlist %s\015\012",group); nntp_write_s(chan,bf,strlen(bf)); 4476 if (!read_status()) { 4477 printf("Sorry, this server does not support the nntp DLIST command
"); 4478 printf("Try DNEWS 2.5 or later or possibly you need to give your web server access to dnews with no 4478 password restrictions
%s
",nntp_status); 4479 return; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 26 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4480 } 4481 read_xover(); 4482 tpl_init(); 4483 tpl_show("list.tpl"); 4484 sprintf(bf,"quit\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4485 read_status(); /* Wait for the channel to close */ 4486 } 4487 void r_article(void) /* from=nnn max=nnn*/ 4488 { 4489 char bf[BFSZ]; 4490 int item = atoi(query_find("item")); 4491 4492 4493 ncpy(group,query_find("group"),BFSZ-1); 4494 imsg("r_article() group=%s item=%d \n",group,item); 4495 if (!group_allow(group)) return; 4496 4497 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4498 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4499 sprintf(bf,"group %s\015\012",group); nntp_write_s(chan,bf,strlen(bf)); 4500 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4501 sprintf(bf,"article %d\015\012",item); nntp_write_s(chan,bf,strlen(bf)); 4502 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4503 read_xover(); 4504 show_article(); 4505 sprintf(bf,"quit\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4506 read_status(); /* Wait for the channel to close */ 4507 } 4508 char *post_template(char *xfname); 4509 #define xisspace(x) ((x==' ') || (x=='\t')) 4510 4511 void do_wrap(char *msg); 4512 void do_wrap(char *msg) 4513 { 4514 int len; 4515 int wrap; 4516 char *s; 4517 4518 wrap = atoi(ini_get(I_WRAP_POST)); 4519 dmsg("wrap at %d\n",wrap); 4520 if (wrap==0) return; 4521 wrap += 2; 4522 for (len=0,s=msg; (*s!=0); len++,s++) { 4523 if (len>wrap) if (xisspace(*s)) { 4524 *s = '\n'; 4525 len = 0; 4526 } 4527 if ((*s=='\r') || (*s=='\n')) len = 0; 4528 } 4529 } 4530 char *fix_email(char *s) 4531 { 4532 static char bf[BFSZ]; 4533 static char bf2[BFSZ]; 4534 char *orig=s; 4535 ncpy(bf,s,200); 4536 s = strtok(s,"<> \t\n"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 27 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4537 for (;s!=NULL;) { 4538 if (strchr(s,'@')!=NULL) { 4539 sprintf(bf2,"<%s>",s); 4540 return bf2; 4541 } 4542 s = strtok(NULL,"<> \t\n"); 4543 } 4544 return orig; 4545 } 4546 char *stripeol(char *s) 4547 { 4548 char *orig=s; 4549 4550 for (;*s!=0;s++) { 4551 if (*s=='\r') *s = 0; 4552 if (*s=='\n') *s = 0; 4553 } 4554 return orig; 4555 } 4556 void r_post(void) /* from=nnn max=nnn*/ 4557 { 4558 char uinfo[BFSZ]; 4559 char ruser[BFSZ]; 4560 char bf[BFSZ]; 4561 char *s; 4562 char xsubj[BFSZ]; 4563 char xfile[BFSZ]; 4564 char newsgroups[BFSZ]; 4565 char xfrom[BFSZ],xname[BFSZ]; 4566 int lp; 4567 int addmid = FALSE; 4568 4569 if (strcmp("true",ini_get(I_ADD_MID))==0) addmid=TRUE; 4570 imsg("mid %d, (%s) \n",addmid,ini_get(I_ADD_MID)); 4571 4572 strcpy(ruser,mygetenv("REMOTE_ADDR")); 4573 4574 if (strlen(ini_get(I_POST_USERS))>0) if (!group_match(ini_get(I_POST_USERS),ruser)) { 4575 printf("Sorry, you (%s) have no permission to post.\n
",ruser); 4576 return; 4577 } 4578 4579 tpl_init(); 4580 imsg("mid2 \n"); 4581 if (strlen(form_find("from"))==0) { 4582 var_set("missing","from"); 4583 tpl_show("required.tpl"); 4584 return; 4585 } 4586 if (strlen(form_find("subject"))==0) { 4587 var_set("missing","subject"); 4588 tpl_show("required.tpl"); 4589 return; 4590 } 4591 4592 imsg("mid3 \n"); 4593 strcpy(bf,form_find("required")); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 28 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4594 s = strtok(bf,","); 4595 for (;s!=NULL;) { 4596 if (strlen(form_find(s))==0) { 4597 var_set("missing",s); 4598 tpl_show("required.tpl"); 4599 return; 4600 } 4601 var_set(s,form_find(s)); 4602 s = strtok(NULL,","); 4603 } 4604 strcpy(bf,form_find("optional")); 4605 s = strtok(bf,","); 4606 for (;s!=NULL;) { 4607 if (strlen(form_find(s))!=0) { 4608 var_set(s,form_find(s)); 4609 } 4610 s = strtok(NULL,","); 4611 } 4612 4613 imsg("mid5 \n"); 4614 4615 ncpy(group,form_find("group"),BFSZ-1); 4616 stripeol(group); 4617 if (strlen(ini_get(I_POST_GROUPS))>0) if (!group_match(ini_get(I_POST_GROUPS),group)) { 4618 printf("Sorry, posting is not permitted to (%s) \n
",group); 4619 return; 4620 } 4621 4622 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4623 if (!do_authent()) {zmsg("News host authentication failed: %s",nntp_status); return;} 4624 sprintf(bf,"group %s\015\012",group); nntp_write_s(chan,bf,strlen(bf)); 4625 if (!read_status()) {zmsg("News host not responding: %s",nntp_status); return;} 4626 sprintf(bf,"post\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4627 if (!read_status()) {zmsg("Post status bad %s\n",nntp_status); return;} 4628 4629 imsg("From %s\n",form_find("from")); 4630 ncpy(xfrom,form_find("from"),200); 4631 ncpy(xname,form_find("from_name"),200); 4632 4633 stripeol(xfrom); 4634 stripeol(xname); 4635 4636 if (strlen(xname)>0) { 4637 sprintf(xfrom,"\"%s\" %s",xname,fix_email(xfrom)); 4638 } 4639 sprintf(bf,"From: %s\015\012",xfrom); nntp_write_s(chan,bf,strlen(bf)); 4640 4641 ncpy(xsubj,stripeol(form_find("subject")),BFSZ-1); 4642 strcpy(bf,xsubj); 4643 strlwr(bf); 4644 s = strtok(bf," \t"); 4645 if (strncmp(s,"cmsg",3)==0) { 4646 ncpy(bf,stripeol(form_find("subject")),BFSZ-10); 4647 strcpy(xsubj,"x-"); 4648 strcat(xsubj,bf); 4649 } 4650 sprintf(bf,"Subject: %s\015\012",xsubj); nntp_write_s(chan,bf,strlen(bf)); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 29 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4651 strcpy(newsgroups,form_find("newsgroups")); 4652 stripeol(newsgroups); 4653 if (strlen(newsgroups)>0) { 4654 sprintf(bf,"Newsgroups: %s\015\012",newsgroups); nntp_write_s(chan,bf,strlen(bf)); 4655 } else { 4656 sprintf(bf,"Newsgroups: %s\015\012",stripeol(form_find("group"))); nntp_write_s(chan,bf,strlen(b 4656 f)); 4657 } 4658 if (addmid) { 4659 sprintf(bf,"Message-ID: <%d@%s>\015\012",time(NULL),ini_get(I_NEWSHOST)); nntp_write_s(chan,bf,s 4659 trlen(bf)); 4660 } 4661 4662 strcpy(uinfo,mygetenv("REMOTE_ADDR")); strcat(uinfo," "); 4663 strcat(uinfo,mygetenv("REMOTE_HOST")); strcat(uinfo," "); 4664 strcat(uinfo,mygetenv("REMOTE_IDENT")); strcat(uinfo," "); 4665 strcat(uinfo,mygetenv("REMOTE_USER")); strcat(uinfo," "); 4666 sprintf(bf,"X-User-Info: %s\015\012",uinfo); nntp_write_s(chan,bf,strlen(bf)); 4667 if (strlen(form_find("ref"))>0) { 4668 sprintf(bf,"References: %s\015\012",stripeol(form_find("ref"))); nntp_write_s(chan,bf,strlen(bf) 4668 ); 4669 } 4670 sprintf(bf,"\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4671 4672 imsg("Message \n"); 4673 s = form_find("message"); 4674 imsg("message length %d\n",strlen(s)); 4675 do_wrap(s); 4676 imsg("message warpeed (%d)\n",strlen(s)); 4677 strcpy(xfile,form_find("template")); 4678 if (strlen(xfile)>0) { 4679 var_set("message",s); 4680 s = post_template(xfile); 4681 } 4682 4683 imsg("message send (%d)\n",strlen(s)); 4684 if (s!=NULL) nntp_write_s(chan,s,strlen(s)); 4685 sprintf(bf,"\015\012.\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4686 for (lp=0;nntp_isbusy(chan) && lp<10000;lp++) { 4687 nntp_write_now(chan); 4688 } 4689 4690 imsg("readstatus (%d)\n",strlen(s)); 4691 read_status(); /* Wait for the channel to close */ 4692 imsg("readstatxxxus (%d)\n",strlen(s)); 4693 4694 4695 var_set("post_status",nntp_status); 4696 if (atoi(nntp_status)==240) { 4697 var_set("ok","TRUE"); 4698 } 4699 tpl_show("posted.tpl"); 4700 sprintf(bf,"quit\015\012"); nntp_write_s(chan,bf,strlen(bf)); 4701 read_status(); /* Wait for the channel to close */ 4702 } 4703 void show_dline(char *s) 4704 { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 30 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4705 char bf[BFSZ]; 4706 char gname[BFSZ]; 4707 char mod[BFSZ]; 4708 char from[BFSZ]; 4709 char to[BFSZ]; 4710 char items[BFSZ]; 4711 4712 ncpy(bf,s,BFSZ-1); 4713 s = strtok(bf," "); if (s==NULL) return; 4714 ncpy(gname,s,BFSZ-1); 4715 s = strtok(NULL," "); if (s==NULL) return; 4716 ncpy(to,s,BFSZ-1); 4717 s = strtok(NULL," "); if (s==NULL) goto doit; 4718 ncpy(from,s,BFSZ-1); 4719 s = strtok(NULL," "); if (s==NULL) goto doit; 4720 strcpy(mod,""); 4721 if (*s=='m') strcpy(mod,"(Moderated)"); 4722 s = strtok(NULL," "); if (s==NULL) goto doit; 4723 ncpy(items,s,BFSZ-1); 4724 doit:; 4725 if (gname[0]=='+') { 4726 strcat(to,"."); 4727 if (group_match(ini_get(I_ALLOW),to)) { 4728 printf("
  • %s.. %s groups
    ",path_script,towww(t 4728 o),to,from); 4729 } 4730 } else { 4731 if (group_match(ini_get(I_ALLOW),gname)) { 4732 printf("
  • %s, %s items %s
    ",path_script,towww(gn 4732 ame),gname,items,mod); 4733 } 4734 } 4735 } 4736 4737 static char topname[BFSZ]; 4738 void r_list(void) 4739 { 4740 tpl_init(); 4741 4742 4743 4744 4745 tpl_show(topname); 4746 dmsg("top done\n"); 4747 } 4748 /* ---------------------------------------- xxx.ini file processing -- */ 4749 void db_setscript(char *script) 4750 { 4751 char *last; 4752 char *s; 4753 char bf[BFSZ]; 4754 strcpy(path_script,script); 4755 ncpy(bf,script,BFSZ-1); 4756 last = bf-1; 4757 for (s=bf;*s!=0;s++) { 4758 if (*s=='/') last = s; 4759 if (*s=='\\') last = s; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 31 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4760 } 4761 ncpy(rootname,last+1,BFSZ-1); 4762 s = strchr(rootname,'.'); 4763 if (s!=NULL) *s = 0; 4764 if (strlen(rootname)==0) strcpy(rootname,"dnewsweb"); 4765 } 4766 4767 4768 char *ini_values[200]; 4769 int ini_find(char *s) 4770 { 4771 int i; 4772 for (i=0; ini_names[i]!=NULL; i++) { 4773 if (strcmp(ini_names[i],s)==0) return i; 4774 } 4775 return -1; 4776 } 4777 char *ini_get(int x) 4778 { 4779 if (ini_values[x]!=NULL) return ini_values[x]; 4780 return ""; 4781 } 4782 int ini_read(char *epath) 4783 { 4784 char bf[BFSZ]; 4785 char bf2[BFSZ]; 4786 char bf3[BFSZ]; 4787 char xroot[BFSZ]; 4788 char xin[5000]; 4789 char *last; 4790 FILE *f; 4791 int i; 4792 char *s; 4793 4794 db_setscript(mygetenv("SCRIPT_NAME")); 4795 sprintf(bf,"%s.ini",rootname); 4796 f = fopen(bf,"r"); 4797 strcpy(bf3,bf); 4798 if (f==NULL) { 4799 imsg("ini file not in working dir, searching in path {%s} \n",epath); 4800 strcpy(xroot,epath); 4801 last = xroot; 4802 for (s=xroot; *s!=0; s++) { 4803 if (*s=='/') last = s; 4804 if (*s=='\\') last = s; 4805 } 4806 *last = 0; 4807 sprintf(bf,"%s/%s.ini",xroot,rootname); 4808 imsg("Looking in (%s) for ini file\n",bf); 4809 f = fopen(bf,"r"); 4810 strcpy(bf2,bf); 4811 } 4812 if (f==NULL) { 4813 sprintf(bf,"/etc/%s.ini",rootname); 4814 imsg("Last resort, looking in (%s) for ini file\n",bf); 4815 f = fopen(bf,"r"); 4816 } Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 32 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4817 if (f==NULL) { 4818 done_content = TRUE; 4819 if (docache) printf("Pragma: cache\n"); 4820 printf("Content-type: %s\n\n",content_type()); 4821 emsg("Unable to find ini file in
    {%s} \n",bf3); 4822 emsg("Also looked in {%s}
    and {%s}
    \n",bf2,bf); 4823 #ifdef WIN32 X 4824 GetCurrentDirectory(200,bf); X 4825 emsg("Place dnewsweb.ini file in this directory {%s} \n",bf); X 4826 #endif 4827 return FALSE; 4828 } 4829 for (;!feof(f);) { 4830 if (fgets(xin,4000,f)!=NULL) { 4831 ncpy(bf,xin,BFSZ-20); 4832 s = strtok(bf," \t\n"); if (s==NULL) continue; 4833 if (*s==0 || *s=='#') continue; 4834 i = ini_find(s); 4835 if (i<0) { emsg("Unknown ini file setting {%s} \n",s); continue; } 4836 s = strtok(NULL,"\n"); if (s==NULL) continue; 4837 ini_values[i] = strdup(s); 4838 } 4839 } 4840 fclose(f); 4841 return TRUE; 4842 } 4843 4844 /* ---------------------- Missing bits that are needed ---------------------- */ 4845 #define OUTSIZE 5000 4846 static char output[OUTSIZE]; 4847 void emsg_do(int x, char *s); 4848 void emsg(char * arg_list, ...) 4849 { 4850 va_list arg_ptr; 4851 char *format; 4852 int len; 4853 va_start(arg_ptr, arg_list); 4854 format = arg_list; 4855 len = vsprintf(output, format, arg_ptr); 4856 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4857 emsg_do(D_ERROR,output); 4858 } 4859 void filemsg(char * arg_list, ...) 4860 { 4861 va_list arg_ptr; 4862 char *format; 4863 int len; 4864 va_start(arg_ptr, arg_list); 4865 format = arg_list; 4866 len = vsprintf(output, format, arg_ptr); 4867 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4868 emsg_do(D_ERROR,output); 4869 } 4870 void imsg(char * arg_list, ...) 4871 { 4872 va_list arg_ptr; 4873 char *format; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 33 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4874 int len; 4875 va_start(arg_ptr, arg_list); 4876 format = arg_list; 4877 len = vsprintf(output, format, arg_ptr); 4878 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4879 emsg_do(D_INFO,output); 4880 } 4881 void h_printf(char * arg_list, ...) 4882 { 4883 va_list arg_ptr; 4884 char *format; 4885 int len; 4886 va_start(arg_ptr, arg_list); 4887 format = arg_list; 4888 len = vsprintf(output, format, arg_ptr); 4889 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4890 printf("%s",output); 4891 emsg_do(D_DEBUG,output); 4892 } 4893 void zmsg(char * arg_list, ...) 4894 { 4895 va_list arg_ptr; 4896 char *format; 4897 int len; 4898 va_start(arg_ptr, arg_list); 4899 format = arg_list; 4900 len = vsprintf(output, format, arg_ptr); 4901 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4902 if (!done_content) { 4903 if (docache) printf("Pragma: cache\n"); 4904 printf("Content-type: %s\n\n",content_type()); 4905 } 4906 printf("%s",output); 4907 emsg_do(D_INFO,output); 4908 } 4909 void wmsg(char * arg_list, ...) 4910 { 4911 va_list arg_ptr; 4912 char *format; 4913 int len; 4914 va_start(arg_ptr, arg_list); 4915 format = arg_list; 4916 len = vsprintf(output, format, arg_ptr); 4917 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4918 emsg_do(D_INFO,output); 4919 } 4920 void dmsg(char * arg_list, ...) 4921 { 4922 va_list arg_ptr; 4923 char *format; 4924 int len; 4925 if (!dodebug) return; 4926 va_start(arg_ptr, arg_list); 4927 format = arg_list; 4928 len = vsprintf(output, format, arg_ptr); 4929 if (len>=OUTSIZE) emsg_do(D_ERROR,"FATAL, EMSG ERROR TOO LONG\n"); 4930 emsg_do(D_DEBUG,output); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 34 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4931 } 4932 void emsg_reset(void) 4933 { 4934 remove(log_file); 4935 } 4936 void emsg_do(int x, char *s) 4937 { 4938 time_t ltime; 4939 char bf[BFSZ]; 4940 FILE *f; 4941 time( <ime ); 4942 strcpy(bf,ctime(<ime)); 4943 bf[19] = 0; 4944 4945 if (x==D_ERROR) printf("
    Error: %s
    ",s); 4946 f = fopen(log_file,"a"); 4947 if (f==NULL) {perror(log_file); return; } 4948 fprintf(f,"%s, %s",bf+4,s); 4949 fclose(f); 4950 } 4951 /* ---------------------- Missing bits that are needed ---------------------- */ 4952 char *group_name(int i) 4953 { 4954 return "(none)"; 4955 } 4956 #ifndef unix 4957 int lib_mail_file(char *to, char *subj, char *fname) 4958 { 4959 return TRUE; 4960 } 4961 int lib_freespace(char *s) 4962 { 4963 return 100000; 4964 } 4965 #endif 4966 int diskuse_get(void) 4967 { 4968 return 0; 4969 } 4970 char *nt_pcname(void); 4971 4972 char *lib_findfile(char *x) 4973 { 4974 return NULL; 4975 } 4976 void dnews_manager_report(char *s) 4977 { 4978 4979 } 4980 int post_local(String *xitem, char *addr, int ismod) 4981 { 4982 return TRUE; 4983 } 4984 void dnews_exit(char *reason, char *file, int line) 4985 { 4986 printf("Crashing\n"); 4987 exit(1); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 35 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 4988 } 4989 4990 4991 4992 #ifdef WIN32 X 4993 char *nt_pcname(void) X 4994 { X 4995 return "pcname"; X 4996 } X 4997 #endif 4998 /* ------------------ library of stuff for web --------------------*/ 4999 5000 static char *query_name[1000]; 5001 static char *query_val[1000]; 5002 static int nquery; 5003 /* Query string */ 5004 char *lib_encode(char *s) 5005 { 5006 char *ss=s; 5007 for (;*s!=0;s++) { 5008 if (isspace(*s)) *s = '+'; 5009 } 5010 return ss; 5011 } 5012 char *value_encode(char *s) 5013 { 5014 static char bf[2010]; 5015 int noencode=FALSE; 5016 int i; 5017 int iniso; 5018 int addend=FALSE; 5019 char *out=bf; 5020 for (i=0; i<2000 && *s!=0;i++,s++) { 5021 if (noencode) { 5022 if (*s==27) { 5023 if (strncmp(s+1,"(B",2)==0) noencode = FALSE; 5024 } 5025 *out++ = *s; 5026 continue; 5027 } 5028 if (*s=='<') { strcpy(out,"<"); out += strlen(out); } 5029 else if (*s=='>') { strcpy(out,">"); out += strlen(out); } 5030 else if (*s=='&') { strcpy(out,"&"); out += strlen(out); } 5031 else if (*s=='"') { strcpy(out,"""); out += strlen(out); } 5032 else if (*s==27) { 5033 if (strncmp(s+1,"$B",2)==0) noencode = TRUE; 5034 *out++ = *s; 5035 } 5036 else *out++ = *s; 5037 } 5038 *out++ = 0; 5039 return bf; 5040 } 5041 char *head_decode(char *s) 5042 { 5043 return s; 5044 Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 36 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5045 /* 5046 static char bf[10000]; 5047 char *out,*s2; 5048 int iniso=FALSE; 5049 5050 for (out=bf;*s!=0;s++) { 5051 if ((strncmp(s,"=?iso",5)==0) || (strncmpnc(s,"=?ISO",5)==0)) { 5052 s2 = strchr(s+3,'?'); 5053 if (s2!=NULL) s = s2; 5054 iniso = TRUE; 5055 strcpy(out,"\033$B"); out+= strlen(out); 5056 continue; 5057 } 5058 if (iniso) if ((strncmp(s,"?=",2)==0)) { 5059 s = s+1; 5060 iniso = FALSE; 5061 strcpy(out,"\033(B"); out+= strlen(out); 5062 continue; 5063 } 5064 *out++ = *s; 5065 } 5066 *out++ = 0; 5067 return bf; 5068 */ 5069 } 5070 /* 5071 Same as value encode except. 5072 user@a.b.c --> user@a.b.c 5073 http://netwin.co.nz --> htp://netwin.co.nz 5074 5075 5076 */ 5077 char *ref_encode_http(char *instr); 5078 char *ref_encode_mail(char *instr); 5079 char *ref_encode(char *s); 5080 char *ref_encode(char *s) 5081 { 5082 static char bf[5000]; 5083 strcpy(bf,s); 5084 if (strchr(s,27)!=NULL) return bf; 5085 s = ref_encode_mail(bf); 5086 s = ref_encode_http(s); 5087 return s; 5088 } 5089 char *ref_encode_mail(char *instr) 5090 { 5091 char bf[BFSZ]; 5092 char bf2[BFSZ]; 5093 char *s,*s1,*s2; 5094 s = instr; 5095 again: 5096 s = strchr(s,'@'); 5097 if (s==NULL) return instr; 5098 if (s>instr) if (s[-1]<0) { 5099 s++; 5100 goto again; 5101 } Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 37 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5102 for (s1=s;s1>instr;s1--) { 5103 if (isspace(*s1)) { 5104 s1++; 5105 break; 5106 } 5107 } 5108 for (s2=s;*s2!=0;s2++) { 5109 if (isspace(*s2)) break; 5110 } 5111 s2--; 5112 ncpy(bf,s1,s2-s1+1); 5113 sprintf(bf2,"%s",bf,bf); 5114 memmove(s1+strlen(bf2),s2+1,strlen(s2+1)+1); 5115 strncpy(s1,bf2,strlen(bf2)); 5116 s = s1 + strlen(bf2); 5117 goto again; 5118 } 5119 char *ref_encode_http(char *instr) 5120 { 5121 char *s,*s1,*s2; 5122 char bf[BFSZ]; 5123 char bf2[BFSZ]; 5124 s = instr; 5125 again: 5126 s = strstr(s,"http:"); 5127 if (s==NULL) return instr; 5128 if (s>instr) if (s[-1]<0) { 5129 s++; 5130 goto again; 5131 } 5132 s1 = s; 5133 for (s2=s;*s2!=0;s2++) { 5134 if (isspace(*s2)) break; 5135 } 5136 s2--; 5137 ncpy(bf,s1,s2-s1+1); 5138 sprintf(bf2,"%s",bf,bf); 5139 memmove(s1+strlen(bf2),s2+1,strlen(s2+1)+1); 5140 strncpy(s1,bf2,strlen(bf2)); 5141 s = s1 + strlen(bf2); 5142 goto again; 5143 } 5144 char *decode_base64s(char *s); 5145 char *decode_base64s(char *s) 5146 { 5147 static char bf[2000]; 5148 int n = decode_base64(s,bf); 5149 bf[n] = 0; 5150 return bf; 5151 } 5152 char *decode_quote(char *s) 5153 { 5154 static char bf[2000]; 5155 int i; 5156 char *out=bf; 5157 for (i=0; i<2000 && *s!=0;i++,s++) { 5158 if (*s<0) { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 38 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5159 *out++ = *s++; 5160 *out++ = *s; 5161 } else if (strncmp(s,"=3D",3)==0) *out++ = '='; 5162 else if (*s=='=') *out++ = '\n'; 5163 else *out++ = *s; 5164 } 5165 *out++ = 0; 5166 return bf; 5167 } 5168 char *wrap_encode(char *s); 5169 char *text_encode(char *s) 5170 { 5171 int noencode=FALSE; 5172 static char bf[2010]; 5173 int i; 5174 char *out=bf; 5175 for (i=0; i<2000 && *s!=0;i++,s++) { 5176 if (noencode) { 5177 if (*s==27) { 5178 if (strncmp(s+1,"(B",2)==0) noencode = FALSE; 5179 } 5180 *out++ = *s; 5181 continue; 5182 } 5183 if (*s<0) { 5184 *out++ = *s++; 5185 *out++ = *s; 5186 } else if (*s=='<') { strcpy(out,"<"); out += strlen(out); } 5187 else if (*s=='>') { strcpy(out,">"); out += strlen(out); } 5188 else if (*s=='&') { strcpy(out,"&"); out += strlen(out); } 5189 else if (*s==27) { 5190 if (strncmp(s+1,"$B",2)==0) noencode = TRUE; 5191 *out++ = *s; 5192 } 5193 else *out++ = *s; 5194 } 5195 *out++ = 0; 5196 return ref_encode(wrap_encode(bf)); 5197 } 5198 char *wrap_encode(char *s) 5199 { 5200 static char bf[4000]; 5201 int i; 5202 char *out=bf; 5203 int len; 5204 int w = atoi(ini_get(I_WRAP_TEXT)); 5205 if (w==0) return s; 5206 dmsg("Wrap text at %d\n",w); 5207 len = 0; 5208 for (i=0; (i<2000) && (*s!=0);i++,s++,len++) { 5209 if (*s=='\n') len = 0; 5210 if (*s=='\r') len = 0; 5211 if (len>w) { 5212 if (isspace(*s)) { 5213 *out++ = '\n'; 5214 len = 0; 5215 continue; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 39 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5216 } 5217 } 5218 *out++ = *s; 5219 } 5220 *out++ = 0; 5221 return bf; 5222 } 5223 char *mygetenv(char *v) 5224 { 5225 char *s = getenv(v); 5226 if (s==NULL) return ""; 5227 return s; 5228 } 5229 char *query_find(char *s) 5230 { 5231 int i; 5232 for (i=0; i= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0')); 5275 digit *= 16; 5276 digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0')); 5277 return(digit); 5278 } 5279 5280 void unescape_url(char *url) 5281 { 5282 register int x,y; 5283 5284 for(x=0,y=0;url[y];++x,++y) { 5285 if((url[x] = url[y]) == '%') { 5286 url[x] = x2c(&url[y+1]); 5287 y+=2; 5288 } 5289 } 5290 url[x] = '\0'; 5291 } 5292 5293 void plustospace(char *str) 5294 { 5295 register int x; 5296 5297 for(x=0;str[x];x++) if(str[x] == '+') str[x] = ' '; 5298 } 5299 5300 5301 static char *form_name[1000]; 5302 static char *form_val[1000]; 5303 static int nform; 5304 char *makeword(char *line, char stop) ; 5305 char *fmakeword(FILE *f, char stop, int *cl); 5306 void convert_crlf(char *s); /* turn crlf into lf's */ 5307 void form_get(void) 5308 { 5309 int x,cl; 5310 char *s = mygetenv("CONTENT_LENGTH"); 5311 if (s==NULL) return; 5312 cl = atoi(s); 5313 for(x=0;cl && (!feof(stdin));x++) { 5314 form_val[x]= fmakeword(stdin,'&',&cl); 5315 plustospace(form_val[x]); 5316 unescape_url(form_val[x]); 5317 form_name[x] = makeword(form_val[x],'='); 5318 convert_crlf(form_val[x]); 5319 } 5320 nform = x; 5321 } 5322 void convert_crlf(char *s) 5323 { 5324 char *out=s; 5325 for (;*s!=0;s++) { 5326 if (*s == '\015') s++; 5327 *out++ = *s; 5328 } 5329 *out++ = 0; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 41 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5330 } 5331 char *makeword(char *line, char stop) 5332 { 5333 int x = 0,y; 5334 char *word = (char *) malloc(sizeof(char) * (strlen(line) + 1)); 5335 5336 for(x=0;((line[x]) && (line[x] != stop));x++) 5337 word[x] = line[x]; 5338 5339 word[x] = '\0'; 5340 if(line[x]) ++x; 5341 y=0; 5342 5343 while(line[y++] = line[x++]); 5344 return word; 5345 } 5346 5347 char *fmakeword(FILE *f, char stop, int *cl) 5348 { 5349 int wsize; 5350 char *word; 5351 int ll; 5352 5353 wsize = 8024; 5354 ll=0; 5355 word = (char *) malloc(sizeof(char) * (wsize + 1)); 5356 5357 while(1) { 5358 word[ll] = (char)fgetc(f); 5359 if(ll==wsize) { 5360 word[ll+1] = '\0'; 5361 wsize+=8024; 5362 word = (char *)realloc(word,sizeof(char)*(wsize+1)); 5363 } 5364 --(*cl); 5365 if((word[ll] == stop) || (feof(f)) || (!(*cl))) { 5366 if(word[ll] != stop) ll++; 5367 word[ll] = '\0'; 5368 return word; 5369 } 5370 ++ll; 5371 } 5372 } 5373 5374 5375 char *form_find(char *s) 5376 { 5377 int i; 5378 for (i=0; i%s",output); 5445 printf(""); 5446 return FALSE; 5447 } 5448 void show_end(char *type) 5449 { 5450 show_headfile(type,NULL); 5451 if (strlen(ini_get(I_NOADVERT))==0) netwin_advert(); 5452 printf(""); 5453 printf(""); 5454 } 5455 int show_headfile(char *type, char *title) 5456 { 5457 char fname[BFSZ]; 5458 char bf[BFSZ],bf2[BFSZ]; 5459 char *s; 5460 FILE *f; 5461 char *ext = ".top"; 5462 if (title==NULL) ext = ".end"; 5463 if (strlen(ini_get(I_HEADERS))==0) return FALSE; 5464 sprintf(fname,"%s/%s%s",ini_get(I_HEADERS),type,ext); 5465 dmsg("Top file (%s)",fname); 5466 f = fopen(fname,"r"); 5467 if (f==NULL) { 5468 if (title!=NULL) printf("Top or End file missing {%s}
    \n",fname); 5469 return FALSE; 5470 } 5471 for (;!feof(f);) { 5472 if (fgets(bf,BFSZ-1,f)==NULL) break; 5473 if (title!=NULL) { 5474 s = strstr(bf,"$title$"); 5475 if (s!=NULL) { 5476 strcpy(bf2,s+7); 5477 strcpy(s,title); 5478 strcat(s,bf2); 5479 } 5480 } 5481 printf("%s",bf); 5482 } 5483 fclose(f); 5484 return TRUE; 5485 } 5486 char *file_tpl(char *fname) 5487 { 5488 char bf[BFSZ]; 5489 static char rslt[BFSZ]; 5490 strcpy(bf,tplname); 5491 if (strlen(bf)>0) strcat(bf,"/"); 5492 5493 if (strlen(ini_get(I_TEMPLATES))>0) 5494 sprintf(rslt,"%s/%s%s",ini_get(I_TEMPLATES),bf,fname); 5495 else sprintf(rslt,"%s/%s%s",ini_get(I_HEADERS),bf,fname); 5496 #ifdef VMS 5497 sprintf(rslt,"%s%s%s",ini_get(I_TEMPLATES),bf,fname); 5498 #endif 5499 return rslt; 5500 Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 44 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5501 } 5502 5503 int tpl_show_file(char *xfname) 5504 { 5505 FILE *f; 5506 char fname[BFSZ]; 5507 char bf[BFSZ]; 5508 5509 strcpy(fname,file_tpl(xfname)); 5510 5511 f = fopen(fname,"r"); 5512 if (f==NULL) { 5513 printf("Include file missing {%s}
    \n",fname); 5514 return FALSE; 5515 } 5516 5517 for (;!feof(f);) { 5518 if (fgets(bf,BFSZ-1,f)==NULL) break; 5519 printf("%s",bf); 5520 } 5521 fclose(f); 5522 return TRUE; 5523 } 5524 5525 5526 char *towww(char *s) 5527 { 5528 static char bf[BFSZ],*out; 5529 for (out=bf;*s!=0;s++) { 5530 if (isspace(*s)) *s = '+'; 5531 if (*s=='+') {sprintf(out,"%%%x",*s); out += strlen(out);} 5532 else if (*s=='&') {sprintf(out,"%%%x",*s); out += strlen(out);} 5533 else *out++ = *s; 5534 } 5535 *out++ = 0; 5536 return bf; 5537 } 5538 char *post_template(char *xfname) 5539 { 5540 FILE *f; 5541 char fname[BFSZ]; 5542 char bf[90000]; 5543 static char msg[90000]; 5544 char *s; 5545 5546 strcpy(fname,file_tpl(xfname)); 5547 5548 tpl_init(); 5549 f = fopen(fname,"r"); 5550 if (f==NULL) { 5551 printf("Cannot open template {%s}
    \n",fname); 5552 #ifndef NOSTRERROR 5553 printf("%s
    ",strerror(errno)); 5554 #endif 5555 return NULL; 5556 } 5557 Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 45 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5558 strcpy(msg,""); 5559 for (;!feof(f);) { 5560 if (fgets(bf,BFSZ-1,f)==NULL) break; 5561 s = strchr(bf,'\n'); 5562 if (s!=NULL) *s = 0; 5563 s = strchr(bf,'\r'); 5564 if (s!=NULL) *s = 0; 5565 5566 s = tpl_replace(bf); 5567 strcat(msg,s); 5568 strcat(msg,"\n"); 5569 5570 } 5571 return msg; 5572 } 5573 void tpl_show(char *xfname) 5574 { 5575 FILE *f; 5576 char fname[BFSZ]; 5577 char bf[10000]; 5578 char *s; 5579 5580 dmsg("tpl_show called (%s)\n",xfname); 5581 5582 tpl_init(); 5583 strcpy(fname,file_tpl(xfname)); 5584 5585 dmsg("tpl_show called (%s)\n",fname); 5586 5587 dmsg("tpl_show init done\n"); 5588 f = fopen(fname,"r"); 5589 if (f==NULL) { 5590 printf("Cannot open {%s} check your templates setting in dnewsweb.ini is correct and that this file 5590 is readable by the web server user code \n",fname); 5591 #ifndef NOSTRERROR 5592 printf("%s
    ",strerror(errno)); 5593 #endif 5594 return; 5595 } 5596 5597 for (;!feof(f);) { 5598 if (fgets(bf,BFSZ-1,f)==NULL) break; 5599 s = strchr(bf,'\n'); 5600 if (s!=NULL) *s = 0; 5601 s = strchr(bf,'\r'); 5602 if (s!=NULL) *s = 0; 5603 5604 s = tpl_replace(bf); 5605 if (strlen(s)>0) printf("%s\n",s); 5606 5607 } 5608 dmsg("tpl_show done\n"); 5609 } 5610 static int tpl_mode; 5611 static char tpl_item[MAX_ITEMS]; 5612 static char tpl_dir[MAX_ITEMS]; 5613 static char* tpl_indent_on[20]; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 46 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5614 static char* tpl_indent_off[20]; 5615 char *tpl_indenton(int i) 5616 { 5617 if (i<0) return ""; 5618 if (i>9) return ""; 5619 if (tpl_indent_on[i]!= NULL) return tpl_indent_on[i]; 5620 return ""; 5621 } 5622 char *tpl_indentoff(int i) 5623 { 5624 if (i<0) return ""; 5625 if (i>9) return ""; 5626 if (tpl_indent_off[i]!= NULL) return tpl_indent_off[i]; 5627 return ""; 5628 } 5629 enum {T_NORM,T_ITEM,T_DIR,T_LIST,T_IF}; 5630 void tpl_setindent(char *s) 5631 { 5632 int i; 5633 /* %%indent%%1%%on%%off%% */ 5634 int n; 5635 char *s2; 5636 char *s3,*s4; 5637 5638 s += 10; 5639 n = atoi(s); if (n<0) return; 5640 if (n>9) return; 5641 s2 = strstr(s,"%%"); if (s2==NULL) return; 5642 s2 += 2; 5643 s3 = strstr(s2,"%%"); if (s3==NULL) return; 5644 *s3 = 0; 5645 s3 += 2; 5646 s4 = strstr(s3,"%%"); if (s4==NULL) return; 5647 *s4 = 0; 5648 tpl_indent_on[n] = mystrdup(s2); 5649 tpl_indent_off[n] = mystrdup(s3); 5650 for (i=n+1; i<10; i++) { 5651 if (tpl_indent_on[i]==NULL) { 5652 tpl_indent_on[i] = ""; 5653 tpl_indent_off[i] = ""; 5654 } 5655 } 5656 return; 5657 } 5658 void tpl_set_buttons(void) 5659 { 5660 char bf[BFSZ]; 5661 if (gfrom>group_from) { 5662 sprintf(bf,"%s?cmd=xover&group=%s&from=%d",path_script,towww(group),gfrom-gmax); 5663 var_set("b_prev",bf); 5664 } 5665 if (gto \n DNEWSWEB %s Copyright © NetWin Lt 5694 d\n ",DNEWS_VERSION,path_script); 5695 var_set("copyright",bf); 5696 5697 ncpy(topname,query_find("top"),BFSZ-1); 5698 if (strlen(topname)==0) { 5699 ncpy(topname,form_find("top"),BFSZ-1); 5700 } 5701 if (strlen(topname)==0) strcpy(topname,"top.tpl"); 5702 var_set("top",topname); 5703 5704 ncpy(tplname,query_find("tpl"),BFSZ-1); 5705 if (strlen(tplname)==0) { 5706 ncpy(tplname,form_find("tpl"),BFSZ-1); 5707 } 5708 if (strlen(tplname)==0) strcpy(tplname,""); 5709 var_set("tpl",tplname); 5710 5711 ncpy(group,query_find("group"),BFSZ-1); 5712 var_set("group",group); 5713 if (strlen(group)==0) { 5714 ncpy(group,form_find("group"),BFSZ-1); 5715 var_set("group",group); 5716 } 5717 5718 sprintf(bf,"%s?cmd=f_find&group=%s",path_script,towww(group)); 5719 var_set("b_searchgrp",bf); 5720 var_set("action",path_script); 5721 if (strlen(ini_get(I_SEARCH))>0) { 5722 sprintf(bf,"%s?cmd=f_search",path_script); 5723 var_set("b_search",bf); 5724 } 5725 } 5726 /* Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 48 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5727 Add options like 5728 %%if var_name 5729 xxxx 5730 %%endif 5731 */ 5732 5733 char *tpl_replace(char *bf) 5734 { 5735 char *s,*s2; 5736 char var[BFSZ]; 5737 char head[BFSZ]; 5738 char list[BFSZ]; 5739 static int lvl; 5740 switch (tpl_mode) { 5741 case T_IF: 5742 if (strncmp(bf,"%%ifdef%%",9)==0) { 5743 lvl++; 5744 } else if (strcmp(bf,"%%endif%%")==0) { 5745 lvl--; 5746 if (lvl==0) tpl_mode = T_NORM; 5747 } 5748 if (lvl==1) if (strcmp(bf,"%%else%%")==0) tpl_mode = T_NORM; 5749 break; 5750 case T_NORM: 5751 if (strcmp(bf,"%%begin_item%%")==0) { 5752 tpl_mode = T_ITEM; 5753 strcpy(tpl_item,""); 5754 return ""; 5755 } else if (strncmp(bf,"%%else%%",9)==0) { 5756 tpl_mode = T_IF; 5757 lvl = 1; 5758 } else if (strncmp(bf,"%%ifdef%%",9)==0) { 5759 /* %%if%%var%% */ 5760 s = bf+9; 5761 s2 = strstr(s,"%%"); 5762 if (s2==NULL) return bf; 5763 ncpy(var,s,s2-s); 5764 if (strcmp(var_find(var),"")==0) { 5765 tpl_mode = T_IF; 5766 lvl = 1; 5767 dmsg("Variable undefined {%s}\n",var); 5768 } else dmsg("Variable is defined {%s}\n",var); 5769 } else if (strncmp(bf,"%%ifgroup%%",11)==0) { 5770 s = bf+11; 5771 s2 = strstr(s,"%%"); 5772 if (s2==NULL) return bf; 5773 ncpy(var,s,s2-s); 5774 if (!group_match(var,group)) { 5775 tpl_mode = T_IF; 5776 lvl = 1; 5777 dmsg("Group didn't match {%s} {%s}\n",var,group); 5778 } else dmsg("Group matched {%s} {%s}\n",var,group); 5779 } else if (strncmp(bf,"%%ifcgi%%",9)==0) { 5780 s = bf+9; 5781 s2 = strstr(s,"%%"); 5782 if (s2==NULL) return bf; 5783 ncpy(head,s,s2-s); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 49 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5784 s = s2+2; 5785 s2 = strstr(s,"%%"); 5786 if (s2==NULL) return bf; 5787 ncpy(list,s,s2-s); 5788 imsg("ifhead Test (%s) (%s) (%s)\n",list,head,mygetenv(head)); 5789 if (!group_match(list,mygetenv(head))) { 5790 tpl_mode = T_IF; 5791 lvl = 1; 5792 imsg("ENV didn't match {%s} {%s}\n",list,mygetenv(head)); 5793 } else imsg("ENV matched {%s} {%s}\n",list,mygetenv(head)); 5794 } else if (strncmp(bf,"%%include%%",11)==0) { 5795 s = bf+11; 5796 s2 = strstr(s,"%%"); 5797 if (s2==NULL) return bf; 5798 ncpy(var,s,s2-s); 5799 tpl_show_file(var); 5800 } else if (strcmp(bf,"%%quote_body%%")==0) { 5801 tpl_quote_body(); 5802 return ""; 5803 } else if (strcmp(bf,"%%show_item_image%%")==0) { 5804 tpl_show_item_image(); 5805 return ""; 5806 } else if (strcmp(bf,"%%show_item%%")==0) { 5807 tpl_show_item(); 5808 return ""; 5809 } else if (strcmp(bf,"%%begin_dir%%")==0) { 5810 tpl_mode = T_DIR; 5811 return ""; 5812 } else if (strncmp(bf,"%%indent%%",10)==0) { 5813 tpl_setindent(bf); 5814 return ""; 5815 } else return tpl_replace_vars(bf); 5816 break; 5817 case T_ITEM: 5818 if (strcmp(bf,"%%end_item%%")==0) { 5819 tpl_mode = T_NORM; 5820 tpl_show_group(); 5821 return ""; 5822 } 5823 strcat(tpl_item,bf); 5824 break; 5825 case T_DIR: 5826 if (strcmp(bf,"%%end_dir%%")==0) { 5827 tpl_mode = T_NORM; 5828 tpl_show_list(); 5829 return ""; 5830 } 5831 break; 5832 } 5833 return ""; 5834 } 5835 5836 static char *var_names[200]; 5837 static char *var_values[200]; 5838 static int nvar; 5839 char *var_find(char *var) 5840 { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 50 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5841 int i; 5842 for (i=0; i 60000) { 5866 s = var_values[i]; 5867 s[60000] = 0; 5868 } 5869 } 5870 char *tpl_replace_vars(char *orig) 5871 { 5872 char var[BFSZ]; 5873 char *s=orig; 5874 char *s2; 5875 again: 5876 s = strstr(s,"%%"); 5877 if (s==NULL) return orig; 5878 s += 2; 5879 s2 = strstr(s,"%%"); 5880 if (s2==NULL) return orig; 5881 ncpy(var,s,s2-s); 5882 tpl_replace_var(s-2,(s2+2) - (s-2) ,var_find(var)); 5883 s -= 2; 5884 goto again; 5885 } 5886 void tpl_replace_var(char *bf, int len, char *var) 5887 { 5888 int nlen = strlen(var); 5889 memmove(bf+nlen,bf+len,strlen(bf+len)+1); 5890 strncpy(bf,var,nlen); 5891 } 5892 int ref_find(char *ref) 5893 { 5894 int i; 5895 int j; 5896 char bf[BFSZ]; 5897 int np; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 51 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5898 char *p[1000]; 5899 strcpy(bf,ref); 5900 np = token_split(bf,p," ",800); 5901 5902 for (j=np-1; j>=0; j--) { 5903 for (i=0; i9) tot = 9; 5920 return tot; 5921 } 5922 static int rev = 1; 5923 void tpl_show_group(void) 5924 { 5925 int p[9000]; 5926 char bf[10000]; 5927 char bf2[10000]; 5928 char *s; 5929 int repeat; 5930 int nloop=0; 5931 int j; 5932 int i2; 5933 int z; 5934 int depth,d,newdepth; 5935 int i,ii; 5936 double px,py; 5937 5938 rev = 1; 5939 if (strcmp("true",ini_get(I_SORT_REV))==0) rev = -1; 5940 if (nitem>MAX_ITEMS) nitem = MAX_ITEMS; 5941 5942 for (i=0; i0) { 5947 x_depth[i] = ref_depth(x_ref[i]); 5948 j = ref_find(x_ref[i]); 5949 if (j>=0) x_fi[i] = j; 5950 else x_f[i] = rev*i; 5951 } else x_f[i] = rev*i; 5952 /* dmsg("[%d] points to %d\n",i,x_fi[i]);*/ 5953 } 5954 for (repeat=TRUE;repeat && (nloop<10);nloop++) { Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 52 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 5955 repeat = FALSE; 5956 for (i=0; i7) py = 7; 5961 px = pow(40,py); 5962 if (px<=1) px = 1; 5963 if (x_f[x_fi[i]] == -9999) repeat = TRUE; 5964 else { 5965 if (px==0) px = 1; 5966 x_f[i] = x_f[x_fi[i]] + ((double) i)/(double) px; 5967 if (x_f[i] > pow(40,8)) x_f[i] = pow(40,8); 5968 } 5969 /* if (x_f[i]<0) repeat = TRUE;*/ 5970 /* dmsg("[%d] set to %d = %g %g [%g]+%g %g\n",i,x_fi[i],x_f[i],(double) pow(50,x_depth[i]),x 5970 _f[x_fi[i]],i/(double) pow(50,x_depth[i]),(double) pow(50,(double) x_depth[i])) ;*/ 5971 } 5972 } 5973 } 5974 if (!search_result) { 5975 if (nitem>2) qsort(p,nitem,sizeof(int),xover_cmp); 5976 printf("%s",tpl_indenton(1)); 5977 } 5978 depth = 1; 5979 for (i=0; i0) i2 = p[i-1]; 5982 if (search_result) goto skip; 5983 5984 newdepth = ref_depth(x_ref[ii]); 5985 if (i==0) newdepth = 1; 5986 if (newdepth!=1) { 5987 if (rev) { 5988 if (((int) (x_f[ii]+0.0000001)) != ((int) (x_f[i2]+0.0000001))) { 5989 newdepth = 1; 5990 } 5991 } else { 5992 if (((int) x_f[ii]) != ((int) x_f[i2])) { 5993 newdepth = 1; 5994 } 5995 } 5996 } 5997 if (newdepth>9) newdepth = 9; 5998 for (d = depth+1; d <= newdepth; d++) { 5999 printf("%s",tpl_indenton(d)); 6000 } 6001 for (d = depth; d > newdepth; d--) { 6002 printf("%s",tpl_indentoff(d)); 6003 } 6004 depth = newdepth; 6005 skip: 6006 if (x_group[ii]!=NULL) if (strlen(x_group[ii])>0) { 6007 strcpy(bf2,x_group[ii]); 6008 s = strchr(bf2,':'); 6009 if (s!=NULL) { 6010 *s = 0; s++; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 53 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6011 strcpy(group,bf2); 6012 x_item[ii] = atoi(s); 6013 goto skip2; 6014 } 6015 } 6016 skip2: 6017 var_set("h_group",value_encode(group)); 6018 sprintf(bf,"%s?cmd=article&group=%s&item=%d",path_script,towww(group),x_item[ii]); 6019 var_set("b_item",bf); 6020 var_set("h_subject",value_encode(x_subject[ii])); 6021 /*sprintf(bf,"%g %s",x_f[ii],value_encode(x_subject[ii])); 6022 var_set("h_subject",bf); 6023 */ 6024 if (depth>1) { 6025 z = (depth-1) * 1; 6026 if (z>10) z=10; 6027 memset(bf,'-',z); 6028 bf[z] = '>'; 6029 bf[z+1] = 0; 6030 var_set("arrows",value_encode(bf)); 6031 } else var_set("arrows",""); 6032 if (depth>1) { 6033 z = (depth-1) * 1 + 1; 6034 if (z>10) z=10; 6035 memset(bf,' ',z); 6036 bf[z] = 0; 6037 var_set("spaces",value_encode(bf)); 6038 } else var_set("spaces",""); 6039 6040 var_set("h_from",value_encode(x_from[ii])); 6041 var_set("h_message-id",value_encode(x_mid[ii])); 6042 var_set("h_lines",x_lines[ii]); 6043 var_set("h_score",x_score[ii]); 6044 var_set("h_date",value_encode(x_date[ii])); 6045 var_set("h_date_trim",value_encode(h_date_trim(x_date[ii]))); 6046 var_set("h_from_trim",value_encode(h_from_trim(x_from[ii]))); 6047 var_set("h_subject_60",value_encode(h_trim(x_subject[ii],60))); 6048 var_set("h_subject_40",value_encode(h_trim(x_subject[ii],40))); 6049 var_set("h_subject_30",value_encode(h_trim(x_subject[ii],30))); 6050 strcpy(bf,tpl_item); 6051 s = tpl_replace_vars(bf); 6052 printf("%s\n",s); 6053 } 6054 if (search_result) return; 6055 for (d = depth; d > 1; d--) { 6056 printf("%s",tpl_indentoff(d)); 6057 } 6058 printf("%s",tpl_indentoff(1)); 6059 } 6060 /* 6061 x y = x y 6062 a@b = a 6063 a@b (name) = name 6064 */ 6065 char *h_from_trim(char *s) 6066 { 6067 static char bf[BFSZ]; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 54 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6068 char *s2; 6069 strcpy(bf,s); 6070 /* a@b (name) */ 6071 s = strchr(bf,'('); 6072 if (s!=NULL) { 6073 s2 = strchr(s,')'); 6074 if (s2==NULL) return bf; 6075 *s2 = 0; 6076 return s+1; 6077 } 6078 /* x y = x y*/ 6079 s = strchr(bf,'<'); 6080 if (s!=NULL) { 6081 for (s=bf;*s!=0; s++) if (!isspace(*s)) break; 6082 if (*s!='<') { 6083 s2 = strchr(s,'<'); 6084 if (s2==NULL) return bf; 6085 *s2 = 0; 6086 return s; 6087 } else { /* */ 6088 s2 = strchr(s,'>'); 6089 if (s2==NULL) return bf; 6090 *s2 = 0; 6091 return s+1; 6092 } 6093 } 6094 if (strchr(bf,'@')==NULL) return bf; 6095 6096 /*a@b*/ 6097 for (s=bf;*s!=0; s++) if (!isspace(*s)) break; 6098 for (s2=s;*s2!=0;s2++) if (isspace(*s2)) break; 6099 *s2 = 0; 6100 return s; 6101 } 6102 char *h_trim(char *s, int len) 6103 { 6104 static char bf[BFSZ]; 6105 ncpy(bf,s,len); 6106 if (strlen(s)>len) strcat(bf,"*"); 6107 return bf; 6108 } 6109 /* Tue, 3 Jan 98 23:33:33 GMT */ 6110 /* 3 Jan 93 */ 6111 6112 char *h_date_trim(char *instr) 6113 { 6114 static char bf[BFSZ]; 6115 char *s; 6116 s = strchr(instr,','); 6117 if (s==NULL) s = instr; else s++; 6118 for (;*s==' ';) s++; 6119 strcpy(bf,s); 6120 s = strchr(bf,' '); if (s==NULL) return bf; 6121 s = strchr(s+1,' '); if (s==NULL) return bf; 6122 s = strchr(s+1,' '); if (s==NULL) return bf; 6123 *s = 0; 6124 return bf; Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 55 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6125 } 6126 void tpl_show_list(void) 6127 { 6128 show_dlist(); 6129 6130 } 6131 void tpl_show_top(void) 6132 { 6133 printf("show list of top news groups\n"); 6134 } 6135 6136 void show_article(void) 6137 { 6138 int part = atoi(query_find("part")); 6139 if (part>0) { 6140 imsg("Show article part\n"); 6141 show_article_part(part); 6142 imsg("Show article part done\n"); 6143 return; 6144 } 6145 tpl_init_item(); 6146 tpl_show("item.tpl"); 6147 } 6148 static char boundary[BFSZ]; 6149 static int isimage = FALSE; 6150 static char mime[BFSZ]; 6151 static char xhtml[BFSZ]; 6152 static char encoding[BFSZ]; 6153 void get_attach_name(char *in); 6154 static char attach_name[BFSZ]; 6155 void tpl_init_item(void) 6156 { 6157 char *s,*x; 6158 char subject[BFSZ]; 6159 static char from[BFSZ]; 6160 static char date[BFSZ]; 6161 static char ref[BFSZ]; 6162 static char mid[BFSZ]; 6163 static char content[BFSZ]; 6164 char bf[BFSZ]; 6165 char *s2; 6166 int gothead = FALSE; 6167 int multi,got,istext; 6168 char newsgroups[BFSZ]; 6169 6170 6171 int item = atoi(query_find("item")); 6172 int related = item; 6173 6174 multi = got = istext = FALSE; 6175 strcpy(subject,""); 6176 strcpy(from,""); 6177 strcpy(date,""); 6178 strcpy(newsgroups,""); 6179 related = item; 6180 6181 if (docache) printf("Pragma: cache\n"); Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 56 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6182 printf("Content-type: %s\n\n",content_type()); 6183 6184 strcpy(attach_name,"attach.jpg"); 6185 var_set("group",group); 6186 var_set("item",query_find("item")); 6187 sprintf(bf,"%s?cmd=xover&group=%s&related=%d",path_script,towww(group),related); 6188 var_set("b_related",bf); 6189 sprintf(bf,"%s?cmd=xover&group=%s",path_script,towww(group)); 6190 var_set("b_recent",bf); 6191 sprintf(bf,"%s?cmd=list",path_script); 6192 var_set("b_topgroups",bf); 6193 sprintf(bf,"%s?cmd=listall",path_script); 6194 var_set("b_allgroups",bf); 6195 sprintf(bf,"%s?cmd=post&group=%s",path_script,towww(group),query_find("item")); 6196 var_set("b_post",bf); 6197 sprintf(bf,"%s?cmd=follow&group=%s&item=%s",path_script,towww(group),query_find("item")); 6198 var_set("b_follow",bf); 6199 6200 s = get_line(instr); 6201 for (;s!=NULL;) { 6202 if (strcmp(s,"\015")==0) break; 6203 head_get("subject:",subject,s); 6204 head_get("date:",date,s); 6205 head_get("message-id:",mid,s); 6206 head_get("from:",from,s); 6207 head_get("references:",ref,s); 6208 head_get("newsgroups:",newsgroups,s); 6209 head_get("mime-version:",mime,s); 6210 head_get("x-html:",xhtml,s); 6211 head_get("content-type:",content,s); 6212 head_get("content-transfer-encoding:",encoding,s); 6213 get_attach_name(s); 6214 s2 = strstr(s,"boundary="); 6215 if (s2==NULL) s2 = strstr(s,"Boundary="); 6216 if (s2!=NULL) { 6217 s2 = strchr(s2,'"'); 6218 strcpy(boundary,"--"); 6219 if (s2!=NULL) ncpy(boundary+2,s2+1,BFSZ-10); 6220 s2 = strchr(boundary,'"'); 6221 if (s2!=NULL) *s2 = 0; 6222 } 6223 s = get_line(instr); 6224 } 6225 6226 var_set("h_from",value_encode(from)); 6227 var_set("h_references",value_encode(ref)); 6228 var_set("h_subject",value_encode(subject)); 6229 var_set("h_date",value_encode(date)); 6230 var_set("h_message-id",value_encode(mid)); 6231 var_set("h_newsgroups",value_encode(newsgroups)); 6232 var_set("h_content-type",value_encode(content)); 6233 strlwr(content); 6234 if (strlen(xhtml)==0) if (strstr(content,"text/html")!=NULL) strcpy(xhtml,content); 6235 } 6236 6237 char *quote_encode(char *s); 6238 void tpl_quote_body(void) Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 57 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6239 { 6240 char *s; 6241 if (instr==NULL) return; 6242 s = strchr(from,'\015'); 6243 if (s!=NULL) *s = 0; 6244 printf("%s wrote:\n",from); 6245 s = get_line(instr); 6246 for (;s!=NULL;) { 6247 printf("%s",quote_encode(s)); 6248 s = get_line(instr); 6249 } 6250 } 6251 char *quote_encode(char *s) 6252 { 6253 static char bf[4000]; 6254 int i; 6255 char *out=bf; 6256 int len; 6257 int w = atoi(ini_get(I_WRAP_TEXT)); 6258 w -= 8; 6259 if (w<=0) w = 1000; 6260 len = 0; 6261 *out++ = '>'; 6262 for (i=0; (i<2000) && (*s!=0);i++,s++,len++) { 6263 if (*s=='\n') len = 0; 6264 if (*s=='\r') len = 0; 6265 if (len>w) { 6266 if (isspace(*s)) { 6267 *out++ = '\n'; 6268 *out++ = '>'; 6269 len = 0; 6270 continue; 6271 } 6272 } 6273 *out++ = *s; 6274 } 6275 *out++ = 0; 6276 return bf; 6277 } 6278 6279 6280 /* 6281 For clarinet *.web groups 6282 6283
    ",path_script,attach_name,towww(group), 6321 item); 6322 } 6323 void tpl_show_item(void) 6324 { 6325 static int multi; 6326 int istext = FALSE; 6327 int ishtml = FALSE; 6328 char *x; 6329 int gothead = FALSE; 6330 int isquoted=FALSE; 6331 int isref = FALSE; 6332 char *z; 6333 int isbase64=FALSE; 6334 char bf[BFSZ]; 6335 int got; 6336 char *s; 6337 int item = atoi(query_find("item")); 6338 char *s2; 6339 int israw = FALSE; 6340 6341 imsg("tpl_show_item()\n"); 6342 strlwr(encoding); 6343 multi = FALSE; 6344 if (strlen(xhtml)>0) israw = TRUE; 6345 if (strlen(mime)>0) if (strlen(boundary)>0) multi = TRUE; 6346 6347 if (!multi) if (strstr(encoding,"base64")!=NULL) { 6348 printf("
    ",path_script,attach_name,towww( 6348 group),item); 6349 goto endbit; 6350 } Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 59 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6351 got = 0; 6352 if (multi) { 6353 s = get_line(instr); 6354 for (;s!=NULL;) { 6355 s2 = strchr(s,'\015') ; if (s2!=NULL) *s2 = 0; s2 = strchr(s,'\012') ; if (s2!=NULL) *s2 = 0; 6356 if (strstr(s,boundary)!=NULL) { 6357 if (!pre_disable) if (istext) if (!ishtml) printf("
  • \n"); 6358 gothead = FALSE; istext = FALSE; got++; 6359 isimage = FALSE; isbase64 = FALSE; 6360 } 6361 if (!gothead) if (strlen(s)==0) { 6362 if (istext) { 6363 if (!pre_disable) if (!ishtml) printf("
    \n");
    	   6364 				else printf("
    "); 6365 } 6366 gothead = TRUE; 6367 if (isimage) 6368 printf("
    ",path_script,attach_ 6368 name,towww(group),item,got); 6369 else 6370 if (isbase64) { 6371 printf("

    %s

    ",path_script, 6371 attach_name,towww(group),item,got,attach_name); 6372 } 6373 goto next_line; 6374 } 6375 6376 if (!gothead) { 6377 /* printf("%s
    \n",s);*/ 6378 strlwr(s); 6379 if (strstr(s,"text/")!=NULL) istext = TRUE; 6380 if (strstr(s,"image/")!=NULL) isimage = TRUE; 6381 if (strstr(s,"text/html")!=NULL) ishtml = TRUE; 6382 if (strstr(s,"base64")!=NULL) isbase64 = TRUE; 6383 if (strstr(s,"quoted-printable")!=NULL) isquoted = TRUE; 6384 get_attach_name(s); 6385 } else { 6386 if (ishtml) { 6387 if (isquoted) printf("%s",decode_quote(s)); 6388 else if (isbase64) printf("%s",decode_base64s(s)); 6389 else printf("%s",s); 6390 } else if (istext) { 6391 printf("%s\n",text_encode(s)); 6392 } 6393 } 6394 next_line: s = get_line(instr); 6395 } 6396 goto endbit; 6397 } 6398 6399 if (!pre_disable) if (!israw) printf("

    \n");
    	   6400 	s = get_line(instr);
    	   6401 	isimage = FALSE;
    	   6402 	for (;s!=NULL;) {
    	   6403 		if (strncmp(s,"begin ",6)==0) {
    	   6404 			ncpy(bf,s,BFSZ-1);
    	   6405 			isref = FALSE;
    
                                    Source Listing                  17-JUN-1998 14:10:30    DEC C V5.0-003                      Page  60
                                                                    17-JUN-1998 14:10:25    USER1:[SRC.DNEWS]DNEWSWEB.C;20
    
    	   6406 			x = strtok(bf," \012\015"); if (x==NULL) goto skip;
    	   6407 			x = strtok(NULL," \012\015"); if (x==NULL) goto skip;
    	   6408 			if (atoi(x)<100) goto skip;
    	   6409 			x = strtok(NULL," \012\015"); if (x==NULL) goto skip;
    	   6410 			strlwr(x);
    	   6411 			if (strchr(x,'.')==NULL) {
    	   6412 				x = strtok(NULL," \012\015"); if (x==NULL) goto skip;
    	   6413 			}
    	   6414 			if (strstr(x,".jpg")!=NULL) {strcpy(attach_name,x); goto isok;}
    	   6415 			if (strstr(x,".jpeg")!=NULL) {strcpy(attach_name,x); goto isok;}
    	   6416 			if (strstr(x,".gif")!=NULL) {strcpy(attach_name,x); goto isok;}
    	   6417 			if (strstr(x,".avi")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6418 			if (strstr(x,".mpg")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6419 			if (strstr(x,".mpeg")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6420 			if (strstr(x,".zip")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6421 			if (strstr(x,".exe")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6422 			if (strstr(x,".doc")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6423 			if (strstr(x,".xls")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6424 			if (strstr(x,".com")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6425 			if (strstr(x,".txt")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6426 			if (strstr(x,".ini")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6427 			if (strstr(x,".log")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6428 			if (strstr(x,".html")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6429 			if (strstr(x,".htm")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6430 			if (strstr(x,".pdb")!=NULL) {isref = TRUE; strcpy(attach_name,x); goto isok;}
    	   6431 			z = strstr(x,".");
    	   6432 			if (z!=NULL) if (strlen(z+1)==3) {isref = TRUE; strcpy(attach_name,x); goto isok;}	
    	   6433 			goto skip;
    	   6434 
    	   6435 isok:			isimage = TRUE;
    	   6436 			if (!isref) 
    	   6437 				printf("
    ",path_script,a 6437 ttach_name,towww(group),item); 6438 else printf("%s

    ",path_scri 6438 pt,attach_name,towww(group),item,attach_name); 6439 } 6440 skip: 6441 if (!israw) { 6442 if (!isimage) if (!isref) printf("%s",text_encode(s)); 6443 } else { 6444 printf("%s",clari_encode(s)); 6445 } 6446 if (isimage) { 6447 if (strncmp(s,"end",3)==0) isimage = FALSE; 6448 } 6449 s = get_line(instr); 6450 } 6451 if (!pre_disable) if (!israw) printf("

    \n"); 6452 endbit:; 6453 6454 } 6455 void clari_insert(char *s, char *in); 6456 void clari_insert(char *s, char *in) 6457 { 6458 memmove(s+strlen(in),s,strlen(s)+1); 6459 strncpy(s,in,strlen(in)); 6460 } Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 61 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 6461 char *clari_encode(char *ss) 6462 { 6463 char *s2; 6464 char *s=ss; 6465 again: 6466 s = strstr(ss,"17) {clari_insert(s+10,"news:"); goto again;} 6471 } 6472 s = strstr(ss,"17) {clari_insert(s+9,"news:"); goto again;} 6477 } 6478 return ss; 6479 } 6480 /* =0)) return sys_errlist[x]; X 6505 return "No error"; X 6506 } X 6507 #endif 6508 void fimsg(char * arg_list, ...) 6509 { 6510 } Command Line ------- ---- CC/NOANSI_ALIAS/ANALYSIS_DATA/ASSUME=(ACCURACY_SENSITIVE,ALIGNED_OBJECTS,WRITABLE_STRING_LITERALS) /CROSS_REFERENCE/NOCOMMENTS/DIAGNOSTICS/DEBUG=(TRACEBACK)/ENDIAN=LITTLE Source Listing 17-JUN-1998 14:10:30 DEC C V5.0-003 Page 62 17-JUN-1998 14:10:25 USER1:[SRC.DNEWS]DNEWSWEB.C;20 /EXTERN_MODEL=RELAXED_REFDEF/FLOAT=(G_FLOAT)/GRANULARITY=QUADWORD/INSTRUCTION_SET=FLOATING_POINT /LINE_CONTROL/L_DOUBLE_SIZE=128/LINE_DIRECTIVES/LIST/NOMACHINE_CODE/MEMBER_ALIGNMENT /NAMES=UPPERCASE/NESTED_INCLUDE_DIRECTORY=INCLUDE_FILE/OBJECT/NOOPTIMIZE /PREFIX=(ALL_ENTRIES)/PSECT_MODEL=NOMULTILANGUAGE/ROUNDING_MODE=NEAREST /SHOW=(HEADER,SOURCE)/SIGNED_CHAR/STANDARD=VAXC/REENTRANCY=TOLERANT/NOTRAP_UNINITIALIZED_VARIABLES /WARNINGS/DEFINE=(BADMALLOC)