home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / ddb / patch01 < prev    next >
Encoding:
Text File  |  1993-11-26  |  22.1 KB  |  1,031 lines

  1. Newsgroups: comp.sources.misc
  2. From: pefv700@hermes.chpc.utexas.edu (Christopher Phillips)
  3. Subject: v40i166:  ddb - dynamic memory database library, Patch01
  4. Message-ID: <1993Nov26.161712.440@sparky.sterling.com>
  5. X-Md4-Signature: b495dbbd7085cc6694b944629e017692
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Reply-To: pefv700@utpe.pe.utexas.edu
  8. Organization: Sterling Software
  9. Date: Fri, 26 Nov 1993 16:17:12 GMT
  10. Approved: kent@sparky.sterling.com
  11.  
  12. Submitted-by: pefv700@hermes.chpc.utexas.edu (Christopher Phillips)
  13. Posting-number: Volume 40, Issue 166
  14. Archive-name: ddb/patch01
  15. Environment: ANSI-C
  16. Patch-To: ddb: Volume 40, Issue 82
  17.  
  18. This is patch01 for ddb, a library of dynamic memory database routines.
  19.  
  20. There are a few changes:
  21.  
  22. - errno is now set upon failure
  23. - The manual page has been modified accordingly
  24. - ddb_bdelete returned NULL instead of -1 for invalid descriptors
  25.  
  26. Just cd to the source directory and unshar this file.  Then type 
  27.  
  28.     patch -p0 < Patch01
  29.  
  30. Chris
  31. pefv700@utpe.pe.utexas.edu
  32. --------------------
  33. #! /bin/sh
  34. # This is a shell archive.  Remove anything before this line, then unpack
  35. # it by saving it into a file and typing "sh file".  To overwrite existing
  36. # files, type "sh file -c".  You can also feed this as standard input via
  37. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  38. # will see the following message at the end:
  39. #        "End of shell archive."
  40. # Contents:  Patch01
  41. # Wrapped by pefv700@hermes on Thu Nov 18 00:15:47 1993
  42. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  43. if test -f 'Patch01' -a "${1}" != "-c" ; then 
  44.   echo shar: Will not clobber existing file \"'Patch01'\"
  45. else
  46. echo shar: Extracting \"'Patch01'\" \(19727 characters\)
  47. sed "s/^X//" >'Patch01' <<'END_OF_FILE'
  48. X*** ../ddb.old/Makefile    Thu Nov 18 00:08:26 1993
  49. X--- Makefile    Wed Nov 17 23:53:07 1993
  50. X***************
  51. X*** 1,5 ****
  52. X  OPT=-O
  53. X! CFLAGS=$(OPT) -I.
  54. X  CDBS=hash.c list.c queue.c stack.c binary.c bit.c
  55. X  CSRCS=new.c $(CDBS)
  56. X  COBJS=$(CSRCS:.c=.o)
  57. X--- 1,5 ----
  58. X  OPT=-O
  59. X! CFLAGS=$(OPT)
  60. X  CDBS=hash.c list.c queue.c stack.c binary.c bit.c
  61. X  CSRCS=new.c $(CDBS)
  62. X  COBJS=$(CSRCS:.c=.o)
  63. X*** ../ddb.old/binary.c    Thu Nov 18 00:08:27 1993
  64. X--- binary.c    Thu Nov 18 00:01:03 1993
  65. X***************
  66. X*** 21,27 ****
  67. X  #include <stdlib.h>
  68. X  #include <string.h>
  69. X  #include <sys/types.h>
  70. X! #include <ddb.h>
  71. X  
  72. X  #define MIN(a,b)    ((a) < (b) ? (a) : (b))
  73. X  
  74. X--- 21,28 ----
  75. X  #include <stdlib.h>
  76. X  #include <string.h>
  77. X  #include <sys/types.h>
  78. X! #include <errno.h>
  79. X! #include "ddb.h"
  80. X  
  81. X  #define MIN(a,b)    ((a) < (b) ? (a) : (b))
  82. X  
  83. X***************
  84. X*** 48,53 ****
  85. X--- 49,56 ----
  86. X  
  87. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  88. X  
  89. X+ extern int    errno;
  90. X+ 
  91. X  int
  92. X  ddb_memcmp(const DATUM *dp1, const DATUM *dp2)
  93. X  {
  94. X***************
  95. X*** 65,71 ****
  96. X  static int
  97. X  validbd(int bd)
  98. X  {
  99. X!     return binary && bd < maxbinaries && binary[bd].used;
  100. X  }
  101. X  
  102. X  static int
  103. X--- 68,78 ----
  104. X  static int
  105. X  validbd(int bd)
  106. X  {
  107. X!     int    valid = binary && bd < maxbinaries && binary[bd].used;
  108. X! 
  109. X!     if (!valid)
  110. X!         errno = EBADF;
  111. X!     return valid;
  112. X  }
  113. X  
  114. X  static int
  115. X***************
  116. X*** 77,82 ****
  117. X--- 84,90 ----
  118. X      case DDB_DUPLICATE:
  119. X          return 1;
  120. X      default:
  121. X+         errno = EINVAL;
  122. X          return 0;
  123. X      }
  124. X  }
  125. X***************
  126. X*** 167,172 ****
  127. X--- 175,181 ----
  128. X              bp->left = bp_new;
  129. X          } else /* DDB_INSERT */ {
  130. X              bfree(bp_new);
  131. X+             errno = EEXIST;
  132. X              return -1;
  133. X          }
  134. X      } else
  135. X***************
  136. X*** 191,198 ****
  137. X      if (bp = find(bd, key, cmp, NULL))
  138. X  #endif
  139. X          return &bp->data;
  140. X!     else
  141. X          return NULL;
  142. X  }
  143. X  
  144. X  int
  145. X--- 200,209 ----
  146. X      if (bp = find(bd, key, cmp, NULL))
  147. X  #endif
  148. X          return &bp->data;
  149. X!     else {
  150. X!         errno = ENOENT;
  151. X          return NULL;
  152. X+     }
  153. X  }
  154. X  
  155. X  int
  156. X***************
  157. X*** 206,212 ****
  158. X  #endif
  159. X  
  160. X      if (!validbd(bd))
  161. X!         return NULL;
  162. X      if (!cmp)
  163. X          cmp = ddb_memcmp;
  164. X  
  165. X--- 217,223 ----
  166. X  #endif
  167. X  
  168. X      if (!validbd(bd))
  169. X!         return -1;
  170. X      if (!cmp)
  171. X          cmp = ddb_memcmp;
  172. X  
  173. X***************
  174. X*** 254,261 ****
  175. X              free(bp);
  176. X          }
  177. X          return 0;
  178. X!     } else
  179. X          return -1;
  180. X  }
  181. X  
  182. X  static void
  183. X--- 265,274 ----
  184. X              free(bp);
  185. X          }
  186. X          return 0;
  187. X!     } else {
  188. X!         errno = ENOENT;
  189. X          return -1;
  190. X+     }
  191. X  }
  192. X  
  193. X  static void
  194. X***************
  195. X*** 385,422 ****
  196. X  {
  197. X      if (validbd(bd))
  198. X          recurse(binary[bd].root, f, order);
  199. X- }
  200. X- 
  201. X- DATUM *
  202. X- ddb_blargestkey(int bd)
  203. X- {
  204. X-     BELEM    *bp;
  205. X- 
  206. X-     if (!validbd(bd))
  207. X-         return NULL;
  208. X- 
  209. X-     if (bp = binary[bd].root) {
  210. X-         while (bp->right)
  211. X-             bp = bp->right;
  212. X-         return &bp->key;
  213. X-     } else
  214. X-         return NULL;
  215. X- }
  216. X- 
  217. X- DATUM *
  218. X- ddb_bsmallestkey(int bd)
  219. X- {
  220. X-     BELEM    *bp;
  221. X- 
  222. X-     if (!validbd(bd))
  223. X-         return NULL;
  224. X- 
  225. X-     if (bp = binary[bd].root) {
  226. X-         while (bp->left)
  227. X-             bp = bp->left;
  228. X-         return &bp->key;
  229. X-     } else
  230. X-         return NULL;
  231. X  }
  232. X  
  233. X  #ifdef DEBUG
  234. X--- 398,403 ----
  235. X*** ../ddb.old/bit.c    Thu Nov 18 00:08:27 1993
  236. X--- bit.c    Thu Nov 18 00:07:35 1993
  237. X***************
  238. X*** 20,26 ****
  239. X  #include <string.h>
  240. X  #include <limits.h>
  241. X  #include <sys/types.h>
  242. X! #include <ddb.h>
  243. X  
  244. X  #define MIN(a,b)    ((a) < (b) ? (a) : (b))
  245. X  
  246. X--- 20,27 ----
  247. X  #include <string.h>
  248. X  #include <limits.h>
  249. X  #include <sys/types.h>
  250. X! #include <errno.h>
  251. X! #include "ddb.h"
  252. X  
  253. X  #define MIN(a,b)    ((a) < (b) ? (a) : (b))
  254. X  
  255. X***************
  256. X*** 42,54 ****
  257. X  static BIT    *vector = NULL;
  258. X  static int    maxvectors = 0;
  259. X  
  260. X! #define CHECK_MAXBIT    1
  261. X  
  262. X  static int
  263. X! validbd(int bd, unsigned long bit, int check)
  264. X  {
  265. X!     return vector && bd < maxvectors && vector[bd].used
  266. X!       && (check != CHECK_MAXBIT || bit <= vector[bd].maxbit);
  267. X  }
  268. X  
  269. X  static int
  270. X--- 43,58 ----
  271. X  static BIT    *vector = NULL;
  272. X  static int    maxvectors = 0;
  273. X  
  274. X! extern int    errno;
  275. X  
  276. X  static int
  277. X! validbd(int bd)
  278. X  {
  279. X!     int    valid = vector && bd < maxvectors && vector[bd].used;
  280. X! 
  281. X!     if (!valid)
  282. X!         errno = EBADF;
  283. X!     return valid;
  284. X  }
  285. X  
  286. X  static int
  287. X***************
  288. X*** 60,65 ****
  289. X--- 64,70 ----
  290. X      case DDB_DUPLICATE:
  291. X          return 1;
  292. X      default:
  293. X+         errno = EINVAL;
  294. X          return 0;
  295. X      }
  296. X  }
  297. X***************
  298. X*** 71,78 ****
  299. X      unsigned long    nints1, nints2;
  300. X      unsigned long    bit;
  301. X  
  302. X!     if (maxbit > (unsigned long)LONG_MAX)
  303. X          return -1;
  304. X  
  305. X      nints1 = vector[bd].maxbit / WORD_BIT + 1;
  306. X      nints2 = maxbit / WORD_BIT + 1;
  307. X--- 76,85 ----
  308. X      unsigned long    nints1, nints2;
  309. X      unsigned long    bit;
  310. X  
  311. X!     if (maxbit > (unsigned long)LONG_MAX) {
  312. X!         errno = EDOM;
  313. X          return -1;
  314. X+     }
  315. X  
  316. X      nints1 = vector[bd].maxbit / WORD_BIT + 1;
  317. X      nints2 = maxbit / WORD_BIT + 1;
  318. X***************
  319. X*** 94,100 ****
  320. X  int
  321. X  ddb_bitwrite(int bd, unsigned long bit, int mode)
  322. X  {
  323. X!     if (!validbd(bd, bit, !CHECK_MAXBIT) || !validmode(mode))
  324. X          return -1;
  325. X      if (bit > vector[bd].maxbit && enlarge(bd, bit) == -1)
  326. X          return -1;
  327. X--- 101,107 ----
  328. X  int
  329. X  ddb_bitwrite(int bd, unsigned long bit, int mode)
  330. X  {
  331. X!     if (!validbd(bd) || !validmode(mode))
  332. X          return -1;
  333. X      if (bit > vector[bd].maxbit && enlarge(bd, bit) == -1)
  334. X          return -1;
  335. X***************
  336. X*** 101,108 ****
  337. X  
  338. X      if (!isset(vector[bd].bits, bit))
  339. X          setbit(vector[bd].bits, bit);
  340. X!     else if (mode & DDB_INSERT)
  341. X          return -1;
  342. X  
  343. X      return 0;
  344. X  }
  345. X--- 108,117 ----
  346. X  
  347. X      if (!isset(vector[bd].bits, bit))
  348. X          setbit(vector[bd].bits, bit);
  349. X!     else if (mode & DDB_INSERT) {
  350. X!         errno = EEXIST;
  351. X          return -1;
  352. X+     }
  353. X  
  354. X      return 0;
  355. X  }
  356. X***************
  357. X*** 110,140 ****
  358. X  int
  359. X  ddb_bitread(int bd, unsigned long bit)
  360. X  {
  361. X!     if (!validbd(bd, bit, !CHECK_MAXBIT))
  362. X          return -1;
  363. X  
  364. X!     if (bit > vector[bd].maxbit)
  365. X          return 0;
  366. X-     return isset(vector[bd].bits, bit) != 0;
  367. X  }
  368. X  
  369. X  int
  370. X  ddb_bitdelete(int bd, unsigned long bit)
  371. X  {
  372. X!     if (!validbd(bd, bit, CHECK_MAXBIT))
  373. X          return -1;
  374. X! 
  375. X!     if (isset(vector[bd].bits, bit)) {
  376. X          clrbit(vector[bd].bits, bit);
  377. X          return 0;
  378. X!     } else
  379. X!         return -1;
  380. X  }
  381. X  
  382. X  int
  383. X  ddb_bitclose(int bd)
  384. X  {
  385. X!     if (!validbd(bd, 0, !CHECK_MAXBIT))
  386. X          return -1;
  387. X  
  388. X      vector[bd].used = 0;
  389. X--- 119,152 ----
  390. X  int
  391. X  ddb_bitread(int bd, unsigned long bit)
  392. X  {
  393. X!     if (!validbd(bd))
  394. X          return -1;
  395. X  
  396. X!     if (bit > vector[bd].maxbit || !isset(vector[bd].bits, bit)) {
  397. X!         errno = ENOENT;
  398. X!         return -1;
  399. X!     } else
  400. X          return 0;
  401. X  }
  402. X  
  403. X  int
  404. X  ddb_bitdelete(int bd, unsigned long bit)
  405. X  {
  406. X!     if (!validbd(bd))
  407. X          return -1;
  408. X!     if (bit > vector[bd].maxbit || !isset(vector[bd].bits, bit)) {
  409. X!         errno = ENOENT;
  410. X!         return -1;
  411. X!     } else {
  412. X          clrbit(vector[bd].bits, bit);
  413. X          return 0;
  414. X!     }
  415. X  }
  416. X  
  417. X  int
  418. X  ddb_bitclose(int bd)
  419. X  {
  420. X!     if (!validbd(bd))
  421. X          return -1;
  422. X  
  423. X      vector[bd].used = 0;
  424. X***************
  425. X*** 147,153 ****
  426. X  int
  427. X  ddb_bitset(int bd, int on)
  428. X  {
  429. X!     if (!validbd(bd, 0, !CHECK_MAXBIT))
  430. X          return -1;
  431. X  
  432. X      (void)memset(vector[bd].bits, on ? ~0 : '\0',
  433. X--- 159,165 ----
  434. X  int
  435. X  ddb_bitset(int bd, int on)
  436. X  {
  437. X!     if (!validbd(bd))
  438. X          return -1;
  439. X  
  440. X      (void)memset(vector[bd].bits, on ? ~0 : '\0',
  441. X***************
  442. X*** 164,171 ****
  443. X      int        j;
  444. X      BIT        *vtmp;
  445. X  
  446. X!     if (maxbit > (unsigned long)LONG_MAX)
  447. X          return -1;
  448. X  
  449. X      for (i = 0; i < maxvectors && vector[i].used; i++)
  450. X          ;
  451. X--- 176,185 ----
  452. X      int        j;
  453. X      BIT        *vtmp;
  454. X  
  455. X!     if (maxbit > (unsigned long)LONG_MAX) {
  456. X!         errno = EDOM;
  457. X          return -1;
  458. X+     }
  459. X  
  460. X      for (i = 0; i < maxvectors && vector[i].used; i++)
  461. X          ;
  462. X***************
  463. X*** 243,250 ****
  464. X  {
  465. X      unsigned long    index;
  466. X  
  467. X!     if (!validbd(bd, 0, !CHECK_MAXBIT) || (index = findword(vector[bd].bits,
  468. X!       0, vector[bd].maxbit / WORD_BIT, 0)) == -1)
  469. X          return -1;
  470. X      else
  471. X          return vector[bd].lastbit = findlowset(vector[bd].bits[index],
  472. X--- 257,264 ----
  473. X  {
  474. X      unsigned long    index;
  475. X  
  476. X!     if (!validbd(bd) || (index = findword(vector[bd].bits, 0,
  477. X!       vector[bd].maxbit / WORD_BIT, 0)) == -1)
  478. X          return -1;
  479. X      else
  480. X          return vector[bd].lastbit = findlowset(vector[bd].bits[index],
  481. X***************
  482. X*** 259,265 ****
  483. X      unsigned int    mask;
  484. X      unsigned long    index;
  485. X  
  486. X!     if (!validbd(bd, 0, !CHECK_MAXBIT))
  487. X          return -1;
  488. X      mask = wordmask(vector[bd].lastbit % WORD_BIT);
  489. X      if ((index = findword(vector[bd].bits, vector[bd].lastbit / WORD_BIT,
  490. X--- 273,279 ----
  491. X      unsigned int    mask;
  492. X      unsigned long    index;
  493. X  
  494. X!     if (!validbd(bd))
  495. X          return -1;
  496. X      mask = wordmask(vector[bd].lastbit % WORD_BIT);
  497. X      if ((index = findword(vector[bd].bits, vector[bd].lastbit / WORD_BIT,
  498. X*** ../ddb.old/ddb.3    Thu Nov 18 00:08:27 1993
  499. X--- ddb.3    Wed Nov 17 23:53:08 1993
  500. X***************
  501. X*** 126,145 ****
  502. X  .BR write(\|)
  503. X  functions use to add to the databases.
  504. X  Must include only one of the following values:
  505. X! .IP DDB_INSERT
  506. X  Insert the pair only if the key is not currently in the database.
  507. X! .IP DDB_REPLACE
  508. X  Add the pair to the database.
  509. X  If the key is already in the database, delete that entry.
  510. X! .IP DDB_DUPLICATE
  511. X  Add the pair to the database.
  512. X  If the key is already in the database, do not delete that entry.
  513. X! 
  514. X  For the
  515. X  .BR ddb_lwrite(\|)
  516. X! function, the value
  517. X! .IR DDB_TAIL
  518. X! can be inclusively OR'ed into
  519. X  .IR flag
  520. X  to specify writing at the tail of the list.
  521. X  .IP \fIf\fP
  522. X--- 126,145 ----
  523. X  .BR write(\|)
  524. X  functions use to add to the databases.
  525. X  Must include only one of the following values:
  526. X! .RS
  527. X! .IP DDB_INSERT 14
  528. X  Insert the pair only if the key is not currently in the database.
  529. X! .IP DDB_REPLACE 14
  530. X  Add the pair to the database.
  531. X  If the key is already in the database, delete that entry.
  532. X! .IP DDB_DUPLICATE 14
  533. X  Add the pair to the database.
  534. X  If the key is already in the database, do not delete that entry.
  535. X! .RE
  536. X! .IP
  537. X  For the
  538. X  .BR ddb_lwrite(\|)
  539. X! function, the value DDB_TAIL can be inclusively OR'ed into
  540. X  .IR flag
  541. X  to specify writing at the tail of the list.
  542. X  .IP \fIf\fP
  543. X***************
  544. X*** 229,240 ****
  545. X  functions.
  546. X  .LP
  547. X  Functions returning type pointer\-to\-DATUM return NULL on failure.
  548. X! .SH NOTES
  549. X! All of the
  550. X  .BR read(\|)
  551. X! functions except
  552. X! .BR ddb_bitread(\|)
  553. X! return pointers to memory which should be freed when unneeded.
  554. X  .LP
  555. X  Altering a database and then calling a
  556. X  .BR next(\|)
  557. X--- 229,329 ----
  558. X  functions.
  559. X  .LP
  560. X  Functions returning type pointer\-to\-DATUM return NULL on failure.
  561. X! .SH ERRORS
  562. X! .LP
  563. X! If an
  564. X! .BR open(\|)
  565. X! function fails, errno will be set to one of the following values:
  566. X! .IP [ENOMEM] 9
  567. X! Sufficient memory could not be allocated.
  568. X! .IP [EDOM] 9
  569. X! .BR ddb_bitopen(\|)
  570. X! has been called with
  571. X! .IR maxbit
  572. X! larger than LONG_MAX.
  573. X! .LP
  574. X! If a
  575. X! .BR close(\|)
  576. X! function fails, errno will be set to
  577. X! .IP [EBADF] 9
  578. X! The
  579. X! .IR dbd
  580. X! argument is not a valid database descriptor.
  581. X! .LP
  582. X! If a
  583. X  .BR read(\|)
  584. X! function fails, errno may be set to one of the following values:
  585. X! .IP [EBADF] 9
  586. X! The
  587. X! .IR dbd
  588. X! argument is not a valid database descriptor.
  589. X! .IP [ENOENT] 9
  590. X! The
  591. X! .IR key
  592. X! argument does not specify an entry in the database.
  593. X! .LP
  594. X! Errno is not changed when the relevant database is empty
  595. X! and
  596. X! .BR ddb_lread(\|)
  597. X! is called with
  598. X! .IR key
  599. X! NULL or
  600. X! .BR ddb_qread(\|)
  601. X! or
  602. X! .BR ddb_sread(\|)
  603. X! are called.
  604. X! .LP
  605. X! If a
  606. X! .BR write(\|)
  607. X! function fails, errno will be set to one of the following values:
  608. X! .IP [EBADF] 9
  609. X! The
  610. X! .IR dbd
  611. X! argument is not a valid database descriptor.
  612. X! .IP [EINVAL] 9
  613. X! The
  614. X! .IR flag
  615. X! argument is not valid.
  616. X! .IP [EEXIST] 9
  617. X! The entry indicated by
  618. X! .IR key
  619. X! is already present in the database and DDB_INSERT was specified.
  620. X! .IP [ENOMEM] 9
  621. X! Sufficient memory could not be allocated.
  622. X! .IP [EDOM] 9
  623. X! .BR ddb_bitwrite(\|)
  624. X! has been called with
  625. X! .IR bit
  626. X! larger than LONG_MAX.
  627. X! .LP
  628. X! If a
  629. X! .BR delete(\|)
  630. X! function fails, errno will be set to one of the following values:
  631. X! .IP [EBADF] 9
  632. X! The
  633. X! .IR dbd
  634. X! argument is not a valid database descriptor.
  635. X! .IP [ENOENT] 9
  636. X! The
  637. X! .IR key
  638. X! argument does not specify an entry in the database.
  639. X! .LP
  640. X! When the
  641. X! .BR first(\|)
  642. X! and
  643. X! .BR next(\|)
  644. X! functions fail because the all of the entries in a database have
  645. X! been returned, errno is not changed.
  646. X! However, they can fail with errno set to
  647. X! .IP [EBADF] 9
  648. X! The
  649. X! .IR dbd
  650. X! argument is not a valid database descriptor.
  651. X! .SH NOTES
  652. X! The
  653. X! .BR ddb_qread(\|)
  654. X! function
  655. X! returns a pointer to memory which should be freed when unneeded.
  656. X  .LP
  657. X  Altering a database and then calling a
  658. X  .BR next(\|)
  659. X*** ../ddb.old/ddb.h    Thu Nov 18 00:08:27 1993
  660. X--- ddb.h    Wed Nov 17 23:53:08 1993
  661. X***************
  662. X*** 46,53 ****
  663. X  extern DATUM    *ddb_bfirst(int);
  664. X  extern DATUM    *ddb_bnext(int);
  665. X  extern void    ddb_bfunc(int, void (*)(const DATUM *, const DATUM *), int);
  666. X- extern DATUM    *ddb_blargestkey(int);
  667. X- extern DATUM    *ddb_bsmallestkey(int);
  668. X  #ifdef DEBUG
  669. X  extern void    ddb_bdump(int, void (*)(const DATUM *), void (*)(const DATUM *),
  670. X            int);
  671. X--- 46,51 ----
  672. X***************
  673. X*** 61,68 ****
  674. X  extern int    ddb_bitread(int, unsigned long);
  675. X  extern long    ddb_bitfirst(int);
  676. X  extern long    ddb_bitnext(int);
  677. X- extern long    ddb_bitlargestkey(int);
  678. X- extern long    ddb_bitsmallestkey(int);
  679. X  extern int    ddb_bitset(int, int);
  680. X  #ifdef DEBUG
  681. X  extern void    ddb_bitdump(int);
  682. X--- 59,64 ----
  683. X*** ../ddb.old/hash.c    Thu Nov 18 00:08:28 1993
  684. X--- hash.c    Wed Nov 17 23:53:08 1993
  685. X***************
  686. X*** 19,25 ****
  687. X  #include <stdlib.h>
  688. X  #include <string.h>
  689. X  #include <sys/types.h>
  690. X! #include <ddb.h>
  691. X  
  692. X  typedef struct hashent {
  693. X      DATUM        key;
  694. X--- 19,26 ----
  695. X  #include <stdlib.h>
  696. X  #include <string.h>
  697. X  #include <sys/types.h>
  698. X! #include <errno.h>
  699. X! #include "ddb.h"
  700. X  
  701. X  typedef struct hashent {
  702. X      DATUM        key;
  703. X***************
  704. X*** 46,51 ****
  705. X--- 47,54 ----
  706. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  707. X  extern int    ddb_memcmp(const DATUM *, const DATUM *);
  708. X  
  709. X+ extern int    errno;
  710. X+ 
  711. X  static size_t
  712. X  def_hash(const char *key, size_t keysize, size_t nbuckets)
  713. X  {
  714. X***************
  715. X*** 60,66 ****
  716. X  static int
  717. X  validhd(int hd)
  718. X  {
  719. X!     return hashtable && hd < maxtables && hashtable[hd].used;
  720. X  }
  721. X  
  722. X  static DATUM *
  723. X--- 63,73 ----
  724. X  static int
  725. X  validhd(int hd)
  726. X  {
  727. X!     int    valid =  hashtable && hd < maxtables && hashtable[hd].used;
  728. X! 
  729. X!     if (!valid)
  730. X!         errno = EBADF;
  731. X!     return valid;
  732. X  }
  733. X  
  734. X  static DATUM *
  735. X***************
  736. X*** 88,100 ****
  737. X          }
  738. X  
  739. X      if (action == H_READ)
  740. X!         return ptr ? &ptr->data : NULL;
  741. X  
  742. X!     if (ptr && action == DDB_INSERT)
  743. X          return NULL;
  744. X  
  745. X!     if (!ptr && action == H_DELETE)
  746. X          return NULL;
  747. X  
  748. X      if (ptr && action != DDB_DUPLICATE) {    /* H_DELETE || DDB_REPLACE */
  749. X          free(ptr->data.addr);
  750. X--- 95,116 ----
  751. X          }
  752. X  
  753. X      if (action == H_READ)
  754. X!         if (ptr)
  755. X!             return &ptr->data;
  756. X!         else {
  757. X!             errno = ENOENT;
  758. X!             return NULL;
  759. X!         }
  760. X  
  761. X!     if (ptr && action == DDB_INSERT) {
  762. X!         errno = EEXIST;
  763. X          return NULL;
  764. X+     }
  765. X  
  766. X!     if (!ptr && action == H_DELETE) {
  767. X!         errno = ENOENT;
  768. X          return NULL;
  769. X+     }
  770. X  
  771. X      if (ptr && action != DDB_DUPLICATE) {    /* H_DELETE || DDB_REPLACE */
  772. X          free(ptr->data.addr);
  773. X***************
  774. X*** 140,148 ****
  775. X  ddb_hwrite(int hd, const DATUM *key, const DATUM *data, ddb_cmp_t cmp, int mode,
  776. X    ddb_hash_t hash)
  777. X  {
  778. X!     if (mode != DDB_INSERT && mode != DDB_REPLACE && mode != DDB_DUPLICATE)
  779. X          return -1;
  780. X!     else if (hashop(hd, mode, key, data, cmp, hash))
  781. X          return 0;
  782. X      else
  783. X          return -1;
  784. X--- 156,166 ----
  785. X  ddb_hwrite(int hd, const DATUM *key, const DATUM *data, ddb_cmp_t cmp, int mode,
  786. X    ddb_hash_t hash)
  787. X  {
  788. X!     if (mode != DDB_INSERT && mode != DDB_REPLACE
  789. X!       && mode != DDB_DUPLICATE) {
  790. X!         errno = EINVAL;
  791. X          return -1;
  792. X!     } else if (hashop(hd, mode, key, data, cmp, hash))
  793. X          return 0;
  794. X      else
  795. X          return -1;
  796. X*** ../ddb.old/list.c    Thu Nov 18 00:08:28 1993
  797. X--- list.c    Wed Nov 17 23:53:08 1993
  798. X***************
  799. X*** 19,25 ****
  800. X  #include <stdlib.h>
  801. X  #include <string.h>
  802. X  #include <sys/types.h>
  803. X! #include <ddb.h>
  804. X  
  805. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  806. X  extern int    ddb_memcmp(const DATUM *, const DATUM *);
  807. X--- 19,26 ----
  808. X  #include <stdlib.h>
  809. X  #include <string.h>
  810. X  #include <sys/types.h>
  811. X! #include <errno.h>
  812. X! #include "ddb.h"
  813. X  
  814. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  815. X  extern int    ddb_memcmp(const DATUM *, const DATUM *);
  816. X***************
  817. X*** 38,47 ****
  818. X  static LIST    *list = NULL;
  819. X  static int    maxlists = 0;
  820. X  
  821. X  static int
  822. X  validld(int ld)
  823. X  {
  824. X!     return list && ld < maxlists && list[ld].used;
  825. X  }
  826. X  
  827. X  static int
  828. X--- 39,54 ----
  829. X  static LIST    *list = NULL;
  830. X  static int    maxlists = 0;
  831. X  
  832. X+ extern int    errno;
  833. X+ 
  834. X  static int
  835. X  validld(int ld)
  836. X  {
  837. X!     int    valid = list && ld < maxlists && list[ld].used;
  838. X! 
  839. X!     if (!valid)
  840. X!         errno = EBADF;
  841. X!     return valid;
  842. X  }
  843. X  
  844. X  static int
  845. X***************
  846. X*** 53,58 ****
  847. X--- 60,66 ----
  848. X      case DDB_DUPLICATE:
  849. X          return 1;
  850. X      default:
  851. X+         errno = EINVAL;
  852. X          return 0;
  853. X      }
  854. X  }
  855. X***************
  856. X*** 99,107 ****
  857. X          if (mode & DDB_TAIL)
  858. X              (void)find(ld, NULL, cmp, &le_prev);
  859. X      } else if (le = find(ld, key, cmp, NULL))
  860. X!         if (mode & DDB_INSERT)
  861. X              return -1;
  862. X!         else /* DDB_REPLACE */ {
  863. X              free(le->key.addr);
  864. X              free(le->data.addr);
  865. X              le->key = le_new->key;
  866. X--- 107,116 ----
  867. X          if (mode & DDB_TAIL)
  868. X              (void)find(ld, NULL, cmp, &le_prev);
  869. X      } else if (le = find(ld, key, cmp, NULL))
  870. X!         if (mode & DDB_INSERT) {
  871. X!             errno = EEXIST;
  872. X              return -1;
  873. X!         } else /* DDB_REPLACE */ {
  874. X              free(le->key.addr);
  875. X              free(le->data.addr);
  876. X              le->key = le_new->key;
  877. X***************
  878. X*** 144,149 ****
  879. X--- 153,159 ----
  880. X      if (le = find(ld, key, cmp, NULL))
  881. X          return &le->data;
  882. X  
  883. X+     errno = ENOENT;
  884. X      return NULL;
  885. X  }
  886. X  
  887. X***************
  888. X*** 173,178 ****
  889. X--- 183,189 ----
  890. X          return 0;
  891. X      }
  892. X  
  893. X+     errno = ENOENT;
  894. X      return -1;
  895. X  }
  896. X  
  897. X*** ../ddb.old/new.c    Thu Nov 18 00:08:28 1993
  898. X--- new.c    Wed Nov 17 23:53:08 1993
  899. X***************
  900. X*** 19,25 ****
  901. X  #include <stdlib.h>
  902. X  #include <sys/types.h>
  903. X  #include <string.h>
  904. X! #include <ddb.h>
  905. X  
  906. X  void *
  907. X  ddb_new(const DATUM *key, const DATUM *data, size_t size)
  908. X--- 19,25 ----
  909. X  #include <stdlib.h>
  910. X  #include <sys/types.h>
  911. X  #include <string.h>
  912. X! #include "ddb.h"
  913. X  
  914. X  void *
  915. X  ddb_new(const DATUM *key, const DATUM *data, size_t size)
  916. X*** ../ddb.old/patchlevel.h    Thu Nov 18 00:08:28 1993
  917. X--- patchlevel.h    Wed Nov 17 23:53:09 1993
  918. X***************
  919. X*** 1 ****
  920. X! #define PATCHLEVEL    0
  921. X--- 1 ----
  922. X! #define PATCHLEVEL    1
  923. X*** ../ddb.old/queue.c    Thu Nov 18 00:08:28 1993
  924. X--- queue.c    Wed Nov 17 23:53:09 1993
  925. X***************
  926. X*** 18,24 ****
  927. X  #include <stdio.h>
  928. X  #include <stdlib.h>
  929. X  #include <sys/types.h>
  930. X! #include <ddb.h>
  931. X  
  932. X  typedef struct qent {
  933. X      DATUM        data;
  934. X--- 18,25 ----
  935. X  #include <stdio.h>
  936. X  #include <stdlib.h>
  937. X  #include <sys/types.h>
  938. X! #include <errno.h>
  939. X! #include "ddb.h"
  940. X  
  941. X  typedef struct qent {
  942. X      DATUM        data;
  943. X***************
  944. X*** 35,44 ****
  945. X  
  946. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  947. X  
  948. X  static int
  949. X  validqd(int qd)
  950. X  {
  951. X!     return queue && qd < maxqueues && queue[qd].used;
  952. X  }
  953. X  
  954. X  int
  955. X--- 36,51 ----
  956. X  
  957. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  958. X  
  959. X+ extern int    errno;
  960. X+ 
  961. X  static int
  962. X  validqd(int qd)
  963. X  {
  964. X!     int    valid = queue && qd < maxqueues && queue[qd].used;
  965. X! 
  966. X!     if (!valid)
  967. X!         errno = EBADF;
  968. X!     return valid;
  969. X  }
  970. X  
  971. X  int
  972. X*** ../ddb.old/stack.c    Thu Nov 18 00:08:29 1993
  973. X--- stack.c    Wed Nov 17 23:53:09 1993
  974. X***************
  975. X*** 18,24 ****
  976. X  #include <stdio.h>
  977. X  #include <stdlib.h>
  978. X  #include <sys/types.h>
  979. X! #include <ddb.h>
  980. X  
  981. X  typedef struct {
  982. X      int    used;
  983. X--- 18,25 ----
  984. X  #include <stdio.h>
  985. X  #include <stdlib.h>
  986. X  #include <sys/types.h>
  987. X! #include <errno.h>
  988. X! #include "ddb.h"
  989. X  
  990. X  typedef struct {
  991. X      int    used;
  992. X***************
  993. X*** 31,40 ****
  994. X  
  995. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  996. X  
  997. X  static int
  998. X  validsd(int sd)
  999. X  {
  1000. X!     return stack && sd < maxstacks && stack[sd].used;
  1001. X  }
  1002. X  
  1003. X  int
  1004. X--- 32,47 ----
  1005. X  
  1006. X  extern void    *ddb_new(const DATUM *, const DATUM *, size_t);
  1007. X  
  1008. X+ extern int    errno;
  1009. X+ 
  1010. X  static int
  1011. X  validsd(int sd)
  1012. X  {
  1013. X!     int    valid = stack && sd < maxstacks && stack[sd].used;
  1014. X! 
  1015. X!     if (!valid)
  1016. X!         errno = EBADF;
  1017. X!     return valid;
  1018. X  }
  1019. X  
  1020. X  int
  1021. END_OF_FILE
  1022. if test 19727 -ne `wc -c <'Patch01'`; then
  1023.     echo shar: \"'Patch01'\" unpacked with wrong size!
  1024. fi
  1025. # end of 'Patch01'
  1026. fi
  1027. echo shar: End of shell archive.
  1028. exit 0
  1029.  
  1030. exit 0 # Just in case...
  1031.