home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / mush.lzh / mush.10 < prev    next >
Text File  |  1990-05-06  |  55KB  |  1,712 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive.  Remove anything before this line, then feed it
  4. # into a shell via "sh file" or similar.  To overwrite existing files,
  5. # type "sh file -c".
  6. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  7. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  8. # If this archive is complete, you will see the following message at the end:
  9. #        "End of archive 10 (of 19)."
  10. # Contents:  mush/curses.c mush/mush.h mush/version.h
  11. # Wrapped by argv@turnpike on Wed May  2 13:59:31 1990
  12. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  13. if test -f 'mush/curses.c' -a "${1}" != "-c" ; then 
  14.   echo shar: Will not clobber existing file \"'mush/curses.c'\"
  15. else
  16. echo shar: Extracting \"'mush/curses.c'\" \(28433 characters\)
  17. sed "s/^X//" >'mush/curses.c' <<'END_OF_FILE'
  18. X/* @(#)curses.c    (c) copyright 3/18/87 (Dan Heller) */
  19. X
  20. X/* curses.c -- routine to deal with the curses interface */
  21. X#ifdef CURSES
  22. X
  23. X#include "mush.h"
  24. X#include "bindings.h"
  25. X
  26. Xcurses_init(argc, argv)
  27. Xregister char **argv;
  28. X{
  29. X    char buf[80];
  30. X    extern char *UP, ttytype[];
  31. X
  32. X    if (argv && *++argv && !strcmp(*argv, "-?"))
  33. X    return help(0, "curses", cmd_help);
  34. X#ifdef SUNTOOL
  35. X    if (istool) {
  36. X    print("Sorry, can't change to curses mode from tool.\n");
  37. X    return -1;
  38. X    } else
  39. X#endif /* SUNTOOL */
  40. X    if (!is_shell) {
  41. X    /*
  42. X     * Can't start curses, but we can prepare to.
  43. X     * Also allow -C switch to be shut off.
  44. X     */
  45. X    if (argv && *argv && !lcase_strncmp(*argv, "off", -1))
  46. X        turnoff(glob_flags, PRE_CURSES);
  47. X    else
  48. X        turnon(glob_flags, PRE_CURSES);
  49. X    return 0;
  50. X    } else if (argc && (iscurses || ison(glob_flags, PRE_CURSES))) {
  51. X    print("You are already using curses mode.\n");
  52. X    return -1;
  53. X    } else if (ison(glob_flags, IS_GETTING)) {
  54. X    print("Finish your letter first.\n");
  55. X    return -1;
  56. X    }
  57. X
  58. X#ifndef attrset        /* terminfo version of curses */
  59. X    /* you can not start curses in no echo mode.. must be in normal mode */
  60. X    echom();
  61. X    nocrmode();
  62. X#endif /* attrset */
  63. X    (void) initscr();
  64. X#ifdef SIGCONT
  65. X    /* initscr will play with signals -- make sure they're set right. */
  66. X    (void) signal(SIGTSTP, stop_start);
  67. X    (void) signal(SIGCONT, stop_start);
  68. X#endif /* SIGCONT */
  69. X#if !defined(SYSV) && !defined(USG)
  70. X    if (!UP || !*UP)
  71. X#else /* ~SYSV && ~USG */
  72. X    if (!stdscr)
  73. X#endif /* ~SYSV && ~USG */
  74. X         {
  75. X    print("Terminal type %s can not use the curses interface.\n", ttytype);
  76. X    return -1;
  77. X    }
  78. X    iscurses = TRUE;
  79. X    noechom(); /* reset tty state -- */
  80. X    crmode(); /* do not use "echo_on/off()" */
  81. X    scrollok(stdscr, TRUE);
  82. X    /* if the user hasn't set his screen explicitly, set it for him */
  83. X    set_screen_size();
  84. X    if (crt > LINES - 1 || !do_set(set_options, "crt")) {
  85. X    crt = LINES;
  86. X    (void)cmd_line(sprintf(buf, "\\set screen = %d crt = %d", screen, crt),
  87. X        msg_list);
  88. X    } else
  89. X    (void)cmd_line(sprintf(buf, "\\set screen = %d", screen), msg_list);
  90. X    if (argc) {
  91. X    (void) cmd_line(sprintf(buf, "\\headers %d", current_msg+1), msg_list);
  92. X    (void) curses_help_msg(TRUE);
  93. X    }
  94. X    if (!do_set(set_options, "no_reverse"))
  95. X    turnon(glob_flags, REV_VIDEO);
  96. X    turnoff(glob_flags, CONT_PRNT);
  97. X    return 0; /* doesn't affect messages */
  98. X}
  99. X
  100. Xstruct cmd_map *active_cmd;    /* See bindings.h for description */
  101. X
  102. X/*
  103. X * get input in cbreak mode and execute the appropriate command.
  104. X * when the command is done (usually), the user is prompted to
  105. X * hit any key to continue. At this point, the user may enter a
  106. X * new command so no screen refreshing needs to be done. This
  107. X * new command is returned to caller and may be passed back.
  108. X *
  109. X * The flag CNTD_CMD (continued command) is set if
  110. X * this routine is called with the passed parameter (c) != 0. If
  111. X * so, then the character passed is the character input by the
  112. X * user at the last "hit return" prompt indicating that he wants
  113. X * to execute a new command and not draw the screen.
  114. X *
  115. X * CNTD_CMD is also set if the command that the user invokes
  116. X * causes any sort of output that requires a screen refresh.  The
  117. X * variable redo is set to 1 if the header page not only requires
  118. X * redrawing, but updating ... (new call to do_hdrs)
  119. X *
  120. X * calls that say: print("%s", compose_hdr(current_msg)) are constructed
  121. X * that way because if the header has a `%' in it, then print will try to
  122. X * expand it.
  123. X */
  124. Xcurses_command(c)
  125. Xregister int c;
  126. X{
  127. X    char    buf[BUFSIZ], file[128], list[128];
  128. X    int     n, curlin;
  129. X    static int  redo = 0;  /* set if headers should be redrawn */
  130. X
  131. X    if (c != 0)
  132. X    turnon(glob_flags, CNTD_CMD);
  133. X    else
  134. X    turnoff(glob_flags, CNTD_CMD);
  135. X    clear_msg_list(msg_list); /* play it safe */
  136. X    if (isoff(glob_flags, CNTD_CMD)) {
  137. X    (void) check_new_mail();
  138. X    curlin = max(1, current_msg - n_array[0] + 1);
  139. X    scrn_line(curlin, buf);
  140. X    if (ison(glob_flags, REV_VIDEO) && msg_cnt)
  141. X        STANDOUT(curlin, 0, buf);
  142. X    mail_status(0);
  143. X    move(curlin, 0), refresh();
  144. X    /* reprint to remove reverse video from current line (don't refresh) */
  145. X    if (ison(glob_flags, REV_VIDEO))
  146. X        mvaddstr(curlin, 0, buf);
  147. X    c = getcmd(); /* get input AFTER line redrawn without reverse video */
  148. X    }
  149. X    buf[0] = list[0] = file[0] = '\0';
  150. X
  151. X    if (c == C_WRITE_LIST || c == C_SAVE_LIST || c == C_COPY_LIST
  152. X       || c == C_DELETE_LIST || c == C_UNDEL_LIST) {
  153. X    if (msg_cnt < 1) {
  154. X        mac_flush();
  155. X        print("Not enough messages.");
  156. X        c = C_NULL;
  157. X    } else if (c == C_DELETE_LIST && ison(glob_flags, READ_ONLY)) {
  158. X        mac_flush();
  159. X        print("Folder is read-only.");
  160. X        c = C_NULL;
  161. X    } else if (!curses_msg_list(sprintf(buf, "%s msg list: ",
  162. X        (c == C_WRITE_LIST)? "write" : (c == C_SAVE_LIST)?  "save" :
  163. X        (c == C_COPY_LIST)? "copy" :
  164. X        (c == C_DELETE_LIST)? "delete" : "undelete"), list, msg_list))
  165. X        c = C_NULL;
  166. X    if (ison(glob_flags, CNTD_CMD))
  167. X        putchar('\n');
  168. X    }
  169. X
  170. X    /* first do non-mail command type stuff */
  171. X    switch (c) {
  172. X    case C_ERROR :
  173. X        bell();
  174. X        mac_flush();
  175. X
  176. X    when C_NULL :
  177. X        if (isoff(glob_flags, CNTD_CMD))
  178. X        bell();
  179. X
  180. X    /* goto a specific message number */
  181. X    when C_GOTO_MSG :
  182. X        if (curses_msg_list(strcpy(buf, "goto msg: "), list, msg_list)) {
  183. X        /*
  184. X         * Reset the current message in case a 
  185. X         * backquoted command (like `from`) changed it
  186. X         */
  187. X        n = current_msg;
  188. X        do if (++n >= msg_cnt)
  189. X            n = 0;
  190. X        while (n != current_msg && !msg_bit(msg_list, n));
  191. X        if (n == current_msg && !msg_bit(msg_list, n)) {
  192. X            mac_flush(); /* bail out if in macro processing */
  193. X            print("Message not found.");
  194. X        }
  195. X        else if ((current_msg = n) < n_array[0]
  196. X            || n > n_array[screen-1])
  197. X            redo = 1;
  198. X        } else {
  199. X        mac_flush();
  200. X        bell();
  201. X        }
  202. X        if (ison(glob_flags, CNTD_CMD) && msg_cnt)
  203. X        print("%-.*s", COLS-2, compose_hdr(current_msg));
  204. X        if (ison(glob_flags, CNTD_CMD))
  205. X        putchar('\n');
  206. X
  207. X    /* screen optimization stuff */
  208. X    when C_REVERSE :
  209. X        if (ison(glob_flags, REV_VIDEO))
  210. X        turnoff(glob_flags, REV_VIDEO);
  211. X        else
  212. X        turnon(glob_flags, REV_VIDEO);
  213. X
  214. X    when C_REDRAW : redo = 1;
  215. X
  216. X    /*
  217. X     * screen movement
  218. X     */
  219. X    when C_NEXT_MSG :
  220. X        if (current_msg + 2 > msg_cnt ||
  221. X        isoff(glob_flags, CNTD_CMD) && curlin == LINES-2) {
  222. X        mac_flush();    /* Bail out if in macro processing */
  223. X        bell();        /* reached the end */
  224. X        } else {
  225. X        if (ison(glob_flags, CNTD_CMD)) {
  226. X            if (++current_msg > n_array[screen-1])
  227. X            redo = 1;
  228. X            print("%-.*s", COLS-2, compose_hdr(current_msg));
  229. X            putchar('\n');
  230. X        } else {
  231. X            if (++current_msg > n_array[screen-1])
  232. X            n_array[screen++] = current_msg;
  233. X            move(++curlin, 0);
  234. X            printw("%-.*s", COLS-2, compose_hdr(current_msg));
  235. X            clrtoeol();
  236. X        }
  237. X        }
  238. X
  239. X    when C_PREV_MSG :
  240. X        if (isoff(glob_flags, CNTD_CMD) && curlin == 1 || current_msg == 0)
  241. X        {
  242. X        mac_flush();    /* Bail out if in macro processing */
  243. X        bell();      /* at the beginning */
  244. X        } else {
  245. X        if (--current_msg < n_array[0])
  246. X            redo = 1;
  247. X        if (ison(glob_flags, CNTD_CMD)) {
  248. X            print("%-.*s", COLS-2, compose_hdr(current_msg));
  249. X            putchar('\n');
  250. X        }
  251. X        }
  252. X
  253. X    when C_FIRST_MSG : case C_LAST_MSG :
  254. X        if (!msg_cnt) {
  255. X        mac_flush();
  256. X        bell();
  257. X        break;
  258. X        }
  259. X        n = current_msg;
  260. X        move(LINES-1, 0), refresh();
  261. X        if (c == C_FIRST_MSG && (current_msg = 0) < n_array[0] ||
  262. X        c == C_LAST_MSG && (current_msg = msg_cnt-1)> n_array[screen-1])
  263. X        if (isoff(glob_flags, CNTD_CMD))
  264. X            (void) cmd_line(sprintf(buf, "\\headers %d", current_msg+1),
  265. X                 msg_list);
  266. X        else
  267. X            redo = 1;
  268. X        if (ison(glob_flags, CNTD_CMD) && n != current_msg)
  269. X        print("%-.*s", COLS-2, compose_hdr(current_msg)), putchar('\n');
  270. X
  271. X    /* top and bottom of headers screen */
  272. X    when C_TOP_PAGE : case C_BOTTOM_PAGE :
  273. X        if (msg_cnt && isoff(glob_flags, CNTD_CMD))
  274. X        if (c == C_TOP_PAGE)
  275. X            current_msg = n_array[0];
  276. X        else
  277. X            current_msg = min(n_array[screen-1], msg_cnt-1);
  278. X        else {
  279. X        mac_flush();
  280. X        bell();
  281. X        }
  282. X
  283. X    when C_NEXT_SCREEN : /* next page */
  284. X        move(LINES-1, 0), refresh();
  285. X        if (msg_cnt-1 > n_array[screen-1]) {
  286. X        clear();
  287. X        set_screen_size();
  288. X        (void) cmd_line(strcpy(buf, "\\headers +"), msg_list);
  289. X        if (current_msg < n_array[0])
  290. X            current_msg = n_array[0];
  291. X        (void) curses_help_msg(TRUE);
  292. X        return redo = 0;
  293. X        } else {
  294. X        mac_flush();
  295. X        bell();
  296. X        }
  297. X
  298. X    when C_PREV_SCREEN : /* previous page */
  299. X        move(LINES-1, 0), refresh();
  300. X        if (n_array[0] > 0) {
  301. X        clear();
  302. X        set_screen_size();
  303. X        (void) cmd_line(strcpy(buf, "\\headers -"), msg_list);
  304. X        if (current_msg > n_array[screen-1])
  305. X            current_msg = n_array[screen-1];
  306. X        (void) curses_help_msg(TRUE);
  307. X        return redo = 0;
  308. X        } else {
  309. X        mac_flush();
  310. X        bell();
  311. X        }
  312. X
  313. X    /* read from/save to record file (.mushrc) */
  314. X    when C_SOURCE : case C_SAVEOPTS : {
  315. X        int argc;
  316. X        char *argv[3];
  317. X        print("%s filename [default]: ",
  318. X        (c == C_SOURCE)? "source" : "save options to");
  319. X        argc = Getstr(file, LINES-40, 0);
  320. X        clr_bot_line();
  321. X        if (argc < 0)
  322. X        break;
  323. X        if (argc > 0)
  324. X        argv[1] = file, argc = 2;
  325. X        else
  326. X        argc = 1;
  327. X        argv[argc] = NULL;
  328. X        turnon(glob_flags, PRE_CURSES);
  329. X        if (c == C_SOURCE) {
  330. X        (void) source(argc, argv);
  331. X        mac_flush(); /* can't change things in mid-macro */
  332. X        redo = isoff(glob_flags, CNTD_CMD);
  333. X        } else
  334. X        (void) save_opts(argc, argv);
  335. X        turnoff(glob_flags, PRE_CURSES);
  336. X    }
  337. X
  338. X    /*
  339. X     * search commands
  340. X     */
  341. X    when C_NEXT_SEARCH : case C_PREV_SEARCH : case C_CONT_SEARCH :
  342. X        if (c != C_CONT_SEARCH)
  343. X        c = search(0 + (c == C_PREV_SEARCH));
  344. X        else
  345. X        c = search(-1);
  346. X        if (ison(glob_flags, CNTD_CMD))
  347. X        putchar('\n');
  348. X        if (c == 0)
  349. X        break;
  350. X        if (ison(glob_flags, CNTD_CMD))
  351. X        print("%-.*s",COLS-2, compose_hdr(current_msg)), putchar('\n');
  352. X        if (n_array[0] > current_msg || n_array[screen-1] < current_msg) {
  353. X        redo = 1;
  354. X        if (isoff(glob_flags, CNTD_CMD))
  355. X            (void) cmd_line(sprintf(buf, "\\headers %d",
  356. X                        current_msg+1), msg_list);
  357. X        }
  358. X
  359. X    /*
  360. X     * actions on messages
  361. X     */
  362. X    /* delete/undelete */
  363. X    when C_DELETE_MSG : case C_DELETE_LIST :
  364. X    case C_UNDEL_MSG : case C_UNDEL_LIST :
  365. X        if (!msg_cnt) {
  366. X        print("No messages.");
  367. X        if (ison(glob_flags, CNTD_CMD))
  368. X            putchar('\n');
  369. X        break;
  370. X        }
  371. X        if (ison(glob_flags, READ_ONLY)) {
  372. X        mac_flush();
  373. X        print("Folder is read-only.");
  374. X        if (ison(glob_flags, CNTD_CMD))
  375. X            putchar('\n');
  376. X        break;
  377. X        }
  378. X        Debug("current message = %d", current_msg + 1);
  379. X        if (!*list)
  380. X        set_msg_bit(msg_list, current_msg);
  381. X        turnon(glob_flags, DO_UPDATE);
  382. X        for (n = 0; n < msg_cnt; n++)
  383. X        if (msg_bit(msg_list, n)) {
  384. X            if (c == C_DELETE_MSG || c == C_DELETE_LIST)
  385. X            turnon(msg[n].m_flags, DELETE);
  386. X            else
  387. X            turnoff(msg[n].m_flags, DELETE);
  388. X            if (isoff(glob_flags, CNTD_CMD) && (msg_cnt < screen ||
  389. X            n >= n_array[0] && n <= n_array[screen-1])) {
  390. X            move(max(1, n - n_array[0] + 1), 0);
  391. X            printw("%-.*s", COLS-1, compose_hdr(n));
  392. X            } else
  393. X            redo = 1;
  394. X        }
  395. X        if (ison(glob_flags, CNTD_CMD) || *list) {
  396. X        /* print(), THEN putchar() -- overwrite line */
  397. X        if (ison(glob_flags, CNTD_CMD)) {
  398. X            print("%sdeleted %s",
  399. X            (c == C_DELETE_MSG || c == C_DELETE_LIST)? "":"un", list);
  400. X            putchar('\n');
  401. X        }
  402. X        if (c == C_DELETE_MSG || c == C_DELETE_LIST) {
  403. X            if (ison(msg[current_msg].m_flags, DELETE) ||
  404. X                ison(msg[current_msg].m_flags, SAVED))
  405. X            (void) next_msg();
  406. X            if (isoff(msg[current_msg].m_flags, DELETE) &&
  407. X                do_set(set_options, "autoprint"))
  408. X            return C_DISPLAY_MSG;
  409. X        }
  410. X        if (ison(glob_flags, CNTD_CMD))
  411. X            puts(compose_hdr(current_msg));
  412. X        else if (current_msg < n_array[0]
  413. X            || current_msg > n_array[screen-1])
  414. X            redo = 1;
  415. X        }
  416. X
  417. X    /*
  418. X     * write/save messages.  If a list is necessary, the user already
  419. X     * entered it above since he must have used a capital letter. If so,
  420. X     * list will contain good data (already been validated above).
  421. X     * if a list is given, set iscurses to 0 so that print statements
  422. X     * will scroll and the user sees the multiple output. else, one
  423. X     * line can go on the bottom line just fine.
  424. X     */
  425. X    when C_WRITE_MSG : case C_SAVE_MSG : case C_COPY_MSG :
  426. X    case C_WRITE_LIST : case C_SAVE_LIST : case C_COPY_LIST : {
  427. X        register char *p =
  428. X        (c == C_WRITE_MSG || c == C_WRITE_LIST)? "write" :
  429. X        (c == C_SAVE_MSG  || c == C_SAVE_LIST)? "save" : "copy";
  430. X        if (!msg_cnt) {
  431. X        print("No messages.");
  432. X        if (ison(glob_flags, CNTD_CMD))
  433. X            putchar('\n');
  434. X        break;
  435. X        }
  436. X        print(sprintf(buf, "filename to %s%s: ", p,
  437. X        (c != C_WRITE_MSG && c != C_WRITE_LIST)? " [mbox]" : ""));
  438. X        if (Getstr(file, COLS-1-strlen(buf), 0) >= 0) {
  439. X        char *argv[3];
  440. X        clr_bot_line();
  441. X        argv[0] = strcpy(buf, p);
  442. X        p = file; skipspaces(0);
  443. X        argv[1] = (*p) ? p : NULL;
  444. X        argv[2] = NULL;
  445. X        if (!*list)
  446. X            set_msg_bit(msg_list, current_msg);
  447. X        move(LINES-1, 0), refresh();
  448. X        if (*list)
  449. X            iscurses = FALSE;
  450. X        /* Turn on piping to make save_msg look at msg_list */
  451. X        turnon(glob_flags, IS_PIPE);
  452. X        if (save_msg(1 + (*file != '\0'), argv, msg_list) < 0)
  453. X            *list = 0;
  454. X        turnoff(glob_flags, IS_PIPE);
  455. X        if (ison(glob_flags, CNTD_CMD))
  456. X            redo = 1, putchar('\n'), puts(compose_hdr(current_msg));
  457. X        if (*list)
  458. X            iscurses = redo = TRUE, turnon(glob_flags, CNTD_CMD);
  459. X        else if (isoff(glob_flags, CNTD_CMD) && msg_cnt) {
  460. X            move(curlin, 0);
  461. X            printw("%-.*s", COLS-1, compose_hdr(current_msg));
  462. X            }
  463. X        } else {
  464. X        print("No messages saved.");
  465. X        if (ison(glob_flags, CNTD_CMD))
  466. X            putchar('\n');
  467. X        }
  468. X    }
  469. X
  470. X    /* preserve message */
  471. X    when C_PRESERVE :
  472. X        if (!msg_cnt) {
  473. X        print("No messages.");
  474. X        if (ison(glob_flags, CNTD_CMD))
  475. X            putchar('\n');
  476. X        break;
  477. X        }
  478. X        if (ison(msg[current_msg].m_flags, PRESERVE))
  479. X        turnoff(msg[current_msg].m_flags, PRESERVE);
  480. X        else
  481. X        turnon(msg[current_msg].m_flags, PRESERVE);
  482. X        turnon(glob_flags, DO_UPDATE);
  483. X        if (ison(glob_flags, CNTD_CMD)) {
  484. X        wprint("%-.*s\n", COLS-1, compose_hdr(current_msg));
  485. X        redo = 1;
  486. X        } else {
  487. X        move(curlin, 0);
  488. X        printw("%-.*s", COLS-1, compose_hdr(current_msg));
  489. X        }
  490. X
  491. X    /* order messages (sort) and redisplay the headers */
  492. X    when C_SORT : case C_REV_SORT :
  493. X        (void) strcpy(file, "sort");
  494. X        if (c == C_REV_SORT) {
  495. X        print("Reverse "), turnon(glob_flags, CONT_PRNT);
  496. X        (void) strcat(file, " -");
  497. X        }
  498. X        print(
  499. X        "Order messages by [author, date, length, Status, subject]: "
  500. X        );
  501. X        if ((c = m_getchar()) == 'a' || c == 'd' || c == 'l' ||
  502. X            c == 'S' || c == 's' || c == 'R') {
  503. X        print("reordering messages...");
  504. X        (void) cmd_line(sprintf(buf, "%s %c", file, c), msg_list);
  505. X        print_more("done.");
  506. X        if (ison(glob_flags, CNTD_CMD))
  507. X            putchar('\n'), puts(compose_hdr(current_msg));
  508. X        redo = 1;
  509. X        } else
  510. X        clr_bot_line();
  511. X
  512. X    when C_QUIT_HARD :
  513. X        (void) mush_quit(0, DUBL_NULL);
  514. X        redo = 1; /* new mail must have come in */
  515. X
  516. X    /* quit or update -- vrfy_update (returns 1 if updated) */
  517. X    when C_QUIT : case C_UPDATE : {
  518. X        clr_bot_line();
  519. X        redo = (c == C_UPDATE);
  520. X        if (!vrfy_update(&redo))
  521. X        if (c == C_UPDATE)
  522. X            break;
  523. X        if (isoff(glob_flags, CNTD_CMD))
  524. X        (void) cmd_line(sprintf(buf, "\\headers %d", current_msg+1),
  525. X                msg_list);
  526. X    }
  527. X
  528. X    when C_EXIT : case C_EXIT_HARD :
  529. X        clr_bot_line();
  530. X        iscurses = FALSE;
  531. X        if (c != C_EXIT && c != C_EXIT_HARD)
  532. X        putchar('\n');
  533. X        cleanup(0);
  534. X
  535. X    /* change to a new folder */
  536. X    when C_FOLDER :
  537. X        for (;;) {
  538. X        SIGRET (*oldint)(), (*oldquit)();
  539. X        on_intr();
  540. X        print("New folder (?=list): ");
  541. X        c = Getstr(file, COLS-22, 0);
  542. X        off_intr();
  543. X        if (c > 0) {
  544. X            if (!strcmp(file, "?")) {
  545. X            clr_bot_line();
  546. X            iscurses = 0;
  547. X            puts("folders in your folder directory:");
  548. X            (void) cmd_line(strcpy(buf, "\\folders"), msg_list);
  549. X    puts("Precede folder names with a +. `%' to specify system mailbox.");
  550. X            turnon(glob_flags, CNTD_CMD), iscurses = 1;
  551. X            continue;
  552. X            }
  553. X            clearok(stdscr, FALSE);
  554. X            /* if vrfy_update doesn't verify, but folder command fails,
  555. X             * then we need to reset the updatability of current folder
  556. X             */
  557. X            c = (ison(glob_flags, DO_UPDATE))? TRUE : FALSE;
  558. X            if (strcmp(file, "-?")) {
  559. X            redo = 1; /* so vrfy_update() won't quit */
  560. X            (void) vrfy_update(&redo);
  561. X            }
  562. X            move(LINES-1, 0), refresh();
  563. X            if (cmd_line(sprintf(buf, "folder ! -N %s", file),
  564. X                 msg_list) == -1) {
  565. X            if (c) /* remember state of updatability of folder */
  566. X                turnon(glob_flags, DO_UPDATE);
  567. X            if (ison(glob_flags, CNTD_CMD))
  568. X                putchar('\n');
  569. X            } else
  570. X            redo = 1, turnoff(glob_flags, CNTD_CMD);
  571. X            break;
  572. X        } else {
  573. X            print("\"%s\" unchanged.", mailfile);
  574. X            if (ison(glob_flags, CNTD_CMD))
  575. X            putchar('\n');
  576. X            break;
  577. X        }
  578. X        }
  579. X
  580. X    /* shell escape */
  581. X    when C_SHELL_ESC :
  582. X        print("Shell command: ");
  583. X        if (Getstr(file, COLS-24, 0) < 0)
  584. X        clr_bot_line();
  585. X        else {
  586. X        putchar('\n');
  587. X        iscurses = FALSE;
  588. X        (void) cmd_line(sprintf(buf, "sh %s", file), msg_list);
  589. X        iscurses = TRUE;
  590. X        turnon(glob_flags, CNTD_CMD);
  591. X        }
  592. X
  593. X    /* do a line-mode like command */
  594. X    when C_CURSES_ESC :
  595. X        print(":");
  596. X        if (Getstr(buf, COLS-2, 0) < 0)
  597. X        break;
  598. X        putchar('\n');
  599. X        iscurses = FALSE;
  600. X        if (!*buf) {
  601. X        /* return -1 because iscurses = 0 is not enough! */
  602. X        redo = 0;
  603. X        endwin(); /* this turns echoing back on! */
  604. X        echo_off();
  605. X        return -1;
  606. X        }
  607. X        /* The "source" and "curses" commands need some indication
  608. X         * that we are in curses mode, so use the PRE_CURSES flag.
  609. X         */
  610. X        turnon(glob_flags, PRE_CURSES);
  611. X        (void) cmd_line(buf, msg_list);
  612. X        /* they may have affected message status or had text output */
  613. X        turnon(glob_flags, CNTD_CMD), redo = 1;
  614. X        turnoff(glob_flags, PRE_CURSES);
  615. X        iscurses = TRUE;
  616. X        if (msg_cnt)
  617. X        puts(compose_hdr(current_msg));
  618. X
  619. X    /* send message to printer, redo to display 'p' status */
  620. X    when C_PRINT_MSG : redo = (lpr(0, DUBL_NULL, msg_list) == 0);
  621. X
  622. X    /* cd */
  623. X    when C_CHDIR :
  624. X        print("chdir to [~]: ");
  625. X        if (Getstr(file, COLS-12, 0) < 0)
  626. X        break;
  627. X        clr_bot_line();
  628. X        (void) cmd_line(sprintf(buf, "cd %s", file), msg_list);
  629. X        if (ison(glob_flags, CNTD_CMD))
  630. X        putchar('\n');
  631. X
  632. X    /* variable settings */
  633. X    when C_VAR_SET : case C_IGNORE : case C_ALIAS : case C_OWN_HDR :
  634. X        curs_vars(c); /* CNTD_CMD is reset if there's output! */
  635. X
  636. X    when C_VERSION :
  637. X        (void) do_version();
  638. X        if (ison(glob_flags, CNTD_CMD))
  639. X        putchar('\n');
  640. X
  641. X    when C_MAIL_FLAGS :
  642. X        print("flags [-?]: ");
  643. X        if ((c = Getstr(file, COLS-12, 0)) < 0)
  644. X        break;
  645. X        putchar('\n');
  646. X        if (c == 0)
  647. X        (void) strcpy(file, "-?");
  648. X        else
  649. X        redo = 1; /* In case of -f flag, to display the 'f' status */
  650. X    /* Fall thru */
  651. X    case C_MAIL : {
  652. X        u_long flgs = glob_flags;
  653. X        turnon(glob_flags, IGN_BANG);
  654. X        clr_bot_line();
  655. X        iscurses = FALSE;
  656. X        (void) cmd_line(sprintf(buf, "mail %s", file), msg_list);
  657. X        glob_flags = flgs;
  658. X        iscurses = TRUE, turnon(glob_flags, CNTD_CMD);
  659. X        if (msg_cnt)
  660. X        print("%-.*s", COLS-2, compose_hdr(current_msg)), putchar('\n');
  661. X    }
  662. X
  663. X    /* reply to mail */
  664. X    when C_REPLY_SENDER : case C_REPLY_ALL : {
  665. X        register char *p = (c == C_REPLY_ALL)? "replyall" : "replysender";
  666. X        clr_bot_line();
  667. X        iscurses = FALSE;
  668. X        if (isoff(msg[current_msg].m_flags, REPLIED))
  669. X        redo = 1;
  670. X        (void) cmd_line(sprintf(buf, "%s %d", p, current_msg+1),
  671. X        msg_list);
  672. X        if (msg_cnt)
  673. X        puts(compose_hdr(current_msg));
  674. X        iscurses = TRUE, turnon(glob_flags, CNTD_CMD);
  675. X    }
  676. X
  677. X    /* type out a message */
  678. X    when C_DISPLAY_MSG : case C_TOP_MSG : case C_DISPLAY_NEXT :
  679. X        if (!msg_cnt ||
  680. X        c != C_DISPLAY_NEXT && ison(msg[current_msg].m_flags, DELETE)) {
  681. X        if (!msg_cnt)
  682. X            print("No messages.");
  683. X        else
  684. X            print("Message %d deleted; type 'u' to undelete.",
  685. X                      current_msg+1);
  686. X        if (ison(glob_flags, CNTD_CMD))
  687. X            putchar('\n');
  688. X        break;
  689. X        }
  690. X        clr_bot_line();
  691. X        iscurses = FALSE;
  692. X        if (ison(glob_flags, CNTD_CMD))
  693. X        putchar('\n');
  694. X        if (c == C_DISPLAY_MSG)
  695. X        c = cmd_line(strcpy(buf, "type"), msg_list);
  696. X        else if (c == C_TOP_MSG)
  697. X        c = cmd_line(strcpy(buf, "top"), msg_list);
  698. X        else {
  699. X        /* "next" screws up the screen whether it displays or not */
  700. X        (void) cmd_line(strcpy(buf, "next"), msg_list);
  701. X        c = 0;
  702. X        }
  703. X        if (c > -1)
  704. X        turnon(glob_flags, CNTD_CMD), redo = 1;
  705. X        iscurses = TRUE;
  706. X        puts(compose_hdr(current_msg));
  707. X
  708. X    /* bind a key or string to a curses-mode command */
  709. X    when C_BIND :  case C_UNBIND : case C_MAP : case C_BIND_MACRO :
  710. X    case C_MAP_BANG : {
  711. X        char *argv[2];
  712. X        argv[0] = (c == C_BIND) ? "bind" :
  713. X              (c == C_UNBIND) ? "unbind" :
  714. X              (c == C_MAP) ? "map" :
  715. X              (c == C_MAP_BANG) ? "map!" : "bind-macro";
  716. X        argv[1] = NULL;
  717. X        if (bind_it(1, argv) < -1)
  718. X        turnon(glob_flags, CNTD_CMD);
  719. X        else if (ison(glob_flags, CNTD_CMD)) /* if it was set anyway */
  720. X        putchar('\n');
  721. X        else
  722. X        (void) curses_help_msg(TRUE);
  723. X    }
  724. X
  725. X    when C_MACRO : 
  726. X        turnon(glob_flags, IN_MACRO);
  727. X        /* Current macro should already be in the mac_stack, so
  728. X         * all we have to do here is look for the next character
  729. X         */
  730. X
  731. X    /* help stuff */
  732. X    when C_HELP :
  733. X        move(LINES-1, 0), refresh();
  734. X        (void) help(0, "curses", cmd_help);
  735. X        turnon(glob_flags, CNTD_CMD);
  736. X        if (msg_cnt)
  737. X        puts(compose_hdr(current_msg));
  738. X
  739. X    otherwise :
  740. X        mac_flush();
  741. X        bell();
  742. X        if (ison(glob_flags, CNTD_CMD)) {
  743. X        /* use print instead of puts to overwrite hit_return msg */
  744. X        print("unknown command"), putchar('\n');
  745. X        redo = 1;
  746. X        }
  747. X    }
  748. X
  749. X    if (ison(glob_flags, CNTD_CMD)) {
  750. X    int old_cnt = msg_cnt;
  751. X    if (!(c = hit_return()) && !redo && msg_cnt == old_cnt)
  752. X        redraw();
  753. X    clr_bot_line();
  754. X    if (old_cnt !=  msg_cnt)
  755. X        redo = 1;
  756. X    if (c)
  757. X        return c;
  758. X    }
  759. X    if (redo) {
  760. X    set_screen_size(); /* it may have changed */
  761. X    n = current_msg;
  762. X    clear();
  763. X    if (/* msg_cnt < screen || */ n_array[0] < n && n < n_array[screen-1])
  764. X        (void) do_hdrs(0, DUBL_NULL, NULL);
  765. X    else
  766. X        (void) cmd_line(sprintf(buf, "\\headers %d", n+1), msg_list);
  767. X    (void) curses_help_msg(TRUE);
  768. X    redo = 0;
  769. X    }
  770. X    return 0;
  771. X}
  772. X
  773. Xvrfy_update(redo)
  774. Xint *redo;
  775. X{
  776. X    char buf[16];
  777. X    int c;
  778. X
  779. X    /* update current folder */
  780. X    if (ison(glob_flags, DO_UPDATE)) {
  781. X    if (ison(glob_flags, READ_ONLY)) {
  782. X        mac_flush();
  783. X        print("Folder is read-only.");
  784. X        if (ison(glob_flags, CNTD_CMD))
  785. X        putchar('\n');
  786. X        return 0;
  787. X    }
  788. X    print("Update folder [y]? ");
  789. X    if ((c = getchar()) != 'y' && c != 'Y' && c != '\n' && !isspace(c)) {
  790. X        print("Folder unchanged.");
  791. X        if (ison(glob_flags, CNTD_CMD))
  792. X        putchar('\n');
  793. X        return 0;
  794. X    }
  795. X    } else if (*redo)
  796. X    return 1;
  797. X    if (cmd_line(strcpy(buf, *redo? "update" : "quit"), msg_list) != -1
  798. X        && ison(glob_flags, CNTD_CMD))
  799. X    *redo = 1, turnoff(glob_flags, CNTD_CMD);
  800. X    turnoff(glob_flags, DO_UPDATE);
  801. X    return 1; /* make sure bottom line is clear and no reverse video */
  802. X}
  803. X
  804. Xscrn_line(line, buf)
  805. Xchar *buf;
  806. X{
  807. X#ifndef A_CHARTEXT
  808. X    (void) strncpy(buf, stdscr->_y[line], COLS-1);
  809. X    buf[COLS-1] = 0; /* strncpy does not null terminate */
  810. X#else
  811. X    int n;
  812. X
  813. X    for (n = 0; n < COLS; n++)
  814. X    if ((buf[n] = (mvinch(line, n) & A_CHARTEXT)) == '\0')
  815. X        break;
  816. X    buf[n] = '\0';
  817. X#endif /* A_CHARTEXT */
  818. X}
  819. X
  820. X/*
  821. X * Generate the help message from the variable curses_help.
  822. X *  If visible is true, the message is displayed,
  823. X *  otherwise its size (in lines) is computed and returned.
  824. X */
  825. Xcurses_help_msg(visible)
  826. Xint visible;
  827. X{
  828. X    int count, i, len, siz = 0, mxm = 0;
  829. X    static int old_siz = 0;
  830. X    register struct cmd_map *list;
  831. X    extern struct cmd_map map_func_names[];
  832. X    char *curs_help = do_set(set_options, "curses_help"), **format;
  833. X
  834. X    if (!curs_help) {
  835. X    if (old_siz && visible) {
  836. X        int bot = min(n_array[screen-1], msg_cnt-1);
  837. X        move(max(0, bot - n_array[0]) + 2, 0), clrtobot();
  838. X        old_siz = 0;
  839. X    }
  840. X    return 0;
  841. X    } else if (!*curs_help)
  842. X    curs_help = DEF_CURSES_HELP;
  843. X    /* Split the help string into words */
  844. X    if (!(format = mk_argv(curs_help, &count, FALSE)) || count <= 0)
  845. X    return 0;
  846. X    /* Generate a help message for each word */
  847. X    for (i = 0; i < count; i++) {
  848. X    char buf[MAX_BIND_LEN*2+MAX_LONG_CMD+5], asc[MAX_BIND_LEN*2];
  849. X
  850. X    buf[0] = '\0'; /* default to empty in case of no match */
  851. X    for (list = cmd_map; list; list = list->m_next) {
  852. X        if (!strcmp(format[i], map_func_names[list->m_cmd].m_str)) {
  853. X        len = strlen(sprintf(buf, "(%s) %s  ",
  854. X                ctrl_strcpy(asc, list->m_str, FALSE),
  855. X                map_func_names[list->m_cmd].m_str));
  856. X        if (len > mxm)
  857. X            mxm = len;
  858. X        break;
  859. X        }
  860. X    }
  861. X    strdup(format[i], buf); /* replace word with its "definition" */
  862. X    }
  863. X    /* Columnate the output nicely */
  864. X    if (mxm > 0) {
  865. X    len = (COLS - 1) / mxm;
  866. X    if (len == 0) {
  867. X        if (visible)
  868. X        print("Curses help message too long!");
  869. X        return 0;
  870. X    }
  871. X    siz = count / len;
  872. X    if (count % len)
  873. X        siz++;
  874. X    if (siz > LINES / 3) {
  875. X        if (visible)
  876. X        print("Curses help message too long!");
  877. X        return 0;
  878. X    }
  879. X    if (visible) {
  880. X        int next = LINES - 1 - siz;
  881. X        if (old_siz > siz) {
  882. X        int bot = min(n_array[screen-1], msg_cnt-1);
  883. X        move(max(0, bot - n_array[0]) + 2, 0), clrtobot();
  884. X        }
  885. X        old_siz = siz;
  886. X        for (i = 0; i < count; i++) {
  887. X        if (!(i % len))
  888. X            move(next, 0), clrtoeol(), ++next;
  889. X        if (format[i][0])
  890. X            printw("%-*.*s", mxm, mxm, format[i]);
  891. X        }
  892. X        refresh();
  893. X    }
  894. X    }
  895. X    free_vec(format);
  896. X    return siz;
  897. X}
  898. X
  899. Xset_screen_size()
  900. X{
  901. X    int hlp_siz = LINES - 2 - curses_help_msg(FALSE); 
  902. X
  903. X    if (!do_set(set_options, "screen"))
  904. X#ifdef USG
  905. X    switch (_tty.sg_ospeed & CBAUD)
  906. X#else /* USG */
  907. X    switch (_tty.sg_ospeed)
  908. X#endif /* USG */
  909. X    {
  910. X        case B300 :  screen = min(hlp_siz, 7);
  911. X        when B1200 : screen = min(hlp_siz, 14);
  912. X        when B2400 : screen = min(hlp_siz, 22);
  913. X        otherwise :  screen = hlp_siz;
  914. X    }
  915. X    else
  916. X    screen = min(screen, hlp_siz);
  917. X}
  918. X
  919. X/*
  920. X * prompt for a carriage return, but return whatever user types unless
  921. X * it's a character which he might regret (like 'q' or 'x'). Ignore
  922. X * interrupts (kind of) because we have nowhere to longjmp to.  When we
  923. X * return, we'll setjmp again (top of loop.c)
  924. X */
  925. Xhit_return()
  926. X{
  927. X    int c;
  928. X
  929. X    turnon(glob_flags, IGN_SIGS);
  930. X    iscurses = FALSE;
  931. X    (void) check_new_mail();
  932. X    iscurses = TRUE;
  933. X    mail_status(1), addstr("...continue... "), refresh();
  934. X    c = getcmd();
  935. X    turnoff(glob_flags, IGN_SIGS);
  936. X
  937. X    /* don't let the user type something he might regret */
  938. X    if (c == C_QUIT || c == C_EXIT)
  939. X    return C_NULL;
  940. X    return c;
  941. X}
  942. X
  943. Xcurses_msg_list(str, list, m_list)
  944. Xregister char *str, *list;
  945. Xchar m_list[];
  946. X{
  947. X    register char *p = NULL;
  948. X    int c, sv_cur_msg = current_msg;
  949. X
  950. X    print(str);
  951. X    c = Getstr(list, COLS-13, 0);
  952. X    move(LINES-1, 0), refresh();
  953. X    if (c <= 0 || !(p = do_range(list, m_list)) ||
  954. X    (p == list && *p && *p != '$' && *p != '^')) {
  955. X    if (p)
  956. X        print("Invalid message list: %s", p);
  957. X    current_msg = sv_cur_msg;
  958. X    return 0;
  959. X    }
  960. X    current_msg = sv_cur_msg;
  961. X    return 1;
  962. X}
  963. X
  964. Xcurs_vars(which)
  965. Xint which;  /* really, a char */
  966. X{
  967. X    char c, buf[128], buf2[128], *string;
  968. X    struct options **list;
  969. X
  970. X    switch(which) {
  971. X    case C_OWN_HDR : string = "my_hdr", list = &own_hdrs;
  972. X    when C_ALIAS : string = "alias", list = &aliases;
  973. X    when C_IGNORE : string = "ignore", list = &ignore_hdr;
  974. X    when C_VAR_SET : string = "set", list = &set_options;
  975. X    otherwise : clr_bot_line(); return;
  976. X    }
  977. X
  978. X    print("%s [? Set Unset All]: ", string);
  979. X    c = m_getchar();
  980. X    clr_bot_line();
  981. X    switch (Lower(c)) {
  982. X    /* if help, print help -- if "all", show all settings. */
  983. X    case '?' : case 'a' :
  984. X        if (c == '?') {
  985. X        if (!strcmp(string, "set")) {
  986. X            print("which variable? [all <var>]: ");
  987. X            if ((c = Getstr(buf+1, COLS-40, 0)) < 0)
  988. X            return;
  989. X            clr_bot_line();
  990. X            buf[0] = '?';
  991. X            if (c > 0) {
  992. X            char *argv[3];
  993. X            argv[0] = string;
  994. X            argv[1] = buf;
  995. X            argv[2] = NULL;
  996. X            Lower(buf[1]);
  997. X            if (!strcmp(buf+1, "a"))
  998. X                (void) strcpy(buf+1, "all");
  999. X            if (!strcmp(buf+1, "all"))
  1000. X                turnon(glob_flags, CNTD_CMD);
  1001. X            (void) set(2, argv, (char *) 0);
  1002. X            break;
  1003. X            }
  1004. X        }
  1005. X        /* help returns next command (hit_return) */
  1006. X        (void) help(0, string, cmd_help);
  1007. X        turnon(glob_flags, CNTD_CMD);
  1008. X        return;
  1009. X        }
  1010. X        turnon(glob_flags, CNTD_CMD);
  1011. X        (void) do_set(*list, NULL);
  1012. X
  1013. X    /* if set, prompt for string and let user type */
  1014. X    when 's' :
  1015. X        print("set: ");
  1016. X        c = Getstr(buf, COLS-18, 0);
  1017. X        clr_bot_line();
  1018. X        if (c > 0)
  1019. X        (void) cmd_line(sprintf(buf2, "%s %s", string, buf), msg_list);
  1020. X
  1021. X    /* if unset, just as easy as set! */
  1022. X    when 'u' :
  1023. X        print("unset: ", string);
  1024. X        if (Getstr(buf, COLS-18, 0) > 0 && !un_set(list, buf))
  1025. X        print("%s isn't set", buf);
  1026. X    }
  1027. X    if (ison(glob_flags, CNTD_CMD))
  1028. X    putchar('\n');
  1029. X    else
  1030. X    (void) curses_help_msg(TRUE);
  1031. X}
  1032. X#endif /* CURSES */
  1033. END_OF_FILE
  1034. if test 28433 -ne `wc -c <'mush/curses.c'`; then
  1035.     echo shar: \"'mush/curses.c'\" unpacked with wrong size!
  1036. fi
  1037. # end of 'mush/curses.c'
  1038. fi
  1039. if test -f 'mush/mush.h' -a "${1}" != "-c" ; then 
  1040.   echo shar: Will not clobber existing file \"'mush/mush.h'\"
  1041. else
  1042. echo shar: Extracting \"'mush/mush.h'\" \(22786 characters\)
  1043. sed "s/^X//" >'mush/mush.h' <<'END_OF_FILE'
  1044. X/* @(#)mush.h    (c) copyright 1986 (Dan Heller) */
  1045. X
  1046. X#include "config.h"
  1047. X
  1048. X#ifdef CURSES
  1049. X
  1050. X#ifdef USG
  1051. X#    define _USG
  1052. X#    undef USG
  1053. X#endif /* USG */
  1054. X#ifdef SYSV
  1055. X#    define _SYSV
  1056. X#    undef SYSV
  1057. X#endif /* SYSV */
  1058. X#include <curses.h>
  1059. X#if !defined(USG) && defined(_USG)
  1060. X#    define USG
  1061. X#endif /* USG */
  1062. X#if !defined(SYSV) && defined(_SYSV)
  1063. X#    define SYSV
  1064. X#endif /* SYSV */
  1065. X
  1066. X#else /* CURSES */
  1067. X#include <stdio.h>
  1068. X#if defined(SYSV) && defined(USG)
  1069. X#include <termio.h>
  1070. X#endif /* SYSV && USG */
  1071. X#endif /* CURSES */
  1072. X
  1073. X#include <ctype.h>
  1074. X#include <errno.h>
  1075. X#include <setjmp.h>
  1076. X#include "strings.h"
  1077. X
  1078. X#ifdef BSD
  1079. X#define fputs Fputs    /* See comments in print.c */
  1080. X#endif /* BSD */
  1081. X
  1082. Xextern char
  1083. X    *malloc(),        /* allocate memory */
  1084. X    *calloc(),        /* allocate and clear memory */
  1085. X    *realloc();        /* re-allocate memory */
  1086. X
  1087. Xextern void
  1088. X    free_vec(),        /* free a malloc'ed argv */
  1089. X    xfree();        /* free malloc'ed pointers */
  1090. X
  1091. X#if defined(SUNTOOL) || defined(SUN_3_5) || defined(SUN_4_0) || defined(SUN_4_1)
  1092. X#if !defined(BSD) && !defined(SYSV)
  1093. X#    define BSD /* default to BSD */
  1094. X#endif /* !BSD && !SYSV */
  1095. X#if !defined(SUN_3_5) && !defined(SUN_4_0)
  1096. X#    define SUN_4_0 /* default to sun 4.0 */
  1097. X#endif /* !SUN_3_5 && !SUN_4_0 */
  1098. X#ifdef SUN_4_0
  1099. X#    undef SUN_3_5
  1100. X#    undef SIGRET
  1101. X#    define SIGRET void
  1102. X#endif /* SUN_4_0 */
  1103. X#endif /* SUNTOOL || SUN_3_5 || SUN_4_0 */
  1104. X
  1105. X#ifdef SUNTOOL
  1106. X#    include <suntool/sunview.h>
  1107. X#ifdef SUN_4_0
  1108. X#    include <suntool/alert.h>
  1109. X#endif /* SUN_4_0 */
  1110. X#    include <suntool/textsw.h>
  1111. X#    include <sys/ioctl.h>   /* for ltchars */
  1112. X#else
  1113. X#    include <sys/types.h>
  1114. X#    include <signal.h>
  1115. X#    ifndef SYSV
  1116. X#    include <sys/time.h>
  1117. X#    include <sys/ioctl.h>   /* for ltchars */
  1118. X#    else
  1119. X#    include <time.h>
  1120. X#    include <fcntl.h>
  1121. X#    endif /* SYSV */
  1122. X#endif /* SUNTOOL */
  1123. X
  1124. X#include <sys/stat.h>
  1125. X#include <sys/file.h>
  1126. X
  1127. X#ifdef SUNTOOL
  1128. X#    include <suntool/panel.h>
  1129. X#    include <suntool/canvas.h>
  1130. X#    include <suntool/tty.h>
  1131. X#    include <suntool/menu.h>
  1132. X#    include <suntool/icon.h>
  1133. X#    include <suntool/scrollbar.h>
  1134. X#    include <suntool/icon_load.h>
  1135. X#endif /* SUNTOOL */
  1136. X
  1137. X/* if no maximum number of files can be found, we'll use getdtablesize() */
  1138. X#ifdef _NFILE
  1139. X#    define MAXFILES _NFILE
  1140. X#else
  1141. X#ifdef NOFILE
  1142. X#    define MAXFILES NOFILE
  1143. X#endif /* NOFILE */
  1144. X#endif /* _NFILE */
  1145. X
  1146. X#ifndef MAXPATHLEN
  1147. X#define MAXPATHLEN BUFSIZ
  1148. X#endif /* MAXPATHLEN */
  1149. X
  1150. X#ifdef CTRL
  1151. X#undef CTRL
  1152. X#endif /* CTRL */
  1153. X#define CTRL(c)        ((c) & 037)
  1154. X
  1155. X#define ESC         '\033'
  1156. X
  1157. X#define NO_STRING    ""
  1158. X#ifdef  NULL
  1159. X#undef  NULL
  1160. X#endif /* NULL */
  1161. X#define NULL        (char *)0
  1162. X#define NULL_FILE    (FILE *)0
  1163. X#define DUBL_NULL    (char **)0
  1164. X#define TRPL_NULL    (char ***)0
  1165. X#ifdef putchar
  1166. X#undef putchar
  1167. X#endif /* putchar */
  1168. X#define putchar(c)    (void) (fputc(c, stdout), fflush(stdout))
  1169. X#ifdef SUNTOOL
  1170. Xextern int bell();
  1171. X#else /* SUNTOOL */
  1172. X#define bell()        (void) (fputc('\007', stderr), fflush(stderr))
  1173. X#endif /* SUNTOOL */
  1174. X
  1175. X/* For error recovery purposes, send keyboard generated signals to a special
  1176. X * routine (interrupt) to set a global flag (WAS_INTR) and return to the
  1177. X * calling routine which is responsible for checking the flag.  For both
  1178. X * on_intr() and off_intr() macros, initialize WAS_INTR to false.
  1179. X */
  1180. X#define on_intr() \
  1181. X    turnoff(glob_flags, WAS_INTR), oldint = signal(SIGINT, intrpt), \
  1182. X    oldquit = signal(SIGQUIT, intrpt)
  1183. X
  1184. X#define off_intr() \
  1185. X    (void) (turnoff(glob_flags, WAS_INTR), signal(SIGINT, oldint), \
  1186. X        signal(SIGQUIT, oldquit))
  1187. X
  1188. X/* Don't flush input when setting echo or cbreak modes (allow typeahead) */
  1189. X#ifdef TIOCSETN
  1190. X#ifdef stty
  1191. X#undef stty
  1192. X#endif /* stty */
  1193. X#define stty(fd, sgttybuf)    ioctl(fd, TIOCSETN, sgttybuf)
  1194. X#endif /* TIOCSETN */
  1195. X
  1196. X/* for system-V machines that run termio */
  1197. X#if defined(SYSV) && defined(USG)
  1198. Xunsigned char vmin, vtime;
  1199. X#define sg_erase  c_cc[2]
  1200. X#define sg_flags  c_lflag
  1201. X#define sg_kill   c_cc[3]
  1202. X#define sg_ospeed c_cflag
  1203. X#define gtty(fd, SGTTYbuf)    ioctl(fd, TCGETA, SGTTYbuf)
  1204. X#undef stty
  1205. X#define stty(fd, SGTTYbuf)    ioctl(fd, TCSETAW, SGTTYbuf)
  1206. X#define echon()    (_tty.sg_flags |= (ECHO|ECHOE),    stty(0, &_tty))
  1207. X#define echoff()   (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
  1208. X#define cbrkon()   \
  1209. X    (_tty.sg_flags &= ~ICANON, _tty.c_cc[VMIN] = 1, stty(0, &_tty))
  1210. X#define cbrkoff()  \
  1211. X    (_tty.sg_flags |= ICANON,_tty.c_cc[VMIN] = vmin,_tty.c_iflag |= ICRNL, \
  1212. X        _tty.c_cc[VTIME] = vtime, stty(0, &_tty))
  1213. X#define savetty()  \
  1214. X    (void) gtty(0, &_tty), vtime = _tty.c_cc[VTIME], vmin = _tty.c_cc[VMIN]
  1215. X#define cbreak()   cbrkon()
  1216. X#define nocbreak() cbrkoff()
  1217. X
  1218. X/* If curses isn't defined, declare our 'tty' and macros for echo/cbreak */
  1219. X#ifndef CURSES
  1220. Xtypedef struct termio SGTTY;
  1221. X#define echom()    echon()
  1222. X#define noechom()  echoff()
  1223. X#define crmode()   cbrkon()
  1224. X#define nocrmode() cbrkoff()
  1225. X
  1226. X#else /* CURSES */
  1227. X/* If curses is defined, use the echo/cbreak commands in library only
  1228. X * if curses is running.  If curses isn't running, use macros above.
  1229. X */
  1230. X#define echom()    ((iscurses) ? echo(): echon())
  1231. X#define noechom()  ((iscurses) ? noecho(): echoff())
  1232. X#define crmode()   ((iscurses) ? cbreak() : cbrkon())
  1233. X#define nocrmode() ((iscurses) ? nocbreak() : cbrkoff())
  1234. X#endif /* CURSES */
  1235. X#endif /* SYSV && USG */
  1236. X
  1237. X#if !defined(USG)
  1238. X#ifndef CURSES
  1239. X/* if curses is not defined, simulate the same tty based macros */
  1240. Xtypedef struct sgttyb SGTTY;
  1241. X/* Do real ioctl calls to set the tty modes */
  1242. X#define crmode()   (_tty.sg_flags |= CBREAK,  stty(0, &_tty))
  1243. X#define nocrmode() (_tty.sg_flags &= ~CBREAK, stty(0, &_tty))
  1244. X#define echom()    (_tty.sg_flags |= ECHO,    stty(0, &_tty))
  1245. X#define noechom()  (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
  1246. X#define savetty()  (void) gtty(0, &_tty)
  1247. X#else /* CURSES */
  1248. X#define echom()    echo()
  1249. X#define noechom()  noecho()
  1250. X#endif /* ~CURSES */
  1251. X#endif /* ~USG */
  1252. X
  1253. X/* With all that out of the way, we can now declare our tty type */
  1254. XSGTTY _tty;
  1255. X
  1256. Xextern char
  1257. X    del_line,        /* tty delete line character */
  1258. X    del_word,        /* tty delete word character */
  1259. X    del_char,        /* backspace */
  1260. X    reprint_line,    /* usually ^R */
  1261. X    eofc,        /* usually ^D */
  1262. X    lit_next,        /* usually ^V */
  1263. X    complete,        /* word completion, usually ESC */
  1264. X    complist;        /* completion listing, usually tab */
  1265. X
  1266. X/* These macros now turn on/off echo/cbreak independent of the UNIX running */
  1267. X#define echo_on()    \
  1268. X    if (_tty.sg_flags && isoff(glob_flags, ECHO_FLAG)) nocrmode(), echom()
  1269. X#define echo_off()    \
  1270. X    if (_tty.sg_flags && isoff(glob_flags, ECHO_FLAG)) crmode(), noechom()
  1271. X
  1272. X#define strdup(dst, src) (xfree (dst), dst = savestr(src))
  1273. X#define Debug        if (debug == 0) {;} else (void) wprint
  1274. X
  1275. X#ifdef SYSV
  1276. X#ifndef L_SET
  1277. X#define L_SET    0
  1278. X#endif /* L_SET */
  1279. X#ifndef F_OK
  1280. X#define F_OK    000
  1281. X#define R_OK    004
  1282. X#define W_OK    002
  1283. X#define E_OK    001
  1284. X#endif /* F_OK */
  1285. X#ifdef u_long
  1286. X#undef u_long
  1287. X#endif /* u_long */
  1288. X#define u_long    unsigned long
  1289. X#ifndef HPUX
  1290. X#define vfork   fork
  1291. X#endif /* HPUX */
  1292. X#ifndef SIGCHLD
  1293. X#define SIGCHLD SIGCLD
  1294. X#endif /* SIGCHLD */
  1295. X#endif /* SYSV */
  1296. X
  1297. X#if !defined(SUNTOOL) && !defined(CURSES)
  1298. X
  1299. X#define TRUE          1
  1300. X#define FALSE          0
  1301. X#define print          (void) printf
  1302. X#define wprint          (void) printf
  1303. X#define print_more      (void) printf
  1304. X
  1305. X#endif /* !SUNTOOL && !CURSES */
  1306. X
  1307. X#ifndef max
  1308. X#define max(a,b) (((a) > (b)) ? (a) : (b))
  1309. X#define min(a,b) (((a) < (b)) ? (a) : (b))
  1310. X#endif /* max */
  1311. X
  1312. X#if defined(CURSES) && (!defined(SUNTOOL))
  1313. X#define wprint    (void) printf
  1314. X#endif /* CURSES && (!SUNTOOL) */
  1315. X
  1316. X#ifdef SUNTOOL
  1317. X/* stdout may be closed */
  1318. X#define printf wprint
  1319. X#endif /* SUNTOOL */
  1320. X
  1321. X#if defined(CURSES) || defined(SUNTOOL)
  1322. X#define print_more      turnon(glob_flags, CONT_PRNT), print
  1323. Xvoid print();    /* printf to window or curses or tty accordingly */
  1324. X#endif /* CURSES || SUNTOOL */
  1325. X
  1326. X#define ArraySize(o)      (sizeof(o) / sizeof(*o))
  1327. X
  1328. X#ifdef SUNTOOL
  1329. X
  1330. X#define NO_ITEM        (Panel_item)0
  1331. X#define NO_EVENT    (struct inputevent *)0
  1332. X#define TIME_OUT    60    /* sleep 60 secs between mailchecks */
  1333. X#define PIX_XOR        PIX_SRC ^ PIX_DST
  1334. X#define ID        event_id(event)
  1335. X#define l_width()    mush_font->pf_defaultsize.x /* width of letter */
  1336. X#define l_height()    mush_font->pf_defaultsize.y /* height of letter */
  1337. X#define Clrtoeol(w,x,y)    ((void) pw_text(w, x, y, PIX_SRC, mush_font, blank))
  1338. X
  1339. X/* Miscellaneous old-SunView cleanup */
  1340. X#ifndef TTY_ARGV_DO_NOT_FORK
  1341. X#define TTY_ARGV_DO_NOT_FORK (-1)
  1342. X#endif
  1343. X
  1344. X#endif /* SUNTOOL */
  1345. X
  1346. X/* bits and pieces */
  1347. X#define turnon(flg,val)   ((flg) |= (u_long)(val))
  1348. X#define turnoff(flg,val)  ((flg) &= ~(u_long)(val))
  1349. X#define ison(flg,val)     ((u_long)(flg) & (u_long)(val))
  1350. X#define isoff(flg,val)    (!ison((flg), (val)))
  1351. X#define set_replied(n)      \
  1352. X    if (isoff(msg[n].m_flags, REPLIED)) \
  1353. X        turnon(glob_flags, DO_UPDATE), turnon(msg[n].m_flags, REPLIED)
  1354. X#define set_isread(n)      \
  1355. X    if (ison(msg[n].m_flags, UNREAD)) \
  1356. X        turnon(glob_flags, DO_UPDATE), turnoff(msg[n].m_flags, UNREAD)
  1357. X
  1358. X#define in_pipe() (ison(glob_flags, DO_PIPE|IS_PIPE))
  1359. X#define in_macro() (ison(glob_flags, LINE_MACRO|IN_MACRO))
  1360. X#define line_macro(s) (void) (turnon(glob_flags, LINE_MACRO), mac_push(s))
  1361. X#define curs_macro(s) (void) (turnon(glob_flags, IN_MACRO), mac_push(s))
  1362. X#define Ungetstr(s) (void) (turnon(glob_flags, QUOTE_MACRO), mac_push(s))
  1363. X
  1364. X/* global conditions */
  1365. X#define is_shell (mailfile && *mailfile)
  1366. X
  1367. X/* msg lists represented by bits (8 should be replaced by sizeof(char) */
  1368. X#define clear_msg_list(list)      ((void) bzero(list, (msg_cnt+7)/8))
  1369. X#define msg_bit(list, n)    ((list[(n) / 8] >> ((n) % 8)) & 1)
  1370. X#define set_msg_bit(list, n)    (list[(n) / 8] |= (1 << ((n) % 8)))
  1371. X#define unset_msg_bit(list, n)  (list[(n) / 8] &= ~(1 << ((n) % 8)))
  1372. X#define bput(S1, S2, Len, op)                   \
  1373. X        do {                         \
  1374. X            register char *s1 = S1, *s2 = S2;         \
  1375. X            register int len = Len;             \
  1376. X            while(len--)                 \
  1377. X            *s2++ op *s1++;             \
  1378. X        } while (0)
  1379. X#define bitput(m1,m2,len,op)    bput(m1, m2, (((len)+7)/8), op)
  1380. X
  1381. X/* convenience and/or readability */
  1382. X#define when          break;case
  1383. X#define otherwise      break;default
  1384. X#define lower(c)      (isupper(c)? tolower(c): c)
  1385. X#define Lower(c)      (c = lower(c))
  1386. X#define upper(c)      (islower(c)? toupper(c): c)
  1387. X#define Upper(c)      (c = upper(c))
  1388. X#define skipspaces(n)     for(p += (n); *p == ' ' || *p == '\t'; ++p)
  1389. X#define skipdigits(n)     for(p += (n); isdigit(*p); ++p)
  1390. X#define ismsgnum(c)       (isdigit(c)||c=='.'||c=='^'||c=='$'||c=='*')
  1391. X#define skipmsglist(n)\
  1392. X    for(p += (n); ismsgnum(*p) || index(" \t,-{`}", *p); ++p)\
  1393. X    if (*p != '`' || !p[1]) {;} else do ++p; while (*p && *p != '`')
  1394. X
  1395. X/* define a macro to declare unsigned-long bits */
  1396. X#define ULBIT(bit)        ((u_long)1 << (u_long)(bit))
  1397. X
  1398. X/* various flags */
  1399. Xu_long   glob_flags;    /* global boolean flags thruout the whole program */
  1400. X#define DO_UPDATE   ULBIT(0) /* folder has been modified -- update it */
  1401. X#define REV_VIDEO   ULBIT(1) /* reverse video for curses or toolmode */
  1402. X#define CONT_PRNT   ULBIT(2) /* continue to print without a '\n' */
  1403. X#define DO_SHELL    ULBIT(3) /* run a shell even if no mail? (true if tool) */
  1404. X#define DO_PIPE     ULBIT(4) /* if commands are piping to other commands */
  1405. X#define IS_PIPE     ULBIT(5) /* true if commands' "input" comes from a pipe */
  1406. X#define IGN_SIGS    ULBIT(6) /* true if catch() should not longjmp */
  1407. X#define IGN_BANG    ULBIT(7) /* ignore ! as a history reference */
  1408. X#define ECHO_FLAG   ULBIT(8) /* if true, echo|cbreak is ON, echo typing (-e) */
  1409. X#define IS_GETTING  ULBIT(9) /* true if we're getting input for a letter */
  1410. X#define PRE_CURSES  ULBIT(10) /* true if curses will run, but hasn't started */
  1411. X#define READ_ONLY   ULBIT(11) /* -r passed to folder() for read only */
  1412. X#define REDIRECT    ULBIT(12) /* true if stdin is being redirected */
  1413. X#define WAS_INTR    ULBIT(13) /* catch interrupts, set this flag (signals.c) */
  1414. X#define WARNING     ULBIT(14) /* if set, various warning messages are printed */
  1415. X#define NEW_MAIL    ULBIT(15) /* new mail has arrived; mush is busy or closed */
  1416. X#define CNTD_CMD    ULBIT(16) /* curses.c -- promotes "...continue..." prompt */
  1417. X#define IS_SENDING  ULBIT(17) /* was run to send mail, not run as a shell */
  1418. X#define MIL_TIME    ULBIT(19) /* if $mil_time is set, use 24hr time fmt */
  1419. X#define DATE_RECV   ULBIT(20) /* $date_received: show date received on msgs */
  1420. X#define IN_MACRO    ULBIT(21) /* input is currently being read from a macro */
  1421. X#define LINE_MACRO  ULBIT(22) /* escape to line mode from curses in progress */
  1422. X#define QUOTE_MACRO ULBIT(23) /* protect current macro from recursive expan.. */
  1423. X#define NEW_FRAME   ULBIT(24) /* toolmode should build a new frame for pager */
  1424. X#define HELP_TEXT   ULBIT(25) /* create textsw frame for paging help messages */
  1425. X
  1426. X/* flags to control composition */
  1427. X#define VERBOSE        ULBIT(0)  /* verbose flag for sendmail */
  1428. X#define INCLUDE        ULBIT(1)  /* include msg in response */
  1429. X#define INCLUDE_H    ULBIT(2)  /* include msg with header */
  1430. X#define EDIT        ULBIT(3)  /* enter editor by default on mailing */
  1431. X#define SIGN        ULBIT(4)  /* auto-include ~/.signature in mail */
  1432. X#define DO_FORTUNE    ULBIT(5)  /* add a fortune at end of msgs */
  1433. X#define EDIT_HDRS    ULBIT(6)  /* user edits headers using editor */
  1434. X#define SEND_NOW    ULBIT(7)  /* send without further changes */
  1435. X#define NO_SIGN        ULBIT(8)  /* override SIGN and DO_FORTUNE */
  1436. X
  1437. X/* msg flags */
  1438. X#define PRINTED        ULBIT(4)  /* sent through lpr command */
  1439. X#define NO_HEADER    ULBIT(6)  /* don't print header of message */
  1440. X#define DELETE        ULBIT(7)
  1441. X#define OLD        ULBIT(8)
  1442. X#define UNREAD        ULBIT(9)
  1443. X#define UPDATE_STATUS    ULBIT(10) /* change status of msg when copyback */
  1444. X#define NO_PAGE        ULBIT(11) /* don't page this message */
  1445. X#define INDENT        ULBIT(12) /* indent included msg with string */
  1446. X#define NO_IGNORE    ULBIT(13) /* don't ignore headers */
  1447. X#define PRESERVE    ULBIT(14) /* preserve in mailbox unless deleted */
  1448. X#define M_TOP        ULBIT(14) /* just print the top of msg (same as pre) */
  1449. X#define FORWARD        ULBIT(15) /* Forward messages into the message buffer */
  1450. X#define REPLIED        ULBIT(16) /* Messages that have been replied to */
  1451. X#define NEW_SUBJECT    ULBIT(17) /* new subject regardless of $ask (mail -s) */
  1452. X#define SAVED        ULBIT(18) /* when message has been saved */
  1453. X#ifdef MSG_SEPARATOR
  1454. X#define NO_SEPARATOR    ULBIT(19) /* don't include message separator lines */
  1455. X#endif /* MSG_SEPARATOR */
  1456. X
  1457. X#define    MAXMSGS_BITS    MAXMSGS/sizeof(char)    /* number of bits for bitmap */
  1458. X
  1459. Xstruct msg {
  1460. X    u_long m_flags;
  1461. X    long   m_offset;    /* offset in tempfile of msg */
  1462. X    long   m_size;    /* number of bytes in msg */
  1463. X    int    m_lines;    /* number of lines in msg */
  1464. X    char   *m_date_recv;/* Date user received msg (see dates.c for fmt) */
  1465. X    char   *m_date_sent;/* Date author sent msg (see dates.c for fmt) */
  1466. X} msg[MAXMSGS];
  1467. X
  1468. Xstruct options {
  1469. X    char *option;
  1470. X    char *value;
  1471. X    struct options *next;
  1472. X} *set_options, *aliases, *ignore_hdr, *functions, *fkeys, *own_hdrs;
  1473. X
  1474. X#define chk_option(v,f)    chk_two_lists(do_set(set_options,(v)), (f), "\t ,")
  1475. X
  1476. Xstruct cmd {
  1477. X    char *command;
  1478. X    int (*func)();
  1479. X};
  1480. Xextern struct cmd ucb_cmds[];
  1481. Xextern struct cmd cmds[], hidden_cmds[];
  1482. X
  1483. XFILE
  1484. X    *tmpf,        /* temporary holding place for all mail */
  1485. X    *mask_fopen(),    /* open a file with umask 077 (permissions 600) */
  1486. X    *open_file(),    /* open a file or program for write/append */
  1487. X    *lock_fopen(),    /* open and lock a file as an atomic operation */
  1488. X    *popen();        /* this should be in stdio.h */
  1489. X
  1490. Xextern char
  1491. X    *sys_errlist[],    /* system's list of global error messages */
  1492. X    **environ;        /* user's environment variables */
  1493. X
  1494. Xextern int errno;    /* global system error number */
  1495. Xjmp_buf jmpbuf;        /* longjmp to jmpbuf on sigs (not in tool) */
  1496. X
  1497. Xchar
  1498. X    debug,        /* debug causes various print statements in code */
  1499. X    tempfile[MAXPATHLEN],    /* path to filename of temporary file */
  1500. X    msg_list[MAXMSGS_BITS],    /* MAXMSGS bits of boolean storage */
  1501. X    **alternates,    /* alternates list --see alts() */
  1502. X    *cmd_help,        /* filename of location for "command -?" commands. */
  1503. X    *login,        /* login name of user */
  1504. X    *mailfile,        /* path to filename of current mailfile */
  1505. X    **ourname,        /* the name and aliases of the current host */
  1506. X    **known_hosts,    /* the names of all hosts connected via uucp */
  1507. X    *prompt,        /* the prompt string -- may have %d */
  1508. X    *format_prompt(),    /* function to format prompts from the prompt string */
  1509. X    *escape,        /* the "tilde escape" when inputting text to letter */
  1510. X    *hdrs_only,        /* true if -H flag was given --set to args */
  1511. X    *hdr_format,    /* set to the header format string; referenced a lot */
  1512. X    *spoolfile,        /* MAILDIR/$USER in a string -- this is used a lot */
  1513. X    *msg_get(),        /* find start of message and return From_ line */
  1514. X    *do_range(),    /* parse a string converting to a "range" of numbers */
  1515. X    *getpath(),        /* static char returning path (expanding ~, +, %, #) */
  1516. X    *getdir(),        /* uses getpath() to expand and test directory names */
  1517. X    *do_set(),        /* set/unset an option, alias, ignored-hdr */
  1518. X    *reverse(),        /* reverse a string */
  1519. X    *trim_filename(),    /* remove or condense leading file name path */
  1520. X    *prog_name,
  1521. X
  1522. X    /* from loop.c */
  1523. X    **make_command(),    /* build a command vector (argv) */
  1524. X    **mk_argv(),    /* given a string, make a vector */
  1525. X    *variable_stuff(),    /* return information about variables */
  1526. X    *check_internal(),    /* test or evaluate internal variables */
  1527. X
  1528. X    /* from dates.c */
  1529. X    *Time(),        /* returns string expression of time (takes args) */
  1530. X    *date_to_ctime(),    /* convert a date into ctime() format */
  1531. X    *date_to_string(),    /* returns a string described by parse_date() */
  1532. X    *msg_date(),    /* return a string of the date of a message */
  1533. X    *parse_date(),    /* parse an ascii date, and return message-id str */
  1534. X    *rfc_date(),    /* create a date string compliant to RFC822 */
  1535. X
  1536. X    /* from hdrs.c */
  1537. X    *cc_to(),         /* when responding, return str which is the cc-list */
  1538. X    *compose_hdr(),    /* passes hdr_format to format_hdr() for displays */
  1539. X    *format_hdr(),    /* returns a formatted line describing passed msg # */
  1540. X    *header_field(),    /* the line in msg described by arg (message header) */
  1541. X    *reply_to(),    /* who do we reply to when responding */
  1542. X    *subject_to(),      /* when responding, return str which is the subject */
  1543. X
  1544. X    /* addrs.c */
  1545. X    *alias_to_address(),/* convert a name[list] to "real" names */
  1546. X    *bang_form(),    /* construct a !-style form of an address */
  1547. X    *get_name_n_addr(), /* get name and addr from a well-formed address */
  1548. X    *set_header(),     /* [interactive] proc to set/display to/subject/cc */
  1549. X    *wrap_addrs();    /* insert newlines in between headers */
  1550. X
  1551. Xint
  1552. X    last_msg_cnt,    /* when checking for new mail, save the last msg_cnt */
  1553. X    msg_cnt,        /* total number of messages */
  1554. X    crt,        /* min number of lines msg contains to invoke pager */
  1555. X    current_msg,    /* the current message we're dealing with */
  1556. X    exec_pid,        /* pid of a command that has been "exec"ed */
  1557. X    hist_no,        /* command's history number */
  1558. X    iscurses,        /* if we're running curses */
  1559. X    istool,        /* argv[0] == "xxxxtool", ranges from 0 to 2 */
  1560. X    n_array[128],    /* array of message numbers in the header window */
  1561. X    screen,        /* number of headers window can handle */
  1562. X    wrapcolumn,        /* compose mode line wrap, measured from left */
  1563. X
  1564. X    close_lock(),     /* unlock and close a file opened by lock_fopen() */
  1565. X
  1566. X    mush_quit(), do_alias(), respond(), cd(), sh(), stop(),
  1567. X    folder(), folders(), merge_folders(), do_undigest(),
  1568. X    save_msg(), delete(), do_mail(), lpr(), alts(), set(), do_hdrs(),
  1569. X    save_opts(), preserve(), sort(), readmsg(), edit_msg(), eval_cmd(),
  1570. X    do_pick(), print_help(), question_mark(), do_from(), my_stty(),
  1571. X    do_version(), disp_hist(), source(), do_echo(), ls(), pipe_msg(),
  1572. X    await(), nopenfiles(), file_to_fp(),
  1573. X    check_new_mail(), get_new_mail(), show_new_mail(),
  1574. X    Setenv(), Unsetenv(), Printenv(), msg_flags(), toggle_debug();
  1575. X
  1576. X#ifndef SIGRET
  1577. X#define SIGRET int
  1578. X#endif /* SIGRET */
  1579. XSIGRET
  1580. X    rm_edfile(),    /* remove letter-compose file on interrupts */
  1581. X    stop_start(),    /* handle job control signals */
  1582. X    bus_n_seg(),    /* handle runtime segfaults -- exit gracefully */
  1583. X    sigchldcatcher(),    /* account for terminated child processes */
  1584. X    catch(),        /* catch user (keyboard) generated signals */
  1585. X    intrpt();        /* handle interrupts when we don't want to */
  1586. X
  1587. Xlong
  1588. X    spool_size,        /* size of spool mail regardless of current folder */
  1589. X    last_size,        /* the last size of the mailfile since last check */
  1590. X    time();        /* satisfy lint */
  1591. X
  1592. Xvoid
  1593. X    error(), getmail(), mail_status(), sign_letter(),
  1594. X    init(), display_msg(), cleanup(), fs_error();
  1595. X    /* printf(), fclose(), fflush(), fputs(), fputc() */
  1596. X#ifdef TIOCGLTC
  1597. Xstruct ltchars ltchars;            /* tty character settings */
  1598. X#endif /* TIOCGLTC */
  1599. X#ifdef BSD /* (TIOCGETC) */
  1600. Xstruct tchars  tchars;            /* more tty character settings */
  1601. X#endif /* BSD (TIOCGETC) */
  1602. X
  1603. X#ifdef CURSES
  1604. X
  1605. X#define STANDOUT(y,x,s) standout(), mvaddstr(y,x,s), standend()
  1606. X#define redraw()    clearok(curscr, TRUE), wrefresh(curscr)
  1607. X
  1608. Xint
  1609. X    curses_init();    /* interpret commands via the curses interface */
  1610. X#endif /* CURSES */
  1611. X
  1612. Xint
  1613. X    mac_push(),        /* set up a string as a macro */
  1614. X    bind_it();        /* bind strings to functions or macros */
  1615. X
  1616. Xvoid
  1617. X    mac_flush();    /* Abandon macro processing (on error) */
  1618. X
  1619. X#ifdef SUNTOOL
  1620. Xvoid
  1621. X    timeout_cursors(), do_file_dir(), toggle_mail_items(), ok_box(),
  1622. X    read_mail(), opts_panel_item(), view_options(), toolquit(), wprint(),
  1623. X    update_list_textsw(), check_icons();
  1624. X
  1625. Xchar
  1626. X    *find_key(),    /* pass x,y coords to find which function key assoc. */
  1627. X    *panel_get(),          /* returns what has been typed in a panel item */
  1628. X    *tool_help,        /* help for tool-related things (sometimes, overlap) */
  1629. X    *more_prompt,    /* when NULL, we're paging a msg; else pager prompt */
  1630. X    blank[128];        /* use to clear to end of line */
  1631. X
  1632. Xint
  1633. X    time_out,        /* time out interval to wait for new mail */
  1634. X    is_iconic;        /* set if the mushview window is iconic. */
  1635. X
  1636. XNotify_value
  1637. X    do_check(),        /* check for new mail on timeout */
  1638. X    destroy_proc(),    /* Destroy procedure. */
  1639. X    scroll_textwin(),    /* Do fancy TEXTSW scrolling */
  1640. X    edit_msg_textwin();    /* Auto-positioning in compose TEXTSW */
  1641. X
  1642. XFrame tool;        /* Main frame. */
  1643. XFrame compose_frame;    /* Compose frame. */
  1644. XTextsw pager_textsw;    /* for "paging" messages and other lists.. */
  1645. XTextsw mfprint_sw;    /* Textsw in main mush frame for wprint() */
  1646. XTextsw cprint_sw;    /* Textsw in compose frame for wprint() */
  1647. XTextsw wprint_sw;    /* Current text subwindow for wprint() */
  1648. XCanvas hdr_sw;         /* Canvas for message headers */
  1649. XTty tty_sw;         /* subwindow which forks a shell (usually editor) */
  1650. X
  1651. XPixwin
  1652. X    *hdr_win;        /* pixwin for message headers */
  1653. X
  1654. Xstruct pixfont *mush_font;    /* array of fonts */
  1655. X
  1656. Xstruct itimerval mail_timer;    /* frequency to check for new mail */
  1657. X
  1658. Xextern Cursor l_cursor, m_cursor, r_cursor;
  1659. Xextern Icon mail_icon;
  1660. X
  1661. X/* When trapping events that represent scrolling actions */
  1662. Xtypedef enum {
  1663. X    MUSH_SCROLL_TO,
  1664. X    MUSH_SCROLL_RELATIVE,
  1665. X    MUSH_SCROLL_IGNORE,
  1666. X    MUSH_SCROLL_PASS_EVENT
  1667. X} Scroll_action;
  1668. X#endif /* SUNTOOL */
  1669. END_OF_FILE
  1670. if test 22786 -ne `wc -c <'mush/mush.h'`; then
  1671.     echo shar: \"'mush/mush.h'\" unpacked with wrong size!
  1672. fi
  1673. # end of 'mush/mush.h'
  1674. fi
  1675. if test -f 'mush/version.h' -a "${1}" != "-c" ; then 
  1676.   echo shar: Will not clobber existing file \"'mush/version.h'\"
  1677. else
  1678. echo shar: Extracting \"'mush/version.h'\" \(182 characters\)
  1679. sed "s/^X//" >'mush/version.h' <<'END_OF_FILE'
  1680. X/* @(#)version.h    (c) Copyright 1989 (Dan Heller) */
  1681. X
  1682. X#define MUSHNAME    "Mail User's Shell"
  1683. X#define RELEASE_DATE    "5/02/90"
  1684. X#define RELEASE        7
  1685. X#define REVISION    "1"
  1686. X#define PATCHLEVEL    1
  1687. END_OF_FILE
  1688. if test 182 -ne `wc -c <'mush/version.h'`; then
  1689.     echo shar: \"'mush/version.h'\" unpacked with wrong size!
  1690. fi
  1691. # end of 'mush/version.h'
  1692. fi
  1693. echo shar: End of archive 10 \(of 19\).
  1694. cp /dev/null ark10isdone
  1695. MISSING=""
  1696. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  1697.     if test ! -f ark${I}isdone ; then
  1698.     MISSING="${MISSING} ${I}"
  1699.     fi
  1700. done
  1701. if test "${MISSING}" = "" ; then
  1702.     echo You have unpacked all 19 archives.
  1703.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1704. else
  1705.     echo You still need to unpack the following archives:
  1706.     echo "        " ${MISSING}
  1707. fi
  1708. ##  End of shell archive.
  1709. exit 0
  1710.  
  1711.  
  1712.