home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume19 / nn / part05 < prev    next >
Encoding:
Internet Message Format  |  1989-06-22  |  49.4 KB

  1. Subject:  v19i066:  NN, a Usenet news reader, Part05/15
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: storm@texas.dk (Kim F. Storm)
  7. Posting-number: Volume 19, Issue 66
  8. Archive-name: nn/part05
  9.  
  10. #!/bin/sh
  11. # this is part 5 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file help.help continued
  14. #
  15. CurArch=5
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file help.help"
  26. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' >> help.help
  27. Xshow        displaying various tables
  28. Xvariables    variables
  29. NO_NEWS_IS_GOOD_NEWS
  30. echo "File help.help is complete"
  31. chmod 0644 help.help || echo "restore of help.help fails"
  32. set `wc -c help.help`;Sum=$1
  33. if test "$Sum" != "269"
  34. then echo original size 269, current size $Sum;fi
  35. echo "x - extracting help.map (Text)"
  36. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.map &&
  37. X;:AMAP COMMAND;:A
  38. X
  39. Xmap TABLE        show contents of mapping table        
  40. X
  41. Xmap menu KEY COMMAND    map KEY into COMMAND in menu mode
  42. Xmap show KEY COMMAND    map KEY into COMMAND in article presentation mode
  43. Xmap key  KEY1 KEY2    map KEY1 into KEY2 (unconditionally)
  44. Xmap #N   CH1 CH2 ...    define the input sequence CH1 CH2 ... as special key N
  45. X
  46. X;:AKEYS;:A
  47. X
  48. X    0xNN: the ascii character NN
  49. X    C: the character C
  50. X    ^C: control-C (^? = DEL)
  51. X    #N: special key number N
  52. X    up, down, left, rigth: the arrow keys
  53. X
  54. X;:Chelp.commands
  55. NO_NEWS_IS_GOOD_NEWS
  56. chmod 0644 help.map || echo "restore of help.map fails"
  57. set `wc -c help.map`;Sum=$1
  58. if test "$Sum" != "494"
  59. then echo original size 494, current size $Sum;fi
  60. echo "x - extracting help.menu (Text)"
  61. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.menu &&
  62. X;:ASELECT (toggle);:A                ;:AMOVE;:A
  63. Xa-z0-9    specified article        ,    Next menu line
  64. Xx-y    range x to y            /    Previous menu line
  65. Xx*    same subject as x        SPACE    Next menu page (if any)
  66. X.    current article            < >    Prev/Next menu page
  67. X@    Reverse all selections        ^ $    First/Last menu page
  68. X
  69. X;:ASHOW SELECTED ARTICLES;:A
  70. XSPACE    Show selected articles (only when on last menu page)
  71. XZ     Show selected articles NOW, and return to this group afterwards
  72. XX    Show selected articles NOW, and continue with next group
  73. X
  74. X;:AGOTO OTHER GROUPS;:A
  75. XX    If no articles are selected then skip to next group.
  76. XN P     Goto next/previous group WITHOUT reading current group
  77. XG    Goto named group or open a folder.
  78. XB A    Go back/forward in groups already read
  79. X
  80. X;:AMISCELLANEOUS;:A
  81. XU    (Un)subscribe            L    Change menu layout
  82. XS O W    Save articles            !    Shell escape
  83. XF R M    Follow-up/Reply/Mail        C    Cancel an article of your own
  84. NO_NEWS_IS_GOOD_NEWS
  85. chmod 0644 help.menu || echo "restore of help.menu fails"
  86. set `wc -c help.menu`;Sum=$1
  87. if test "$Sum" != "858"
  88. then echo original size 858, current size $Sum;fi
  89. echo "x - extracting help.more (Text)"
  90. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.more &&
  91. X;:ASCROLLING;:A          ;:AABSOLUTE LINE;:A        ;:ASEARCHING;:A
  92. XSP      1 page forw      ^    top        /RE    find regular expr.
  93. Xd    1/2 page forw      gNUM    line NUM    . //    repeat last search
  94. XCR      1 line forw      $    last line
  95. XDEL       1 page back      h    header        ;:ATEXT CONVERSIONS;:A
  96. Xu       1/2 page back      H    full digest    D       decrypt article (rot13)
  97. X                        c       compress spaces
  98. X;:AGOTO ANOTHER ARTICLE;:A
  99. XSP      next (at end of current article)    ;:ACANCEL, SUBSCRIBE, KILL;:A
  100. Xn       next                                C       cancel article
  101. Xp       previous article                    U       (un)subscribe to group
  102. Xk       kill subject (not permanently)      K       kill/select handling
  103. X*       select subject                  
  104. X                                                ;:AQUIT / ESCAPE;:A
  105. X;:ASAVE;:A                                   =       back to menu
  106. Xs, o, w   save with full/short/no header         N       goto next group
  107. X:unshar      unshar article            X       as N, mark as read
  108. X                             !, ^Z   Shell escape, suspend
  109. X;:AREPLY, POST;:A                    Q       quit nn
  110. Xr       mail reply to author of article                      
  111. Xm       mail (or forward article)           ;:AREDRAW;:A
  112. Xf       post follow-up to article           ^P      Repeat last message
  113. X:post   post new article                    ^L, ^R  Redraw screen
  114. NO_NEWS_IS_GOOD_NEWS
  115. chmod 0644 help.more || echo "restore of help.more fails"
  116. set `wc -c help.more`;Sum=$1
  117. if test "$Sum" != "1258"
  118. then echo original size 1258, current size $Sum;fi
  119. echo "x - extracting help.read (Text)"
  120. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.read &&
  121. X;:Chelp.more
  122. NO_NEWS_IS_GOOD_NEWS
  123. chmod 0644 help.read || echo "restore of help.read fails"
  124. set `wc -c help.read`;Sum=$1
  125. if test "$Sum" != "13"
  126. then echo original size 13, current size $Sum;fi
  127. echo "x - extracting help.set (Text)"
  128. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.set &&
  129. X;:ASET COMMAND;:A
  130. X
  131. X:set            show current variables
  132. X
  133. X:set VARIABLE VALUE    set variable
  134. X:unset VARIABLE        reset variable 
  135. X:toggle VARIABLE
  136. X
  137. X;:Chelp.variables
  138. NO_NEWS_IS_GOOD_NEWS
  139. chmod 0644 help.set || echo "restore of help.set fails"
  140. set `wc -c help.set`;Sum=$1
  141. if test "$Sum" != "152"
  142. then echo original size 152, current size $Sum;fi
  143. echo "x - extracting help.show (Text)"
  144. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.show &&
  145. X;:ASHOW COMMAND;:A
  146. X
  147. Xshow kill        show auto kill/select entries for current
  148. X            groups and all groups.
  149. X
  150. Xshow groups        show groups with unread articles (= Y command)
  151. X
  152. Xshow groups all        show all subscribed groups
  153. X
  154. Xshow groups total    show all available groups
  155. X
  156. Xshow map key/menu/show    show key bindings
  157. NO_NEWS_IS_GOOD_NEWS
  158. chmod 0644 help.show || echo "restore of help.show fails"
  159. set `wc -c help.show`;Sum=$1
  160. if test "$Sum" != "292"
  161. then echo original size 292, current size $Sum;fi
  162. echo "x - extracting help.variables (Text)"
  163. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.variables &&
  164. X;:AVARIABLES;:A
  165. X
  166. Xbackup            Keep backup of rc file + delay update until quit (= -B)
  167. Xcomp1-key KEY        Completion key 1 (space)
  168. Xcomp2-key KEY        Completion key 2 (tab)
  169. Xconfirm            User must confirm all messages with return (= -W)
  170. Xdate              Show article dates (date = -D)
  171. Xdefault-save-file FILE    Default save file (for + abbreviation)        
  172. Xdelay-redraw        Do not redraw screen immediately after : commands
  173. Xerase-key KEY        Erase last input character or completion
  174. Xexpert            Use shorter prompts
  175. Xfolder DIR         Folder directory
  176. Xfsort            Sort folders in subject order (nofsort = -f)
  177. Xheader-lines LIST    Customized article header format
  178. Xhelp-key KEY        Completion help key (?)
  179. Xincluded-mark STR      Prefix on included lines in replies (>) 
  180. Xkill            Enable/disable auto kill/select (nokill = -k)
  181. Xkill-key KEY        Delete input line key
  182. Xlayout N        Menu layout N (-LN)
  183. Xlimit N              Limit number of presented articles to N (-aN)
  184. Xlong-menu        Use all lines on the menu screen
  185. Xmacro-debug        Trace the execution of all macros
  186. Xmail-format        Folders are created in mail compatible format
  187. Xmail-record FILE      Save all replies in FILE
  188. Xmonitor            Print all characters when reading article
  189. Xnews-record FILE      Save all posted articles in FILE
  190. Xold   N              Show read articles also (-xN, or -x if N is omitted)
  191. Xoverlap N        Display last N lines on next page when reading
  192. Xpager CMD          Screen pager used in administration mode (e.g. pg -n)
  193. Xprinter CMD         Default print command (e.g. lp -s)
  194. Xquick-save        Save in default save file without asking
  195. Xrecord FILE          Set both news-record and mail-record to FILE
  196. Xrepeat            Do not truncate repeated subject lines
  197. Xretry-on-error N    Retry N times if open of article fails
  198. Xsave-counter FMT      Format of the save counter (e.g. .%02d)
  199. Xsave-report        Display number of lines saved
  200. Xsilent            Do not print "No news" etc.
  201. Xsort              Sort articles on menu (nosort = -q)
  202. Xsplit              Split digests (nosplit = -d)
  203. Xstop N            Stop printing of articles after N lines (= -lN)
  204. Xtime              Show current time on prompt line (notime = -T)
  205. Xwindow N        Preview window size is N lines (= -wN)
  206. X
  207. NO_NEWS_IS_GOOD_NEWS
  208. chmod 0644 help.variables || echo "restore of help.variables fails"
  209. set `wc -c help.variables`;Sum=$1
  210. if test "$Sum" != "2023"
  211. then echo original size 2023, current size $Sum;fi
  212. echo "x - extracting help.welcome (Text)"
  213. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > help.welcome &&
  214. X;:AWelcome to the nn news reader;:A
  215. X
  216. XUnlike the other news readers you might be familiar with, the ultimate
  217. Xgoal of nn is "not to read news"; actually, "nn" is an acronym for "No
  218. XNews", and the parole for nn is:
  219. X
  220. X    No news is good news, but nn is better.
  221. X
  222. XI hope that you will enjoy using nn.
  223. X
  224. XIf you have problems, try the '?' command which will provide a quick
  225. Xreference guide for the present environment.  Otherwise, consult the
  226. Xmanuals or ask a local guru.  
  227. X
  228. X
  229. XHave fun,
  230. X
  231. XKim Fabricius Storm
  232. XTexas Instruments A/S
  233. XDenmark
  234. NO_NEWS_IS_GOOD_NEWS
  235. chmod 0644 help.welcome || echo "restore of help.welcome fails"
  236. set `wc -c help.welcome`;Sum=$1
  237. if test "$Sum" != "525"
  238. then echo original size 525, current size $Sum;fi
  239. echo "x - extracting init.c (Text)"
  240. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > init.c &&
  241. X/*
  242. X *    .nn/init file handling
  243. X */
  244. X
  245. X
  246. X#include "config.h"
  247. X#include "articles.h"
  248. X#include "term.h"
  249. X#include "keymap.h"
  250. X#include "menu.h"
  251. X
  252. Xexport int in_init = 0;        /* true when parsing init file */
  253. Xexport int alt_cmd_key;        /* K_ when parse_command returns AC_KEYCMD */
  254. X
  255. Xstatic int init_err = 0;    /* errors in init file */
  256. X
  257. X
  258. X/*VARARGS*/
  259. Xinit_message(va_alist)
  260. Xva_dcl
  261. X{
  262. X    char *fmt;
  263. X    va_list ap;
  264. X    
  265. X    va_start(ap);
  266. X    
  267. X    if (in_init) {
  268. X    fmt = va_arg1(char *);
  269. X
  270. X    printf("init error: ");
  271. X    vprintf(fmt, va_args2toN);
  272. X    putchar(NL);
  273. X    init_err++;
  274. X    } else
  275. X    vmsg(va_args1toN);
  276. X
  277. X    va_end(ap);
  278. X}
  279. X
  280. X    
  281. Xvisit_init_file()
  282. X{
  283. X    extern FILE *loc_seq_hook, *glob_seq_hook;
  284. X    in_init = 1;
  285. X    load_init_file(relative(lib_directory, "init"), &glob_seq_hook);
  286. X    load_init_file("init", &loc_seq_hook);
  287. X    if (init_err) nn_exit(1);
  288. X    in_init = 0;
  289. X}
  290. X
  291. X
  292. X#define START_SEQUENCE 555
  293. X
  294. X
  295. Xstatic load_init_file(name, seq_hook_ptr)
  296. Xchar *name;
  297. XFILE **seq_hook_ptr;
  298. X{
  299. X    FILE *init;
  300. X    char cmdbuf[512], *cmd, *term;
  301. X    extern char *term_name;
  302. X
  303. X    /* use cmdbuf temporarily (to handle @ expansion) */
  304. X    for (cmd = cmdbuf; *name; name++)
  305. X    if (*name == '@') {
  306. X        term = term_name;
  307. X        while (term && *term) *cmd++ = *term++;
  308. X    } else
  309. X        *cmd++ = *name;
  310. X    *cmd = NUL;
  311. X    name = cmdbuf;
  312. X
  313. X    if (*name != '/')
  314. X    name = relative(nn_directory, name);
  315. X    
  316. X    init = open_file(name, OPEN_READ);
  317. X    if (init == NULL) return;
  318. X
  319. X    while (fgets(cmdbuf, 512, init)) {
  320. X    /* we use AC_REDRAW to avoid !-commands clear the screen */
  321. X    if (parse_command(cmdbuf, AC_REDRAW, init) == START_SEQUENCE) {
  322. X        if (seq_hook_ptr) {
  323. X        *seq_hook_ptr = init;
  324. X        return;    /* no close !! */
  325. X        } else {
  326. X        init_message("load file contains 'sequence'");
  327. X        fclose(init);
  328. X        return;
  329. X        }
  330. X    }
  331. X    }
  332. X    
  333. X    fclose(init);
  334. X}
  335. X
  336. X
  337. X#define MAXARG 10
  338. X
  339. Xstatic char *argvec[MAXARG + 2];
  340. Xstatic int argc;
  341. X
  342. Xstatic char *strip_str(cmd)
  343. Xregister char *cmd;
  344. X{
  345. X    if (cmd == NULL) return cmd;
  346. X
  347. X    while (*cmd && isspace(*cmd)) cmd++;
  348. X    if (*cmd == NUL || *cmd == NL) return NULL;
  349. X    
  350. X    return cmd;
  351. X}
  352. X
  353. X    
  354. Xstatic split_command(cmd)
  355. Xregister char *cmd;
  356. X{
  357. X    /* split command string */
  358. X
  359. X    for (argc = 0; argc < MAXARG + 2; argc++) argvec[argc] = NULL;
  360. X    if ((cmd = strip_str(cmd)) == NULL || *cmd == '#') return 0;
  361. X    
  362. X    argc = 0;
  363. X    argvec[0] = cmd;
  364. X
  365. X    if (in_init)
  366. X    while (*cmd) {
  367. X        if (*cmd == NL) {
  368. X        *cmd = NUL;
  369. X        break;
  370. X        }
  371. X        cmd++;
  372. X    }
  373. X
  374. X    return 1;
  375. X}
  376. X
  377. Xstatic char *argv(i)
  378. Xint i;
  379. X{
  380. X    register char *cmd;
  381. X    
  382. X    if (i > MAXARG) return NULL;
  383. X    
  384. X    if (argc <= i)
  385. X    if (cmd = argvec[argc])
  386. X        while (argc <= i) {
  387. X        while (*cmd && !isspace(*cmd)) cmd++;
  388. X        if (*cmd == NUL) {
  389. X            argc = MAXARG;
  390. X            break;
  391. X        }
  392. X        
  393. X        *cmd++ = NUL;
  394. X        if ((cmd = strip_str(cmd)) == NULL) {
  395. X            argc = MAXARG;
  396. X            break;
  397. X        }
  398. X        argvec[++argc] = cmd;
  399. X        }
  400. X    else
  401. X        argc = MAXARG;
  402. X
  403. X    return argvec[i];
  404. X}
  405. X
  406. X    
  407. X/*
  408. X * parse a command (also :-commands)
  409. X */
  410. X
  411. Xstatic char *sw_string;
  412. X
  413. X#define    SWITCH(str)    \
  414. X    for (sw_string = str; sw_string; sw_string = NULL) 
  415. X
  416. X#define CASE(str)    \
  417. X    if (strcmp(sw_string, str) == 0)
  418. X    
  419. X
  420. X#define ARG(i, str)    (argv(i) && strcmp(argv(i), str) == 0)
  421. X#define ARGVAL(i)    atol(argv(i))
  422. X#define ARGTAIL        argvec[argc]
  423. X
  424. Xstruct alt_commands {
  425. X    char *alt_name;
  426. X    int     alt_len;
  427. X    int  alt_type;
  428. X} alt_commands[] = {
  429. X    "admin",            5,    0,
  430. X    "cd",            2,    1,
  431. X    "compile",            7,    0,
  432. X    "coredump",            8,    0,
  433. X    "define",            6,    0,
  434. X    "help",            4,    2,
  435. X    "man",            3,    0,
  436. X    "map",            3,    -1,
  437. X    "map both",            8,    4,
  438. X    "map key",            7,    0,
  439. X    "map menu",            8,    4,
  440. X    "map show",            8,    4,
  441. X    "mkdir",            5,    1,
  442. X    "print",            5,    0, /* QUICK HACK */
  443. X    "pwd",            3,    0,
  444. X    "rmail",            5,    0,
  445. X    "set",            3,    3,
  446. X    "show",            4,    -1,
  447. X    "show groups",        11,    -1,
  448. X    "show groups all",        15,    0,
  449. X    "show groups subscr",    18,    0,
  450. X    "show groups total",    17,    0,
  451. X    "show groups unsub",    17,    0,
  452. X    "show kill",        9,    0,
  453. X    "show map",            8,    -1,
  454. X    "show map #",        10,    0,
  455. X    "show map key",        12,    0,
  456. X    "show map menu",        13,    0,
  457. X    "show map show",        13,    0,
  458. X    "sort",            4,    -1,
  459. X    "sort age",            8,    0,
  460. X    "sort arrival",        12,    0,
  461. X    "sort subject",        12,    0,
  462. X    "toggle",            6,    3,
  463. X    "unread",            6,    0,
  464. X    "unset",            5,    3,
  465. X    "unshar",            6,    0, /* QUICK HACK */
  466. X    NULL,            0,    0
  467. X};
  468. X
  469. Xalt_completion(buf, index)
  470. Xchar *buf;
  471. Xint index;
  472. X{
  473. X    static char *head, *tail = NULL, buffer[FILENAME];
  474. X    static int len;
  475. X    static struct alt_commands *alt, *help_alt;
  476. X    static int (*other_compl)();
  477. X    int temp;
  478. X    register char *p, *q;
  479. X    extern int file_completion(), var_completion(), cmd_completion();
  480. X    extern int list_offset;
  481. X    
  482. X    if (other_compl) {
  483. X    temp = (*other_compl)(buf, index);
  484. X    if (index == 0 && temp == 1 && tail) strcpy(tail, head);
  485. X    if (index < 0 || (index == 0 && temp == 0)) {
  486. X        other_compl = NULL;
  487. X        list_offset = 0;
  488. X    }
  489. X    return temp;
  490. X    }
  491. X    
  492. X    if (index < 0) return 0;
  493. X
  494. X    if (buf) {
  495. X    head = buf;
  496. X    tail = buf + index;
  497. X    alt = help_alt = alt_commands;
  498. X    len = tail - head;
  499. X    other_compl = NULL;
  500. X    
  501. X    for (; alt->alt_name; alt++) {
  502. X        if (len <= alt->alt_len || head[alt->alt_len] != SP) continue;
  503. X        index = strncmp(alt->alt_name, head, alt->alt_len);
  504. X        if (index < 0) continue;
  505. X        if (index > 0) break;
  506. X
  507. X        if (alt->alt_type < 0) {
  508. X        if (len > alt->alt_len) continue;
  509. X        break;
  510. X        }
  511. X        
  512. X        if (alt->alt_type == 0) return -1; /* cannot be further compl */
  513. X
  514. X        head += alt->alt_len;
  515. X        while (*head && *head == SP) head++;
  516. X        len = tail - head;
  517. X        temp = -1;
  518. X        
  519. X        switch (alt->alt_type) {
  520. X         case 1:
  521. X        other_compl = file_completion;
  522. X        tail = NULL;
  523. X        temp = file_completion(head, len);
  524. X        break;
  525. X        
  526. X         case 2:
  527. X        other_compl = file_completion;
  528. X        sprintf(buffer, "%s.%s",
  529. X            relative(lib_directory, "help"), head);
  530. X        len = strlen(buffer);
  531. X        head = buffer + len;
  532. X        list_offset = 5;
  533. X        temp = file_completion(buffer, len);
  534. X        break;
  535. X        
  536. X         case 3:
  537. X        /* [set ]variable[ value] */
  538. X        for (p = head; *p; ) 
  539. X            if (*p++ == SP) return -1;
  540. X        other_compl = var_completion;
  541. X        tail = NULL;
  542. X        temp = var_completion(head, len);
  543. X        break;
  544. X        
  545. X         case 4:
  546. X        /* [map XXX ]Y command[ N] */
  547. X        for (p = head, temp = 0; *p; ) 
  548. X            if (*p++ == SP) {
  549. X            while (*p && *p == SP) p++;
  550. X            head = p;
  551. X            temp++;
  552. X            }
  553. X        if (temp != 1) return -1;
  554. X
  555. X        other_compl = cmd_completion;
  556. X        tail = NULL;
  557. X        len = p - head;
  558. X        temp = cmd_completion(head, len);
  559. X        break;
  560. X        }
  561. X        if (temp <= 0) other_compl = NULL;
  562. X        return temp;
  563. X    }
  564. X    
  565. X    alt = alt_commands;
  566. X    return 1;
  567. X    }
  568. X    
  569. X    if (index) {
  570. X    list_completion((char *)NULL);
  571. X    if (help_alt->alt_name == NULL) help_alt = alt_commands;
  572. X    list_offset = 0;
  573. X    if (p = strrchr(head, ' ')) list_offset = p - head;
  574. X    
  575. X    while (help_alt->alt_name) {
  576. X        if (len > help_alt->alt_len ||
  577. X        (index = strncmp(help_alt->alt_name, head, len)) < 0) {
  578. X        help_alt++;
  579. X        continue;
  580. X        }
  581. X        if (index > 0) {
  582. X        help_alt = alt_commands;
  583. X        break;
  584. X        }
  585. X        p = help_alt->alt_name;
  586. X        if (list_completion(p) == 0) break;
  587. X        temp = help_alt->alt_len;
  588. X    
  589. X        do help_alt++;
  590. X        while ((q = help_alt->alt_name) && help_alt->alt_len > temp &&
  591. X           strncmp(p, q, temp) == 0);
  592. X    }
  593. X    fl;
  594. X    list_offset = 0;
  595. X    return 1;
  596. X    }
  597. X
  598. X    for (; alt->alt_name; alt++) {
  599. X    if (len == 0) 
  600. X        index = 0;
  601. X    else
  602. X        index = strncmp(alt->alt_name, head, len);
  603. X    if (index < 0) continue;
  604. X    if (index > 0) break;
  605. X    
  606. X    p = alt->alt_name;
  607. X    sprintf(tail, "%s ", p + len);
  608. X    temp = alt->alt_len;
  609. X    
  610. X    do alt++;
  611. X    while ((q = alt->alt_name) && alt->alt_len > temp &&
  612. X           strncmp(p, q, temp) == 0);
  613. X    
  614. X    return 1;
  615. X    }
  616. X    return 0;
  617. X}
  618. X
  619. X    
  620. Xparse_command(cmd, ok_val, initf)
  621. Xchar *cmd;
  622. Xint ok_val;
  623. XFILE *initf;
  624. X{
  625. X    if (!split_command(cmd)) return ok_val;
  626. X
  627. X    if (*ARGTAIL == '!') {
  628. X    if (run_shell(ARGTAIL+1, ok_val == AC_PROMPT)) {
  629. X        any_key(0);
  630. X        return AC_REDRAW;
  631. X    }
  632. X    return ok_val;
  633. X    }
  634. X
  635. X    SWITCH( argv(0) ) {
  636. X
  637. X    CASE( "unset" ) {
  638. X        if (argv(1) == NULL) goto stx_err;
  639. X        
  640. X        if (set_variable(argv(1), 0, (char *)NULL))
  641. X        return AC_REDRAW;
  642. X        else
  643. X        return ok_val;
  644. X    }
  645. X    
  646. X    CASE( "set" ) {
  647. X        if (ARGTAIL == NULL) {
  648. X        disp_variables();
  649. X        return AC_REDRAW;
  650. X        }
  651. X
  652. X        cmd = argv(1);    /* get ARGTAIL right */
  653. X        if (set_variable(cmd, 1, ARGTAIL))
  654. X        return AC_REDRAW;
  655. X        else
  656. X        return ok_val;
  657. X    }
  658. X
  659. X    CASE( "toggle" ) {
  660. X        if (argv(1) == NULL) goto stx_err;
  661. X        toggle_variable(argv(1));
  662. X        break;
  663. X    }
  664. X    
  665. X    CASE( "define" ) {
  666. X        if (in_init) {
  667. X        if (argv(1) == NULL) {
  668. X            init_message("macro number missing");
  669. X            break;
  670. X        }
  671. X        m_define(argv(1), initf);
  672. X        } else
  673. X        if (m_define(argv(1), (FILE *)NULL))
  674. X            return AC_REDRAW;
  675. X        
  676. X        break;
  677. X    }
  678. X        
  679. X    CASE( "map" ) {
  680. X        if (argv(2) == NULL) {
  681. X        if (do_show("map", 1))
  682. X            return AC_REDRAW;
  683. X        break;
  684. X        }
  685. X
  686. X        do_map();
  687. X        break;
  688. X    }
  689. X        
  690. X    CASE( "cd" ) {
  691. X        if (change_dir(argv(1), in_init))
  692. X        init_message("chdir %s FAILED", argv(1));
  693. X        
  694. X        break;
  695. X    }
  696. X    
  697. X    if (in_init) {
  698. X        
  699. X        CASE( "load" ) {
  700. X        if (argv(1)) load_init_file(argv(1), (FILE **)NULL);
  701. X        break;
  702. X        }
  703. X
  704. X        CASE( "sequence" ) {
  705. X        return START_SEQUENCE;
  706. X        }
  707. X
  708. X        print_command("unknown command");
  709. X        break;
  710. X    }
  711. X    
  712. X    /* 
  713. X     * commands only available from : command line 
  714. X     */
  715. X
  716. X    if (ok_val != AC_REDRAW) {
  717. X        extern in_menu_mode;
  718. X        
  719. X        alt_cmd_key = lookup_command(sw_string, 
  720. X                 in_menu_mode ? K_ONLY_MENU : K_ONLY_MORE);
  721. X        if (alt_cmd_key != K_INVALID && alt_cmd_key != K_HELP)
  722. X        return AC_KEYCMD;
  723. X    }
  724. X    
  725. X    CASE( "q" ) {
  726. X        break;
  727. X    }
  728. X    
  729. X    CASE( "Q" ) {
  730. X        return AC_QUIT;
  731. X    }
  732. X    
  733. X    CASE( "q!" ) {
  734. X        if (restore_bak())
  735. X        return AC_QUIT;
  736. X        break;
  737. X    }
  738. X    
  739. X    CASE( "x" ) {
  740. X        update_rc(current_group);
  741. X        return AC_QUIT;
  742. X    }
  743. X    
  744. X    CASE( "help" ) {
  745. X        if (argv(1) == NULL)
  746. X        display_help("help");
  747. X        else
  748. X        display_help(argv(1));
  749. X        return AC_REDRAW;
  750. X    }
  751. X    
  752. X    CASE( "man" ) {
  753. X        char *manual;
  754. X        group_header *orig_group;
  755. X        int orig_layout, orig_fsort;
  756. X        import int fmt_linenum, dont_sort_folders;
  757. X        
  758. X        manual = relative(lib_directory, "Manual");
  759. X        if (!file_exist(manual, "fr")) {
  760. X        manual = relative(db_directory, "Manual");
  761. X        if (!file_exist(manual, "fr")) {
  762. X            msg("Online manual is not available");
  763. X            break;
  764. X        }
  765. X        }
  766. X        orig_group = current_group;
  767. X        orig_layout = fmt_linenum;
  768. X        orig_fsort = dont_sort_folders;
  769. X        
  770. X        fmt_linenum = 4;
  771. X        dont_sort_folders = 1;
  772. X        
  773. X        folder_menu(manual);
  774. X        
  775. X        fmt_linenum = orig_layout;
  776. X        dont_sort_folders = orig_fsort;
  777. X        init_group(orig_group);
  778. X        
  779. X        return AC_REDRAW;
  780. X    }
  781. X    
  782. X    CASE( "sort" ) {
  783. X        if ARG(1, "age")
  784. X        unsort_articles(0);
  785. X        else if (ARG(1, "no") || ARG(1, "arrival"))
  786. X        unsort_articles(1);        
  787. X        else
  788. X        sort_articles();
  789. X        return AC_REORDER;
  790. X    }
  791. X
  792. X    CASE( "unread" ) {
  793. X        if (restore_rc(current_group, argv(2) ? ARGVAL(2) : 0))
  794. X        return AC_HEADER;
  795. X        break;
  796. X    }
  797. X    
  798. X    CASE( "dump" ) {
  799. X        if (do_show(argv(1), 2))
  800. X        return AC_REDRAW;
  801. X        break;
  802. X    }
  803. X    
  804. X    CASE( "show" ) {
  805. X        if (do_show(argv(1), 2))
  806. X        return AC_REDRAW;
  807. X        break;
  808. X    }
  809. X
  810. X    CASE( "compile" ) {
  811. X        import int do_kill_handling;
  812. X        
  813. X        clrdisp();
  814. X        rm_kill_file();
  815. X        do_kill_handling = init_kill() && do_kill_handling;
  816. X        return AC_REDRAW;
  817. X    }
  818. X
  819. X    CASE( "pwd" ) {
  820. X        FILE *p = popen("exec pwd", "r");
  821. X        char dir[FILENAME];
  822. X        if (p) {
  823. X        if (fgets(dir, FILENAME, p)) {
  824. X            dir[strlen(dir) - 1] = NUL;
  825. X            msg("%s", dir);
  826. X        }
  827. X        pclose(p);
  828. X        }
  829. X        break;
  830. X    }
  831. X
  832. X    CASE( "rmail" ) {
  833. X        import char *mail_box;
  834. X        group_header *orig_group;
  835. X        
  836. X        if (mail_box == NULL) {
  837. X        msg("'mail' path not defined");
  838. X        break;
  839. X        }
  840. X        
  841. X        orig_group = current_group;
  842. X        folder_menu(mail_box);
  843. X        init_group(orig_group);
  844. X
  845. X        return AC_REDRAW;
  846. X    }
  847. X    
  848. X    CASE( "mkdir" ) {
  849. X        char *dir, *run_mkdir();
  850. X        char name_buf[FILENAME];
  851. X    
  852. X        if (dir = run_mkdir(argv(1), name_buf)) {
  853. X        prompt("Change to %s", dir);
  854. X        if (yes(0)) change_dir(dir, 0);
  855. X        }
  856. X        break;
  857. X    }
  858. X    
  859. X    CASE( "sh" ) {
  860. X        suspend_nn();
  861. X        s_redraw = 0;
  862. X        return AC_REDRAW;
  863. X    }
  864. X    
  865. X    CASE( "admin" ) {
  866. X        group_header *cur_group;
  867. X        
  868. X        cur_group = current_group;
  869. X        no_raw();
  870. X        clrdisp();
  871. X        printf("\n\n\n\rADMINISTRATION MODE\r\n\n\n");
  872. X        admin_mode((char *)NULL);
  873. X        clrdisp();
  874. X        raw();
  875. X        init_group(cur_group);
  876. X        return AC_REDRAW;
  877. X    }
  878. X    
  879. X    CASE( "coredump" ) {
  880. X        no_raw();
  881. X        abort();
  882. X    }
  883. X
  884. X    msg("unknown command: \"%s\"", argv(0));
  885. X     }
  886. X
  887. X    return ok_val;
  888. X
  889. X stx_err:
  890. X    print_command("syntax error");
  891. X    return ok_val;
  892. X}
  893. X
  894. X
  895. Xstatic print_command(str)
  896. Xchar *str;
  897. X{
  898. X    char **av;
  899. X
  900. X    if (!in_init) {
  901. X    msg(str);
  902. X    return;
  903. X    }
  904. X    
  905. X    printf("\r%s:", str);
  906. X    for (av = argvec; *av; av++)
  907. X        printf(" %s", *av);
  908. X    putchar(NL);
  909. X}
  910. X
  911. X
  912. Xstatic do_show(table, mode_arg)
  913. Xchar *table;
  914. Xint mode_arg;
  915. X{
  916. X    if (in_init || table == NULL) return 0;
  917. X    
  918. X    no_raw();
  919. X    SWITCH( table ) {
  920. X    
  921. X    CASE( "kill" ) {
  922. X        clrdisp();
  923. X        dump_kill_list();
  924. X        break;
  925. X    }
  926. X    
  927. X    CASE( "groups" ) {
  928. X    
  929. X        clrdisp();
  930. X        if ARG(mode_arg, "all")
  931. X        group_overview(1);
  932. X        else 
  933. X        if ARG(mode_arg, "total")
  934. X        group_overview(2);
  935. X        else
  936. X        if ARG(mode_arg, "unsub")
  937. X        group_overview(3);
  938. X        else
  939. X        group_overview(0);
  940. X
  941. X        break;
  942. X    }
  943. X    
  944. X    CASE( "map" ) {
  945. X
  946. X        if (argv(mode_arg) == NULL) {
  947. X        init_message("map name missing");
  948. X        goto err;
  949. X        }
  950. X        
  951. X        if (argv(mode_arg)[0] == '#') {
  952. X        clrdisp();
  953. X        dump_multi_keys();
  954. X        break;
  955. X        }
  956. X        
  957. X        SWITCH( argv(mode_arg) ) {
  958. X            
  959. X        CASE( "key" ) {
  960. X            clrdisp();
  961. X            dump_global_map();
  962. X            break;
  963. X        }
  964. X        CASE( "menu" ) {
  965. X            clrdisp();
  966. X            dump_key_map(menu_key_map, "menu", K_ONLY_MENU);
  967. X            break;
  968. X        }
  969. X        CASE( "show" ) {
  970. X            clrdisp();
  971. X            dump_key_map(more_key_map, "show", K_ONLY_MORE);
  972. X            break;
  973. X        }
  974. X
  975. X        init_message("unknown map '%s'", argv(mode_arg));
  976. X        goto err;
  977. X        /*NOTREACHED*/
  978. X        }
  979. X
  980. X        break;
  981. X    }
  982. X
  983. X    init_message("unknown table '%s'", table);
  984. X    goto err;
  985. X    /*NOTREACHED*/
  986. X    }
  987. X    
  988. X    raw();    
  989. X    return 1;
  990. Xerr:    
  991. X    raw();    
  992. X    return 0;
  993. X}
  994. X
  995. X    
  996. Xstatic do_map()
  997. X{
  998. X    int code, map_menu, map_show;
  999. X    
  1000. X    SWITCH( argv(1) ) {
  1001. X    
  1002. X    CASE( "key" ) {
  1003. X        if (argv(3) == NULL) break;
  1004. X        global_key_map[parse_key(argv(2))] = parse_key(argv(3));
  1005. X        return;
  1006. X    }
  1007. X    
  1008. X    if (argv(1)[0] == '#') {
  1009. X        char multi_buffer[16], *mb;
  1010. X        int i, parse_key();
  1011. X        
  1012. X        if (!isdigit(argv(1)[1])) break;
  1013. X        
  1014. X        for (i = 2, mb = multi_buffer; argv(i); i++)
  1015. X        *mb++ = (char)parse_key(argv(i));
  1016. X        *mb = NUL;
  1017. X        
  1018. X        enter_multi_key(K_function(argv(1)[1] - '0'),
  1019. X                copy_str(multi_buffer));
  1020. X        
  1021. X        return;
  1022. X    }
  1023. X    
  1024. X    code = K_UNBOUND;
  1025. X    map_menu = map_show = 0;
  1026. X    
  1027. X    CASE( "menu" ) {
  1028. X        map_menu++;
  1029. X    }
  1030. X    CASE( "show" ) {
  1031. X        map_show++;
  1032. X    }
  1033. X    CASE( "both" ) {
  1034. X        map_menu++;
  1035. X        map_show++;
  1036. X    }
  1037. X    
  1038. X    if (map_menu) {
  1039. X        if (argv(3))
  1040. X        code = lookup_command(argv(3), K_ONLY_MENU);
  1041. X
  1042. X        if (code == K_MACRO)
  1043. X        if (argv(4)) 
  1044. X            code |= atoi(argv(4));
  1045. X        else
  1046. X            goto mac_err;
  1047. X        
  1048. X        if (code != K_INVALID) {
  1049. X        menu_key_map[parse_key(argv(2))] = code;
  1050. X        return;
  1051. X        }
  1052. X    }
  1053. X    
  1054. X    if (map_show) {
  1055. X        if (argv(3))
  1056. X        code = lookup_command(argv(3), K_ONLY_MORE);
  1057. X        
  1058. X        if (code == K_MACRO)
  1059. X        if (argv(4)) 
  1060. X            code |= atoi(argv(4));
  1061. X        else
  1062. X            goto mac_err;
  1063. X        
  1064. X        if (code != K_INVALID) {
  1065. X        more_key_map[parse_key(argv(2))] = code;
  1066. X        return;
  1067. X        }
  1068. X    }
  1069. X
  1070. X    if (argv(4)) break;
  1071. X    
  1072. X    if (code == K_INVALID) {
  1073. X        init_message("unknown key command: %s", argv(3));
  1074. X        return;
  1075. X    }
  1076. X    }    
  1077. X
  1078. X    print_command("syntax error");
  1079. X    return;
  1080. X    
  1081. X mac_err:
  1082. X    print_command("macro number missing");
  1083. X    return;
  1084. X}
  1085. X
  1086. X
  1087. X
  1088. Xdisplay_help(subject)
  1089. Xchar *subject;
  1090. X{
  1091. X    char file[FILENAME];
  1092. X    
  1093. X    strcpy(file, "help.");
  1094. X    strcpy(file+5, subject);
  1095. X    
  1096. X    display_file(file, CLEAR_DISPLAY | CONFIRMATION);
  1097. X}
  1098. NO_NEWS_IS_GOOD_NEWS
  1099. chmod 0644 init.c || echo "restore of init.c fails"
  1100. set `wc -c init.c`;Sum=$1
  1101. if test "$Sum" != "15652"
  1102. then echo original size 15652, current size $Sum;fi
  1103. echo "x - extracting init.sample (Text)"
  1104. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > init.sample &&
  1105. X#
  1106. X# Sample global init file
  1107. X#
  1108. X#    THIS IS JUST AN EXAMPLE OF WHAT YOU CAN DO IN THE GLOBAL
  1109. X#    SEQUENCE FILE.  DO NOT USE IT AS IS (OR YOU WILL BE IN BIG
  1110. X#    TROUBLES :-).
  1111. X
  1112. X# these are some of the variables you may want to set-up globally;
  1113. X# check with the manual to see if you really need them!
  1114. X
  1115. Xset default-save-file +$G
  1116. Xset header-lines _FOD=S
  1117. Xset mail-format
  1118. Xset newsrc
  1119. Xset pager /bin/less
  1120. Xset printer lp -s -dnews-pr
  1121. Xset retry-on-error 2
  1122. Xset save-counter .%02
  1123. X
  1124. Xsequence
  1125. X
  1126. X    # groups everybody should read first (local groups)
  1127. X< texas.
  1128. X< general
  1129. X
  1130. X    # also put local test first -- if users want to experiment, they want
  1131. X    # to see the results immediately.
  1132. X< test
  1133. X
  1134. X    # ignore some groups for ordinary users; anybody can get these
  1135. X    # by including them in their own init file.
  1136. X
  1137. X    # ignore non-local test groups
  1138. X! .test
  1139. X    # ignore offensive groups
  1140. X! .sex
  1141. X! .bizarre
  1142. X! rec.humor
  1143. X
  1144. X    # the default sequence for the other groups
  1145. X    # subgroups are presented in alphabetical order
  1146. X
  1147. X    # danish/scandinavian groups
  1148. Xdk.
  1149. Xnordunet.
  1150. X
  1151. X    # ordinary users will not get any of the following groups.
  1152. X    #
  1153. X    # they mey include a @ in their private presentation
  1154. X    # sequence to disable the '!!' operator, or they may include
  1155. X    # the (few) groups they want to see.
  1156. X!!
  1157. X
  1158. X    # european groups
  1159. X    # read eunet.general before eunet.followup and other eunet groups
  1160. Xeunet.general
  1161. Xeunet.followup
  1162. Xeunet.
  1163. X
  1164. X    # new groups are presented here
  1165. XNEW
  1166. X
  1167. X    # world groups - prefer technical groups to other groups.
  1168. Xgnu.
  1169. Xnews.
  1170. Xcomp.
  1171. Xsci.
  1172. Xbionet.
  1173. Xalt.
  1174. Xrec.
  1175. Xmisc.
  1176. Xtalk.
  1177. X
  1178. X    # delay junk (we then only see non-cross postings.)
  1179. X> junk
  1180. X
  1181. X# groups that are not mentioned above will be shown here in alphabetical
  1182. X# order
  1183. X
  1184. X
  1185. NO_NEWS_IS_GOOD_NEWS
  1186. chmod 0644 init.sample || echo "restore of init.sample fails"
  1187. set `wc -c init.sample`;Sum=$1
  1188. if test "$Sum" != "1643"
  1189. then echo original size 1643, current size $Sum;fi
  1190. echo "x - extracting install_aux (Text)"
  1191. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > install_aux &&
  1192. Xset -u
  1193. Xecho
  1194. X
  1195. XOP="$1"
  1196. Xshift
  1197. XOWNER="$1"
  1198. Xshift
  1199. XGROUP="$1"
  1200. Xshift
  1201. XDIR="$1"
  1202. Xshift
  1203. XFILES="$1"
  1204. Xshift
  1205. XMODES="$1"
  1206. Xshift
  1207. X
  1208. Xcase "$OP" in
  1209. X
  1210. Xincr)
  1211. X    # increase update number
  1212. X
  1213. X    awk 'NF==3{printf "%s %s %d\n",$1,$2,$3+1}' update.h > update1.h 
  1214. X    mv update1.h update.h 
  1215. X
  1216. X    $DIR/log_entry I "$1"
  1217. X
  1218. X    echo "INSTALLATION COMPLETED"
  1219. X
  1220. X    if [ -n "$2" ]
  1221. X    then
  1222. X        echo
  1223. X        echo "--------------------------------------------------------"
  1224. X        if [ -f $2/MASTER ]
  1225. X        then
  1226. X            echo "Remember to restart $DIR/nnmaster"
  1227. X        else
  1228. X            echo "Now run 'make initdb'"
  1229. X        fi
  1230. X        echo "--------------------------------------------------------"
  1231. X    fi
  1232. X    ;;
  1233. X
  1234. Xbin)
  1235. X    LINKS="$1"
  1236. X
  1237. X    echo Installing user programs in $DIR:
  1238. X    echo "   " $FILES $LINKS
  1239. X
  1240. X    if [ -f $DIR/nn ]
  1241. X    then 
  1242. X         (
  1243. X        cd $DIR
  1244. X        mv nn nn.old 
  1245. X        rm -f $FILES $LINKS
  1246. X         )
  1247. X    fi
  1248. X
  1249. X    cp $FILES $DIR
  1250. X
  1251. X    for link in $LINKS
  1252. X    do
  1253. X        ln $DIR/nn $DIR/$link
  1254. X    done
  1255. X    ;;
  1256. X
  1257. Xaux)
  1258. X    echo Installing $OP files in $DIR:
  1259. X    echo "   " $FILES
  1260. X
  1261. X    if [ ! -d $DIR ]
  1262. X    then
  1263. X        mkdir $DIR
  1264. X        chown $OWNER $DIR
  1265. X        chgrp $GROUP $DIR
  1266. X        chmod 755 $DIR 
  1267. X        echo "   " Created directory $DIR
  1268. X    fi
  1269. X
  1270. X    cp $FILES $DIR
  1271. X    ;;
  1272. X
  1273. Xhelp)
  1274. X    echo Installing $OP files in $DIR:
  1275. X    echo "   " $FILES
  1276. X
  1277. X    for h in $FILES
  1278. X    do
  1279. X        cvt-help < $h > $DIR/$h
  1280. X    done
  1281. X    ;;
  1282. X
  1283. Xmaster)
  1284. X    MASTER="$FILES"
  1285. X    echo Installing $MASTER in $DIR:
  1286. X
  1287. X    if [ -f $DIR/$MASTER ]
  1288. X    then
  1289. X        (
  1290. X        cd $DIR
  1291. X        if [ -f MPID ]
  1292. X        then
  1293. X            echo "Stopping running master..."
  1294. X            kill -1 `cat MPID`
  1295. X            sleep 5
  1296. X        fi
  1297. X        mv $MASTER ${MASTER}.old
  1298. X       )
  1299. X    fi
  1300. X
  1301. X    cp $FILES $DIR
  1302. X    ;;
  1303. X
  1304. X1*)
  1305. X    echo Installing manual section $FILES in $DIR
  1306. X
  1307. X    NEW=""
  1308. X
  1309. X    if [ -d $DIR ]
  1310. X    then
  1311. X        for i in *.$OP
  1312. X        do
  1313. X            MAN=`basename ${i} .$OP`
  1314. X            cp $i $DIR/${MAN}.$FILES
  1315. X            NEW="$NEW ${MAN}.$FILES"
  1316. X        done
  1317. X
  1318. X        FILES="$NEW"
  1319. X    else
  1320. X        echo $DIR not found
  1321. X        exit 0
  1322. X    fi
  1323. X    ;;
  1324. X
  1325. Xonline)
  1326. X    if [ ! -d $DIR ]
  1327. X    then
  1328. X        echo You must install the package first
  1329. X        exit 0
  1330. X    fi
  1331. X
  1332. X    echo Formatting online manual....
  1333. X    rm -f $DIR/Manual
  1334. X    sh mk_online_man $FILES > $DIR/Manual
  1335. X    echo Done
  1336. X
  1337. X    FILES="Manual"
  1338. X    ;;
  1339. X
  1340. Xdb)
  1341. X    if [ ! -d $DIR ]
  1342. X    then
  1343. X        echo Creating Database Directory $DIR
  1344. X        mkdir $DIR
  1345. X    fi
  1346. X
  1347. X    if [ ! -d $DIR/DATA ]
  1348. X    then
  1349. X        mkdir $DIR/DATA
  1350. X    fi
  1351. X    ;;
  1352. X
  1353. Xinit)
  1354. X    echo Running $FILES to initialize database.
  1355. X    echo
  1356. X    $DIR/$FILES $1
  1357. X    echo
  1358. X    echo "Now start $DIR/$FILES -r"
  1359. X    exit 0
  1360. X    ;;
  1361. Xesac
  1362. X
  1363. Xcd $DIR 
  1364. Xchown $OWNER $FILES
  1365. Xchgrp $GROUP $FILES
  1366. Xchmod $MODES $FILES
  1367. X
  1368. Xexit 0
  1369. NO_NEWS_IS_GOOD_NEWS
  1370. chmod 0644 install_aux || echo "restore of install_aux fails"
  1371. set `wc -c install_aux`;Sum=$1
  1372. if test "$Sum" != "2274"
  1373. then echo original size 2274, current size $Sum;fi
  1374. echo "x - extracting keymap.c (Text)"
  1375. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > keymap.c &&
  1376. X#include "config.h"
  1377. X#include "keymap.h"
  1378. X#include "term.h"
  1379. X
  1380. X
  1381. X/*
  1382. X * standard keyboard mapping for more()
  1383. X *
  1384. X *    redraw            ^L, ^R
  1385. X *    continue        space
  1386. X *    repeat message        ^P
  1387. X *    help            ?
  1388. X *    shell escape        !
  1389. X *    version            V
  1390. X *    extended command    :
  1391. X *    quit            Q
  1392. X *
  1393. X *    save            S, O
  1394. X *    save, no header        W
  1395. X *    reply            R
  1396. X *    follow up        F
  1397. X *    mail (forward)        M
  1398. X *    cancel            C
  1399. X *    unsubscribe        U
  1400. X *    group overview        Y
  1401. X *    print article        P
  1402. X *    kill handling        K
  1403. X *
  1404. X *    update, goto next group    X
  1405. X *    no update, next group    q, Z
  1406. X *    return to menu        =
  1407. X *    prev article        p    
  1408. X *    goto group        G
  1409. X *
  1410. X *    line forward        CR/NL
  1411. X *    half page forward    d/^D
  1412. X *    half page back        u/^U
  1413. X *    full page back        BS, DEL, (up arrow)
  1414. X *    goto line        g
  1415. X *    goto match        /
  1416. X *    next match        .
  1417. X *    
  1418. X *    select subject        N, *
  1419. X *
  1420. X *    header            h
  1421. X *    digest header        H
  1422. X *    top            t
  1423. X *    last page        $
  1424. X *    leave article        l
  1425. X *    next article        n
  1426. X *    kill subject        k
  1427. X *
  1428. X *    rot13            D
  1429. X *    compress        c
  1430. X */
  1431. X
  1432. Xexport int more_key_map[KEY_MAP_SIZE] = {
  1433. X
  1434. X/* NUL ^@ */    K_UNBOUND, 
  1435. X/* SOH ^A */    K_UNBOUND, 
  1436. X/* STX ^B */    K_UNBOUND, 
  1437. X/* ETX ^C */    K_UNBOUND, 
  1438. X/* EOT ^D */        K_NEXT_HALF_PAGE, 
  1439. X/* ENQ ^E */    K_UNBOUND, 
  1440. X/* ACK ^F */    K_UNBOUND, 
  1441. X/* BEL ^G */    K_UNBOUND, 
  1442. X/* BS  ^H */        K_PREV_PAGE, 
  1443. X/* TAB ^I */    K_UNBOUND, 
  1444. X/* NL  ^J */        K_NEXT_LINE, 
  1445. X/* VT  ^K */    K_UNBOUND, 
  1446. X/* FF  ^L */        K_REDRAW, 
  1447. X/* CR  ^M */        K_NEXT_LINE, 
  1448. X/* SO  ^N */    K_UNBOUND, 
  1449. X/* SI  ^O */    K_UNBOUND, 
  1450. X/* DLE ^P */        K_LAST_MESSAGE, 
  1451. X/* DC1 ^Q */    K_UNBOUND, 
  1452. X/* DC2 ^R */        K_REDRAW, 
  1453. X/* DC3 ^S */    K_UNBOUND, 
  1454. X/* DC4 ^T */    K_UNBOUND, 
  1455. X/* NAK ^U */        K_PREV_HALF_PAGE, 
  1456. X/* SYN ^V */        K_NEXT_PAGE, 
  1457. X/* ETB ^W */    K_UNBOUND, 
  1458. X/* CAN ^X */    K_UNBOUND, 
  1459. X/* EM  ^Y */    K_UNBOUND, 
  1460. X/* SUB ^Z */    K_UNBOUND, 
  1461. X/* ESC ^[ */    K_UNBOUND, 
  1462. X/* FS  ^\ */    K_UNBOUND, 
  1463. X/* GS  ^] */    K_UNBOUND, 
  1464. X/* RS  ^^ */    K_UNBOUND, 
  1465. X/* US  ^_ */    K_UNBOUND, 
  1466. X/* SP  */        K_CONTINUE, 
  1467. X/* !   */        K_SHELL, 
  1468. X/* "   */    K_UNBOUND, 
  1469. X/* #   */    K_UNBOUND, 
  1470. X/* $   */        K_LAST_PAGE, 
  1471. X/* %   */        K_PREVIEW, 
  1472. X/* &   */    K_UNBOUND, 
  1473. X/* '   */    K_UNBOUND, 
  1474. X/* (   */    K_UNBOUND, 
  1475. X/* )   */    K_UNBOUND, 
  1476. X/* *   */        K_SELECT_SUBJECT, 
  1477. X/* +   */    K_UNBOUND, 
  1478. X/* ,   */    K_UNBOUND, 
  1479. X/* -   */    K_UNBOUND, 
  1480. X/* .   */        K_NEXT_MATCH, 
  1481. X/* /   */        K_GOTO_MATCH, 
  1482. X/* 0   */    K_UNBOUND, 
  1483. X/* 1   */    K_UNBOUND, 
  1484. X/* 2   */    K_UNBOUND, 
  1485. X/* 3   */    K_UNBOUND, 
  1486. X/* 4   */    K_UNBOUND, 
  1487. X/* 5   */    K_UNBOUND, 
  1488. X/* 6   */    K_UNBOUND, 
  1489. X/* 7   */    K_UNBOUND, 
  1490. X/* 8   */    K_UNBOUND, 
  1491. X/* 9   */    K_UNBOUND, 
  1492. X/* :   */         K_EXTENDED_CMD, 
  1493. X/* ;   */    K_UNBOUND, 
  1494. X/* <   */    K_UNBOUND, 
  1495. X/* =   */        K_BACK_TO_MENU, 
  1496. X/* >   */    K_UNBOUND, 
  1497. X/* ?   */        K_HELP, 
  1498. X/* @   */    K_UNBOUND, 
  1499. X/* A   */    K_UNBOUND, 
  1500. X/* B   */    K_UNBOUND, 
  1501. X/* C   */        K_CANCEL, 
  1502. X/* D   */        K_ROT13, 
  1503. X/* E   */    K_UNBOUND, 
  1504. X/* F   */        K_FOLLOW_UP,
  1505. X/* G   */        K_GOTO_GROUP, 
  1506. X/* H   */        K_FULL_DIGEST,
  1507. X/* I   */    K_UNBOUND, 
  1508. X/* J   */    K_UNBOUND, 
  1509. X/* K   */        K_KILL_HANDLING,
  1510. X/* L   */    K_UNBOUND, 
  1511. X/* M   */        K_MAIL_OR_FORWARD, 
  1512. X/* N   */        K_NEXT_GROUP_NO_UPDATE, 
  1513. X/* O   */        K_SAVE_SHORT_HEADER, 
  1514. X/* P   */        K_PRINT, 
  1515. X/* Q   */         K_QUIT, 
  1516. X/* R   */        K_REPLY, 
  1517. X/* S   */        K_SAVE_FULL_HEADER, 
  1518. X/* T   */    K_UNBOUND, 
  1519. X/* U   */        K_UNSUBSCRIBE, 
  1520. X/* V   */         K_VERSION, 
  1521. X/* W   */        K_SAVE_NO_HEADER, 
  1522. X/* X   */        K_READ_GROUP_UPDATE, 
  1523. X/* Y   */        K_GROUP_OVERVIEW, 
  1524. X/* Z   */        K_BACK_TO_MENU, 
  1525. X/* [   */    K_UNBOUND, 
  1526. X/* \   */    K_UNBOUND, 
  1527. X/* ]   */    K_UNBOUND, 
  1528. X/* ^   */        K_FIRST_PAGE, 
  1529. X/* _   */    K_UNBOUND, 
  1530. X/* `   */    K_UNBOUND, 
  1531. X/* a   */    K_UNBOUND, 
  1532. X/* b   */    K_UNBOUND, 
  1533. X/* c   */        K_COMPRESS, 
  1534. X/* d   */        K_NEXT_HALF_PAGE, 
  1535. X/* e   */    K_UNBOUND, 
  1536. X/* f   */        K_FOLLOW_UP, 
  1537. X/* g   */        K_GOTO_LINE, 
  1538. X/* h   */        K_HEADER_PAGE, 
  1539. X/* i   */    K_UNBOUND, 
  1540. X/* j   */    K_UNBOUND, 
  1541. X/* k   */        K_NEXT_SUBJECT, 
  1542. X/* l   */        K_LEAVE_ARTICLE, 
  1543. X/* m   */        K_MAIL_OR_FORWARD, 
  1544. X/* n   */        K_NEXT_ARTICLE,
  1545. X/* o   */        K_SAVE_SHORT_HEADER, 
  1546. X/* p   */        K_PREVIOUS /* article */, 
  1547. X/* q   */        K_NEXT_GROUP_NO_UPDATE,
  1548. X/* r   */        K_REPLY,
  1549. X/* s   */        K_SAVE_FULL_HEADER, 
  1550. X/* t   */        K_FIRST_PAGE,
  1551. X/* u   */        K_PREV_HALF_PAGE,
  1552. X/* v   */    K_UNBOUND, 
  1553. X/* w   */        K_SAVE_NO_HEADER,
  1554. X/* x   */    K_UNBOUND, 
  1555. X/* y   */    K_UNBOUND, 
  1556. X/* z   */    K_UNBOUND, 
  1557. X/* {   */    K_UNBOUND, 
  1558. X/* |   */    K_UNBOUND, 
  1559. X/* }   */    K_UNBOUND, 
  1560. X/* ~   */    K_UNBOUND, 
  1561. X/* DEL */        K_PREV_PAGE,
  1562. X/* 200 */    K_UNBOUND, 
  1563. X/* up  */        K_PREV_PAGE,
  1564. X/* down */        K_NEXT_PAGE,
  1565. X/* left */    K_UNBOUND,
  1566. X/* right */    K_UNBOUND,
  1567. X/* #0  */    K_UNBOUND,
  1568. X/* #1  */    K_UNBOUND,
  1569. X/* #2  */    K_UNBOUND,
  1570. X/* #3  */    K_UNBOUND,
  1571. X/* #4  */    K_UNBOUND,
  1572. X/* #5  */    K_UNBOUND,
  1573. X/* #6  */    K_UNBOUND,
  1574. X/* #7  */    K_UNBOUND,
  1575. X/* #8  */    K_UNBOUND,
  1576. X/* #9  */    K_UNBOUND
  1577. X};
  1578. X
  1579. X
  1580. X
  1581. X/*
  1582. X * standard keyboard mappings for menu()
  1583. X *
  1584. X *    illegal command
  1585. X *    redraw            ^L, ^R
  1586. X *    continue        space
  1587. X *    repeat message        ^P
  1588. X *    help            ?
  1589. X *    shell escape        !
  1590. X *    version            V
  1591. X *    alternative commands    :
  1592. X *    quit            Q
  1593. X *
  1594. X *    save            S, O
  1595. X *    save, no header        W
  1596. X *    reply            R
  1597. X *    follow up        F
  1598. X *    mail (forward)        M
  1599. X *    cancel            C
  1600. X *    unsubscribe        U
  1601. X *    group overview        Y
  1602. X *    kill handling        K
  1603. X *
  1604. X *    read, then next        X
  1605. X *    read, then same        Z
  1606. X *    no update, next        N
  1607. X *    prev group        P
  1608. X *    goto group        G
  1609. X *    advance group        A
  1610. X *    back group        B
  1611. X *
  1612. X *    article identifier    a-z 0-9
  1613. X *    inverse            @
  1614. X *    select current, next    .
  1615. X *    next            , (down arrow)
  1616. X *    prev            / (up arrow)
  1617. X *    select subject        *
  1618. X *    range            -
  1619. X *    auto select         +
  1620. X *
  1621. X *    next page        >
  1622. X *    prev page        <
  1623. X *    first page        ^
  1624. X *    last page        $
  1625. X *    
  1626. X *    pre-view article    %
  1627. X *
  1628. X *    layout            L
  1629. X */
  1630. X
  1631. X
  1632. Xexport int menu_key_map[KEY_MAP_SIZE] = {
  1633. X
  1634. X/* NUL ^@ */    K_UNBOUND, 
  1635. X/* SOH ^A */    K_UNBOUND, 
  1636. X/* STX ^B */    K_UNBOUND, 
  1637. X/* ETX ^C */    K_UNBOUND, 
  1638. X/* EOT ^D */    K_UNBOUND, 
  1639. X/* ENQ ^E */    K_UNBOUND, 
  1640. X/* ACK ^F */    K_UNBOUND, 
  1641. X/* BEL ^G */    K_UNBOUND, 
  1642. X/* BS  ^H */        K_PREV_LINE,
  1643. X/* TAB ^I */    K_UNBOUND, 
  1644. X/* NL  ^J */        K_CONTINUE,
  1645. X/* VT  ^K */    K_UNBOUND, 
  1646. X/* FF  ^L */        K_REDRAW,
  1647. X/* CR  ^M */        K_CONTINUE,
  1648. X/* SO  ^N */    K_UNBOUND, 
  1649. X/* SI  ^O */    K_UNBOUND, 
  1650. X/* DLE ^P */        K_LAST_MESSAGE,
  1651. X/* DC1 ^Q */    K_UNBOUND, 
  1652. X/* DC2 ^R */        K_REDRAW,
  1653. X/* DC3 ^S */    K_UNBOUND, 
  1654. X/* DC4 ^T */    K_UNBOUND, 
  1655. X/* NAK ^U */    K_UNBOUND, 
  1656. X/* SYN ^V */    K_UNBOUND, 
  1657. X/* ETB ^W */    K_UNBOUND, 
  1658. X/* CAN ^X */    K_UNBOUND, 
  1659. X/* EM  ^Y */    K_UNBOUND, 
  1660. X/* SUB ^Z */    K_UNBOUND, 
  1661. X/* ESC ^[ */    K_UNBOUND, 
  1662. X/* FS  ^\ */    K_UNBOUND, 
  1663. X/* GS  ^] */    K_UNBOUND, 
  1664. X/* RS  ^^ */    K_UNBOUND, 
  1665. X/* US  ^_ */    K_UNBOUND, 
  1666. X/* SP  */        K_CONTINUE,
  1667. X/* !   */        K_SHELL,
  1668. X/* "   */    K_UNBOUND, 
  1669. X/* #   */    K_UNBOUND, 
  1670. X/* $   */        K_LAST_PAGE,
  1671. X/* %   */        K_PREVIEW,
  1672. X/* &   */    K_UNBOUND, 
  1673. X/* '   */    K_UNBOUND, 
  1674. X/* (   */    K_UNBOUND, 
  1675. X/* )   */    K_UNBOUND, 
  1676. X/* *   */        K_SELECT_SUBJECT,
  1677. X/* +   */        K_AUTO_SELECT,
  1678. X/* ,   */        K_NEXT_LINE,
  1679. X/* -   */        K_SELECT_RANGE,
  1680. X/* .   */        K_SELECT,
  1681. X/* /   */        K_PREV_LINE,
  1682. X/* 0   */    K_ARTICLE_ID + 26, 
  1683. X/* 1   */    K_ARTICLE_ID + 27, 
  1684. X/* 2   */    K_ARTICLE_ID + 28, 
  1685. X/* 3   */    K_ARTICLE_ID + 29, 
  1686. X/* 4   */    K_ARTICLE_ID + 30, 
  1687. X/* 5   */    K_ARTICLE_ID + 31, 
  1688. X/* 6   */    K_ARTICLE_ID + 32, 
  1689. X/* 7   */    K_ARTICLE_ID + 33, 
  1690. X/* 8   */    K_ARTICLE_ID + 34, 
  1691. X/* 9   */    K_ARTICLE_ID + 35, 
  1692. X/* :   */        K_EXTENDED_CMD,
  1693. X/* ;   */    K_UNBOUND, 
  1694. X/* <   */        K_PREV_PAGE,
  1695. X/* =   */    K_UNBOUND, 
  1696. X/* >   */        K_NEXT_PAGE,
  1697. X/* ?   */        K_HELP,
  1698. X/* @   */        K_SELECT_INVERT,
  1699. X/* A   */        K_ADVANCE_GROUP,
  1700. X/* B   */        K_BACK_GROUP,
  1701. X/* C   */        K_CANCEL,
  1702. X/* D   */    K_UNBOUND, 
  1703. X/* E   */    K_UNBOUND, 
  1704. X/* F   */        K_FOLLOW_UP,
  1705. X/* G   */        K_GOTO_GROUP,
  1706. X/* H   */    K_UNBOUND, 
  1707. X/* I   */    K_UNBOUND, 
  1708. X/* J   */    K_UNBOUND, 
  1709. X/* K   */        K_KILL_HANDLING,
  1710. X/* L   */        K_LAYOUT,
  1711. X/* M   */        K_MAIL_OR_FORWARD,
  1712. X/* N   */        K_NEXT_GROUP_NO_UPDATE,
  1713. X/* O   */        K_SAVE_SHORT_HEADER,
  1714. X/* P   */        K_PREVIOUS /* group */,
  1715. X/* Q   */        K_QUIT,
  1716. X/* R   */        K_REPLY,
  1717. X/* S   */        K_SAVE_FULL_HEADER,
  1718. X/* T   */    K_UNBOUND, 
  1719. X/* U   */        K_UNSUBSCRIBE,
  1720. X/* V   */        K_VERSION,
  1721. X/* W   */        K_SAVE_NO_HEADER,
  1722. X/* X   */        K_READ_GROUP_UPDATE,
  1723. X/* Y   */        K_GROUP_OVERVIEW,
  1724. X/* Z   */        K_READ_GROUP_THEN_SAME,
  1725. X/* [   */    K_UNBOUND, 
  1726. X/* \   */    K_UNBOUND, 
  1727. X/* ]   */    K_UNBOUND, 
  1728. X/* ^   */        K_FIRST_PAGE,
  1729. X/* _   */    K_UNBOUND, 
  1730. X/* `   */    K_UNBOUND, 
  1731. X/* a   */    K_ARTICLE_ID +  0, 
  1732. X/* b   */    K_ARTICLE_ID +  1, 
  1733. X/* c   */    K_ARTICLE_ID +  2, 
  1734. X/* d   */    K_ARTICLE_ID +  3, 
  1735. X/* e   */    K_ARTICLE_ID +  4, 
  1736. X/* f   */    K_ARTICLE_ID +  5, 
  1737. X/* g   */    K_ARTICLE_ID +  6, 
  1738. X/* h   */    K_ARTICLE_ID +  7, 
  1739. X/* i   */    K_ARTICLE_ID +  8, 
  1740. X/* j   */    K_ARTICLE_ID +  9, 
  1741. X/* k   */    K_ARTICLE_ID + 10, 
  1742. X/* l   */    K_ARTICLE_ID + 11, 
  1743. X/* m   */    K_ARTICLE_ID + 12, 
  1744. X/* n   */    K_ARTICLE_ID + 13, 
  1745. X/* o   */    K_ARTICLE_ID + 14, 
  1746. X/* p   */    K_ARTICLE_ID + 15, 
  1747. X/* q   */    K_ARTICLE_ID + 16, 
  1748. X/* r   */    K_ARTICLE_ID + 17, 
  1749. X/* s   */    K_ARTICLE_ID + 18, 
  1750. X/* t   */    K_ARTICLE_ID + 19, 
  1751. X/* u   */    K_ARTICLE_ID + 20, 
  1752. X/* v   */    K_ARTICLE_ID + 21, 
  1753. X/* w   */    K_ARTICLE_ID + 22, 
  1754. X/* x   */    K_ARTICLE_ID + 23, 
  1755. X/* y   */    K_ARTICLE_ID + 24, 
  1756. X/* z   */    K_ARTICLE_ID + 25, 
  1757. X/* {   */    K_UNBOUND, 
  1758. X/* |   */    K_UNBOUND, 
  1759. X/* }   */    K_UNBOUND, 
  1760. X/* ~   */        K_UNSELECT_ALL, 
  1761. X/* DEL */        K_PREV_LINE,
  1762. X/* 200 */    K_UNBOUND, 
  1763. X/* up  */        K_PREV_LINE,
  1764. X/* down */        K_NEXT_LINE,
  1765. X/* left */    K_UNBOUND,
  1766. X/* right */    K_UNBOUND,
  1767. X/* #0  */    K_UNBOUND,
  1768. X/* #1  */    K_UNBOUND,
  1769. X/* #2  */    K_UNBOUND,
  1770. X/* #3  */    K_UNBOUND,
  1771. X/* #4  */    K_UNBOUND,
  1772. X/* #5  */    K_UNBOUND,
  1773. X/* #6  */    K_UNBOUND,
  1774. X/* #7  */    K_UNBOUND,
  1775. X/* #8  */    K_UNBOUND,
  1776. X/* #9  */    K_UNBOUND
  1777. X};
  1778. X
  1779. X
  1780. X
  1781. Xstatic struct command_name_map {
  1782. X    char *    cmd_name;
  1783. X    int       cmd_code;
  1784. X    int          cmd_restriction;
  1785. X} command_name_map[] = {
  1786. X    
  1787. X    "advance-group",        K_ADVANCE_GROUP,    0,
  1788. X
  1789. X    "back-group",        K_BACK_GROUP,        0,
  1790. X
  1791. X    "cancel",            K_CANCEL,        0,
  1792. X    "command",            K_EXTENDED_CMD,        0,
  1793. X    "compress",            K_COMPRESS,        K_ONLY_MORE,
  1794. X    "continue",            K_CONTINUE,        0,
  1795. X
  1796. X    "find",            K_GOTO_MATCH,        K_ONLY_MORE,
  1797. X    "find-next",        K_NEXT_MATCH,        K_ONLY_MORE,
  1798. X    "follow",            K_FOLLOW_UP,        0,
  1799. X    "full-digest",        K_FULL_DIGEST,        K_ONLY_MORE,
  1800. X
  1801. X    "goto-group",        K_GOTO_GROUP,        0,
  1802. X    "goto-menu",        K_BACK_TO_MENU,        K_ONLY_MORE,
  1803. X
  1804. X    "help",            K_HELP,            0,
  1805. X
  1806. X    "kill-select",        K_KILL_HANDLING,    0,
  1807. X
  1808. X    "layout",            K_LAYOUT,        K_ONLY_MENU,
  1809. X    "leave-article",        K_LEAVE_ARTICLE,    K_ONLY_MORE,
  1810. X    "line+1",            K_NEXT_LINE,        0,
  1811. X    "line-1",            K_PREV_LINE,        0,
  1812. X    "line=@",            K_GOTO_LINE,        K_ONLY_MORE,
  1813. X
  1814. X    "macro",            K_MACRO,        0,
  1815. X    "mail",            K_MAIL_OR_FORWARD,    0,
  1816. X    "message",            K_LAST_MESSAGE,        0,
  1817. X
  1818. X    "next-article",        K_NEXT_ARTICLE,        K_ONLY_MORE,
  1819. X    "next-group",        K_NEXT_GROUP_NO_UPDATE,    0,
  1820. X    "next-subject",        K_NEXT_SUBJECT,        K_ONLY_MORE,
  1821. X    "nil",            K_UNBOUND,        0,
  1822. X
  1823. X    "overview",            K_GROUP_OVERVIEW,    0,
  1824. X
  1825. X    "page+1",            K_NEXT_PAGE,        0,
  1826. X    "page+1/2",            K_NEXT_HALF_PAGE,    K_ONLY_MORE,
  1827. X    "page-1",            K_PREV_PAGE,        0,
  1828. X    "page-1/2",            K_PREV_HALF_PAGE,    K_ONLY_MORE,
  1829. X    "page=$",            K_LAST_PAGE,        0,
  1830. X    "page=0",            K_HEADER_PAGE,        0,
  1831. X    "page=1",            K_FIRST_PAGE,        0,
  1832. X    "page=@",            K_GOTO_PAGE,        K_ONLY_MORE,
  1833. X
  1834. X    "patch",            K_PATCH,        0,
  1835. X    "post",            K_POST,            0,
  1836. X    "preview",            K_PREVIEW,        0,
  1837. X    "previous",            K_PREVIOUS,        0,
  1838. X    "print",            K_PRINT,        0,
  1839. X
  1840. X    "quit",            K_QUIT,            0,
  1841. X
  1842. X    "read-return",        K_READ_GROUP_THEN_SAME,    K_ONLY_MENU,
  1843. X    "read-skip",        K_READ_GROUP_UPDATE,    0,
  1844. X    "redraw",            K_REDRAW,        0,
  1845. X    "reply",            K_REPLY,        0,
  1846. X    "rot13",            K_ROT13,        K_ONLY_MORE,
  1847. X
  1848. X    "save-body",        K_SAVE_NO_HEADER,    0,
  1849. X    "save-full",        K_SAVE_FULL_HEADER,    0,
  1850. X    "save-short",        K_SAVE_SHORT_HEADER,    0,
  1851. X    "select",            K_SELECT,        K_ONLY_MENU,
  1852. X    "select-auto",        K_AUTO_SELECT,        K_ONLY_MENU,
  1853. X    "select-invert",        K_SELECT_INVERT,    K_ONLY_MENU,
  1854. X    "select-range",        K_SELECT_RANGE,        K_ONLY_MENU,
  1855. X    "select-subject",        K_SELECT_SUBJECT,    0,
  1856. X    "shell",            K_SHELL,        0,
  1857. X
  1858. X    "unselect-all",        K_UNSELECT_ALL,        K_ONLY_MENU,
  1859. X    "unshar",            K_UNSHAR,        0,
  1860. X    "unsub",            K_UNSUBSCRIBE,        0,
  1861. X
  1862. X    "version",            K_VERSION,        0,
  1863. X
  1864. X    (char *)NULL,        0,            0
  1865. X};
  1866. X
  1867. Xstatic int name_map_size;
  1868. Xstatic int max_cmd_name_length = 14;    /* recalculate if table is changed */
  1869. X
  1870. Xexport char global_key_map[KEY_MAP_SIZE];
  1871. X
  1872. X
  1873. Xinit_key_map()
  1874. X{
  1875. X    register int c;
  1876. X    register struct command_name_map *cnmp;
  1877. X    
  1878. X    for (c = 0; c < KEY_MAP_SIZE; c++) global_key_map[c] = c;
  1879. X
  1880. X    for (cnmp = command_name_map; cnmp->cmd_name; cnmp++);
  1881. X    name_map_size = cnmp - command_name_map;
  1882. X}
  1883. X
  1884. X
  1885. Xlookup_command(command, restriction)
  1886. Xchar *command;
  1887. Xint restriction;
  1888. X{
  1889. X    register struct command_name_map *cnmp;
  1890. X    register i, j, k, t;
  1891. X    
  1892. X    i = 0; j = name_map_size - 1; 
  1893. X    
  1894. X    while (i <= j) {
  1895. X    k = (i + j) / 2;
  1896. X    cnmp = &command_name_map[k];
  1897. X    
  1898. X    if ( (t=strcmp(command, cnmp->cmd_name)) > 0) 
  1899. X        i = k+1;
  1900. X    else
  1901. X    if (t < 0)
  1902. X        j = k-1;
  1903. X    else {
  1904. X        if (cnmp->cmd_restriction == 0
  1905. X        || (cnmp->cmd_restriction & restriction))
  1906. X        return cnmp->cmd_code;
  1907. X        break;
  1908. X    }
  1909. X    }
  1910. X
  1911. X    return K_INVALID;
  1912. X}    
  1913. X
  1914. X
  1915. Xcmd_completion(path, index)
  1916. Xchar *path;
  1917. Xint index;
  1918. X{
  1919. X    static char *head, *tail = NULL;
  1920. X    static int len;
  1921. X    static struct command_name_map *cmd, *help_cmd;
  1922. X
  1923. X    if (index < 0) return 0;
  1924. X
  1925. X    if (path) {
  1926. X    head = path;
  1927. X    tail = path + index;
  1928. X    while (*head && isspace(*head)) head++;
  1929. X    help_cmd = cmd = command_name_map;
  1930. X    len = tail - head;
  1931. X    
  1932. X    return 1;
  1933. X    }
  1934. X    
  1935. X    if (index) {
  1936. X    list_completion((char *)NULL);
  1937. X
  1938. X    if (help_cmd->cmd_name == NULL)
  1939. X        help_cmd = command_name_map;
  1940. X    
  1941. X    for (;help_cmd->cmd_name; help_cmd++) {
  1942. X        index = strncmp(help_cmd->cmd_name, head, len);
  1943. X        if (index < 0) continue;
  1944. X        if (index > 0) {
  1945. X        help_cmd = command_name_map;
  1946. X        break;
  1947. X        }
  1948. X        if (list_completion(help_cmd->cmd_name) == 0) break;
  1949. X    }
  1950. X    fl;
  1951. X    return 1;
  1952. X    }
  1953. X
  1954. X    for (; cmd->cmd_name; cmd++) {
  1955. X    if (len == 0) 
  1956. X        index = 0;
  1957. X    else
  1958. X        index = strncmp(cmd->cmd_name, head, len);
  1959. X    if (index < 0) continue;
  1960. X    if (index > 0) break;
  1961. X    if (cmd->cmd_code == K_MACRO)
  1962. X        sprintf(tail, "%s ", cmd->cmd_name + len);
  1963. X    else
  1964. X        strcpy(tail, cmd->cmd_name + len);
  1965. X    cmd++;
  1966. X    return 1;
  1967. X    }
  1968. X    return 0;
  1969. X}
  1970. X
  1971. X
  1972. Xchar *command_name(cmd)
  1973. Xint cmd;
  1974. X{
  1975. X    register struct command_name_map *cnmp;
  1976. X
  1977. X    cmd &= ~GETC_COMMAND;
  1978. X
  1979. X    for (cnmp = command_name_map; cnmp->cmd_name; cnmp++)
  1980. X    if (cnmp->cmd_code == cmd) return cnmp->cmd_name;
  1981. X    
  1982. X    return "unknown";
  1983. X}
  1984. X
  1985. X
  1986. X/*
  1987. X * convert key name into ascii code
  1988. X *
  1989. X *    key names are:
  1990. X *        c    character c
  1991. X *        ^C    control-C
  1992. X *        0xNN    hex value (0..0x7f)
  1993. X *        0NNN    octal value (0..0177)
  1994. X *        NNN    decimal value (0..127)
  1995. X *        up, down, left, rigth    arrow keys
  1996. X *        #0..#9            function keys (initially undefined)
  1997. X */
  1998. X
  1999. Xparse_key(str)
  2000. Xchar *str;
  2001. X{
  2002. X    int x;
  2003. X    
  2004. X    if (str[1] == NUL)
  2005. X    return str[0] & 0177;
  2006. X    
  2007. X    if (str[0] == '^')
  2008. X    if (str[1] == '?') 
  2009. X        return 0177;
  2010. X    else
  2011. X        return CTRL(str[1]);
  2012. X    
  2013. X    if (isdigit(str[0])) {
  2014. X    if (str[0] == '0')
  2015. X        if (str[1] == 'x')
  2016. X        sscanf(str+2, "%x", &x);
  2017. X        else
  2018. X        sscanf(str+1, "%o", &x);
  2019. X    else
  2020. X        sscanf(str, "%d", &x);
  2021. X    
  2022. X    return x & 0177;
  2023. X    }
  2024. X
  2025. X    if (str[0] == '#' && isdigit(str[1])) 
  2026. X    return K_function(str[1] - '0');
  2027. X    
  2028. X    if (strcmp(str, "up") == 0)
  2029. X    return K_up_arrow;
  2030. X    
  2031. X    if (strcmp(str, "down") == 0)
  2032. X    return K_down_arrow;
  2033. X    
  2034. X    if (strcmp(str, "left") == 0)
  2035. X    return K_left_arrow;
  2036. X    
  2037. X    if (strcmp(str, "right") == 0)
  2038. X    return K_right_arrow;
  2039. X
  2040. X    init_message("unknown key: %s", str);
  2041. X    
  2042. X    return 0200;
  2043. X}
  2044. X
  2045. Xchar *key_name(c)
  2046. Xint c;
  2047. X{
  2048. X    static char buf[3];
  2049. X    
  2050. X    if (c & 0200) {
  2051. X    switch (c) {
  2052. X     case K_up_arrow:
  2053. X        return "up";
  2054. X     case K_down_arrow:
  2055. X        return "down";
  2056. X     case K_left_arrow:
  2057. X        return "left";
  2058. X     case K_right_arrow:
  2059. X        return "right";
  2060. X     default:
  2061. X        buf[0] = '#';
  2062. X        buf[1] = (c - K_function(0)) + '0';
  2063. X        buf[2] = NUL;
  2064. X        goto out;
  2065. X    }
  2066. X    }
  2067. X
  2068. X    if (c < SP) {
  2069. X    buf[0] = '^';
  2070. X    buf[1] = c + '@';
  2071. X    buf[2] = NUL;
  2072. X    goto out;
  2073. X    }
  2074. X
  2075. X    if (c == 0177) {
  2076. X    strcpy(buf, "^?");
  2077. X    goto out;
  2078. X    }
  2079. X
  2080. X    buf[0] = c;
  2081. X    buf[1] = NUL;
  2082. X
  2083. X out:    
  2084. X    return buf;
  2085. X}
  2086. X
  2087. X    
  2088. Xdump_global_map()
  2089. X{
  2090. X    register int c;
  2091. X    
  2092. X    clrdisp();
  2093. X    so_printf("\1REMAPPED KEYS\1\n\n");
  2094. X    pg_init(2, 4);
  2095. X    
  2096. X    for (c = 0; c < KEY_MAP_SIZE; c++)
  2097. X    if (c != global_key_map[c]) {
  2098. X        if (pg_next() < 0) break;
  2099. X        printf("%s", key_name(c));
  2100. X        pg_indent(6);
  2101. X        printf("-> %s", key_name(global_key_map[c]));
  2102. X    }
  2103. X
  2104. X    pg_end();
  2105. X}
  2106. X
  2107. X
  2108. Xdump_key_map(map, where, restriction)
  2109. Xint map[];
  2110. Xchar *where;
  2111. Xint restriction;
  2112. X{
  2113. X    register struct command_name_map *cnmp;
  2114. X    register c, code, first_prt;
  2115. X    
  2116. X    clrdisp();
  2117. X    so_printf("\1KEY BINDINGS (%s)\1\n\n", where);
  2118. X
  2119. X    if (restriction == K_ONLY_MENU) {
  2120. X    printf("\rarticle:  ");
  2121. X    for (c = 0; c < KEY_MAP_SIZE; c++)
  2122. X        if (map[c] & K_ARTICLE_ID) printf("%s", key_name(c));
  2123. X    }
  2124. X
  2125. X    pg_init(4, 2);
  2126. X    
  2127. X    for (cnmp = command_name_map; cnmp->cmd_name; cnmp++) {
  2128. X    if (cnmp->cmd_restriction && cnmp->cmd_restriction != restriction)
  2129. X        continue;
  2130. X    if (cnmp->cmd_code == K_UNBOUND) continue;
  2131. X    if (cnmp->cmd_code == K_MACRO) continue;
  2132. X
  2133. X    code = cnmp->cmd_code;
  2134. X    first_prt = 1;
  2135. X
  2136. X    for (c = 0; c < KEY_MAP_SIZE; c++)
  2137. X        if (map[c] == code) {
  2138. X        if (first_prt) {
  2139. X            if (pg_next() < 0) goto out;
  2140. X            fputs(cnmp->cmd_name, stdout);
  2141. X            pg_indent(max_cmd_name_length);
  2142. X            first_prt = 0;
  2143. X        }
  2144. X        printf(" %s", key_name(c));
  2145. X        }
  2146. X    }
  2147. X
  2148. X    for (c = 0; c < KEY_MAP_SIZE; c++)
  2149. X    if (map[c] & K_MACRO) {
  2150. X        if (pg_next() < 0) goto out;
  2151. X        printf("macro %d: %s", (map[c] & ~K_MACRO), key_name(c));
  2152. X    }
  2153. X
  2154. X out:
  2155. X    pg_end();
  2156. X}
  2157. NO_NEWS_IS_GOOD_NEWS
  2158. chmod 0644 keymap.c || echo "restore of keymap.c fails"
  2159. set `wc -c keymap.c`;Sum=$1
  2160. if test "$Sum" != "16844"
  2161. then echo original size 16844, current size $Sum;fi
  2162. echo "x - extracting keymap.h (Text)"
  2163. sed 's/^X//' << 'NO_NEWS_IS_GOOD_NEWS' > keymap.h &&
  2164. X/*
  2165. X * keyboard (re)mapping
  2166. X *
  2167. X * you cannot assign alternative commands to the "article identifier"
  2168. X * keys in the selection mode
  2169. X */
  2170. X
  2171. X#define K_INVALID        0x0000 /* unknown command (for lookup) */
  2172. X
  2173. X#define K_UNBOUND        0x0001 /* unbound command key         */
  2174. X
  2175. X#define K_REDRAW        0x0002 /* redraw             */
  2176. X#define K_CONTINUE        0x0003 /* continue with next ...     */
  2177. X#define K_LAST_MESSAGE        0x0004 /* repeat last message         */
  2178. X#define K_HELP            0x0005 /* online help             */
  2179. X#define K_SHELL            0x0006 /* shell escape         */
  2180. X#define K_VERSION        0x0007 /* print version         */
  2181. X#define K_EXTENDED_CMD        0x0008 /* extended commands        */
  2182. X
  2183. X#define K_QUIT            0x0009 /* quit             */
  2184. X
  2185. X#define K_SAVE_NO_HEADER     0x0011 /* save articles without header */
  2186. X#define K_SAVE_SHORT_HEADER     0x0012 /* save article with short header */
  2187. X#define K_SAVE_FULL_HEADER     0x0013 /* save articles with full header */
  2188. X
  2189. X#define K_PRINT            0x0014 /* print ariticle         */
  2190. X
  2191. X#define K_UNSHAR        0x0015 /* unshar article        */
  2192. X
  2193. X#define K_REPLY            0x0016 /* reply to article         */
  2194. X#define K_FOLLOW_UP        0x0017 /* follow up to article     */
  2195. X#define K_POST            0x0018 /* post an article        */
  2196. X#define K_MAIL_OR_FORWARD     0x0019 /* mail (forward article)     */
  2197. X#define K_CANCEL        0x001a /* cancel article         */
  2198. X#define K_UNSUBSCRIBE        0x001b /* (un)subscribe to group     */
  2199. X#define K_GROUP_OVERVIEW     0x001c /* group overview         */
  2200. X#define K_PATCH            0x001d /* pipe article to patch         */
  2201. X
  2202. X#define K_GOTO_GROUP        0x0020 /* goto named group/folder    */
  2203. X
  2204. X#define K_KILL_HANDLING        0x0021 /* enter kill menu        */
  2205. X
  2206. X    /* scrolling/menu movement */
  2207. X
  2208. X#define K_NEXT_PAGE        0x0024 /* next page             */
  2209. X#define K_NEXT_HALF_PAGE     0x0025 /* next half page        */
  2210. X#define K_NEXT_LINE        0x0026 /* next line            */
  2211. X#define K_PREV_PAGE        0x0027 /* previous page         */
  2212. X#define K_PREV_HALF_PAGE     0x0028 /* previous half page        */
  2213. X#define K_PREV_LINE        0x0029 /* previous line        */
  2214. X
  2215. X#define K_HEADER_PAGE        0x002a /* first page incl. header    */
  2216. NO_NEWS_IS_GOOD_NEWS
  2217. echo "End of part 5"
  2218. echo "File keymap.h is continued in part 6"
  2219. echo "6" > s2_seq_.tmp
  2220. exit 0
  2221.  
  2222.