home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3959 < prev    next >
Encoding:
Internet Message Format  |  1991-09-04  |  49.3 KB

  1. Path: wupost!uunet!mcsun!unido!estevax!norisc!iain
  2. From: iain@norisc.UUCP (Iain Lea)
  3. Newsgroups: alt.sources
  4. Subject: tin v1.0 Patchlevel 1 Newsreader (part 06/08)
  5. Message-ID: <604@norisc.UUCP>
  6. Date: 3 Sep 91 11:01:11 GMT
  7. Sender: iain@norisc.UUCP (Iain Lea)
  8. Organization: What organization?
  9. Lines: 1817
  10.  
  11. Submitted-by: iain@estevax.uucp
  12. Archive-name: tin1.0/part06
  13.  
  14. #!/bin/sh
  15. # this is tin.shar.06 (part 6 of tin1.0)
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file prompt.c continued
  18. #
  19. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  20.  then TOUCH=touch
  21.  else TOUCH=true
  22. fi
  23. if test ! -r shar3_seq_.tmp; then
  24.     echo "Please unpack part 1 first!"
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 6; then
  29.     echo "Please unpack part $Scheck next!"
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < shar3_seq_.tmp || exit 1
  35. echo "x - Continuing file prompt.c"
  36. sed 's/^X//' << 'SHAR_EOF' >> prompt.c &&
  37. X *              trade or  reproduction.  You may not change this copy-
  38. X *              right notice, and it must be included in any copy made
  39. X */
  40. X
  41. X#include    "tin.h"
  42. X
  43. X/*
  44. X *  parse_num
  45. X *  get a number from the user
  46. X *  Return -1 if missing or bad number typed
  47. X */
  48. X
  49. Xint parse_num (ch, prompt)
  50. X    char ch;
  51. X    char *prompt;
  52. X{
  53. X    char buf[40];
  54. X    int len;
  55. X    int i;
  56. X    int num;
  57. X
  58. X    MoveCursor(LINES,0);
  59. X    printf("%s %c",prompt,ch);
  60. X    fflush(stdout);
  61. X    buf[0] = ch;
  62. X    buf[1] = '\0';
  63. X    len = 1;
  64. X    ch = ReadCh();
  65. X    while (ch != '\n' && ch != '\r') {
  66. X        if (ch == 8 || ch == 127) {
  67. X            if (len) {
  68. X                len--;
  69. X                buf[len] = '\0';
  70. X                putchar('\b');
  71. X                putchar(' ');
  72. X                putchar('\b');
  73. X            } else {
  74. X                MoveCursor(LINES, 0);
  75. X                CleartoEOLN();
  76. X                return(-1);
  77. X            }
  78. X        } else if (ch == 21) {    /* control-U    */
  79. X            for (i = len;i>0;i--) {
  80. X                putchar('\b');
  81. X                putchar(' ');
  82. X                putchar('\b');
  83. X            }
  84. X            buf[0] = '\0';
  85. X            len = 0;
  86. X        } else if (ch >= '0' && ch <= '9' && len < 4) {
  87. X            buf[len++] = ch;
  88. X            buf[len] = '\0';
  89. X            putchar (ch);
  90. X        } else
  91. X            putchar(7);
  92. X        fflush(stdout);
  93. X        ch = ReadCh();
  94. X    }
  95. X
  96. X    MoveCursor(LINES, 0);
  97. X    CleartoEOLN();
  98. X
  99. X    if (len) {
  100. X        num = atoi(buf);
  101. X        return(num);
  102. X    } else
  103. X        return(-1);
  104. X}
  105. X
  106. X
  107. X/*
  108. X *  parse_string
  109. X *  get a string from the user
  110. X *  Return TRUE if a valid string was typed, FALSE otherwise
  111. X */
  112. X
  113. Xint parse_string (prompt, buf)
  114. X    char *prompt;
  115. X    char *buf;
  116. X{
  117. X    int len;
  118. X    int i;
  119. X    char ch;
  120. X
  121. X    clear_message();
  122. X    MoveCursor(LINES,0);
  123. X    printf("%s", prompt);
  124. X    fflush(stdout);
  125. X
  126. X    buf[0] = '\0';
  127. X    len = 0;
  128. X    ch = ReadCh();
  129. X    while (ch != '\n' && ch != '\r') {
  130. X        if (ch == 8 || ch == 127) {
  131. X            if (len) {
  132. X                len--;
  133. X                buf[len] = '\0';
  134. X                putchar('\b');
  135. X                putchar(' ');
  136. X                putchar('\b');
  137. X            } else {
  138. X                MoveCursor(LINES, 0);
  139. X                CleartoEOLN();
  140. X                return(FALSE);
  141. X            }
  142. X        } else if (ch == 21) {    /* control-U    */
  143. X            for (i = len;i>0;i--) {
  144. X                putchar('\b');
  145. X                putchar(' ');
  146. X                putchar('\b');
  147. X            }
  148. X            buf[0] = '\0';
  149. X            len = 0;
  150. X        } else if (ch >= ' ' && len < 60) {
  151. X            buf[len++] = ch;
  152. X            buf[len] = '\0';
  153. X            putchar (ch);
  154. X        } else
  155. X            putchar(7);
  156. X        fflush(stdout);
  157. X        ch = ReadCh();
  158. X    }
  159. X    MoveCursor(LINES,0);
  160. X    CleartoEOLN();
  161. X
  162. X    return TRUE;
  163. X}
  164. X
  165. X
  166. Xint prompt_yn (line, prompt, default_ch)
  167. X    int line;
  168. X    char *prompt;
  169. X    char default_ch;
  170. X{
  171. X    char ch;
  172. X
  173. X    MoveCursor (line, 0);
  174. X    CleartoEOLN ();
  175. X    printf ("%s%c", prompt, default_ch);
  176. X    fflush (stdout);
  177. X    MoveCursor (line, strlen (prompt));
  178. X
  179. X    if ((ch = ReadCh()) == CR) {
  180. X        ch = default_ch;
  181. X    }    
  182. X
  183. X    if (line == LINES) {
  184. X        clear_message();
  185. X    } else {
  186. X        MoveCursor (line, strlen (prompt));
  187. X        printf ("%c", ch);
  188. X        fflush (stdout);
  189. X    }
  190. X
  191. X    return (ch == 'y' ? TRUE : FALSE);
  192. X}
  193. X
  194. X
  195. Xvoid continue_prompt()
  196. X{
  197. X    info_message(txt_hit_any_key);
  198. X    ReadCh();
  199. X}
  200. X
  201. X
  202. SHAR_EOF
  203. echo "File prompt.c is complete" &&
  204. $TOUCH -am 0903095091 prompt.c &&
  205. chmod 0600 prompt.c ||
  206. echo "restore of prompt.c failed"
  207. set `wc -c prompt.c`;Wc_c=$1
  208. if test "$Wc_c" != "3062"; then
  209.     echo original size 3062, current size $Wc_c
  210. fi
  211. # ============= proto.h ==============
  212. echo "x - extracting proto.h (Text)"
  213. sed 's/^X//' << 'SHAR_EOF' > proto.h &&
  214. X#ifdef __STDC__
  215. X/* art.c */
  216. Xlong my_atol(char *s, int n);
  217. Xvoid find_base(void);
  218. Xint num_of_arts(void);
  219. Xint valid_artnum(long art);
  220. Xint purge_needed(void);
  221. Xvoid index_group(char *group, char *group_path);
  222. Xint read_group(char *group, char *group_path);
  223. Xvoid make_threads(int rethread);
  224. Xchar *eat_re(char *s);
  225. Xlong hash_s(char *s);
  226. Xint parse_headers(int fd, struct header *h);
  227. Xvoid dump_index(char *group, int killed);
  228. Xvoid my_strncpy(char *p, char *q, int n);
  229. Xint load_index(void);
  230. Xvoid find_local_index(char *group);
  231. Xvoid do_update(void);
  232. Xvoid reload_index_file(char *group, int killed);
  233. Xchar *parse_date(char *date, char *str);
  234. Xint artnum_comp(struct header *s1, struct header *s2);
  235. Xint subj_comp(struct header *s1, struct header *s2);
  236. Xint from_comp(struct header *s1, struct header *s2);
  237. Xint date_comp(struct header *s1, struct header *s2);
  238. Xint set_article(struct header *art);
  239. X/* curses.c */
  240. Xint InitScreen(void);
  241. Xvoid ScreenSize(int *num_lines, int *num_columns);
  242. Xvoid ClearScreen(void);
  243. Xvoid MoveCursor(int row, int col);
  244. Xvoid CleartoEOLN(void);
  245. Xvoid CleartoEOS(void);
  246. Xvoid StartInverse(void);
  247. Xvoid EndInverse(void);
  248. Xint RawState(void);
  249. Xvoid Raw(int state);
  250. Xint ReadCh(void);
  251. Xint outchar(int c);
  252. X/* debug.c */
  253. Xint debug_print_arts(void);
  254. Xvoid debug_print_header(struct header *s);
  255. Xint debug_print_comment(char *comment);
  256. Xvoid debug_print_base(void);
  257. Xvoid debug_print_active(void);
  258. X/* feed.c */
  259. Xint feed_articles(int function, int level, char *prompt, int respnum, char *group_path);
  260. X/* group.c */
  261. Xvoid group_page(char *group);
  262. Xvoid fix_new_highest(int groupnum);
  263. Xvoid show_group_page(char *group);
  264. Xvoid draw_subject_arrow(void);
  265. Xvoid erase_subject_arrow(void);
  266. Xint prompt_subject_num(int ch, char *group);
  267. Xint new_responses(int thread);
  268. Xvoid clear_note_area(void);
  269. Xint find_new_pos(int old_top, long old_artnum, int cur_pos);
  270. X/* hashstr.c */
  271. Xchar *hash_str(char *s);
  272. Xstruct hashnode *add_string(char *s);
  273. Xvoid hash_init(void);
  274. Xvoid hash_reclaim(void);
  275. X/* help.c */
  276. Xvoid show_help_page(char *help[], char *title);
  277. Xvoid help_select_info(void);
  278. Xvoid help_group_info(void);
  279. Xvoid help_page_info(void);
  280. X/* kill.c */
  281. Xint read_kill_file(void);
  282. Xvoid write_kill_file(void);
  283. Xint kill_art_menu(char *group_name, int index);
  284. Xint untag_all_articles(void);
  285. Xint kill_any_articles(char *group);
  286. X/* lang.c */
  287. X/* mail.c */
  288. Xvoid mail_setup(void);
  289. Xint mail_check(void);
  290. X/* main.c */
  291. Xvoid main(int argc, char *argv[]);
  292. Xvoid usage(char *progname);
  293. X/* memory.c */
  294. Xvoid init_alloc(void);
  295. Xvoid expand_art(void);
  296. Xvoid free_art_array(void);
  297. Xvoid expand_active(void);
  298. Xvoid expand_kill(void);
  299. Xvoid expand_save(void);
  300. Xvoid init_screen_array(int allocate);
  301. Xvoid free_all_arrays(void);
  302. Xvoid free_kill_array(void);
  303. Xvoid free_save_array(void);
  304. Xchar *my_malloc(unsigned size);
  305. Xchar *my_realloc(char *p, unsigned size);
  306. X/* misc.c */
  307. Xvoid init_selfinfo(void);
  308. Xint which_base(int n);
  309. Xint which_resp(int n);
  310. Xint nresp(int n);
  311. Xvoid asfail(char *file, int line, char *cond);
  312. Xvoid copy_fp(FILE *a, FILE *b, char *prefix);
  313. Xchar *get_val(char *env, char *def);
  314. Xint invoke_editor(char *nam);
  315. Xvoid shell_escape(void);
  316. Xvoid tin_done(int ret);
  317. Xvoid read_active(void);
  318. Xvoid add_signature(FILE *fp, int flag);
  319. Xlong hash_groupname(char *buf);
  320. Xvoid rename_file(char *old_filename, char *new_filename);
  321. Xchar *str_dup(char *str);
  322. Xint invoke_cmd(char *nam);
  323. Xint draw_percent_mark(int cur_num, int max_num);
  324. Xvoid set_real_uid_gid(void);
  325. Xvoid set_tin_uid_gid(void);
  326. X/* newsrc.c */
  327. Xvoid read_newsrc(int sub_only);
  328. Xvoid write_newsrc(void);
  329. Xvoid rewrite_newsrc(void);
  330. Xvoid read_newsrc_line(char *group);
  331. Xvoid update_newsrc(char *group, int groupnum);
  332. Xvoid subscribe(char *group, int ch, int num, int out_seq);
  333. Xvoid reset_newsrc(void);
  334. Xvoid delete_group(char *group);
  335. Xint undel_group(void);
  336. Xvoid mark_group_read(char *group, int groupnum);
  337. Xvoid parse_seq(char *s);
  338. Xint parse_unread(char *s, int groupnum);
  339. Xint get_line_unread(char *group, int groupnum);
  340. Xvoid print_seq(FILE *fp, int groupnum);
  341. Xint pos_group_in_newsrc(char *group, int pos);
  342. X/* open.c */
  343. Xchar *is_remote(void);
  344. Xvoid nntp_startup(void);
  345. Xvoid nntp_finish(void);
  346. XFILE *open_active_fp(void);
  347. XFILE *open_art_fp(char *group_path, long art);
  348. Xint open_header_fd(char *group_path, long art);
  349. Xint base_comp(long *a, long *b);
  350. Xvoid setup_base(char *group, char *group_path);
  351. Xint get_respcode(void);
  352. Xint stuff_nntp(char *fnam);
  353. XFILE *nntp_to_fp(void);
  354. Xint nntp_to_fd(void);
  355. X/* page.c */
  356. Xint show_page(int respnum, char *group, char *group_path);
  357. Xvoid redraw_page(int respnum, char *group);
  358. Xvoid show_note_page(int respnum, char *group);
  359. Xvoid show_first_header(int respnum, char *group);
  360. Xvoid show_cont_header(int respnum);
  361. Xvoid open_note(long art, char *group_path);
  362. Xvoid note_cleanup(void);
  363. Xint prompt_response(int ch, int respnum);
  364. Xint choose_resp(int i, int n);
  365. Xvoid parse_from(char *str, char *addr, char *name);
  366. Xint prev_response(int n);
  367. Xint next_response(int n);
  368. Xint next_basenote(int n);
  369. Xvoid yank_to_addr(char *orig, char *addr);
  370. Xint show_last_page(void);
  371. X/* post.c */
  372. Xint user_posted_messages(void);
  373. Xvoid update_art_posted_file(char *group, char *subj);
  374. Xint post_base(char *group);
  375. Xint post_response(char *group, int respnum);
  376. Xint mail_to_someone(int single_article, char *address);
  377. Xint mail_bug_report(void);
  378. Xint mail_to_author(int copy_text);
  379. Xvoid find_new_to(char *nam, char *mail_to);
  380. X/* prompt.c */
  381. Xint parse_num(int ch, char *prompt);
  382. Xint parse_string(char *prompt, char *buf);
  383. Xint prompt_yn(int line, char *prompt, int default_ch);
  384. Xvoid continue_prompt(void);
  385. X/* rcfile.c */
  386. Xint read_rcfile(void);
  387. Xvoid write_rcfile(void);
  388. Xint change_rcfile(char *group, int kill_at_once);
  389. Xvoid show_rcfile_menu(void);
  390. Xvoid parse_menu_string(int line, int col, char *var);
  391. Xvoid expand_rel_abs_pathname(int line, int col, char *str);
  392. Xvoid show_menu_help(char *help_message);
  393. X/* save.c */
  394. Xint save_art_to_file(int respnum, int index, int mailbox, char *filename);
  395. Xint save_thread_to_file(int respnum, int is_mailbox, char *group_path);
  396. Xint save_regex_arts(int is_pattern, char *pattern, int is_mailbox, char *group_path);
  397. Xint append_to_existing_file(int i);
  398. Xint create_path(char *path);
  399. Xint create_sub_dir(int i);
  400. Xvoid add_to_save_list(int index, struct header *article, int is_mailbox, char *path);
  401. Xvoid sort_save_list(void);
  402. Xint save_comp(struct save_t *s1, struct save_t *s2);
  403. Xchar *save_filename(int i);
  404. Xchar *get_first_savefile(void);
  405. Xchar *get_last_savefile(void);
  406. Xint post_process_files(void);
  407. Xvoid post_process_uud(int pp);
  408. Xvoid post_process_sh(void);
  409. Xchar *get_archive_file(char *dir, char *ext);
  410. Xvoid delete_processed_files(void);
  411. Xvoid post_process_patch(void);
  412. X/* screen.c */
  413. Xvoid info_message(char *msg);
  414. Xvoid wait_message(char *msg);
  415. Xvoid error_message(char *template, char *msg);
  416. Xvoid clear_message(void);
  417. Xvoid center_line(int line, int inverse, char *str);
  418. Xvoid draw_arrow(int line);
  419. Xvoid erase_arrow(int line);
  420. X/* search.c */
  421. Xint search_author(int current_art, int forward);
  422. Xvoid search_group(int forward);
  423. Xvoid search_subject(int forward, char *group);
  424. Xint search_article(int forward);
  425. Xchar *str_str(char *text, char *pattern);
  426. Xvoid make_lower(char *s, char *t);
  427. X/* select.c */
  428. Xvoid selection_index(void);
  429. Xvoid group_selection_page(void);
  430. Xint prompt_group_num(int ch);
  431. Xvoid erase_group_arrow(void);
  432. Xvoid draw_group_arrow(void);
  433. Xint choose_new_group(void);
  434. Xint add_group(char *s, int get_unread);
  435. Xint next_unread(int n);
  436. Xint prev_unread(int n);
  437. Xint reposition_group(char *group, int default_num);
  438. Xint catchup_group(int goto_next_unread_group);
  439. Xvoid next_unread_group(int enter_group);
  440. X/* signal.c */
  441. Xvoid set_signal_handlers(void);
  442. Xvoid signal_handler(int sig);
  443. Xvoid set_win_size(int *num_lines, int *num_cols);
  444. Xvoid art_suspend(int sig);
  445. Xvoid main_suspend(int sig);
  446. Xvoid select_suspend(int sig);
  447. Xvoid group_suspend(int sig);
  448. Xvoid page_suspend(int sig);
  449. Xvoid rcfile_suspend(int sig);
  450. Xvoid art_resize(int sig);
  451. Xvoid main_resize(int sig);
  452. Xvoid select_resize(int sig);
  453. Xvoid group_resize(int sig);
  454. Xvoid page_resize(int sig);
  455. X/* time.c */
  456. Xvoid nicedate(char *timestr, char *newstr);
  457. Xvoid nicetime(char *timestr, char *newstr);
  458. Xchar *nice_time(void);
  459. X/* wildmat.c */
  460. Xint wildmat(char *text, char *p);
  461. X#else
  462. X/* art.c */
  463. Xlong my_atol(/*char *s, int n*/);
  464. Xvoid find_base(/*void*/);
  465. Xint num_of_arts(/*void*/);
  466. Xint valid_artnum(/*long art*/);
  467. Xint purge_needed(/*void*/);
  468. Xvoid index_group(/*char *group, char *group_path*/);
  469. Xint read_group(/*char *group, char *group_path*/);
  470. Xvoid make_threads(/*int rethread*/);
  471. Xchar *eat_re(/*char *s*/);
  472. Xlong hash_s(/*char *s*/);
  473. Xint parse_headers(/*int fd, struct header *h*/);
  474. Xvoid dump_index(/*char *group, int killed*/);
  475. Xvoid my_strncpy(/*char *p, char *q, int n*/);
  476. Xint load_index(/*void*/);
  477. Xvoid find_local_index(/*char *group*/);
  478. Xvoid do_update(/*void*/);
  479. Xvoid reload_index_file(/*char *group, int killed*/);
  480. Xchar *parse_date(/*char *date, char *str*/);
  481. Xint artnum_comp(/*struct header *s1, struct header *s2*/);
  482. Xint subj_comp(/*struct header *s1, struct header *s2*/);
  483. Xint from_comp(/*struct header *s1, struct header *s2*/);
  484. Xint date_comp(/*struct header *s1, struct header *s2*/);
  485. Xint set_article(/*struct header *art*/);
  486. X/* curses.c */
  487. Xint InitScreen(/*void*/);
  488. Xvoid ScreenSize(/*int *num_lines, int *num_columns*/);
  489. Xvoid ClearScreen(/*void*/);
  490. Xvoid MoveCursor(/*int row, int col*/);
  491. Xvoid CleartoEOLN(/*void*/);
  492. Xvoid CleartoEOS(/*void*/);
  493. Xvoid StartInverse(/*void*/);
  494. Xvoid EndInverse(/*void*/);
  495. Xint RawState(/*void*/);
  496. Xvoid Raw(/*int state*/);
  497. Xint ReadCh(/*void*/);
  498. Xint outchar(/*int c*/);
  499. X/* debug.c */
  500. Xint debug_print_arts(/*void*/);
  501. Xvoid debug_print_header(/*struct header *s*/);
  502. Xint debug_print_comment(/*char *comment*/);
  503. Xvoid debug_print_base(/*void*/);
  504. Xvoid debug_print_active(/*void*/);
  505. X/* feed.c */
  506. Xint feed_articles(/*int function, int level, char *prompt, int respnum, char *group_path*/);
  507. X/* group.c */
  508. Xvoid group_page(/*char *group*/);
  509. Xvoid fix_new_highest(/*int groupnum*/);
  510. Xvoid show_group_page(/*char *group*/);
  511. Xvoid draw_subject_arrow(/*void*/);
  512. Xvoid erase_subject_arrow(/*void*/);
  513. Xint prompt_subject_num(/*int ch, char *group*/);
  514. Xint new_responses(/*int thread*/);
  515. Xvoid clear_note_area(/*void*/);
  516. Xint find_new_pos(/*int old_top, long old_artnum, int cur_pos*/);
  517. X/* hashstr.c */
  518. Xchar *hash_str(/*char *s*/);
  519. Xstruct hashnode *add_string(/*char *s*/);
  520. Xvoid hash_init(/*void*/);
  521. Xvoid hash_reclaim(/*void*/);
  522. X/* help.c */
  523. Xvoid show_help_page(/*char *help[], char *title*/);
  524. Xvoid help_select_info(/*void*/);
  525. Xvoid help_group_info(/*void*/);
  526. Xvoid help_page_info(/*void*/);
  527. X/* kill.c */
  528. Xint read_kill_file(/*void*/);
  529. Xvoid write_kill_file(/*void*/);
  530. Xint kill_art_menu(/*char *group_name, int index*/);
  531. Xint untag_all_articles(/*void*/);
  532. Xint kill_any_articles(/*char *group*/);
  533. X/* lang.c */
  534. X/* mail.c */
  535. Xvoid mail_setup(/*void*/);
  536. Xint mail_check(/*void*/);
  537. X/* main.c */
  538. Xvoid main(/*int argc, char *argv[]*/);
  539. Xvoid usage(/*char *progname*/);
  540. X/* memory.c */
  541. Xvoid init_alloc(/*void*/);
  542. Xvoid expand_art(/*void*/);
  543. Xvoid free_art_array(/*void*/);
  544. Xvoid expand_active(/*void*/);
  545. Xvoid expand_kill(/*void*/);
  546. Xvoid expand_save(/*void*/);
  547. Xvoid init_screen_array(/*int allocate*/);
  548. Xvoid free_all_arrays(/*void*/);
  549. Xvoid free_kill_array(/*void*/);
  550. Xvoid free_save_array(/*void*/);
  551. Xchar *my_malloc(/*unsigned size*/);
  552. Xchar *my_realloc(/*char *p, unsigned size*/);
  553. X/* misc.c */
  554. Xvoid init_selfinfo(/*void*/);
  555. Xint which_base(/*int n*/);
  556. Xint which_resp(/*int n*/);
  557. Xint nresp(/*int n*/);
  558. Xvoid asfail(/*char *file, int line, char *cond*/);
  559. Xvoid copy_fp(/*FILE *a, FILE *b, char *prefix*/);
  560. Xchar *get_val(/*char *env, char *def*/);
  561. Xint invoke_editor(/*char *nam*/);
  562. Xvoid shell_escape(/*void*/);
  563. Xvoid tin_done(/*int ret*/);
  564. Xvoid read_active(/*void*/);
  565. Xvoid add_signature(/*FILE *fp, int flag*/);
  566. Xlong hash_groupname(/*char *buf*/);
  567. Xvoid rename_file(/*char *old_filename, char *new_filename*/);
  568. Xchar *str_dup(/*char *str*/);
  569. Xint invoke_cmd(/*char *nam*/);
  570. Xint draw_percent_mark(/*int cur_num, int max_num*/);
  571. Xvoid set_real_uid_gid(/*void*/);
  572. Xvoid set_tin_uid_gid(/*void*/);
  573. X/* newsrc.c */
  574. Xvoid read_newsrc(/*int sub_only*/);
  575. Xvoid write_newsrc(/*void*/);
  576. Xvoid rewrite_newsrc(/*void*/);
  577. Xvoid read_newsrc_line(/*char *group*/);
  578. Xvoid update_newsrc(/*char *group, int groupnum*/);
  579. Xvoid subscribe(/*char *group, int ch, int num, int out_seq*/);
  580. Xvoid reset_newsrc(/*void*/);
  581. Xvoid delete_group(/*char *group*/);
  582. Xint undel_group(/*void*/);
  583. Xvoid mark_group_read(/*char *group, int groupnum*/);
  584. Xvoid parse_seq(/*char *s*/);
  585. Xint parse_unread(/*char *s, int groupnum*/);
  586. Xint get_line_unread(/*char *group, int groupnum*/);
  587. Xvoid print_seq(/*FILE *fp, int groupnum*/);
  588. Xint pos_group_in_newsrc(/*char *group, int pos*/);
  589. X/* open.c */
  590. Xchar *is_remote(/*void*/);
  591. Xvoid nntp_startup(/*void*/);
  592. Xvoid nntp_finish(/*void*/);
  593. XFILE *open_active_fp(/*void*/);
  594. XFILE *open_art_fp(/*char *group_path, long art*/);
  595. Xint open_header_fd(/*char *group_path, long art*/);
  596. Xint base_comp(/*long *a, long *b*/);
  597. Xvoid setup_base(/*char *group, char *group_path*/);
  598. Xint get_respcode(/*void*/);
  599. Xint stuff_nntp(/*char *fnam*/);
  600. XFILE *nntp_to_fp(/*void*/);
  601. Xint nntp_to_fd(/*void*/);
  602. X/* page.c */
  603. Xint show_page(/*int respnum, char *group, char *group_path*/);
  604. Xvoid redraw_page(/*int respnum, char *group*/);
  605. Xvoid show_note_page(/*int respnum, char *group*/);
  606. Xvoid show_first_header(/*int respnum, char *group*/);
  607. Xvoid show_cont_header(/*int respnum*/);
  608. Xvoid open_note(/*long art, char *group_path*/);
  609. Xvoid note_cleanup(/*void*/);
  610. Xint prompt_response(/*int ch, int respnum*/);
  611. Xint choose_resp(/*int i, int n*/);
  612. Xvoid parse_from(/*char *str, char *addr, char *name*/);
  613. Xint prev_response(/*int n*/);
  614. Xint next_response(/*int n*/);
  615. Xint next_basenote(/*int n*/);
  616. Xvoid yank_to_addr(/*char *orig, char *addr*/);
  617. Xint show_last_page(/*void*/);
  618. X/* post.c */
  619. Xint user_posted_messages(/*void*/);
  620. Xvoid update_art_posted_file(/*char *group, char *subj*/);
  621. Xint post_base(/*char *group*/);
  622. Xint post_response(/*char *group, int respnum*/);
  623. Xint mail_to_someone(/*int single_article, char *address*/);
  624. Xint mail_bug_report(/*void*/);
  625. Xint mail_to_author(/*int copy_text*/);
  626. Xvoid find_new_to(/*char *nam, char *mail_to*/);
  627. X/* prompt.c */
  628. Xint parse_num(/*int ch, char *prompt*/);
  629. Xint parse_string(/*char *prompt, char *buf*/);
  630. Xint prompt_yn(/*int line, char *prompt, int default_ch*/);
  631. Xvoid continue_prompt(/*void*/);
  632. X/* rcfile.c */
  633. Xint read_rcfile(/*void*/);
  634. Xvoid write_rcfile(/*void*/);
  635. Xint change_rcfile(/*char *group, int kill_at_once*/);
  636. Xvoid show_rcfile_menu(/*void*/);
  637. Xvoid parse_menu_string(/*int line, int col, char *var*/);
  638. Xvoid expand_rel_abs_pathname(/*int line, int col, char *str*/);
  639. Xvoid show_menu_help(/*char *help_message*/);
  640. X/* save.c */
  641. Xint save_art_to_file(/*int respnum, int index, int mailbox, char *filename*/);
  642. Xint save_thread_to_file(/*int respnum, int is_mailbox, char *group_path*/);
  643. Xint save_regex_arts(/*int is_pattern, char *pattern, int is_mailbox, char *group_path*/);
  644. Xint append_to_existing_file(/*int i*/);
  645. Xint create_path(/*char *path*/);
  646. Xint create_sub_dir(/*int i*/);
  647. Xvoid add_to_save_list(/*int index, struct header *article, int is_mailbox, char *path*/);
  648. Xvoid sort_save_list(/*void*/);
  649. Xint save_comp(/*struct save_t *s1, struct save_t *s2*/);
  650. Xchar *save_filename(/*int i*/);
  651. Xchar *get_first_savefile(/*void*/);
  652. Xchar *get_last_savefile(/*void*/);
  653. Xint post_process_files(/*void*/);
  654. Xvoid post_process_uud(/*int pp*/);
  655. Xvoid post_process_sh(/*void*/);
  656. Xchar *get_archive_file(/*char *dir, char *ext*/);
  657. Xvoid delete_processed_files(/*void*/);
  658. Xvoid post_process_patch(/*void*/);
  659. X/* screen.c */
  660. Xvoid info_message(/*char *msg*/);
  661. Xvoid wait_message(/*char *msg*/);
  662. Xvoid error_message(/*char *template, char *msg*/);
  663. Xvoid clear_message(/*void*/);
  664. Xvoid center_line(/*int line, int inverse, char *str*/);
  665. Xvoid draw_arrow(/*int line*/);
  666. Xvoid erase_arrow(/*int line*/);
  667. X/* search.c */
  668. Xint search_author(/*int current_art, int forward*/);
  669. Xvoid search_group(/*int forward*/);
  670. Xvoid search_subject(/*int forward, char *group*/);
  671. Xint search_article(/*int forward*/);
  672. Xchar *str_str(/*char *text, char *pattern*/);
  673. Xvoid make_lower(/*char *s, char *t*/);
  674. X/* select.c */
  675. Xvoid selection_index(/*void*/);
  676. Xvoid group_selection_page(/*void*/);
  677. Xint prompt_group_num(/*int ch*/);
  678. Xvoid erase_group_arrow(/*void*/);
  679. Xvoid draw_group_arrow(/*void*/);
  680. Xint choose_new_group(/*void*/);
  681. Xint add_group(/*char *s, int get_unread*/);
  682. Xint next_unread(/*int n*/);
  683. Xint prev_unread(/*int n*/);
  684. Xint reposition_group(/*char *group, int default_num*/);
  685. Xint catchup_group(/*int goto_next_unread_group*/);
  686. Xvoid next_unread_group(/*int enter_group*/);
  687. X/* signal.c */
  688. Xvoid set_signal_handlers(/*void*/);
  689. Xvoid signal_handler(/*int sig*/);
  690. Xvoid set_win_size(/*int *num_lines, int *num_cols*/);
  691. Xvoid art_suspend(/*int sig*/);
  692. Xvoid main_suspend(/*int sig*/);
  693. Xvoid select_suspend(/*int sig*/);
  694. Xvoid group_suspend(/*int sig*/);
  695. Xvoid page_suspend(/*int sig*/);
  696. Xvoid rcfile_suspend(/*int sig*/);
  697. Xvoid art_resize(/*int sig*/);
  698. Xvoid main_resize(/*int sig*/);
  699. Xvoid select_resize(/*int sig*/);
  700. Xvoid group_resize(/*int sig*/);
  701. Xvoid page_resize(/*int sig*/);
  702. X/* time.c */
  703. Xvoid nicedate(/*char *timestr, char *newstr*/);
  704. Xvoid nicetime(/*char *timestr, char *newstr*/);
  705. Xchar *nice_time(/*void*/);
  706. X/* wildmat.c */
  707. Xint wildmat(/*char *text, char *p*/);
  708. X#endif
  709. SHAR_EOF
  710. $TOUCH -am 0903095091 proto.h &&
  711. chmod 0600 proto.h ||
  712. echo "restore of proto.h failed"
  713. set `wc -c proto.h`;Wc_c=$1
  714. if test "$Wc_c" != "17093"; then
  715.     echo original size 17093, current size $Wc_c
  716. fi
  717. # ============= rcfile.c ==============
  718. echo "x - extracting rcfile.c (Text)"
  719. sed 's/^X//' << 'SHAR_EOF' > rcfile.c &&
  720. X/*
  721. X *  Project   : tin - a visual threaded usenet newsreader
  722. X *  Module    : rcfile.c
  723. X *  Author    : I.Lea
  724. X *  Created   : 01-04-91
  725. X *  Updated   : 30-08-91
  726. X *  Release   : 1.0
  727. X *  Notes     :
  728. X *  Copyright : (c) Copyright 1991 by Iain Lea
  729. X *                You may  freely  copy or  redistribute  this software,
  730. X *              so  long as there is no profit made from its use, sale
  731. X *              trade or  reproduction.  You may not change this copy-
  732. X *              right notice, and it must be included in any copy made
  733. X */
  734. X
  735. X#include    "tin.h"
  736. X
  737. X#define COL2    COLS/2
  738. X
  739. Xextern char index_file[LEN+1];
  740. X
  741. X/*
  742. X *  read_rcfile - read defaults from ~/.tin/tinrc
  743. X */
  744. X
  745. Xint read_rcfile ()
  746. X{
  747. X    char buf[LEN+1];
  748. X    FILE *fp;
  749. X
  750. X    if ((fp = fopen (rcfile, "r")) != NULL) {
  751. X        while (fgets (buf, LEN, fp) != NULL) {
  752. X            if (buf[0] != '#') { 
  753. X                if (strncmp (buf, "save_archive=", 13) == 0) {
  754. X                    save_archive_name = (strncmp (&buf[13], "ON", 2) == 0 ? TRUE : FALSE);
  755. X                } else if (strncmp (buf, "save_separate=", 14) == 0) {
  756. X                    save_separate = (strncmp (&buf[14], "ON", 2) == 0 ? TRUE : FALSE);
  757. X                } else if (strncmp (buf, "mark_saved_read=", 16) == 0) {
  758. X                    mark_saved_read = (strncmp (&buf[16], "ON", 2) == 0 ? TRUE : FALSE);
  759. X                } else if (strncmp (buf, "kill_articles=", 14) == 0) {
  760. X                    kill_articles = (strncmp (&buf[14], "ON", 2) == 0 ? TRUE : FALSE);
  761. X                } else if (strncmp (buf, "show_author=", 12) == 0) {
  762. X                    show_author = (strncmp (&buf[12], "ON", 2) == 0 ? TRUE : FALSE);
  763. X                } else if (strncmp (buf, "draw_arrow=", 11) == 0) {
  764. X                    draw_arrow_mark = (strncmp (&buf[11], "ON", 2) == 0 ? TRUE : FALSE);
  765. X                    if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
  766. X                        inverse_okay = TRUE;
  767. X                    }
  768. X                } else if (strncmp (buf, "post_process=", 13) == 0) {
  769. X                    post_process = (strncmp (&buf[13], "ON", 2) == 0 ? TRUE : FALSE);
  770. X                } else if (strncmp (buf, "print_header=", 13) == 0) {
  771. X                    print_header = (strncmp (&buf[14], "ON", 2) == 0 ? TRUE : FALSE);
  772. X                } else if (strncmp (buf, "post_process_type=", 18) == 0) {
  773. X                    post_proc_type = atoi (&buf[18]);
  774. X                } else if (strncmp (buf, "sort_article_type=", 18) == 0) {
  775. X                    sort_art_type = atoi (&buf[18]);
  776. X                } else if (strncmp (buf, "savedir=", 8) == 0) {
  777. X                    strncpy (savedir, &buf[8], LEN);
  778. X                    savedir[strlen (savedir) - 1] = '\0';
  779. X                    if (savedir[0] == '.' && strlen (savedir) == 1) {
  780. X#ifdef BSD
  781. X                        getwd (buf);    
  782. X#else
  783. X                        getcwd (buf, LEN);
  784. X#endif
  785. X                        my_strncpy (savedir, buf, LEN);
  786. X                    } /*  else if (savedir[0] == '.' && savedir[1] == '.' && strlen (savedir) == 2) {
  787. X                    } */
  788. X                } else if (strncmp (buf, "maildir=", 8) == 0) {
  789. X                    strncpy (maildir, &buf[8], LEN);
  790. X                    maildir[strlen (maildir) - 1] = '\0';
  791. X                } else if (strncmp (buf, "printer=", 8) == 0) {
  792. X                    strncpy (printer, &buf[8], LEN);
  793. X                    printer[strlen (printer) - 1] = '\0';
  794. X                } else if (strncmp (buf, "spooldir=", 9) == 0) {
  795. X                    strncpy (spooldir, &buf[9], LEN);
  796. X                    spooldir[strlen (spooldir) - 1] = '\0';
  797. X                } else if (strncmp (buf, "signature=", 10) == 0) {
  798. X                    strncpy (signature, &buf[10], LEN);
  799. X                    signature[strlen (signature) - 1] = '\0';
  800. X                } else if (strncmp (buf, "sig=", 4) == 0) {
  801. X                    strncpy (sig, &buf[4], LEN);
  802. X                    sig[strlen (sig) - 1] = '\0';
  803. X                }
  804. X            }
  805. X        }
  806. X        fclose (fp);
  807. X        return TRUE;        
  808. X    }
  809. X    return FALSE;        
  810. X}
  811. X
  812. X/*
  813. X *  write_rcfile - write defaults to ~/.tin/tinrc
  814. X */
  815. X
  816. Xvoid write_rcfile ()
  817. X{
  818. X    FILE *fp;
  819. X
  820. X    set_real_uid_gid ();
  821. X    
  822. X    if ((fp = fopen (rcfile, "w")) != NULL) {
  823. X        wait_message (txt_saving);
  824. X
  825. X        fprintf (fp, "# (-a) if ON articles/threads with Archive-name: in mail header will\n");
  826. X        fprintf (fp, "# be automatically saved with the Archive-name & part/patch no.\n");
  827. X        fprintf (fp, "save_archive=%s\n\n", (save_archive_name ? "ON" : "OFF"));
  828. X        fprintf (fp, "# (-s) if ON articles of a threads will be saved to separate files\n");
  829. X        fprintf (fp, "# otherwise the whole thread will be saved to one file\n");
  830. X        fprintf (fp, "save_separate=%s\n\n", (save_separate ? "ON" : "OFF"));
  831. X        fprintf (fp, "# if ON mark articles that are saved as read\n");
  832. X        fprintf (fp, "mark_saved_read=%s\n\n", (mark_saved_read ? "ON" : "OFF"));
  833. X        fprintf (fp, "# if ON show Subject & From otherwise just Subject\n");
  834. X        fprintf (fp, "show_author=%s\n\n", (show_author ? "ON" : "OFF"));
  835. X        fprintf (fp, "# if ON use -> otherwise highlighted bar for selection\n");
  836. X        fprintf (fp, "draw_arrow=%s\n\n", (draw_arrow_mark ? "ON" : "OFF"));
  837. X        fprintf (fp, "# if ON kill articles that match kill file\n");
  838. X        fprintf (fp, "kill_articles=%s\n\n", (kill_articles ? "ON" : "OFF"));
  839. X        fprintf (fp, "# if ON save articles/threads to subdir with Archive-name: under -d directory\n");
  840. X        fprintf (fp, "print_header=%s\n\n", (print_header ? "ON" : "OFF"));
  841. X        fprintf (fp, "# if ON post process saved articles/threads\n");
  842. X        fprintf (fp, "post_process=%s\n\n", (post_process ? "ON" : "OFF"));
  843. X        fprintf (fp, "# type of post processing to perform\n");
  844. X        fprintf (fp, "post_process_type=%d\n\n", post_proc_type);
  845. X        fprintf (fp, "# sort articles by 0) nothing 1) subject 2) from or 3) date field\n");
  846. X        fprintf (fp, "sort_article_type=%d\n\n", sort_art_type);
  847. X        fprintf (fp, "# (-d) directory where articles/threads are saved\n");
  848. X        fprintf (fp, "savedir=%s\n\n", savedir);
  849. X        fprintf (fp, "# (-M) directory where articles/threads are saved in mailbox format\n");    
  850. X        fprintf (fp, "maildir=%s\n\n", maildir);    
  851. X        fprintf (fp, "# (-p) print program with parameters used to print articles/threads\n");
  852. X        fprintf (fp, "printer=%s\n\n", printer);
  853. X        fprintf (fp, "# (-S) directory where news is spooled\n");
  854. X        fprintf (fp, "spooldir=%s\n\n", spooldir);
  855. X
  856. X        fprintf (fp, "# .signature file used for replies, followups\n");
  857. X        fprintf (fp, "signature=%s\n\n", signature);
  858. X        fprintf (fp, "# .Sig file used for postings\n");
  859. X        fprintf (fp, "sig=%s\n\n", sig);
  860. X
  861. X        fclose (fp);
  862. X        chmod (rcfile, 0600);
  863. X    }
  864. X    set_tin_uid_gid ();
  865. X}
  866. X
  867. X/*
  868. X *  options menu so that the user can dynamically change parameters
  869. X */
  870. Xint change_rcfile (group, kill_at_once)
  871. X    char *group;
  872. X    int kill_at_once;
  873. X{
  874. X    char *str;
  875. X    int ch;
  876. X    int kill_changed = FALSE;
  877. X    int orig_kill_state;
  878. X    int option;
  879. X    int ret_code = NO_KILLING;
  880. X#ifdef SIGTSTP
  881. X    void (*susp)();
  882. X
  883. X    if (do_sigtstp) {
  884. X#ifdef POSIX_JOB_CONTROL
  885. X        sigemptyset (&rcfile_act.sa_mask);
  886. X        rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
  887. X        rcfile_act.sa_handler = SIG_DFL;
  888. X        sigaction (SIGTSTP, &rcfile_act, &old_act);
  889. X#else
  890. X        susp = signal (SIGTSTP, SIG_DFL);
  891. X#endif
  892. X    }
  893. X#endif
  894. X
  895. X    show_rcfile_menu ();
  896. X
  897. X    while (1) {
  898. X
  899. X#ifdef SIGTSTP
  900. X        if (do_sigtstp) {
  901. X#ifdef POSIX_JOB_CONTROL
  902. X            sigemptyset (&rcfile_act.sa_mask);
  903. X            rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
  904. X            rcfile_act.sa_handler = rcfile_suspend;
  905. X            sigaction (SIGTSTP, &rcfile_act, 0L);
  906. X#else
  907. X            signal (SIGTSTP, rcfile_suspend);
  908. X#endif
  909. X        }
  910. X#endif
  911. X        show_menu_help (txt_select_rcfile_option);
  912. X        MoveCursor (LINES, 0);
  913. X        ch = ReadCh ();
  914. X        if (ch == '0') {
  915. X            option = 0;
  916. X        } else {
  917. X            option = parse_num (ch, "Enter option number> ");
  918. X        }
  919. X#ifdef SIGTSTP
  920. X        if (do_sigtstp) {
  921. X#ifdef POSIX_JOB_CONTROL
  922. X            sigemptyset (&rcfile_act.sa_mask);
  923. X            rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
  924. X            rcfile_act.sa_handler = SIG_IGN;
  925. X            sigaction (SIGTSTP, &rcfile_act, 0L);
  926. X#else
  927. X            signal (SIGTSTP, SIG_IGN);
  928. X#endif
  929. X        }
  930. X#endif
  931. X        switch (option) {
  932. X        case 0:
  933. X            write_rcfile ();
  934. X            if (kill_changed) {
  935. X                if (kill_at_once) {
  936. X                    if (kill_articles) {
  937. X                        read_kill_file ();
  938. X                        if (kill_any_articles (group)) {
  939. X                            reload_index_file (group, TRUE);    /* kill arts */
  940. X                        }
  941. X                    } else {
  942. X                        reload_index_file (group, FALSE);    /* add killed arts */
  943. X                    }
  944. X                }
  945. X                ret_code = KILLING;
  946. X            }
  947. X            clear_note_area ();
  948. X#ifdef SIGTSTP
  949. X            if (do_sigtstp) {
  950. X#ifdef POSIX_JOB_CONTROL
  951. X                sigemptyset (&rcfile_act.sa_mask);
  952. X                rcfile_act.sa_flags = SA_RESTART | SA_RESETHAND;
  953. X                rcfile_act.sa_handler = SIG_IGN;
  954. X                sigaction (SIGTSTP, &old_act, 0L);
  955. X#else
  956. X                signal (SIGTSTP, susp);
  957. X#endif
  958. X            }
  959. X#endif
  960. X            return ret_code;
  961. X            
  962. X        case 1:        /* auto save */
  963. X            show_menu_help (txt_help_autosave);
  964. X            do {
  965. X                MoveCursor (INDEX_TOP, strlen (txt_opt_autosave));
  966. X                if ((ch = ReadCh()) == ' ') {
  967. X                    save_archive_name = !save_archive_name;
  968. X                    printf ("%s", (save_archive_name ? "ON " : "OFF"));
  969. X                    fflush(stdout);
  970. X                }
  971. X            } while (ch != CR);
  972. X            break;
  973. X
  974. X        case 2:        /* save sperate */
  975. X            show_menu_help (txt_help_save_separate);
  976. X            do {
  977. X                MoveCursor (INDEX_TOP, COL2 + (int) strlen (txt_opt_save_separate));
  978. X                if ((ch = ReadCh()) == ' ') {
  979. X                    save_separate = !save_separate;
  980. X                    printf ("%s", (save_separate ? "ON " : "OFF"));
  981. X                    fflush(stdout);
  982. X                }
  983. X            } while (ch != CR);
  984. X            break;
  985. X            
  986. X        case 3:        /* mark saved articles read */
  987. X            show_menu_help (txt_help_mark_saved_read);
  988. X            do {
  989. X                MoveCursor (INDEX_TOP+2, strlen (txt_opt_mark_saved_read));
  990. X                if ((ch = ReadCh()) == ' ') {
  991. X                    mark_saved_read = !mark_saved_read;
  992. X                    printf ("%s", (mark_saved_read ? "ON " : "OFF"));
  993. X                    fflush(stdout);
  994. X                }
  995. X            } while (ch != CR);
  996. X            break;
  997. X
  998. X        case 4:        /* kill articles */
  999. X            orig_kill_state = kill_articles;
  1000. X            show_menu_help (txt_help_kill_articles);
  1001. X            do {
  1002. X                MoveCursor (INDEX_TOP+2, COL2 + (int) strlen (txt_opt_kill_articles));
  1003. X                if ((ch = ReadCh()) == ' ') {
  1004. X                    kill_articles = !kill_articles;
  1005. X                    kill_changed = (kill_articles != orig_kill_state ? TRUE : FALSE);
  1006. X                    printf ("%s", (kill_articles ? "ON " : "OFF"));
  1007. X                    fflush(stdout);
  1008. X                }
  1009. X            } while (ch != CR);
  1010. X            break;
  1011. X
  1012. X        case 5:        /* show subject & author / subject only */
  1013. X            show_menu_help (txt_help_show_author);
  1014. X            do {
  1015. X                MoveCursor (INDEX_TOP+4, strlen (txt_opt_show_author));
  1016. X                if ((ch = ReadCh()) == ' ') {
  1017. X                    show_author = !show_author;
  1018. X                    printf ("%s", (show_author ? "ON " : "OFF"));
  1019. X                    fflush(stdout);    
  1020. X                }
  1021. X            } while (ch != CR);
  1022. X            break;
  1023. X            
  1024. X        case 6:        /* draw -> / highlighted bar */
  1025. X            show_menu_help (txt_help_draw_arrow);
  1026. X            do {
  1027. X                MoveCursor (INDEX_TOP+4, COL2 + (int) strlen (txt_opt_draw_arrow));
  1028. X                if ((ch = ReadCh()) == ' ') {
  1029. X                    draw_arrow_mark = !draw_arrow_mark;
  1030. X                    printf ("%s", (draw_arrow_mark ? "ON " : "OFF"));
  1031. X                    fflush(stdout);
  1032. X                }
  1033. X            } while (ch != CR);
  1034. X            if (draw_arrow_mark == FALSE && inverse_okay == FALSE) {
  1035. X                inverse_okay = TRUE;
  1036. X            }
  1037. X            break;
  1038. X
  1039. X        case 7:        /* post process saved files */
  1040. X            show_menu_help (txt_help_post_process);
  1041. X            do {
  1042. X                MoveCursor (INDEX_TOP+6, strlen (txt_opt_post_process));
  1043. X                if ((ch = ReadCh()) == ' ') {
  1044. X                    post_process = !post_process;
  1045. X                    printf ("%s", (post_process ? "ON " : "OFF"));
  1046. X                    fflush(stdout);
  1047. X                }
  1048. X            } while (ch != CR);
  1049. X            break;
  1050. X            
  1051. X        case 8:        /* print header */
  1052. X            show_menu_help (txt_help_print_header);
  1053. X            do {
  1054. X                MoveCursor (INDEX_TOP+6, COL2 + (int) strlen (txt_opt_print_header));
  1055. X                if ((ch = ReadCh()) == ' ') {
  1056. X                    print_header = !print_header;
  1057. X                    printf ("%s", (print_header ? "ON " : "OFF"));
  1058. X                    fflush(stdout);
  1059. X                }
  1060. X            } while (ch != CR);
  1061. X            break;
  1062. X            
  1063. X        case 9:
  1064. X            show_menu_help (txt_help_post_proc_type);
  1065. X            do {
  1066. X                MoveCursor (INDEX_TOP+8, strlen (txt_opt_process_type));
  1067. X                if ((ch    = ReadCh()) == ' ') {
  1068. X                    if (post_proc_type + 1 > POST_PROC_PATCH) {
  1069. X                        post_proc_type = POST_PROC_SH;
  1070. X                    } else {
  1071. X                        post_proc_type++;
  1072. X                    }
  1073. X                    switch (post_proc_type) {
  1074. X                        case POST_PROC_SH:
  1075. X                            str = txt_post_process_sh;
  1076. X                            break;
  1077. X                        case POST_PROC_UUD:
  1078. X                            str = txt_post_process_uud;
  1079. X                            break;
  1080. X                        case POST_PROC_UUD_ZOO:
  1081. X                            str = txt_post_process_uud_zoo;
  1082. X                            break;
  1083. X                        case POST_PROC_UUD_LZH:
  1084. X                            str = txt_post_process_uud_lzh;
  1085. X                            break;
  1086. X                        case POST_PROC_UUD_ARC:
  1087. X                            str = txt_post_process_uud_arc;
  1088. X                            break;
  1089. X                        case POST_PROC_UUD_ZIP:
  1090. X                            str = txt_post_process_uud_zip;
  1091. X                            break;
  1092. X                        case POST_PROC_PATCH:
  1093. X                            str = txt_post_process_patch;
  1094. X                            break;
  1095. X                    }
  1096. X                    CleartoEOLN (); 
  1097. X                    printf ("%s", str);
  1098. X                    fflush(stdout);
  1099. X                }
  1100. X            } while (ch != CR);
  1101. X            break;
  1102. X        case 10:
  1103. X            show_menu_help (txt_help_sort_type);
  1104. X            do {
  1105. X                MoveCursor (INDEX_TOP+10, strlen (txt_opt_sort_type));
  1106. X                if ((ch    = ReadCh()) == ' ') {
  1107. X                    if (sort_art_type + 1 > SORT_BY_DATE) {
  1108. X                        sort_art_type = SORT_BY_NONE;
  1109. X                    } else {
  1110. X                        sort_art_type++;
  1111. X                    }
  1112. X                    switch (sort_art_type) {
  1113. X                        case SORT_BY_NONE:
  1114. X                            str = txt_sort_by_none;
  1115. X                            break;
  1116. X                        case SORT_BY_SUBJ:
  1117. X                            str = txt_sort_by_subj;
  1118. X                            break;
  1119. X                        case SORT_BY_FROM:
  1120. X                            str = txt_sort_by_from;
  1121. X                            break;
  1122. X                        case SORT_BY_DATE:
  1123. X                            str = txt_sort_by_date;
  1124. X                            break;
  1125. X                    }
  1126. X                    CleartoEOLN (); 
  1127. X                    printf ("%s", str);
  1128. X                    fflush(stdout);
  1129. X                }
  1130. X            } while (ch != CR);
  1131. X            break;
  1132. X        case 11:
  1133. X            show_menu_help (txt_help_savedir);
  1134. X            parse_menu_string (INDEX_TOP+12, strlen (txt_opt_savedir), savedir);
  1135. X            expand_rel_abs_pathname (INDEX_TOP+12, strlen (txt_opt_savedir), savedir);
  1136. X            break;
  1137. X        case 12:
  1138. X            show_menu_help (txt_help_maildir);
  1139. X            parse_menu_string (INDEX_TOP+14, strlen (txt_opt_maildir), maildir);
  1140. X            expand_rel_abs_pathname (INDEX_TOP+14, strlen (txt_opt_maildir), maildir);
  1141. X            break;
  1142. X        case 13:
  1143. X            show_menu_help (txt_help_printer);
  1144. X            parse_menu_string (INDEX_TOP+16, strlen (txt_opt_printer), printer);
  1145. X            expand_rel_abs_pathname (INDEX_TOP+16, strlen (txt_opt_printer), printer);
  1146. X            break;
  1147. X    }
  1148. X    }
  1149. X}
  1150. X
  1151. Xvoid show_rcfile_menu ()
  1152. X{
  1153. X    char *str;
  1154. X
  1155. X    ClearScreen ();
  1156. X    printf("%s\r\n", nice_time());    /* time in upper left */
  1157. X
  1158. X    center_line (1, TRUE, txt_options_menu);
  1159. X    
  1160. X    MoveCursor(INDEX_TOP, 0);
  1161. X    printf ("%s%s\r\n\r\n", txt_opt_autosave, (save_archive_name ? "ON " : "OFF"));
  1162. X    printf ("%s%s\r\n\r\n", txt_opt_mark_saved_read, (mark_saved_read ? "ON " : "OFF"));
  1163. X    printf ("%s%s\r\n\r\n", txt_opt_show_author, (show_author ? "ON " : "OFF"));
  1164. X    printf ("%s%s", txt_opt_post_process, (post_process ? "ON " : "OFF"));
  1165. X
  1166. X    MoveCursor(INDEX_TOP, COL2);
  1167. X    printf ("%s%s", txt_opt_save_separate, (save_separate ? "ON " : "OFF"));
  1168. X    MoveCursor(INDEX_TOP+2, COL2);
  1169. X    printf ("%s%s", txt_opt_kill_articles, (kill_articles ? "ON " : "OFF"));
  1170. X    MoveCursor(INDEX_TOP+4, COL2);
  1171. X    printf ("%s%s", txt_opt_draw_arrow, (draw_arrow_mark ? "ON " : "OFF"));
  1172. X    MoveCursor(INDEX_TOP+6, COL2);
  1173. X    printf ("%s%s", txt_opt_print_header, (print_header ? "ON " : "OFF"));
  1174. X
  1175. X
  1176. X    MoveCursor(INDEX_TOP+8, 0);
  1177. X    switch (post_proc_type) {
  1178. X        case POST_PROC_SH:
  1179. X            str = txt_post_process_sh;
  1180. X            break;
  1181. X        case POST_PROC_UUD:
  1182. X            str = txt_post_process_uud;
  1183. X            break;
  1184. X        case POST_PROC_UUD_ZOO:
  1185. X            str = txt_post_process_uud_zoo;
  1186. X            break;
  1187. X        case POST_PROC_UUD_LZH:
  1188. X            str = txt_post_process_uud_lzh;
  1189. X            break;
  1190. X        case POST_PROC_UUD_ARC:
  1191. X            str = txt_post_process_uud_arc;
  1192. X            break;
  1193. X        case POST_PROC_UUD_ZIP:
  1194. X            str = txt_post_process_uud_zip;
  1195. X            break;
  1196. X        case POST_PROC_PATCH:
  1197. X            str = txt_post_process_patch;
  1198. X            break;
  1199. X    }
  1200. X    printf ("%s%s\r\n\r\n", txt_opt_process_type, str);
  1201. X    
  1202. X    MoveCursor(INDEX_TOP+10, 0);
  1203. X    switch (sort_art_type) {
  1204. X        case SORT_BY_NONE:
  1205. X            str = txt_sort_by_none;
  1206. X            break;
  1207. X        case SORT_BY_SUBJ:
  1208. X            str = txt_sort_by_subj;
  1209. X            break;
  1210. X        case SORT_BY_FROM:
  1211. X            str = txt_sort_by_from;
  1212. X            break;
  1213. X        case SORT_BY_DATE:
  1214. X            str = txt_sort_by_date;
  1215. X            break;
  1216. X    }
  1217. X    printf ("%s%s\r\n\r\n", txt_opt_sort_type, str);
  1218. X
  1219. X    printf ("%s%s\r\n\r\n", txt_opt_savedir, savedir);
  1220. X    printf ("%s%s\r\n\r\n", txt_opt_maildir, maildir);
  1221. X    printf ("%s%s\r\n\r\n", txt_opt_printer, printer);
  1222. X    fflush(stdout);
  1223. X
  1224. X    show_menu_help (txt_select_rcfile_option);
  1225. X    MoveCursor (LINES, 0);
  1226. X}
  1227. X
  1228. X/*
  1229. X *  parse_menu_string
  1230. X *  get a string from the user
  1231. X *  Return TRUE if a valid string was typed, FALSE otherwise
  1232. X */
  1233. X
  1234. Xvoid parse_menu_string (line, col, var)
  1235. X    int line;
  1236. X    int col;
  1237. X    char *var;
  1238. X{
  1239. X    char buf[LEN+1];
  1240. X    char ch;
  1241. X    int len;
  1242. X    int i;
  1243. X
  1244. X    MoveCursor (line, col);
  1245. X    buf[0] = '\0';
  1246. X    len = 0;
  1247. X    ch = ReadCh();
  1248. X    while (ch != '\n' && ch != '\r') {
  1249. X        if (ch == 8 || ch == 127) {
  1250. X            if (len) {
  1251. X                len--;
  1252. X                buf[len] = '\0';
  1253. X                putchar('\b');
  1254. X                putchar(' ');
  1255. X                putchar('\b');
  1256. X            } else {
  1257. X                strcpy (var, buf);
  1258. X                MoveCursor(line, col);
  1259. X                CleartoEOLN();
  1260. X            }
  1261. X        } else if (ch == 21) {    /* control-U    */
  1262. X            for (i = len;i>0;i--) {
  1263. X                putchar('\b');
  1264. X                putchar(' ');
  1265. X                putchar('\b');
  1266. X            }
  1267. X            buf[0] = '\0';
  1268. X            len = 0;
  1269. X        } else if (ch >= ' ' && len < 60) {
  1270. X            buf[len++] = ch;
  1271. X            buf[len] = '\0';
  1272. X            putchar (ch);
  1273. X        } else
  1274. X            putchar(7);
  1275. X        fflush(stdout);
  1276. X        ch = ReadCh();
  1277. X    }
  1278. X
  1279. X    if (buf[0]) {
  1280. X        strcpy (var, buf);
  1281. X    }
  1282. X}
  1283. X
  1284. X/*
  1285. X *  expand ~/News to /usr/username/News and print to screen
  1286. X */
  1287. Xvoid expand_rel_abs_pathname (line, col, str)
  1288. X    int line;
  1289. X    int col;
  1290. X    char *str;
  1291. X{
  1292. X    char buf[LEN+1];
  1293. X    
  1294. X    if (str[0] == '~') {
  1295. X        if (strlen (str) == 1) {
  1296. X            strcpy (str, homedir);
  1297. X        } else {
  1298. X            sprintf (buf, "%s%s", homedir, str+1);
  1299. X            strcpy (str, buf);
  1300. X        }
  1301. X    }
  1302. X    MoveCursor (line, col);
  1303. X    CleartoEOLN ();
  1304. X    puts (str);
  1305. X    fflush (stdout);
  1306. X}
  1307. X
  1308. X/*
  1309. X *  show_menu_help
  1310. X */
  1311. Xvoid show_menu_help (help_message)
  1312. X    char *help_message;
  1313. X{
  1314. X     MoveCursor (INDEX_TOP+18, 0);
  1315. X     CleartoEOLN ();
  1316. X     center_line (INDEX_TOP+18, FALSE, help_message);
  1317. X}
  1318. SHAR_EOF
  1319. $TOUCH -am 0903095091 rcfile.c &&
  1320. chmod 0600 rcfile.c ||
  1321. echo "restore of rcfile.c failed"
  1322. set `wc -c rcfile.c`;Wc_c=$1
  1323. if test "$Wc_c" != "16801"; then
  1324.     echo original size 16801, current size $Wc_c
  1325. fi
  1326. # ============= save.c ==============
  1327. echo "x - extracting save.c (Text)"
  1328. sed 's/^X//' << 'SHAR_EOF' > save.c &&
  1329. X/*
  1330. X *  Project   : tin - a visual threaded usenet newsreader
  1331. X *  Module    : save.c
  1332. X *  Author    : R.Skrenta / I.Lea
  1333. X *  Created   : 01-04-91
  1334. X *  Updated   : 03-09-91
  1335. X *  Release   : 1.0
  1336. X *  Notes     :
  1337. X *  Copyright : (c) Copyright 1991 by Rich Skrenta, Iain Lea & Wayne Brandt
  1338. X *                You may  freely  copy or  redistribute  this software,
  1339. X *              so  long as there is no profit made from its use, sale
  1340. X *              trade or  reproduction.  You may not change this copy-
  1341. X *              right notice, and it must be included in any copy made
  1342. X */
  1343. X
  1344. X#include    "tin.h"
  1345. X
  1346. X#define    INITIAL        1
  1347. X#define MIDDLE        2
  1348. X#define OFF            3
  1349. X#define END            4
  1350. X
  1351. Xint create_subdir = TRUE;
  1352. X
  1353. Xstruct save_t *save;
  1354. Xint save_num=0;
  1355. Xint max_save;
  1356. X
  1357. X/*
  1358. X * types of archive programs
  1359. X * 0=archiver, 1=extension, 2=extract option, 3=list option
  1360. X */
  1361. Xstruct archiver_t { 
  1362. X    char *name;
  1363. X    char *ext;
  1364. X    char *extract;
  1365. X    char *list;
  1366. X};
  1367. X
  1368. Xstruct archiver_t archiver[] = {
  1369. X    { "",      "",    "",         "" },
  1370. X    { "",      "",    "",         "" },
  1371. X    { "",      "",    "",         "" },
  1372. X    { "zoo",   "zoo", "-extract", "-list" },
  1373. X    { "lharc", "lzh", "x",        "l" },
  1374. X    { "arc",   "arc", "x",        "l" },
  1375. X    { "zip",   "zip", "-x",       "-l" },
  1376. X    { "",      "",    "",         "" }
  1377. X};
  1378. X
  1379. Xextern char *glob_group;
  1380. Xextern char note_h_path[LEN+1];    /* Path:    */
  1381. Xextern char note_h_date[LEN+1];    /* Date:    */
  1382. Xextern FILE    *note_fp;            /* the body of the current article */
  1383. Xextern int index_point;
  1384. Xextern int note_end;
  1385. Xextern int note_page;
  1386. Xextern long note_mark[MAX_PAGES];
  1387. X
  1388. X
  1389. Xint save_art_to_file (respnum, index, mailbox, filename)
  1390. X    int respnum;
  1391. X    int index;
  1392. X    int mailbox;
  1393. X    char *filename;
  1394. X{
  1395. X    char file[LEN+1], *p;
  1396. X    char save_art_info[LEN+1];
  1397. X    FILE *fp;
  1398. X    int is_mailbox = FALSE;
  1399. X    int i = 0, ret_code = FALSE;
  1400. X    
  1401. X    if (filename) {
  1402. X        my_strncpy (file, filename, LEN);
  1403. X        is_mailbox = mailbox;
  1404. X        i = index;
  1405. X    } else if (save_archive_name && arts[respnum].archive) {
  1406. X            my_strncpy (file, arts[respnum].archive, LEN);
  1407. X    }
  1408. X
  1409. X    if (! append_to_existing_file (i)) {
  1410. X        save[i].saved = FALSE;
  1411. X        info_message (txt_art_not_saved);
  1412. X        sleep (1);
  1413. X        return (ret_code);
  1414. X    }
  1415. X
  1416. X    set_real_uid_gid ();
  1417. X
  1418. X    if ((fp = fopen (save_filename (i), "a+")) == NULL) {
  1419. X        save[i].saved = FALSE;
  1420. X        info_message (txt_art_not_saved);
  1421. X        set_tin_uid_gid ();
  1422. X        return (ret_code);
  1423. X    }
  1424. X
  1425. X    if (! filename) {
  1426. X        wait_message (txt_saving);
  1427. X    }
  1428. X    
  1429. X    fprintf(fp, "From %s %s\n", note_h_path, note_h_date);
  1430. X
  1431. X    if (fseek(note_fp, 0L, 0) == -1) {
  1432. X        error_message ("fseek error on \"%s\"", arts[respnum].subject);
  1433. X    }
  1434. X    copy_fp(note_fp, fp, "");
  1435. X    fputs("\n", fp);
  1436. X    fclose(fp);
  1437. X    fseek(note_fp, note_mark[note_page], 0);
  1438. X
  1439. X    save[i].saved = TRUE;
  1440. X
  1441. X    if (mark_saved_read) {
  1442. X        arts[respnum].unread = ART_READ;
  1443. X    }
  1444. X    
  1445. X    set_tin_uid_gid ();
  1446. X
  1447. X    if (! filename) {
  1448. X        if (is_mailbox) {
  1449. X            sprintf (save_art_info, txt_saved_to_mailbox, get_first_savefile ());
  1450. X        } else {
  1451. X            sprintf (save_art_info, txt_art_saved_to, get_first_savefile ());
  1452. X        }
  1453. X        info_message(save_art_info);
  1454. X    }
  1455. X    return TRUE;
  1456. X}
  1457. X
  1458. X
  1459. Xint save_thread_to_file (respnum, is_mailbox, group_path)
  1460. X    int respnum;
  1461. X    int is_mailbox;
  1462. X    char *group_path;
  1463. X{
  1464. X    char *p;
  1465. X    char save_thread_info[LEN+1];
  1466. X    char *first_savefile;
  1467. X    FILE *fp;
  1468. X    int count = 0;
  1469. X    int b, i, ret_code = FALSE;
  1470. X
  1471. X    set_real_uid_gid ();
  1472. X
  1473. X    for (i=0 ; i < save_num ; i++) {
  1474. X        if (! append_to_existing_file (i)) {
  1475. X            save[i].saved = FALSE;
  1476. X            info_message (txt_art_not_saved);
  1477. X            sleep (1);
  1478. X            continue;
  1479. X        } else {
  1480. X            sprintf (msg, "%s%d", txt_saving, ++count);
  1481. X            wait_message (msg);
  1482. X        }
  1483. X
  1484. X        if ((fp = fopen (save_filename (i), "a+")) == NULL) {
  1485. X            info_message (txt_thread_not_saved);
  1486. X            set_tin_uid_gid ();
  1487. X            return (ret_code);
  1488. X        }    
  1489. X
  1490. X        open_note (arts[save[i].index].artnum, group_path);
  1491. X        fprintf (fp, "From %s %s\n", note_h_path, note_h_date);
  1492. X        fseek (note_fp, 0L, 0);
  1493. X        copy_fp (note_fp, fp, "");
  1494. X        note_cleanup ();
  1495. X        save[i].saved = TRUE;
  1496. X
  1497. X        if (mark_saved_read) {
  1498. X            arts[save[i].index].unread = ART_READ;
  1499. X        }
  1500. X
  1501. X        fclose (fp);
  1502. X    }
  1503. X    set_tin_uid_gid ();
  1504. X    
  1505. X    if (! (first_savefile = get_first_savefile ())) {
  1506. X        info_message (txt_thread_not_saved);
  1507. X    } else {
  1508. X        if (is_mailbox) {
  1509. X            sprintf (save_thread_info, txt_saved_to_mailbox, first_savefile);
  1510. X        } else {
  1511. X            if (save_num == 1) {
  1512. X                sprintf (save_thread_info, txt_art_saved_to, first_savefile);
  1513. X            } else {
  1514. X                if (save_separate) {
  1515. X                    sprintf (save_thread_info, txt_thread_saved_to_many,
  1516. X                        first_savefile, get_last_savefile ());
  1517. X                } else {
  1518. X                    sprintf (save_thread_info, txt_thread_saved_to,
  1519. X                        first_savefile);
  1520. X                }
  1521. X            }
  1522. X            free (first_savefile);
  1523. X            first_savefile = (char *) 0;
  1524. X        }
  1525. X        info_message (save_thread_info);
  1526. X    }
  1527. X    return TRUE;
  1528. X}
  1529. X
  1530. X
  1531. Xint save_regex_arts (is_pattern, pattern, is_mailbox, group_path)
  1532. X    int is_pattern;
  1533. X    char *pattern;
  1534. X    int is_mailbox;
  1535. X    char *group_path;
  1536. X{
  1537. X    char buf[LEN+1];
  1538. X    char buf2[LEN+1];
  1539. X    char dir[LEN+1];
  1540. X    char mailbox[LEN+1];
  1541. X    int i, j, ret_code;     
  1542. X    
  1543. X    for (i=0 ; i < save_num ; i++) {
  1544. X        sprintf(buf, "%s%d", txt_saving, i+1);
  1545. X        wait_message (buf);
  1546. X
  1547. X        if (is_mailbox) {
  1548. X            strcpy (buf2, mailbox);
  1549. X        }else {
  1550. X            sprintf (buf2, "%s.%02d", save[i].file, i+1);
  1551. X        }
  1552. X
  1553. X        open_note (arts[save[i].index].artnum, group_path);
  1554. X        ret_code = save_art_to_file (save[i].index, i, is_mailbox, buf2);
  1555. X        note_cleanup ();            
  1556. X        save[i].saved = TRUE;
  1557. X    }
  1558. X
  1559. X    if (! save_num) {    
  1560. X        info_message(txt_no_match);
  1561. X    } else {
  1562. X        if (is_mailbox) {
  1563. X            sprintf (buf, txt_saved_to_mailbox, get_first_savefile ());
  1564. X        } else {
  1565. X            sprintf (buf,txt_saved_pattern_to,
  1566. X                get_first_savefile (), get_last_savefile ());
  1567. X        }
  1568. X        info_message(buf);
  1569. X    }
  1570. X    return (ret_code);
  1571. X}
  1572. X
  1573. X
  1574. Xint append_to_existing_file (i)
  1575. X    int i;
  1576. X{
  1577. X    char buf[LEN+1];
  1578. X    char *file;
  1579. X    struct stat st;
  1580. X
  1581. X    if (! save[i].is_mailbox && save_separate) {
  1582. X        file = save_filename (i);
  1583. X        if (stat(file, &st) != -1) {    
  1584. X            sprintf (buf, txt_append_to_file, file); 
  1585. X            if (! prompt_yn (LINES, buf, 'n')) {
  1586. X                free (file);
  1587. X                file = NULL;
  1588. X                return FALSE;
  1589. X            }
  1590. X        }
  1591. X        free (file);
  1592. X        file = NULL;
  1593. X    }
  1594. X    
  1595. X    return TRUE;
  1596. X}
  1597. X
  1598. X
  1599. Xint create_path (path)
  1600. X    char *path;
  1601. X{
  1602. X    char buf [LEN+1];
  1603. X    int i, j, len;
  1604. X    struct stat st;
  1605. X    
  1606. X    /*
  1607. X     * save in mailbox format to ~/Mail/<group.name>
  1608. X     */
  1609. X    if (path[0] == '=') {
  1610. X        return TRUE;
  1611. X    }
  1612. X
  1613. X    /*
  1614. X     * if ~/file expand (ie. /usr/homedir/file)
  1615. X     */
  1616. X    switch (path[0]) {
  1617. X        case '~':
  1618. X            my_strncpy (buf, path+1, LEN);
  1619. X            sprintf (path, "%s%s", homedir, buf);
  1620. X            break;
  1621. X        case '.':
  1622. X            error_message ("Cannot create %s", buf);
  1623. X            return FALSE;
  1624. X            break;
  1625. X        default:
  1626. X            sprintf (buf, "%s/%s", savedir, path);
  1627. X            my_strncpy (path, buf, LEN);
  1628. X            break;
  1629. X    }
  1630. X
  1631. X    /*
  1632. X     *  create any directories, otherwise check
  1633. X     *  errno and give appropiate error message
  1634. X     */
  1635. X    len = (int) strlen (path);
  1636. X    
  1637. X    for (i=0, j=0 ; i < len ; i++, j++) {
  1638. X        buf[j] = path[i];
  1639. X        if (i+1 < len && path[i+1] == '/') {
  1640. X            buf[j+1] = '\0';
  1641. X            if (stat (buf, &st) == -1) {
  1642. X                if (mkdir (buf, 0755) == -1) {
  1643. X                    error_message ("Cannot create %s", buf);
  1644. X                    return FALSE;
  1645. X                }
  1646. X            }
  1647. X        }
  1648. X    }
  1649. X    return FALSE;
  1650. X}
  1651. X
  1652. X
  1653. Xint create_sub_dir (i)
  1654. X    int i;
  1655. X{
  1656. X    char dir[LEN+1];
  1657. X    struct stat st;
  1658. X
  1659. X    if (! save[i].is_mailbox && save[i].archive) {
  1660. X        sprintf (dir, "%s/%s", save[i].dir, save[i].archive);
  1661. X        if (stat (dir, &st) == -1) {
  1662. X            mkdir (dir, 0755);
  1663. X            return TRUE;
  1664. X        }
  1665. X        if ((st.st_mode & S_IFMT) == S_IFDIR) {
  1666. X            return TRUE;
  1667. X        } else {
  1668. X            return FALSE;
  1669. X        }
  1670. X    }
  1671. X    return FALSE;
  1672. X}
  1673. X
  1674. X/*
  1675. X *  add files to be saved to save array
  1676. X */
  1677. X
  1678. Xvoid add_to_save_list (index, article, is_mailbox, path)
  1679. X    int index;
  1680. X    struct header *article;
  1681. X    int is_mailbox;
  1682. X    char *path;
  1683. X{
  1684. X    char dir[LEN+1];
  1685. X    char file[LEN+1];
  1686. X    int i;
  1687. X    
  1688. X    dir[0] = '\0';
  1689. X    file[0] = '\0';
  1690. X
  1691. X    if (save_num == max_save-1) {
  1692. X        expand_save ();
  1693. X    }
  1694. X
  1695. X    save[save_num].index   = index;
  1696. X    save[save_num].saved   = FALSE;
  1697. X    save[save_num].is_mailbox = is_mailbox;
  1698. X    save[save_num].dir     = (char *) 0;
  1699. X    save[save_num].file    = (char *) 0;
  1700. X    save[save_num].archive = (char *) 0;
  1701. X    save[save_num].part    = (char *) 0;
  1702. X    save[save_num].patch   = (char *) 0;
  1703. X
  1704. X    save[save_num].subject = str_dup (article->subject);
  1705. X    if (article->archive) {
  1706. X        save[save_num].archive = str_dup (article->archive);
  1707. X    }
  1708. X    if (article->part) {
  1709. X        save[save_num].part = str_dup (article->part);
  1710. X    }
  1711. X    if (article->patch) {
  1712. X        save[save_num].patch = str_dup (article->patch);
  1713. X    }
  1714. X
  1715. X    if (is_mailbox) {
  1716. X        if ((int) strlen (path) > 1) {
  1717. X            if (path[0] == '=') {
  1718. X                strcpy (file, path+1);
  1719. X            } else {
  1720. X                strcpy (file, path);
  1721. X            }
  1722. X        } else {
  1723. X            strcpy (file, glob_group);
  1724. X        }
  1725. X        save[save_num].dir = maildir;
  1726. X        save[save_num].file = str_dup (file);
  1727. X    } else {
  1728. X        if (path[0]) {
  1729. X            for (i=strlen (path) ; i ; i--) {
  1730. X                if (path[i] == '/') {
  1731. X                    strncpy (dir, path, i);
  1732. X                    dir[i] = '\0';
  1733. X                    strcpy (file, path+i+1);
  1734. X                    break;
  1735. X                }
  1736. X            }
  1737. X        }
  1738. X        
  1739. X        if (dir[0]) {
  1740. X            save[save_num].dir = str_dup (dir);
  1741. X        } else {
  1742. X            save[save_num].dir = str_dup (savedir);
  1743. X        }
  1744. X
  1745. X        if (file[0]) {
  1746. X            save[save_num].file = str_dup (file);
  1747. X        } else {
  1748. X            if (path[0]) {
  1749. X                save[save_num].file = str_dup (path);
  1750. X            } else {
  1751. X                save[save_num].file = save[save_num].archive;
  1752. X            }
  1753. X        }
  1754. X    }
  1755. X    save_num++;
  1756. X}
  1757. X
  1758. X/*
  1759. X *  print save array of files to be saved
  1760. X */
  1761. X
  1762. Xvoid sort_save_list ()
  1763. X{
  1764. X    qsort (save, save_num, sizeof (struct save_t), save_comp);
  1765. X}
  1766. X
  1767. X/*
  1768. X *  string comparison routine for the qsort()
  1769. X *  ie. qsort(array, 5, 32, save_comp);
  1770. X */
  1771. X
  1772. Xint save_comp (s1, s2)
  1773. X    struct save_t *s1;
  1774. X    struct save_t *s2;
  1775. X{
  1776. X    /* s1->subject less than s2->subject */
  1777. X    if (strcmp (s1->subject, s2->subject) < 0) {
  1778. X        return -1;
  1779. X    }
  1780. X    /* s1->subject greater than s2->subject */
  1781. X    if (strcmp (s1->subject, s2->subject) > 0) {
  1782. X        return 1;
  1783. X    }
  1784. X    return 0;
  1785. X}
  1786. X
  1787. X
  1788. Xchar *save_filename (i)
  1789. X    int i;
  1790. X{
  1791. X    char *filename;
  1792. X
  1793. X    filename = (char *) my_malloc (LEN);
  1794. X
  1795. X    if (save[i].is_mailbox) {
  1796. X        sprintf (filename, "%s/%s", save[i].dir, save[i].file);
  1797. X        return (filename);
  1798. X    }
  1799. X    
  1800. X    if (! save_separate || ! save_archive_name || (! save[i].part && ! save[i].patch)) {
  1801. X        if (! save_separate || save_num == 1) {
  1802. X            sprintf (filename, "%s/%s", save[i].dir, save[i].file);
  1803. X        } else {
  1804. X            sprintf (filename, "%s/%s.%02d", save[i].dir, save[i].file, i+1);
  1805. X        }
  1806. X    } else {
  1807. X        if (save[i].part) {
  1808. SHAR_EOF
  1809. echo "End of tin1.0 part 6"
  1810. echo "File save.c is continued in part 7"
  1811. echo "7" > shar3_seq_.tmp
  1812. exit 0
  1813.  
  1814.  
  1815. --
  1816. NAME   Iain Lea
  1817. EMAIL  norisc!iain@estevax.UUCP  ...!unido!estevax!norisc!iain
  1818. SNAIL  Siemens AG, AUT 922C, Postfach 4848, Nuernberg, Germany
  1819. PHONE  +49-911-895-3853, +49-911-895-3877, +49-911-331963
  1820.