home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8707 / 60 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  23.9 KB

  1. From: mark@cogent.UUCP (Captain Neptune)
  2. Newsgroups: comp.sources.misc
  3. Subject: A Function Key maintenance program for HP2392a and clones
  4. Message-ID: <3290@ncoast.UUCP>
  5. Date: 23 Jul 87 23:54:47 GMT
  6. Sender: allbery@ncoast.UUCP
  7. Organization: Cogent Software Solutions, Stockton, CA
  8. Lines: 810
  9. Approved: allbery@ncoast.UUCP
  10. X-Archive: comp.sources.misc/8707/60
  11.  
  12. This is a  very early version of "fnkey", a  program which allows
  13. you to maintain function key settings in text files. It is device
  14. dependant in  that it  works only  on the  HP 2392a  terminal and
  15. those terminals that are compatible in the way they program their
  16. function keys.
  17.  
  18. "Fnkey" actually  loads your  specified labels and  commands into
  19. the programmable function keys on your terminal. The function key
  20. configurations are held in "description files". Description files
  21. can be  put in  a central  place, where all  users can  use them.
  22. Also, individual  users can add  description files of  their own,
  23. either  augmenting  or overriding  the  main  set of  description
  24. files. Read the manual page for more details.
  25.  
  26. Read the  README file before  doing anything.  Good luck, keep me
  27. informed on how it goes.
  28.  
  29. ihnp4!ptsfa!cogent!mark
  30.  
  31. ----------------- cut here ---------------- cut here ----------------
  32. #! /bin/sh
  33. # This is a shell archive, meaning:
  34. # 1. Remove everything above the #! /bin/sh line.
  35. # 2. Save the resulting text in a file.
  36. # 3. Execute the file with /bin/sh (not csh) to create:
  37. #    Makefile
  38. #    README
  39. #    fnkey.1
  40. #    fnkey.c
  41. #    samples
  42. # This archive created: Wed Jul 22 23:02:02 1987
  43. export PATH; PATH=/bin:/usr/bin:$PATH
  44. echo shar: "extracting 'Makefile'" '(608 characters)'
  45. if test -f 'Makefile'
  46. then
  47.     echo shar: "will not over-write existing file 'Makefile'"
  48. else
  49. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  50. XCFLAGS= -O
  51. XCC= cc
  52. XDESTDIR=/usr/local/bin
  53. XLIBDIR=/usr/local/lib
  54. XMANDIR=/usr/local/man/man1
  55. X
  56. Xall:    fnkey
  57. X
  58. Xfnkey:    fnkey.o
  59. X    $(CC) $(CFLAGS) fnkey.o -o fnkey
  60. X
  61. Xinstall:
  62. X    strip fnkey
  63. X    cp fnkey $(DESTDIR)
  64. X    cp fnkey.1 $(MANDIR)
  65. X    -mkdir $(LIBDIR) $(LIBDIR)/fnkey
  66. X    -chmod +x $(LIBDIR) $(LIBDIR)/fnkey
  67. X
  68. Xsample:
  69. X    -mkdir $HOME/.fnkey
  70. X    -chmod +x $HOME/.fnkey
  71. X    -cp samples/* $HOME/.fnkey
  72. X    fnkey
  73. X    @echo "\n\t\t***************************************\n\t\t** Warning: these samples need to be **\n\t\t** edited to suit your own needs ! ! **\n\t\t***************************************\n"
  74. X
  75. Xclean:
  76. X    -rm -f fnkey *.o a.out core
  77. X
  78. SHAR_EOF
  79. if test 608 -ne "`wc -c < 'Makefile'`"
  80. then
  81.     echo shar: "error transmitting 'Makefile'" '(should have been 608 characters)'
  82. fi
  83. echo shar: "extracting 'README'" '(3669 characters)'
  84. if test -f 'README'
  85. then
  86.     echo shar: "will not over-write existing file 'README'"
  87. else
  88. sed 's/^X//' << \SHAR_EOF > 'README'
  89. XHello.
  90. X
  91. XThis is a  very early version of "fnkey", a  program which allows
  92. Xyou to maintain function key settings in text files. It is device
  93. Xdependant in  that it  works only  on the  HP 2392a  terminal and
  94. Xthose terminals that are compatible in the way they program their
  95. Xfunction keys. Zentec makes a  clone of this terminal and "fnkey"
  96. Xshould work on it as well.
  97. X
  98. X"Fnkey" actually  loads your  specified labels and  commands into
  99. Xthe programmable function keys on your terminal. The function key
  100. Xconfigurations are held in "description files". Description files
  101. Xcan be  put in  a central place  (created automatically  when you
  102. Xinstall "fnkey"), where all users  can use them. Also, individual
  103. Xusers can add  description files of their  own, either augmenting
  104. Xor overriding the main set  of description files. Read the manual
  105. Xpage for more details.
  106. X
  107. XCurrently, "fnkey" requires that  your current terminal driver be
  108. Xeither  "hp2392" or  "ansi-d"  (a terminfo  driver  for using  HP
  109. X2392a's in ANSI mode).
  110. X
  111. XNote: the "ansi-d" driver is included here as a freebie, since it
  112. Xis pertinent to the discussion; if  any of you are sick and tired
  113. Xof the awful escape sequences in HP mode, try ANSI mode with this
  114. Xdriver. It might be helpful to you.
  115. X
  116. XAlthough this is  an early version, it seems to  run fairly well.
  117. XWhile I  wouldn't call it a  beta-test version, I would  say that
  118. Xpeople who  try it out  should keep their  eyes open for  any odd
  119. Xbehavior (except  for known bugs  listed below) and inform  me of
  120. Xtheir observations.
  121. X
  122. XI am willing to do some maintenance of the program, including the
  123. Xrelease  of  future  versions with  improvements/fixes  that  you
  124. Xsuggest to me. Please email your feedback, diffs of patches, etc.
  125. Xto this mail path:
  126. X
  127. Xihnp4!ptsfa!cogent!mark
  128. X
  129. X-----------------------------------------------------------------
  130. XKnown bugs/limitations:
  131. X
  132. X1.  For each  newline that  is  programmed into  a function  key,
  133. X"fnkey"  leaks  a  newline   to  the  screen,  causing  unsightly
  134. Xscrolling. It is probably HP's fault  and not mine, but I am open
  135. Xto suggestions on how to supress the scrolling.
  136. X
  137. X2. "Fnkey" does not use terminfo entries. If it did, the hardware
  138. Xdependancy might be  largely overcome. I don't  know, however, if
  139. Xterminfo  has enough  smarts  for this,  however.  It can  handle
  140. Xfunction keys that  emit a fixed escape sequence,  but a sequence
  141. Xto load a programmable function key? Hmmm...
  142. X
  143. X3. Some programs will not see all the characters that you program
  144. Xyour function  key to send  (since they  have a short  delay then
  145. Xflush the  input buffer, etc...).  An example  of this is  in the
  146. X"rn" news reader  when you try to type "cy"  (the catchup command
  147. Xplus  "yes" verification).  You  can program  a  function key  to
  148. Xoutput "cy",  but "rn" will  not see  the letter "y".  Again, not
  149. Xreally the fault of "fnkey" or the function keys, but I'm open to
  150. Xideas on how to get around it nonetheless.
  151. X
  152. X4.  Given enough  interest and/or  advice from  Unix PC  users, I
  153. Xcould be  persuaded to explore the  possibilities of implementing
  154. X"fnkey" on the Unix PC.
  155. X
  156. X-----------------------------------------------------------------
  157. XTo compile and install:
  158. X
  159. XLook over  the declarations in  "Makefile", in case you  want the
  160. Xexecutable, manual  page, or whatever,  to reside in  a different
  161. Xplace.
  162. X
  163. Xmake -        compiles the program
  164. X
  165. Xmake install -    installs it (you must be root or super-user)
  166. X
  167. Xmake sample -    loads sample "fnkey" description files into
  168. X        "$HOME/.fnkey" for you to try out and tailor
  169. X        to your own needs
  170. X
  171. Xmake clean -    cleans up junk
  172. X
  173. X-----------------------------------------------------------------
  174. XGood luck, keep me informed on how it goes.
  175. SHAR_EOF
  176. if test 3669 -ne "`wc -c < 'README'`"
  177. then
  178.     echo shar: "error transmitting 'README'" '(should have been 3669 characters)'
  179. fi
  180. echo shar: "extracting 'fnkey.1'" '(6081 characters)'
  181. if test -f 'fnkey.1'
  182. then
  183.     echo shar: "will not over-write existing file 'fnkey.1'"
  184. else
  185. sed 's/^X//' << \SHAR_EOF > 'fnkey.1'
  186. X.TH Cogent Local "MSJ 7/16/87"
  187. X.SH NAME
  188. Xfnkey \- A user-defined function-key manager for \fIHP 2392a\fR terminals
  189. X(and clones)
  190. X.SH SYNOPSIS
  191. X.B fnkey
  192. X[ \fIfk_file\fR ]
  193. X.SH DESCRIPTION
  194. X.B Fnkey
  195. Xis a program which allows you to program function keys conveniently
  196. Xon \fIHP 2392a\fR terminals and any terminals which have compatible
  197. Xescape sequences.  Details about how the function keys should be
  198. Xprogrammed are stored in a user-defined definition file
  199. X.I fk_file
  200. Xin the format described below.  The definition file is read by
  201. X.B fnkey
  202. Xand the definitions are inserted into the terminals function key
  203. Xmemory automatically.  If no definition file is specified,
  204. X.B fnkey
  205. Xuses the '\fIfn_default\fR' as the name of the definition file to
  206. Xread.  Also, if '\fB\-\fR' is given as the definition file, then
  207. Xstandard input is read instead.
  208. X.PP
  209. X.B Fnkey
  210. Xlooks in the following places to find the definition file that has
  211. Xbeen specified, and in this order:
  212. X.nf
  213. X
  214. X    - in the directory $FNKEY, if the environment variable
  215. X      $FNKEY exists and if the directory exists
  216. X
  217. X    - in the directory $H, if the environment variable
  218. X      $H exists and if the directory exists
  219. X
  220. X    - in the directory $H/.fnkey, if the environment
  221. X      variable $H exists and if the directory exists
  222. X
  223. X    - in the directory $HOME, if the environment variable
  224. X      $HOME exists and if the directory exists
  225. X
  226. X    - in the directory $HOME/.fnkey, if the environment
  227. X      variable $HOME exists and if the directory exists
  228. X
  229. X    - in the directory /usr/local/fnkeys, if it exists
  230. X
  231. X.fi
  232. XUpon finding a directory where the description file exists and is
  233. Xreadable, the search is ended and that file is used.
  234. X.SH "DESCRIPTION FILE FORMAT"
  235. XThe description file contains one or more lines, each of which defines
  236. Xone function key.  Each line consists of four mandatory fields and an
  237. Xoptional fifth field, all of which are delimited by colons ('\fB:\fR').
  238. XColons can not be a part of any field.
  239. X.PP
  240. XThe first field is a single numeric digit ranging from 1 to 8,
  241. Xspecifying the number of the function key.
  242. X.PP
  243. XThe second and third fields specify the contents of the upper and lower,
  244. Xrespectively, rows of the screen label for the specified function key.
  245. XThese fields should be padded with whatever leading spaces are desired,
  246. Xand their lengths must not exceed 8.  The second field can be a '\fB*\fR',
  247. Xwhich causes the function key to be disabled.  Either field can be null,
  248. Xwhich will appear on the screen as blank.
  249. X.PP
  250. XThe fourth field specifies the actual string which is to be output by the
  251. Xspecified function key.  This field has no size limit (within reason) and
  252. Xcan include both leading and trailing spaces.  If you wish for a carriage
  253. Xreturn to be automatically entered after the string (e.g. for a command
  254. Xwhich is to be executed in the shell), then a carriage return must be
  255. Ximbedded in this field (as shown in the next section).
  256. X.PP
  257. XA typical definition file might look like this:
  258. X.nf
  259. X
  260. X1:Get keys:for Tape:fnkey tape\\n
  261. X2:Read the:time:clock\\n:this is just a shell script
  262. X3:Who's on::who\\n
  263. X6:*
  264. X7:Check my:Process':ps -f\\n
  265. X8:Other:Process':ps -ef\\n
  266. X
  267. X.fi
  268. XIn the above example, the first function key would execute
  269. X.B fnkey
  270. Xin order to load function key definitions used for handling magnetic
  271. Xtapes.  This pseudo-recursive use of
  272. X.B fnkey
  273. Xallows you to set up entire 'menus' of function keys.  The second
  274. Xfunction key executes a shell script called 'clock'.  The third function
  275. Xkey executes the 'who' command.  Since there are no entries for function
  276. Xkeys 4 and 5, they will be unaffected and remain as they were.  The sixth
  277. Xfunction key will be disabled and output merely a carriage return.  The
  278. Xlast two function keys will execute the 'ps' command with various options.
  279. X
  280. XThe definition of function key 2 includes a comment field.  All fourth
  281. Xfields have '\fB\\n\fR' at the end in order to assure that a carriage
  282. Xreturn is issued.  There will, of course, be times when a carriage return
  283. Xis not preferred.  An example would be this line:
  284. X.nf
  285. X
  286. X1:Delete:the line:dd
  287. X
  288. X.fi
  289. Xwhich would cause function key 1 to issue the 'delete line' command while
  290. Xediting with 'vi'.
  291. X.SH "IMBEDDED CHARACTERS"
  292. XIn the second, third and fourth fields of the description file, special
  293. Xcharacters can be imbedded by using '\fB^\fR' to imply control characters
  294. Xand '\fB\\\fR' to imply other special escape codes.  For example:
  295. X.nf
  296. X
  297. X    ^X - this would be interpreted as 'control-X'
  298. X
  299. X.fi
  300. XAny alphabetic character may follow the '\fB^\fR' in order to signify a
  301. Xcontrol character.  This can be used, for example, to enter a 'control-D'
  302. Xinto the fourth field, for a 'logoff' function key:
  303. X.nf
  304. X
  305. X8:Log off:system:^D
  306. X
  307. X.fi
  308. XThe following uses of '\fB\\\fR' are supported:
  309. X.nf
  310. X
  311. X    \\n - newline
  312. X
  313. X    \\r - carriage return
  314. X
  315. X    \\b - bell (^G)
  316. X
  317. X    \\E - escape
  318. X
  319. X.fi
  320. XAny other characters placed after an '\fB\\\fR' will be interpreted
  321. Xliterally ('\fB\\\\\fR' would allow an '\fB\\\fR' to be a part of the
  322. Xfield, '\fB\\^\fR' would allow '\fB^\fR' to be a part of the field, etc).
  323. X.SH WARNINGS
  324. X.B Fnkey
  325. Xwill complain if your terminal is not capable of having it's function keys
  326. Xset or if the escape sequences of your terminal are not \fIHP 2392a\fR
  327. Xcompatible.  The environment variable \fI$TERM\fR is checked to determine
  328. Xthis.
  329. X.SH BUGS
  330. XIn keeping with HP's policy of making their terminals braindamaged, the
  331. Xescape sequence to program function keys leaks carriage returns to the
  332. Xscreen.  Thus, each occurance of a newline ('\fB\\n\fR') in a fourth field
  333. Xwill cause the cursor to drop down one line and possibly scroll.  If you
  334. Ximbed this command in any screen-oriented programs, beware.  You will
  335. Xprobably have to home the cursor, execute the
  336. X.B fnkey
  337. Xcommand, then reposition the cursor to wherever you had intended it to
  338. Xbe all this time.
  339. X.PP
  340. XThis program is device dependant.  I will not adapt it to other
  341. Xterminals except for cases of my own personal preference.  If you want
  342. Xit on a different terminal, then you must hack it yourself.  Using
  343. X.I terminfo
  344. Xfor portability would be nice, but I don't know if it is capable of this
  345. Xstuff.
  346. X.SH AUTHOR
  347. XMark Steven Jeghers, Cogent Software Solutions, July 1987
  348. SHAR_EOF
  349. if test 6081 -ne "`wc -c < 'fnkey.1'`"
  350. then
  351.     echo shar: "error transmitting 'fnkey.1'" '(should have been 6081 characters)'
  352. fi
  353. echo shar: "extracting 'fnkey.c'" '(5393 characters)'
  354. if test -f 'fnkey.c'
  355. then
  356.     echo shar: "will not over-write existing file 'fnkey.c'"
  357. else
  358. sed 's/^X//' << \SHAR_EOF > 'fnkey.c'
  359. X/****************************************************************
  360. X * fnkey.c - a program to maintain function key definitions
  361. X *
  362. X * Author: Mark Steven Jeghers
  363. X *
  364. X * SCCS Version:    @(#)fnkey.c    1.1
  365. X *
  366. X * Last Modified:    07/22/87 22:46:59
  367. X * Last Retrieved:    07/22/87 22:47:19
  368. X *
  369. X * The author of "fnkey" grants permission to use and
  370. X * redistribute this program as long as these three conditions
  371. X * are met:
  372. X *
  373. X * 1. The program is not sold for profit, distributed for
  374. X *    personal gain, or given to anyone else (unless it is
  375. X *    given with ABSOLUTELY no strings attached and at NO
  376. X *    expense to the recipient).
  377. X *
  378. X * 2. The contents of this box (title, version numbers, author
  379. X *    info and terms of permissions) are left intact at the top
  380. X *    of this program.
  381. X *
  382. X * 3. No other person takes credit for authorship of this program.
  383. X * 
  384. X ****************************************************************
  385. X * 
  386. X * Author's whereabouts: (last known whereabouts, at any rate...)
  387. X *
  388. X * Business Address:            Home Address:
  389. X * -------------------------        ----------------------
  390. X * Cogent Software Solutions        Mark Jeghers
  391. X * 221 Tuxedo Ct. #F            2014 W. Willow
  392. X * Stockton CA 95204            Stockton CA 95203
  393. X * (209) 467-0276            (209) 465-0391
  394. X * 
  395. X ****************************************************************/
  396. X
  397. X#include <fcntl.h>
  398. X#include <stdio.h>
  399. X#include <string.h>
  400. X
  401. Xchar    record[256];
  402. X
  403. Xstatic    char    *TERM[] = {    /* list of $TERM values we can deal with */
  404. X    "hp2392",
  405. X    "ansi-d",
  406. X    "*end*"        /* <--- end of the list */
  407. X    };
  408. X
  409. Xmain(argc, argv)
  410. Xint    argc;
  411. Xchar    *argv[];
  412. X{
  413. X    int    i, fd, termok = 0;
  414. X    FILE    *strm;
  415. X    char    fk_num[2];
  416. X
  417. X    for (i=0; strcmp(TERM[i], "*end*") != 0; i++)
  418. X        if ((strcmp(TERM[i], getenv("TERM"))) == 0)
  419. X            termok = 1;
  420. X
  421. X    if (termok != 1) {
  422. X        fprintf(stderr, "%s: Inadequate terminal type '%s'\n", argv[0], getenv("TERM"));
  423. X        exit(1);
  424. X    }
  425. X
  426. X    if (argc == 2) {
  427. X        if (strcmp(argv[1], "-") == 0) {    /* hook stdin to fd */
  428. X            fd = dup(0);
  429. X            close(0);
  430. X        } else {        /* open normal file */
  431. X            fd = find_open(argv[1]);
  432. X        }
  433. X    } else {
  434. X        fd = find_open("fn_default");
  435. X    }
  436. X    if (fd == -1) {
  437. X        fprintf(stderr, "%s: Cannot open any source file\n", argv[0]);
  438. X        exit(1);
  439. X    }
  440. X    strm = fdopen(fd, "r");
  441. X
  442. X    all_keys_off();
  443. X
  444. X    while (fgets(record, 256, strm) != NULL) {
  445. X        if (strlen(record) > 1) {
  446. X            parse(record, fk_num);
  447. X            if ((atoi(fk_num) > 0) && (atoi(fk_num) < 9))
  448. X                process_key(fk_num);
  449. X            else
  450. X                complain(argv[0], fk_num);
  451. X        }
  452. X    }
  453. X
  454. X    all_keys_on();
  455. X
  456. X    fclose(strm);
  457. X    close(fd);
  458. X
  459. X    exit(0);
  460. X} /* end of main */
  461. X
  462. Xprocess_key(k_num)
  463. Xchar    *k_num;
  464. X{
  465. X    char    Label1[9], Label2[9], Command[99];
  466. X
  467. X    parse(record, Label1);
  468. X    if (strcmp(Label1, "*") != 0) {
  469. X        process_string(Label1);
  470. X        pad(Label1, 8);
  471. X        parse(record, Label2);
  472. X        process_string(Label2);
  473. X        pad(Label2, 8);
  474. X        parse(record, Command);
  475. X        process_string(Command);
  476. X    } else {
  477. X        strcpy(Label1, "        ");
  478. X        strcpy(Label2, "        ");
  479. X        strcpy(Command, "\n");
  480. X    }
  481. X    output_fkey(k_num, Label1, Label2, Command);
  482. X}
  483. X
  484. Xoutput_fkey(k_num, L1, L2, Cmd)
  485. Xchar *k_num, *L1, *L2, *Cmd;
  486. X{
  487. X    char    string[199], tmp[99];
  488. X
  489. X    strcpy(string, "\033&f");
  490. X    sprintf(tmp, "%dk", atoi(k_num));
  491. X    strcat(string, tmp);
  492. X    strcat(string, "16d");
  493. X    sprintf(tmp, "%d\L", strlen(Cmd));
  494. X    strcat(string, tmp);
  495. X    strcat(string, L1);
  496. X    strcat(string, L2);
  497. X    strcat(string, Cmd);
  498. X    printf(string);
  499. X}
  500. X
  501. Xall_keys_on()
  502. X{
  503. X    printf("\033&jB");
  504. X}
  505. X
  506. Xall_keys_off()
  507. X{
  508. X    printf("\033&j@");
  509. X}
  510. X
  511. Xcomplain(pgname, k)
  512. Xchar    *pgname, *k;
  513. X{
  514. X    fprintf(stderr, "%s: Invalid entry for key '%s'\n", pgname, k);
  515. X}
  516. X
  517. Xpad(str, len)
  518. Xchar    *str;
  519. Xint    len;
  520. X{
  521. X    while (strlen(str) < len)
  522. X        strcat(str, " ");
  523. X}
  524. X
  525. Xprocess_string(str)
  526. Xchar    *str;
  527. X{
  528. X    int    i, j;
  529. X    char    escape(), control();
  530. X
  531. X    for (i=0; i<strlen(str); i++) {
  532. X        switch(str[i]) {
  533. X            case '\\':
  534. X                str[i] = escape(str[i+1]);
  535. X                for (j=i+1; j<strlen(str); j++)
  536. X                    str[j] = str[j+1];
  537. X                str[strlen(str)] = '\0';
  538. X                break;
  539. X            case '^':
  540. X                str[i] = control(str[i+1]);
  541. X                for (j=i+1; j<strlen(str); j++)
  542. X                    str[j] = str[j+1];
  543. X                str[strlen(str)] = '\0';
  544. X                break;
  545. X        }
  546. X    }
  547. X}
  548. X
  549. Xchar escape(c)
  550. Xchar    c;
  551. X{
  552. X    switch(c) {
  553. X        case 'n':
  554. X            return('\012');
  555. X        case 'r':
  556. X            return('\015');
  557. X        case 'b':
  558. X            return('\007');
  559. X        case 'E':
  560. X            return('\033');
  561. X    }
  562. X    return(c);
  563. X}
  564. X
  565. Xchar control(c)
  566. Xchar    c;
  567. X{
  568. X    c = toupper(c);
  569. X    return(c - 'A' + 1);
  570. X}
  571. X
  572. Xparse(rec, str)
  573. Xchar    *rec, *str;
  574. X{
  575. X    int    i = 0, j, k;
  576. X    char    *ptr1 = rec, *ptr2 = rec;
  577. X
  578. X    while ((ptr1[0] != ':') && (ptr1[0] != '\012') && (ptr1[0] != '\0'))
  579. X        ptr1++;
  580. X    while (ptr2 != ptr1) {
  581. X        str[i] = ptr2[0];
  582. X        ptr2++;
  583. X        i++;
  584. X    }
  585. X    str[i] = '\0';
  586. X    k = strlen(rec);    /* get it now because it will change!! */
  587. X    for (j=0; j != k-i; j++)
  588. X        rec[j] = rec[j+i+1];
  589. X}
  590. X
  591. Xfind_open(file)
  592. Xchar    *file;
  593. X{
  594. X    int    fd;
  595. X
  596. X    if (getenv("FNKEY") != NULL) {
  597. X        if ((fd = chk_path(getenv("FNKEY"), file)) != -1)
  598. X            return(fd);
  599. X    }
  600. X    if (getenv("H") != NULL) {
  601. X        if ((fd = chk_path(getenv("H"), file)) != -1)
  602. X            return(fd);
  603. X        if ((fd = chk_path(strcat(getenv("H"), "/.fnkey"), file)) != -1)
  604. X            return(fd);
  605. X    }
  606. X    if (getenv("HOME") != NULL) {
  607. X        if ((fd = chk_path(getenv("HOME"), file)) != -1)
  608. X            return(fd);
  609. X        if ((fd = chk_path(strcat(getenv("HOME"), "/.fnkey"), file)) != -1)
  610. X            return(fd);
  611. X    }
  612. X    if ((fd = chk_path("/usr/local/lib/fnkey", file)) != -1)
  613. X        return(fd);
  614. X
  615. X    return(-1);
  616. X}
  617. X
  618. Xchk_path(dir, file)
  619. Xchar    *dir, *file;
  620. X{
  621. X    int    fd;
  622. X    char    path[99];
  623. X
  624. X    strcpy(path, dir);
  625. X    strcat(path, "/");
  626. X    strcat(path, file);
  627. X    if (access(path, 4) == 0) {
  628. X        return(fd = open(path, O_RDONLY));
  629. X    } else {
  630. X        return(-1);
  631. X    }
  632. X}
  633. X
  634. SHAR_EOF
  635. if test 5393 -ne "`wc -c < 'fnkey.c'`"
  636. then
  637.     echo shar: "error transmitting 'fnkey.c'" '(should have been 5393 characters)'
  638. fi
  639. if test ! -d 'samples'
  640. then
  641.     echo shar: "creating directory 'samples'"
  642.     mkdir 'samples'
  643. fi
  644. echo shar: "entering directory 'samples'"
  645. cd 'samples'
  646. echo shar: "extracting 'dial'" '(274 characters)'
  647. if test -f 'dial'
  648. then
  649.     echo shar: "will not over-write existing file 'dial'"
  650. else
  651. sed 's/^X//' << \SHAR_EOF > 'dial'
  652. X1:Hook to: Modem:cu -s2400 -m -lcul0p1\n
  653. X2: Manual:  Dial:cu -s2400 
  654. X3:  Call: Jersey:cu nj\n:    often used
  655. X4:  Call:  Argo:cu argo\n:    often used
  656. X5:  Call:Stockton:cu stkn\n:    seldom used
  657. X6:  Call:Winston:cu ws\n:    seldom used
  658. X7:Back to:top set:fnkey\n
  659. X8: Logoff:or Exit:exit\n
  660. SHAR_EOF
  661. if test 274 -ne "`wc -c < 'dial'`"
  662. then
  663.     echo shar: "error transmitting 'dial'" '(should have been 274 characters)'
  664. fi
  665. echo shar: "extracting 'fn_default'" '(236 characters)'
  666. if test -f 'fn_default'
  667. then
  668.     echo shar: "will not over-write existing file 'fn_default'"
  669. else
  670. sed 's/^X//' << \SHAR_EOF > 'fn_default'
  671. X1: Go to:main set:fnkey main\n
  672. X2: Go to:UUCP set:fnkey uucp\n
  673. X3: Go to:dial set:fnkey dial\n
  674. X4: Go to:news set:fnkey news\n
  675. X5: Go to:unix set:fnkey unix\n
  676. X6: Go to: fun set:fnkey fun\n
  677. X7:  Read:the Mail:mailx\n
  678. X8: Logoff:or Exit:exit\n
  679. SHAR_EOF
  680. if test 236 -ne "`wc -c < 'fn_default'`"
  681. then
  682.     echo shar: "error transmitting 'fn_default'" '(should have been 236 characters)'
  683. fi
  684. echo shar: "extracting 'fun'" '(184 characters)'
  685. if test -f 'fun'
  686. then
  687.     echo shar: "will not over-write existing file 'fun'"
  688. else
  689. sed 's/^X//' << \SHAR_EOF > 'fun'
  690. X1: Read a:fortune:fortune\n
  691. X2: Read a:Headline:spew\n
  692. X3:  Play: Chess:chess\n
  693. X4:  Play:Othello:othello\n
  694. X5:  Play:Advnture:adv\n
  695. X6:*
  696. X7:Back to:top set:fnkey\n
  697. X8: Logoff:or Exit:exit\n
  698. SHAR_EOF
  699. if test 184 -ne "`wc -c < 'fun'`"
  700. then
  701.     echo shar: "error transmitting 'fun'" '(should have been 184 characters)'
  702. fi
  703. echo shar: "extracting 'main'" '(262 characters)'
  704. if test -f 'main'
  705. then
  706.     echo shar: "will not over-write existing file 'main'"
  707. else
  708. sed 's/^X//' << \SHAR_EOF > 'main'
  709. X1:  Do a: uusnap:uusnap\n
  710. X2:  Do a: uulog:uulog | tail\n
  711. X3:  Call: Jersey:cu nj\n:    often used
  712. X4:  Call:  Argo:cu argo\n:    often used
  713. X5:  Call:Stockton:cu stkn\n:    seldom used
  714. X6:  Call:Winston:cu ws\n:    seldom used
  715. X7:Back to:top set:fnkey\n
  716. X8: Logoff:or Exit:exit\n
  717. SHAR_EOF
  718. if test 262 -ne "`wc -c < 'main'`"
  719. then
  720.     echo shar: "error transmitting 'main'" '(should have been 262 characters)'
  721. fi
  722. echo shar: "extracting 'news'" '(297 characters)'
  723. if test -f 'news'
  724. then
  725.     echo shar: "will not over-write existing file 'news'"
  726. else
  727. sed 's/^X//' << \SHAR_EOF > 'news'
  728. X1:Post new:article:!Pnews\n
  729. X2:  Post:Followup:F:followup command in 'rn'
  730. X3:Reply by:  Mail:R:reply command in 'rn'
  731. X4:Catch up:articles:c:catch-up command in 'rn'
  732. X5: Browse :articles:=:browse command in 'rn'
  733. X6:  Quit:  this:q:quit command in 'rn'
  734. X7:Back to:top set:fnkey\n
  735. X8: Logoff:or Exit:exit\n
  736. SHAR_EOF
  737. if test 297 -ne "`wc -c < 'news'`"
  738. then
  739.     echo shar: "error transmitting 'news'" '(should have been 297 characters)'
  740. fi
  741. echo shar: "extracting 'tape'" '(357 characters)'
  742. if test -f 'tape'
  743. then
  744.     echo shar: "will not over-write existing file 'tape'"
  745. else
  746. sed 's/^X//' << \SHAR_EOF > 'tape'
  747. X1:Read the:  Tape:tape.read\n:a tape-reading script
  748. X2:Save out:my area:tape.save -u mark\n:a tape-saving script
  749. X3:|pipe to:tapesave: | tape.save\n:same as 2, but via pipeline
  750. X4:|pipe to:raw tape: | dd of=/dev/rmt/0m obs=5120\n
  751. X5:read in:raw tape:dd if=/dev/rmt/0m ibs=5120 
  752. X6:Back to:unix set:fnkey unix\n
  753. X7:Back to:top set:fnkey\n
  754. X8: Logoff:or Exit:exit\n
  755. SHAR_EOF
  756. if test 357 -ne "`wc -c < 'tape'`"
  757. then
  758.     echo shar: "error transmitting 'tape'" '(should have been 357 characters)'
  759. fi
  760. echo shar: "extracting 'unix'" '(182 characters)'
  761. if test -f 'unix'
  762. then
  763.     echo shar: "will not over-write existing file 'unix'"
  764. else
  765. sed 's/^X//' << \SHAR_EOF > 'unix'
  766. X1: Go to:Tape set:fnkey tape\n
  767. X2:Read the:  time:date\n
  768. X3: Who is:   on?:who\n
  769. X4:  Disk: space?:df\n
  770. X5:Check my:Process':ps -f\n
  771. X6: Check:Process':ps -ef\n
  772. X7:Back to:top set:fnkey\n
  773. SHAR_EOF
  774. if test 182 -ne "`wc -c < 'unix'`"
  775. then
  776.     echo shar: "error transmitting 'unix'" '(should have been 182 characters)'
  777. fi
  778. echo shar: "extracting 'uucp'" '(274 characters)'
  779. if test -f 'uucp'
  780. then
  781.     echo shar: "will not over-write existing file 'uucp'"
  782. else
  783. sed 's/^X//' << \SHAR_EOF > 'uucp'
  784. X1:  Do a: uusnap:uusnap\n
  785. X2:  Do a: uulog:uulog | tail\n
  786. X3:  Poll: Jersey:uupoll nj\n:often used
  787. X4:  Poll:  Argo:uupoll argo\n:often used
  788. X5:  Poll:Stockton:uupoll stkn\n:seldom used
  789. X6:  Poll:Winston:uupoll ws\n:seldom used
  790. X7:Back to:top set:fnkey\n
  791. X8: Logoff:or Exit:exit\n
  792. SHAR_EOF
  793. if test 274 -ne "`wc -c < 'uucp'`"
  794. then
  795.     echo shar: "error transmitting 'uucp'" '(should have been 274 characters)'
  796. fi
  797. echo shar: "done with directory 'samples'"
  798. cd ..
  799. exit 0
  800. #    End of shell archive
  801. -- 
  802. +----------------------------------------------------------------------------+
  803. |     Mark Steven Jeghers: the terrorist smuggling CIA weapons to Libya      |
  804. |                                                                            |
  805. |     {ihnp4,cbosgd,lll-lcc,lll-crg}|{dual,ptsfa}!cogent!mark                |
  806. |                                                                            |
  807. |     Standard Disclaimer:  Contents may have settled during shipment.       |
  808. +----------------------------------------------------------------------------+
  809.