home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1343 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  23.8 KB

  1. From: greim@sbsvax.cs.uni-sb.de (Michael Greim)
  2. Newsgroups: alt.sources
  3. Subject: KEF - a library to store and identify function key presses, Part 05/06
  4. Message-ID: <4367@sbsvax.cs.uni-sb.de>
  5. Date: 15 May 90 15:17:29 GMT
  6.  
  7.  
  8. #! /bin/sh
  9. # This is a shell archive.  Remove anything before this line, then unpack
  10. # it by saving it into a file and typing "sh file".  To overwrite existing
  11. # files, type "sh file -c".  You can also feed this as standard input via
  12. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  13. # will see the following message at the end:
  14. #        "End of archive 4 (of 5)."
  15. # Contents:  kdb-low/kdb-low.man kef/kef.man
  16. # Wrapped by greim@usb370 on Tue May 15 09:38:17 1990
  17. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  18. if test -f 'kdb-low/kdb-low.man' -a "${1}" != "-c" ; then 
  19.   echo shar: Will not clobber existing file \"'kdb-low/kdb-low.man'\"
  20. else
  21. echo shar: Extracting \"'kdb-low/kdb-low.man'\" \(10202 characters\)
  22. sed "s/^X//" >'kdb-low/kdb-low.man' <<'END_OF_FILE'
  23. X.TH kdb-low 3 local
  24. X.DA 6 December 89
  25. X.SH NAME
  26. Xkdb-low : kef__init_db, kef__add, kef__remove, kef__cleanup, kef__read,
  27. Xkef_write, kef_error, kef_match, kef_walk, kef_get_value, kef_advance,
  28. Xkef__next_inst, kef__build_str
  29. X.SH SYNOPSIS
  30. X.nf
  31. X# include <kef.h>
  32. X
  33. Xkef__init_db (kdb, nd, num_nodes, my_malloc, my_realloc, my_free)
  34. X
  35. Xkef__add (kdb, str, val)
  36. X
  37. Xkef__remove (kdb, str)
  38. X
  39. Xkef__cleanup (kdb)
  40. X
  41. Xkef__read (fd, kdb, nd, num_nodes, my_malloc, my_realloc, my_free)
  42. X
  43. Xkef_write (fd, kdb)
  44. X
  45. Xstr = kef_error (num)
  46. X
  47. Xkef_match (kdb, str, val)
  48. X
  49. Xkef_walk (kdb, c, pinx)
  50. X
  51. Xkef_get_value (kdb, pos, pval)
  52. X
  53. Xkef_advance (kdb, c, pinx)
  54. X
  55. Xkef__next_inst (kdb, val, pinx)
  56. X
  57. Xkef__build_str (kdb, inx, buf, size_buf)
  58. X
  59. Xint kef_errno;
  60. X
  61. XWith:
  62. X
  63. Xstruct kef_db * kdb;
  64. Xstruct kef_node * nd;
  65. Xint num_nodes, size_buf;
  66. Xchar * (* my_malloc) ();
  67. Xchar * (* my_realloc) ();
  68. Xvoid (* my_free) ();
  69. Xchar * str, * buf;
  70. Xkef_value val;
  71. Xkef_value * pval;
  72. Xint num;
  73. Xchar c;
  74. Xkef_index pos, * pinx;
  75. X
  76. X.ef
  77. X
  78. X.SH DESCRIPTION
  79. XThe routines described here belong to kdb-low, a part of the KEF library
  80. Xused to recognize function key presses. The KEF library
  81. Xis divided into 4 parts: kdb-low, kdb-high, kef and kef-id.
  82. Xkdb-low contains all low level routines to work on the datastructures
  83. Xused to store the strings. The datastructures are called "KEF database",
  84. Xor short "kef_db" or "kdb". The routines are low level because they don't
  85. Xcall malloc/realloc/free and treat the database as static storage. For some
  86. Xof these routines there are equivalents in kdb-high, namely for those routines
  87. Xwhose names start with "kef__".
  88. X.br
  89. XThe database stores pairs (string, value) so that "value" can be retrieved,
  90. Xwhen "string" is encountered in an input.
  91. X.br
  92. XAll routines of the KEF library, except where noted otherwise, return 
  93. Xan integer number indicating success or failure. An error has occured,
  94. Xwhen the number is less or equal -10, everything was ok when the number is 0.
  95. X
  96. X.SH ROUTINE DESCRIPTION
  97. X.sp 2
  98. XAny parameter with name "kdb" is declared as "struct kef_db * kdb".
  99. X.PP
  100. X\fBkef__init_db\fR (kdb, nd, num_nodes, my_malloc, my_realloc, my_free)
  101. X.in +4
  102. Xstruct kef_node * nd;
  103. X.br
  104. Xint num_nodes;
  105. X.br
  106. Xchar * (* my_malloc) ();
  107. X.br
  108. Xchar * (* my_realloc) ();
  109. X.br
  110. Xvoid (* my_free) ();
  111. X.in -4
  112. X
  113. XInitializes a kef_db database structure for further use setting it
  114. Xto state "empty". The structure
  115. Xof a header (kef_db) and an array of slots (kef_node), in which entries
  116. Xinto the database are stored, must have been allocated already.
  117. Xnum_nodes is the number of elements in array nd.
  118. XThe kef_db structure contains
  119. X3 slots for pointers at functions, which may be called only by high
  120. Xlevel routines. They are set to my_malloc, my_realloc and my_free
  121. Xrespectively. Whenever a KEF routine tries to allocate storage it will
  122. Xuse the routines specified here. If you don't want to use any dynamic
  123. Xstorage you can specify a null pointer ("(char * (*)())0") here.
  124. X.sp 2
  125. X\fBkef__add\fR (kdb, str, val)
  126. X.in +4
  127. Xchar * str;
  128. X.br
  129. Xkef_value val;
  130. X.in -4
  131. Xadds pair (str, val) to database associated with structure pointed at by kdb.
  132. XIt is possible to add a string which
  133. Xis a prefix to another string already in the database.
  134. X.sp 2
  135. X\fBkef__remove\fR (kdb, str)
  136. X.in +4
  137. Xchar * str;
  138. X.in -4
  139. X.br
  140. XRemove entry for string str from database kdb.
  141. X.sp 2
  142. X\fBkef__cleanup\fR (kdb)
  143. X.br
  144. XReorder the information in database to allow faster access.
  145. X
  146. X.sp 2
  147. X\fBkef__read\fR (fd, kdb, nd, num_nd, my_malloc, my_realloc, my_free)
  148. X.in +4
  149. Xint fd;
  150. X.br
  151. Xstruct kef_node * nd;
  152. X.br
  153. Xint num_nodes;
  154. X.br
  155. Xint num_nd;
  156. X.br
  157. Xchar * (my_alloc *) ();
  158. X.br
  159. Xchar * (my_realloc *) ();
  160. X.br
  161. Xvoid (my_free *) ();
  162. X.in -4
  163. XSetup the KEF database, fill it with data from file. The file referenced
  164. Xby file descriptor fd must be open for reading and the file pointer
  165. Xmust point at the start of data suitable for reading by kef.
  166. XThe data that KEF expects in the file has the following format:
  167. X.br
  168. X- header; fixed size; contains number of nodes to follow
  169. X.br
  170. X- nodes
  171. X.br
  172. XNote that the read routines automatically detect when the data was
  173. Xwritten on a machine with a different byte order and swap the byte to
  174. Xget the data correct.
  175. X.br
  176. XIt is an error when the array nd is not large enough to receive all
  177. Xdata from file.
  178. X
  179. X.sp 2
  180. X\fBkef_write\fR (fd, kdb)
  181. X.in +4
  182. Xint fd;
  183. X.in -4
  184. XWrite essential information from KEF database pointed at by kdb to file
  185. Xfd, suitable for reading by kef_read (or other read routines).
  186. X
  187. X.sp 2
  188. Xs = \fBkef_error\fR (kef_errno)
  189. X.in +4
  190. Xchar * s;
  191. X.br
  192. Xint kef_errno;
  193. X.in -4
  194. XWhen a KEF routine returns an error code you can use kef_error to
  195. Xobtain a descriptive string for error code kef_errno.
  196. X
  197. X.sp 2
  198. X\fBkef_match\fR (kdb, str, val)
  199. X.in +4
  200. Xchar * str;
  201. X.br
  202. Xkef_value * val;
  203. X.in -4
  204. XWith kef_match you can look whether a string is in the database.
  205. X"str" is the string for which kef_match searches, it returns
  206. X0 : not found or 1 : found. If the string was found, val is set to
  207. Xthe associated value from the database.
  208. XNote that this routine does not return any error, if kdb is not pointing
  209. Xat a correctly created KEF database, the results are unpredictable.
  210. X
  211. X.sp 2
  212. X\fBkef_advance\fR (kdb, c, pinx)
  213. X.in +4
  214. Xchar c;
  215. X.br
  216. Xkef_index * pinx;
  217. X.in -4
  218. XWalk around in a database representation. Calling this routine you step
  219. Xdown level by level in the tree that the database is using to store its
  220. Xentries. pinx holds the current place in the tree. If "*pinx == KEE_NIL"
  221. Xthen the routine starts from the root node.
  222. XIf the character was found the routine returns 1 and writes the relevant index
  223. Xat the place pointed at by pinx. If the character was not found, it
  224. Xreturns 0 but the contents of the location pointed at by pinx
  225. Xare not changed.
  226. X.br
  227. Xkef_advance does not maintain the structures necessary for kef__build_str to
  228. Xfunction.
  229. X.sp 2
  230. XExample:
  231. X.br
  232. XYou want to search for string "abc". Not only do you want to know whether this
  233. Xstring is in the database, you also want to know whether there is any
  234. Xprefix of it in the database.
  235. X.br
  236. X.nf
  237. X    char * s, * base;
  238. X    int count;
  239. X    kef_index p;
  240. X    kef_value val;
  241. X
  242. X    base = s = "abc";
  243. X    
  244. X    p = KEF_NIL;
  245. X    for (count = 0; *(++s) != '\0' && kef_advance (kdb, *s, &p) == 1;) {
  246. X        if (kef_get_value (kdb, p, &val) == 1) {
  247. X            printf ("prefix string found, length %1d, val = %1d\\n",
  248. X                (int)(s - base), val);
  249. X            count ++;
  250. X        }
  251. X    }
  252. X    /*
  253. X     * Note that p is either KEF_NIL, or the index of the last cell
  254. X     * examined.
  255. X     */
  256. X    if (*s == '\0' && p != KEF_NIL && kef_get_value (kdb, p, &val) == 1)
  257. X        printf ("string is in database, value = %1d\\n", val);
  258. X    else
  259. X        printf ("string is not in database\\n");
  260. X    printf ("there are %1d prefix strings in database\\n", count);
  261. X.fi
  262. X
  263. X.sp 2
  264. X\fBkef_walk\fR (kdb, pinx)
  265. X.in +4
  266. Xkef_index * pinx;
  267. X.in -4
  268. XWalk depth first through the tree of character cells.
  269. XTo start a walk, write KEF_NIL at the location pointed at by pinx.
  270. XThe walk is finished, when there is a KEF_NIL at the location
  271. Xpointed at by pinx after a call to kef_walk.
  272. XThe routine returns standard KEF error values.
  273. X.br
  274. Xkef_walk manipulates the contents of the array to find its way back
  275. Xwithout needing an external data structure. This internal data structure
  276. Xcan be used to build the string leading to the current place in the tree.
  277. Xkef_walk uses a field of the node structure that is unused except by the
  278. X"cleanup" routines.
  279. XAfter a call to kef_walk you can call kef__build_str (see below) to get
  280. Xthe string that leads to the place in the tree that you are at now.
  281. X.sp 2
  282. XExample :
  283. X.br
  284. XVisit all nodes in the tree:
  285. X.br
  286. X.nf
  287. X    kee_index inx;
  288. X    int ret;
  289. X
  290. X    inx = KEF_NIL;
  291. X    while ((ret = kef_walk (kdb, &inx)) == KEF_E_OK && inx != KEF_NIL)
  292. X        printf ("at node %1d\n", inx);
  293. X    if (ret != KEF_E_OK)
  294. X        printf ("kef error %s\n", kee_error(ret));
  295. X    else
  296. X        printf ("walk done.\n");
  297. X.fi
  298. X
  299. X.sp 2
  300. X\fBkef_get_value\fR (kdb, pos, pval)
  301. X.in +4
  302. Xkef_index pos;
  303. X.br
  304. Xkef_value * pval;
  305. X.in -4
  306. XExamine the entry with internal address pos whether there is a value
  307. Xassociated with the string by which we arrived at this entry. "pos" was
  308. Xreturned by kef_advance or kef_walk.
  309. XReturns 0 : if no value 1 : if value. If there is a value, the cell pointed
  310. Xat by pval will receive the value.
  311. X.br
  312. XNote that you must not add or delete entries from the database, nor call
  313. Xkef_cleanup while walking the tree with
  314. Xkef_start_walk, kef_walk and kef_get_value.
  315. X
  316. X.sp 2
  317. X\fBkef__next_inst\fR (kdb, val, pinx)
  318. X.in +4
  319. Xkef_value val;
  320. X.br
  321. Xkef_index * pinx;
  322. X.in -4
  323. XRun depth-first through tree of character cells searching for cells
  324. Xwith value val. When found return index of found cell at location
  325. Xpointed at by pinx. Start with search at cell "*pinx", or at start
  326. Xof tree if "*pinx" is equal KEF_NIL.
  327. X.br
  328. XThis routine is used while searching for all occurances of a value
  329. Xin a tree.
  330. Xkef__next_inst uses kef_walk to traverse the tree (see above).
  331. X.br
  332. XThe routine returns  0 : no value found i.e. at end of tree; 1 : found, the
  333. Xindex of the cell at which value was found will be written to "*pinx"; else
  334. Xnormal KEF error values.
  335. X
  336. X.sp 2
  337. X\fBkef__build_str\fR (kdb, inx, buf, size_buf)
  338. X.in +4
  339. Xkef_index inx;
  340. X.br
  341. Xchar * buf;
  342. X.br
  343. Xint size_buf;
  344. X.in -4
  345. XUse the information built and returned by kef__next_inst to build a
  346. Xstring. buf receives the string, size_buf is the maximal number of
  347. Xbytes to use in buf.
  348. XReturns 0 : everything ok, -1 : buffer too small.
  349. X.br
  350. XTypically, kef__next_inst and kef__build_str are used together like in
  351. X.nf
  352. X    /*
  353. X     * Search for "val"
  354. X     */
  355. X    kef_index here;
  356. X    int ret;
  357. X
  358. X    here = KEF_NIL;
  359. X    while (kef__next_inst (kdb, val, &here) == 1) {
  360. X        ret = kef__build_str (kdb, here, buf, size_buf);
  361. X        if (ret == -1)
  362. X            printf ("buffer too small\\n");
  363. X        else if (ret == 0)
  364. X            printf ("string found : %s\\n", buf);
  365. X        else
  366. X            printf ("kef error : %s\\n", kef_error (ret));
  367. X    }
  368. X.fi
  369. X
  370. X.SH BUGS
  371. X-
  372. X'in +4
  373. XThe KEF routines do not try to save a user from his/her own foolishness
  374. Xbeyond a sensible limit. I.e. most routines do not check whether the
  375. Xparameter kdb is pointing at a valid data structure.
  376. X.in -4
  377. X
  378. X.SH SEE ALSO
  379. Xkdb-high(3), kef(3), kef-id(3)
  380. X.br
  381. X"Kee - a library of routines to handle input from ASCII terminals" by M. Greim
  382. X
  383. X.SH AUTHOR
  384. XMichael Greim (greim@cs.uni-sb.de)
  385. END_OF_FILE
  386. if test 10202 -ne `wc -c <'kdb-low/kdb-low.man'`; then
  387.     echo shar: \"'kdb-low/kdb-low.man'\" unpacked with wrong size!
  388. fi
  389. # end of 'kdb-low/kdb-low.man'
  390. fi
  391. if test -f 'kef/kef.man' -a "${1}" != "-c" ; then 
  392.   echo shar: Will not clobber existing file \"'kef/kef.man'\"
  393. else
  394. echo shar: Extracting \"'kef/kef.man'\" \(11349 characters\)
  395. sed "s/^X//" >'kef/kef.man' <<'END_OF_FILE'
  396. X.TH kef 3 local
  397. X.DA 7 march 90
  398. X.SH NAME
  399. Xkef : kef_create, kef_mcreate, kef__init, kef_get, kef_set_timeout,
  400. Xkef_get_timeout, kef_set_delay, kef_get_delay
  401. X.SH SYNOPSIS
  402. X.nf
  403. X# include <kef.h>
  404. X
  405. Xkef_create (pk, buf, buf_size, kdb, fd)
  406. X
  407. Xkef_mcreate (pk, buf, buf_size, kdb, fd, my_malloc, my_realloc, my_free)
  408. X
  409. Xkef__init (k, buf, buf_size, kdb, fd, my_malloc, my_realloc, my_free)
  410. X
  411. Xkef_get (k)
  412. X
  413. Xkef_set_timeout (k, msec, ind)
  414. X
  415. Xkef_set_delay (k, msec, ind)
  416. X
  417. Xkef_get_timeout (k, pmsec)
  418. X
  419. Xkef_get_delay (k, pmsec)
  420. X
  421. Xint kef_errno;
  422. X
  423. XWith:
  424. X
  425. Xstruct kef * k, ** pk;
  426. Xstruct kef_db * kdb;
  427. Xchar * buf;
  428. Xint size_buf, ind, msec, * pmsec;
  429. Xchar * (* my_malloc) ();
  430. Xchar * (* my_realloc) ();
  431. XFREE_TYPE (* my_free) ();
  432. X
  433. X.ef
  434. X
  435. X.SH DESCRIPTION
  436. XThe routines described here belong to kef, a part of the KEF library
  437. Xused to recognize function key presses. The KEF library
  438. Xis divided into 4 parts: kdb-low, kdb-high, kef and kef-id.
  439. Xkef contains the routines to read characters from a terminal, search
  440. Xthrough the KEF database and return either a character or a value
  441. Xassociated with a string in the KEF database.
  442. XPart of kef does not use malloc/realloc/free and can be used in an
  443. Xenvironment where these routines are not available, have different names
  444. Xor are known to be buggy.
  445. X.br
  446. XAll routines of the KEF library, except where noted otherwise, return 
  447. Xan integer number indicating success or failure. An error has occured,
  448. Xwhen the number is less or equal -10, everything was ok when the number is 0.
  449. X
  450. X.SH ROUTINE DESCRIPTION
  451. X.sp 2
  452. XAny parameter with name "k" is declared as "struct kef * k".
  453. X.PP
  454. X
  455. X\fBkef_create\fR (pk, buf, buf_size, kdb, fd)
  456. X.in +4
  457. Xchar * buf;
  458. X.br
  459. Xint buf_size;
  460. X.br
  461. Xstruct kef_db * kdb;
  462. X.br
  463. Xint fd;
  464. X.in -4
  465. XCall kef_mcreate as 
  466. Xkef_mcreate (pk, buf, buf_size, kdb, fd, malloc, realloc, free)
  467. X
  468. X.sp 2
  469. X\fBkef__init\fR (k, buf, buf_size, kdb, fd, my_malloc, my_realloc, my_free)
  470. X.in +4
  471. Xchar * buf;
  472. X.br
  473. Xint buf_size;
  474. X.br
  475. Xstruct kef_db * kdb;
  476. X.br
  477. Xint fd;
  478. X.br
  479. Xchar * (my_malloc *) ();
  480. X.br
  481. Xchar * (my_realloc *) ();
  482. X.br
  483. XFREE_TYPE (my_free *) ();
  484. X.in -4
  485. XInitialize the structure pointed at by k using the variables passed.
  486. XIt is an error INV_PAR for k or buf to be NULL or for buf_size to be less or
  487. Xequal 0.
  488. X
  489. X.sp 2
  490. X\fBkef_mcreate\fR (pk, buf, buf_size, kdb, fd, my_malloc, my_realloc, my_free)
  491. X.in +4
  492. Xstruct kef ** pk;
  493. X.br
  494. Xchar * buf;
  495. X.br
  496. Xint buf_size;
  497. X.br
  498. Xstruct kef_db * kdb;
  499. X.br
  500. Xint fd;
  501. X.br
  502. Xchar * (my_malloc *) ();
  503. X.br
  504. Xchar * (my_realloc *) ();
  505. X.br
  506. XFREE_TYPE (my_free *) ();
  507. X.in -4
  508. XAllocate space for a kef structure and initialize it by calling kef__init.
  509. XReturn the pointer to the allocate area in the place pointed to by pk.
  510. Xbuf is the address of an area used for temporary storage of characters,
  511. Xjust after they have been read in and before they are passed to
  512. Xany calling routine. If buf is NULL an area of length buf_size is
  513. Xallocated, if buf_size is 0 a default size of 512 is used.
  514. XIt is an error INV_PAR, if buf is not equal NULL and buf_size is equal
  515. Xor less than 0.
  516. X
  517. X.sp 2
  518. X\fBkef_get\fR (k)
  519. X.br
  520. XRead a character or a string generated by pressing a key on the keyboard.
  521. XThis key can either send a single character or a sequence of several
  522. Xcharacters. Keys that send several characters are traditionally called
  523. X"function keys". KEF can recognise that a function key was pressed, if
  524. Xthe sequence of characters transmitted is in the KEF database and
  525. Xit has a value associated with it. When KEF sees such a string it
  526. Xreturns the associated value from the database.
  527. Xkef buffers characters as long as the sequence read so far is
  528. Xa prefix of a sequence stored in the KEF database and no delay or
  529. Xtimeout was exceeded.
  530. X.br
  531. XA delay is the time that can elapse while kef_get is waiting for the
  532. Xfirst character, the character that may start a sequence.
  533. XA timeout is the time that may elapse while kef_get is waiting for any
  534. Xsubsequent characters.
  535. XA delay can be set with kef_set_delay, a timeout can be set with
  536. Xkef_set_timeout.
  537. XFor possible values for timeout and delay see kef_set_timeout and
  538. Xkef_set_delay.
  539. X.sp 2
  540. XExample:
  541. X.br
  542. XSuppose your KEF database contains, among other, the sequence "\\E[C",
  543. Xwhere "\\E" is the escape character 0x1b.
  544. XYou press a function key, that generates the sequence "\\E[C",
  545. Xso the
  546. Xkeyboard sends 3 characters to the program. kef_get is waiting for
  547. Xa character (controlled by delay), it receives "\\E", it checks the KEF
  548. Xdatabase and
  549. Xsees that there are sequences starting with "\\E". It tries to read another
  550. Xcharacter (controlled by timeout) and gets (fairly fast) the "[". It checks
  551. Xagain the KEF
  552. Xdatabase and sees that there is a sequence starting with "\\E[". It
  553. Xtries to read another character (again controlled by timeout) and gets
  554. Xthe "C". Now kef_get sees that there is only one sequence starting with
  555. X"\\E[C" so it returns the value associated with this sequence.
  556. X.sp 2
  557. Xkef_get returns a signed integer value. If this value is >= 0 then
  558. Xit is the value associated with a character or a character sequence.
  559. XIf it is less than 0 then it is either
  560. X.br
  561. XKEF_NO_CHAR :
  562. X'in +4
  563. Xthere is no character available, i.e. delay was exceeded.
  564. X.in -4
  565. XKEF_INTERRUPT :
  566. X'in +4
  567. Xsome system call got interrupted by a signal. Nothing was
  568. Xread, try again, if necessary.
  569. X.in -4
  570. XKEF_EOF :
  571. X'in +4
  572. XEOF was reached. This can happen when the input was a file or a pipe.
  573. X.in -4
  574. XKEF_SOME_ERROR :
  575. X'in +4
  576. Xsome system call has returned an error indication. The value of the
  577. Xvariable errno was stored in kef_errno.
  578. X.in -4
  579. X
  580. X.sp 2
  581. X\fBkef_set_timeout\fR (k, msec, ind)
  582. X.in +4
  583. Xint msec, ind;
  584. X.in -4
  585. XA timeout is a pair of (ind,msec) values. ind is a boolean flag, msec
  586. Xis a time in milliseconds. If ind == 0  then there is no timeout,
  587. Xmsec is ignored. If ind != 0 and msec == 0 then kef_get will wait
  588. Xforever ("block") for a character,  if ind != 0 and msec != 0 then
  589. Xkef_get will use msec as the number of milliseconds to wait for a
  590. Xcharacter.
  591. X
  592. X.sp 2
  593. X\fBkef_set_delay\fR (k, msec, ind)
  594. X.in +4
  595. Xint msec, ind;
  596. X.in -4
  597. XA delay is (like timeout) a pair of (ind,msec) values. ind is a boolean flag,
  598. Xmsec
  599. Xis a time in milliseconds. If ind == 0  then there is no delay,
  600. Xmsec is ignored. If ind != 0 and msec == 0 then kef_get will wait
  601. Xforever ("block") for a character,  if ind != 0 and msec != 0 then
  602. Xkef_get will use msec as the number of milliseconds to wait for a
  603. Xcharacter.
  604. X
  605. X.sp 2
  606. X\fBkef_get_timeout\fR (k, pmsec)
  607. X.in +4
  608. Xint * pmsec;
  609. X.in -4
  610. XReturns 0 if there is no timeout, 1 if there is one. If there is a timeout,
  611. Xthen kef_get_timeout writes the milliseconds value at the place pointed
  612. Xat by pmsec.
  613. X
  614. X.sp 2
  615. X\fBkef_get_delay\fR (k, pmsec)
  616. X.in +4
  617. Xint * pmsec;
  618. X.in -4
  619. XReturns 0 if there is no delay, 1 if there is one. If there is a delay,
  620. Xthen kef_get_delay writes the milliseconds value at the place pointed
  621. Xat by pmsec.
  622. X
  623. X.sp 2
  624. XYou can forbid kef_get and its friends to use the KEF database.
  625. XSet the k->use_db to 0 and any subsequent calls to kef_get will
  626. Xnot use the database. Set k->use_db to 1 and kef_get will use the
  627. Xdatabase again.
  628. X.br
  629. XNote that there may be several kef structures in a program and that they
  630. Xcan be used independently. Each kef structure holds the associated
  631. Xfile descriptor.
  632. X.br
  633. XDon't use routines from stdio (standard IO) library on the same
  634. Xfiles as a KEF structure. Both KEF and stdio buffer output, KEF holds
  635. Xthe characters that are read but not processed yet and the characters
  636. Xthat were peeked in advance to determine whether a certain character
  637. Xor sequence of characters was the start of a sequence in the KEF database.
  638. X
  639. X.SH ERRORS
  640. XKEF routines return values below -10 to indicate errors. The routine
  641. Xkef_error (see kdb-low(3)) returns a string for any such value or,
  642. Xif it has no string for a given integer value, returns
  643. Xa string "** kef error N **" with the numeric value substituted for
  644. X"N".
  645. X.br
  646. XHere is a listing of errors as they appear in kef.h. All names of
  647. Xerror constants
  648. Xstart with "KEF_E_", this prefix is dropped.
  649. X.sp 2
  650. XOK
  651. X.in +4
  652. XRoutine returned no error, everything is ok.
  653. X.in -4
  654. XSOME_ERROR
  655. X.in +4
  656. XA system call or a library routine returned with an error indication.
  657. XThe value of variable errno (see errno(2)) has been stored in kef_errno.
  658. X.in -4
  659. XNODES_USEDUP
  660. X.in +4
  661. XThere are no more nodes available in the KEF database to store characters
  662. Xin. This error is returned by kef__add (see kdb-low(3)).
  663. X.in -4
  664. XSTRING_TWICE
  665. X.in +4
  666. XThere was a try to add string to the database that was already in it.
  667. X.in -4
  668. XWRITE_ERROR
  669. X.in +4
  670. XThere was an error while writing the internal representation of
  671. Xthe KEF database to a file.
  672. X.in -4
  673. XREAD_ERROR
  674. X.in +4
  675. XThere was an error while reading the internal representation of
  676. Xthe KEF database from a file. Note that this error will also occur when
  677. Xyou try to read a file that does not contain a valid dump of a KEF
  678. Xdatabase or that is not positioned at the start of the database data.
  679. X.in -4
  680. XNOT_FOUND
  681. X.in +4
  682. XThe routine kef_remove was called to remove a string from the database,
  683. Xbut that string could not be found.
  684. X.in -4
  685. XEMPTY_STRING
  686. X.in +4
  687. XA string was given to a routine that was either the NULL pointer or
  688. Xstarted with a NUL character.
  689. X.in -4
  690. XWRONG_MAGIC
  691. X.in +4
  692. XWhen starting to read from a file that allegedly contains a dump of
  693. Xthe KEF database the first 4 bytes are examined and compared to a
  694. X4 byte magic number. If they don't match an error WRONG_MAGIC is
  695. Xgenerated.
  696. X.in -4
  697. XTOO_MANY_NODES
  698. X.in +4
  699. XThe routine kef__read was called to read a dump of a KEF database.
  700. XThere are too many nodes on file to fit in the area at kef__read's
  701. Xdisposal.
  702. X.in -4
  703. XSIZE_KDB
  704. X.in +4
  705. XA part of a KEF database dump specifies the size of the "kef_db"
  706. Xstructure. If it is not the same as the size
  707. Xfor the internal structure an error SIZE_KDB is generated.
  708. X.in -4
  709. XSIZE_NODE
  710. X.in +4
  711. XA part of a KEF database dump specifies the size of the "kef_node"
  712. Xstructure. If it is not the same as the size
  713. Xfor the internal structure an error SIZE_NODE is generated.
  714. X.in -4
  715. XNO_MALLOC
  716. X.in +4
  717. XA routine was called that needs to do some allocation, but the internal
  718. Xfield for malloc is empty.
  719. X.in -4
  720. XNO_REALLOC
  721. X.in +4
  722. XA routine was called that needs to do some allocation, but the internal
  723. Xfield for realloc is empty.
  724. X.in -4
  725. XNO_FREE
  726. X.in +4
  727. XA routine was called that needs to do some allocation and releasing,
  728. Xbut the internal
  729. Xfield for free is empty.
  730. X.in -4
  731. XALLOC_FAILED
  732. X.in +4
  733. XAllocation of memory failed.
  734. X.in -4
  735. XCHECK
  736. X.in +4
  737. XThere is a routine that is part of the library, that checks the KEF
  738. Xdatabase for validity. This routine returns an error CHECK when it
  739. Xfinds an inconsistency. The user is not supposed to call this routine
  740. Xdirectly, therefore it is not documented here.
  741. X.in -4
  742. XINV_PAR
  743. X.in +4
  744. Xkef_mcreate was called with parameter buf != NULL but size_buf <= 0
  745. X.in -4
  746. XINV_INX
  747. X.in +4
  748. XThe parameter "inx" to kef__build_str is not in the acceptable range
  749. Xfor indices in the internal KEF database.
  750. X.in -4
  751. XTAG_LOOP
  752. X.in +4
  753. XThe routine kef_build_str tried to build a string, but there seems to
  754. Xbe a loop in its data structures. This may happen if you call kef_build_str
  755. Xor its associates with wrong parameter values.
  756. X.in -4
  757. X
  758. X.SH BUGS
  759. X-
  760. X'in +4
  761. XThe KEF routines do not try to save a user from his/her own foolishness
  762. Xbeyond a sensible limit. I.e. most routines do not check whether the
  763. Xparameter k is pointing at a valid data structure.
  764. X.in -4
  765. X
  766. X.SH SEE ALSO
  767. Xkdb-low(3), kdb-high(3), kef-id(3)
  768. X.br
  769. X"Kee - a library of routines to handle input from ASCII terminals" by M. Greim
  770. X
  771. X.SH AUTHOR
  772. XMichael Greim (greim@cs.uni-sb.de)
  773. END_OF_FILE
  774. if test 11349 -ne `wc -c <'kef/kef.man'`; then
  775.     echo shar: \"'kef/kef.man'\" unpacked with wrong size!
  776. fi
  777. # end of 'kef/kef.man'
  778. fi
  779. echo shar: End of archive 4 \(of 5\).
  780. cp /dev/null ark4isdone
  781. MISSING=""
  782. for I in 1 2 3 4 5 ; do
  783.     if test ! -f ark${I}isdone ; then
  784.     MISSING="${MISSING} ${I}"
  785.     fi
  786. done
  787. if test "${MISSING}" = "" ; then
  788.     echo You have unpacked all 5 archives.
  789.     rm -f ark[1-9]isdone
  790. else
  791.     echo You still need to unpack the following archives:
  792.     echo "        " ${MISSING}
  793. fi
  794. ##  End of shell archive.
  795. exit 0
  796. -- 
  797.  .-. .-.  .-.  Michael Greim
  798. (   X   )( __) e-mail : greim@cs.uni-sb.de
  799.  \ / \ /  \ /  or     : ...!uunet!unido!sbsvax!greim
  800.   ~   ~    ~
  801.