home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rcs / sources / patches.os2 < prev    next >
Text File  |  1992-01-19  |  58KB  |  1,996 lines

  1. diff -cb orig/bucket.c gdbm/bucket.c
  2. *** orig/bucket.c    Sun Jan 19 14:44:14 1992
  3. --- gdbm/bucket.c    Sun Jan 19 14:43:18 1992
  4. ***************
  5. *** 59,65 ****
  6.      is already in memory.  If not, a bucket may be tossed to read the new
  7.      bucket.  In any case, the requested bucket is make the "current" bucket
  8.      and dbf->bucket points to the correct bucket. */
  9. ! int
  10.   _gdbm_get_bucket (dbf, dir_index)
  11.        gdbm_file_info *dbf;
  12.        long dir_index;
  13. --- 59,65 ----
  14.      is already in memory.  If not, a bucket may be tossed to read the new
  15.      bucket.  In any case, the requested bucket is make the "current" bucket
  16.      and dbf->bucket points to the correct bucket. */
  17. ! void
  18.   _gdbm_get_bucket (dbf, dir_index)
  19.        gdbm_file_info *dbf;
  20.        long dir_index;
  21. ***************
  22. *** 114,120 ****
  23.   void
  24.   _gdbm_split_bucket (dbf, next_insert)
  25.        gdbm_file_info *dbf;
  26. !      int next_insert;
  27.   {
  28.     hash_bucket *bucket[2];     /* Pointers to the new buckets. */
  29.   
  30. --- 114,120 ----
  31.   void
  32.   _gdbm_split_bucket (dbf, next_insert)
  33.        gdbm_file_info *dbf;
  34. !      long next_insert;
  35.   {
  36.     hash_bucket *bucket[2];     /* Pointers to the new buckets. */
  37.   
  38. ***************
  39. *** 184,190 ****
  40.         dir_adr  = _gdbm_alloc (dbf, dir_size);
  41.         new_dir  = (long *) malloc (dir_size);
  42.         if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error");
  43. !       for (index = 0; index < dbf->header->dir_size/sizeof (int); index++)
  44.           {
  45.             new_dir[2*index]   = dbf->dir[index];
  46.             new_dir[2*index+1] = dbf->dir[index];
  47. --- 184,190 ----
  48.         dir_adr  = _gdbm_alloc (dbf, dir_size);
  49.         new_dir  = (long *) malloc (dir_size);
  50.         if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error");
  51. !       for (index = 0; index < dbf->header->dir_size/sizeof (long); index++)
  52.           {
  53.             new_dir[2*index]   = dbf->dir[index];
  54.             new_dir[2*index+1] = dbf->dir[index];
  55. ***************
  56. *** 209,216 ****
  57.         for (index = 0; index < dbf->header->bucket_elems; index++)
  58.       {
  59.         old_el = & (dbf->bucket->h_table[index]);
  60. !       select = (old_el->hash_value >> (31-new_bits)) & 1;
  61. !       elem_loc = old_el->hash_value % dbf->header->bucket_elems;
  62.         while (bucket[select]->h_table[elem_loc].hash_value != -1)
  63.           elem_loc = (elem_loc + 1) % dbf->header->bucket_elems;
  64.         bucket[select]->h_table[elem_loc] = *old_el;
  65. --- 209,216 ----
  66.         for (index = 0; index < dbf->header->bucket_elems; index++)
  67.       {
  68.         old_el = & (dbf->bucket->h_table[index]);
  69. !       select = (int) (old_el->hash_value >> (31-new_bits)) & 1;
  70. !       elem_loc = (int) (old_el->hash_value % dbf->header->bucket_elems);
  71.         while (bucket[select]->h_table[elem_loc].hash_value != -1)
  72.           elem_loc = (elem_loc + 1) % dbf->header->bucket_elems;
  73.         bucket[select]->h_table[elem_loc] = *old_el;
  74. ***************
  75. *** 260,266 ****
  76.         dbf->second_changed = TRUE;
  77.   
  78.         /* Update the cache! */
  79. !       dbf->bucket_dir = next_insert >> (31-dbf->header->dir_bits);
  80.   
  81.         /* Invalidate old cache entry. */
  82.         old_bucket.av_adr  = dbf->cache_entry->ca_adr;
  83. --- 260,266 ----
  84.         dbf->second_changed = TRUE;
  85.   
  86.         /* Update the cache! */
  87. !       dbf->bucket_dir = (int) (next_insert >> (31-dbf->header->dir_bits));
  88.   
  89.         /* Invalidate old cache entry. */
  90.         old_bucket.av_adr  = dbf->cache_entry->ca_adr;
  91. ***************
  92. *** 296,302 ****
  93.   
  94.   /* The only place where a bucket is written.  CA_ENTRY is the
  95.      cache entry containing the bucket to be written. */
  96.   _gdbm_write_bucket (dbf, ca_entry)
  97.        gdbm_file_info *dbf;
  98.        cache_elem *ca_entry;
  99. --- 296,302 ----
  100.   
  101.   /* The only place where a bucket is written.  CA_ENTRY is the
  102.      cache entry containing the bucket to be written. */
  103. ! void
  104.   _gdbm_write_bucket (dbf, ca_entry)
  105.        gdbm_file_info *dbf;
  106.        cache_elem *ca_entry;
  107. diff -cb orig/dbm.h gdbm/dbm.h
  108. *** orig/dbm.h    Sun Jan 19 14:44:14 1992
  109. --- gdbm/dbm.h    Thu May 23 19:26:30 1991
  110. ***************
  111. *** 34,55 ****
  112.         } datum;
  113.   
  114.   
  115. - /* These are the routines in dbm. */
  116.   
  117. ! extern int    dbminit ();
  118.   
  119.   extern datum    fetch ();
  120.   extern int    store ();
  121.   extern int    delete ();
  122. - extern int    delete ();
  123.   extern datum    firstkey ();
  124.   extern datum    nextkey ();
  125. ! /* To make some versions work we need the following define. */
  126. ! #define dbmclose()
  127. --- 34,56 ----
  128.         } datum;
  129.   
  130.   
  131.   
  132. ! /* To make some versions work we need the following define. */
  133.   
  134. + #define dbmclose()
  135. + /* These are the routines in dbm. */
  136. + #ifdef __STDC__
  137. + extern  int dbminit (char *file);
  138. + extern datum fetch(datum key);
  139. + extern int store (datum key, datum content);
  140. + extern int delete (datum key);
  141. + extern datum firstkey (void);
  142. + extern datum nextkey (datum key);
  143. + #else /* not __STDC__ */
  144. + extern int    dbminit ();
  145.   extern datum    fetch ();
  146.   extern int    store ();
  147.   extern int    delete ();
  148.   extern datum    firstkey ();
  149.   extern datum    nextkey ();
  150. ! #endif /* not __STDC__ */
  151. diff -cb orig/dbminit.c gdbm/dbminit.c
  152. *** orig/dbminit.c    Sun Jan 19 14:44:14 1992
  153. --- gdbm/dbminit.c    Sun Jan 19 14:43:18 1992
  154. ***************
  155. *** 87,93 ****
  156. --- 87,97 ----
  157.     if (stat (dir_file, &dir_stat) == 0)
  158.       {
  159.         if (dir_stat.st_size == 0)
  160. + #ifdef OS2
  161. +         if ( 0 /* open (dir_file, O_RDWR|O_TRUNC, S_IREAD|S_IWRITE) < 0 */ )
  162. + #else /* not OS2 */
  163.       if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0)
  164. + #endif /* not OS2 */
  165.         {
  166.           gdbm_errno = GDBM_FILE_OPEN_ERROR;
  167.           gdbm_close (_gdbm_file);
  168. ***************
  169. *** 98,104 ****
  170. --- 102,112 ----
  171.       {
  172.         /* Since we can't stat it, we assume it is not there and try
  173.            to link the dir_file to the pag_file. */
  174. + #ifdef OS2
  175. +       if ( 0 /* open (dir_file, O_RDWR|O_CREAT, S_IREAD|S_IWRITE) < 0 */ )
  176. + #else /* not OS2 */
  177.         if (link (pag_file, dir_file) != 0)
  178. + #endif /* not OS2 */
  179.       {
  180.         gdbm_errno = GDBM_FILE_OPEN_ERROR;
  181.         gdbm_close (_gdbm_file);
  182. diff -cb orig/dbmopen.c gdbm/dbmopen.c
  183. *** orig/dbmopen.c    Sun Jan 19 14:44:16 1992
  184. --- gdbm/dbmopen.c    Sun Jan 19 14:43:18 1992
  185. ***************
  186. *** 105,111 ****
  187. --- 105,115 ----
  188.     if (stat (dir_file, &dir_stat) == 0)
  189.       {
  190.         if (dir_stat.st_size == 0)
  191. + #ifdef OS2
  192. +         if ( 0 /* open (dir_file, O_RDWR|O_TRUNC, S_IREAD|S_IWRITE) < 0 */ )
  193. + #else /* not OS2 */
  194.       if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0)
  195. + #endif /* not OS2 */
  196.         {
  197.           gdbm_errno = GDBM_FILE_OPEN_ERROR;
  198.           gdbm_close (temp_dbf);
  199. ***************
  200. *** 116,122 ****
  201. --- 120,130 ----
  202.       {
  203.         /* Since we can't stat it, we assume it is not there and try
  204.            to link the dir_file to the pag_file. */
  205. + #ifdef OS2
  206. +       if ( 0 /* open (dir_file, O_RDWR|O_CREAT, S_IREAD|S_IWRITE) < 0 */ )
  207. + #else /* not OS2 */
  208.         if (link (pag_file, dir_file) != 0)
  209. + #endif /* not OS2 */
  210.       {
  211.         gdbm_errno = GDBM_FILE_OPEN_ERROR;
  212.         gdbm_close (temp_dbf);
  213. diff -cb orig/extern.h gdbm/extern.h
  214. *** orig/extern.h    Sun Jan 19 14:44:18 1992
  215. --- gdbm/extern.h    Thu May 23 19:26:52 1991
  216. ***************
  217. *** 37,53 ****
  218.   
  219.   
  220.   /* External routines used. */
  221.   extern gdbm_file_info *gdbm_open ();
  222.   extern datum gdbm_fetch ();
  223.   extern datum gdbm_firstkey ();
  224.   extern datum gdbm_nextkey ();
  225.   extern int gdbm_delete ();
  226.   extern int gdbm_store ();
  227.   
  228.   extern void gdbm_close ();
  229. --- 37,56 ----
  230.   
  231.   
  232.   /* External routines used. */
  233. ! #ifdef __STDC__
  234. ! extern gdbm_file_info *gdbm_open (char *file, int block_size, int read_write, int mode, void (*fatal_func)());
  235. ! extern datum gdbm_fetch (gdbm_file_info *dbf, datum key);
  236. ! extern datum gdbm_firstkey (gdbm_file_info *dbf);
  237. ! extern datum gdbm_nextkey (gdbm_file_info *dbf, datum key);
  238. ! extern int gdbm_delete (gdbm_file_info *dbf, datum key);
  239. ! extern int gdbm_reorganize (gdbm_file_info *dbf);
  240. ! #else /* not __STDC__ */
  241.   extern gdbm_file_info *gdbm_open ();
  242.   extern datum gdbm_fetch ();
  243.   extern datum gdbm_firstkey ();
  244.   extern datum gdbm_nextkey ();
  245.   extern int gdbm_delete ();
  246.   extern int gdbm_store ();
  247. + #endif /* not __STDC__ */
  248.   
  249.   extern void gdbm_close ();
  250. diff -cb orig/falloc.c gdbm/falloc.c
  251. *** orig/falloc.c    Sun Jan 19 14:44:18 1992
  252. --- gdbm/falloc.c    Sun Jan 19 14:43:18 1992
  253. ***************
  254. *** 33,43 ****
  255. --- 33,51 ----
  256.   /* The forward definitions for this file.  See the functions for
  257.      the definition of the function. */
  258.   
  259. + #ifdef __STDC__
  260. + static avail_elem get_elem (int size, avail_elem *av_table, int *av_count);
  261. + static avail_elem get_block (int size, gdbm_file_info *dbf);
  262. + static void push_avail_block (gdbm_file_info *dbf);
  263. + static void pop_avail_block (gdbm_file_info *dbf);
  264. + static void adjust_bucket_avail (gdbm_file_info *dbf);
  265. + #else /* not __STDC__ */
  266.   static avail_elem get_elem ();
  267.   static avail_elem get_block ();
  268.   static push_avail_block ();
  269.   static pop_avail_block ();
  270.   static adjust_bucket_avail ();
  271. + #endif /* not __STDC__ */
  272.   
  273.   /* Allocate space in the file DBF for a block NUM_BYTES in length.  Return
  274.      the file address of the start of the block.
  275. ***************
  276. *** 100,105 ****
  277. --- 108,114 ----
  278.      avail structure.  The value TRUE is returned if there were errors.  If no
  279.      errors occured, the value FALSE is returned. */
  280.   
  281. + int
  282.   _gdbm_free (dbf, file_adr, num_bytes)
  283.        gdbm_file_info *dbf;
  284.        long file_adr;
  285. ***************
  286. *** 109,115 ****
  287.   
  288.     /* Is it too small to worry about? */
  289.     if (num_bytes <= IGNORE_SIZE)
  290. !     return;
  291.   
  292.     /* Initialize the avail element. */
  293.     temp.av_size = num_bytes;
  294. --- 118,124 ----
  295.   
  296.     /* Is it too small to worry about? */
  297.     if (num_bytes <= IGNORE_SIZE)
  298. !     return TRUE;        /* is that correct (was "return;")? -tho */
  299.   
  300.     /* Initialize the avail element. */
  301.     temp.av_size = num_bytes;
  302. ***************
  303. *** 148,154 ****
  304.       adjust_bucket_avail (dbf);
  305.   
  306.     /* All work is done. */
  307. !   return;
  308.   }
  309.   
  310.   
  311. --- 157,163 ----
  312.       adjust_bucket_avail (dbf);
  313.   
  314.     /* All work is done. */
  315. !   return TRUE;            /* is that correct (was "return;")? -tho */
  316.   }
  317.   
  318.   
  319. ***************
  320. *** 159,165 ****
  321.   /* Gets the avail block at the top of the stack and loads it into the
  322.      active avail block.  It does a "free" for itself! */
  323.   
  324. ! static
  325.   pop_avail_block (dbf)
  326.        gdbm_file_info *dbf;
  327.   {
  328. --- 168,174 ----
  329.   /* Gets the avail block at the top of the stack and loads it into the
  330.      active avail block.  It does a "free" for itself! */
  331.   
  332. ! static void
  333.   pop_avail_block (dbf)
  334.        gdbm_file_info *dbf;
  335.   {
  336. ***************
  337. *** 189,201 ****
  338.   
  339.   /* Splits the header avail block and pushes half onto the avail stack. */
  340.   
  341. ! static
  342.   push_avail_block (dbf)
  343.        gdbm_file_info *dbf;
  344.   {
  345.     int  num_bytes;
  346.     int  av_size;
  347. !   int  av_adr;
  348.     int  index;
  349.     long file_pos;
  350.     avail_block *temp;
  351. --- 198,210 ----
  352.   
  353.   /* Splits the header avail block and pushes half onto the avail stack. */
  354.   
  355. ! static void
  356.   push_avail_block (dbf)
  357.        gdbm_file_info *dbf;
  358.   {
  359.     int  num_bytes;
  360.     int  av_size;
  361. !   long av_adr;
  362.     int  index;
  363.     long file_pos;
  364.     avail_block *temp;
  365. ***************
  366. *** 216,221 ****
  367. --- 225,237 ----
  368.   
  369.     /* Split the header block. */
  370.     temp = (avail_block *) alloca (av_size);
  371. + #ifdef OS2
  372. +   if (temp == (avail_block *) 0)
  373. +     {
  374. +       fprintf (stderr, "Error: alloca() failed in gdbm (%s).\n", __FILE__);
  375. +       exit (-2);
  376. +     }
  377. + #endif /* OS2 */
  378.     /* Set the size to be correct AFTER the pop_avail_block. */
  379.     temp->size = dbf->header->avail.size;
  380.     temp->count = 0;
  381. ***************
  382. *** 293,298 ****
  383. --- 309,315 ----
  384.   /* This routine inserts a single NEW_EL into the AV_TABLE block in
  385.      sorted order. This routine does no I/O. */
  386.   
  387. + int
  388.   _gdbm_put_av_elem (new_el, av_table, av_count)
  389.        avail_elem new_el;
  390.        avail_elem av_table[];
  391. ***************
  392. *** 366,372 ****
  393.   
  394.   /*  When the header already needs writing, we can make sure the current
  395.       bucket has its avail block as close to 1/2 full as possible. */
  396. ! static
  397.   adjust_bucket_avail (dbf)
  398.        gdbm_file_info *dbf;
  399.   {
  400. --- 383,389 ----
  401.   
  402.   /*  When the header already needs writing, we can make sure the current
  403.       bucket has its avail block as close to 1/2 full as possible. */
  404. ! static void
  405.   adjust_bucket_avail (dbf)
  406.        gdbm_file_info *dbf;
  407.   {
  408. diff -cb orig/findkey.c gdbm/findkey.c
  409. *** orig/findkey.c    Sun Jan 19 14:44:20 1992
  410. --- gdbm/findkey.c    Sun Jan 19 14:43:18 1992
  411. ***************
  412. *** 100,106 ****
  413.   
  414.     /* Compute hash value and load proper bucket.  */
  415.     *new_hash_val = _gdbm_hash (key);
  416. !   _gdbm_get_bucket (dbf, *new_hash_val>> (31-dbf->header->dir_bits));
  417.   
  418.     /* Is the element the last one found for this bucket? */
  419.     if (*new_hash_val == dbf->cache_entry->ca_data.hash_val
  420. --- 100,106 ----
  421.   
  422.     /* Compute hash value and load proper bucket.  */
  423.     *new_hash_val = _gdbm_hash (key);
  424. !   _gdbm_get_bucket (dbf, (int) (*new_hash_val>> (31-dbf->header->dir_bits)));
  425.   
  426.     /* Is the element the last one found for this bucket? */
  427.     if (*new_hash_val == dbf->cache_entry->ca_data.hash_val
  428. ***************
  429. *** 114,120 ****
  430.       }
  431.   
  432.     /* It is not the cached value, search for element in the bucket. */
  433. !   elem_loc = *new_hash_val % dbf->header->bucket_elems;
  434.     home_loc = elem_loc;
  435.     bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value;
  436.     while (bucket_hash_val != -1)
  437. --- 114,120 ----
  438.       }
  439.   
  440.     /* It is not the cached value, search for element in the bucket. */
  441. !   elem_loc = (int) (*new_hash_val % dbf->header->bucket_elems);
  442.     home_loc = elem_loc;
  443.     bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value;
  444.     while (bucket_hash_val != -1)
  445. diff -cb orig/gdbm.proto gdbm/gdbm.proto
  446. *** orig/gdbm.proto    Sun Jan 19 14:44:20 1992
  447. --- gdbm/gdbm.proto    Thu May 23 21:57:34 1991
  448. ***************
  449. *** 53,72 ****
  450.   
  451.   /* These are the routines! */
  452.   
  453.   extern GDBM_FILE gdbm_open ();
  454.   extern void     gdbm_close ();
  455.   extern datum     gdbm_fetch ();
  456.   extern int     gdbm_store ();
  457.   extern int     gdbm_delete ();
  458.   extern datum     gdbm_firstkey ();
  459.   extern datum     gdbm_nextkey ();
  460.   extern int     gdbm_reorganize ();
  461. --- 53,74 ----
  462.   
  463.   /* These are the routines! */
  464.   
  465. + #ifdef __STDC__
  466. + extern GDBM_FILE gdbm_open (char *, int, int, int, void (*) ());
  467. + extern void     gdbm_close (gdbm_file_info *);
  468. + extern datum     gdbm_fetch (gdbm_file_info *, datum);
  469. + extern int     gdbm_store (gdbm_file_info *, datum, datum, int);
  470. + extern int     gdbm_delete (gdbm_file_info *, datum);
  471. + extern datum     gdbm_firstkey (gdbm_file_info *);
  472. + extern datum     gdbm_nextkey (gdbm_file_info *, datum);
  473. + extern int     gdbm_reorganize (gdbm_file_info *);
  474. + #else
  475.   extern GDBM_FILE gdbm_open ();
  476.   extern void     gdbm_close ();
  477.   extern datum     gdbm_fetch ();
  478.   extern int     gdbm_store ();
  479.   extern int     gdbm_delete ();
  480.   extern datum     gdbm_firstkey ();
  481.   extern datum     gdbm_nextkey ();
  482.   extern int     gdbm_reorganize ();
  483. ! #endif
  484. diff -cb orig/gdbmdefs.h gdbm/gdbmdefs.h
  485. *** orig/gdbmdefs.h    Sun Jan 19 14:44:22 1992
  486. --- gdbm/gdbmdefs.h    Sun Jan 19 14:37:08 1992
  487. ***************
  488. *** 26,36 ****
  489. --- 26,43 ----
  490.           phone:  (206) 676-3035
  491.   *************************************************************************/
  492.   
  493. + #ifdef __STDC__
  494. + #include <stdio.h>
  495. + #include <stdlib.h>
  496. + #include <string.h>
  497. + #endif /*not __STDC__ */
  498.   
  499.   /* Include the standard include files needed for gdbm. */
  500.   #include <stdio.h>
  501.   #include <sys/types.h>
  502. + #ifndef OS2
  503.   #include <sys/file.h>
  504. + #endif
  505.   #include <sys/stat.h>
  506.   #include "gdbmconst.h"
  507.   #include "systems.h"
  508. ***************
  509. *** 198,200 ****
  510. --- 205,247 ----
  511.         } gdbm_file_info;
  512.   
  513.   
  514. + #ifdef __STDC__
  515. + extern void gdbm_close (gdbm_file_info *dbf);
  516. + extern int gdbm_delete (gdbm_file_info *dbf, datum key);
  517. + extern datum gdbm_fetch (gdbm_file_info *dbf, datum key);
  518. + extern gdbm_file_info *gdbm_open (char *file, int block_size, int read_write, int mode, void (*fatal_func)());
  519. + extern int gdbm_reorganize (gdbm_file_info *dbf);
  520. + extern datum gdbm_firstkey (gdbm_file_info *dbf);
  521. + extern datum gdbm_nextkey (gdbm_file_info *dbf, datum key);
  522. + extern int gdbm_store (gdbm_file_info *dbf, datum key, datum content, int flags);
  523. + extern void _gdbm_new_bucket (gdbm_file_info *dbf, hash_bucket *bucket, int bits);
  524. + extern void _gdbm_get_bucket (gdbm_file_info *dbf, long dir_index);
  525. + extern void _gdbm_split_bucket (gdbm_file_info *dbf, long next_insert);
  526. + extern void _gdbm_write_bucket (gdbm_file_info *dbf, cache_elem *ca_entry);
  527. + extern long _gdbm_alloc (gdbm_file_info *dbf, int num_bytes);
  528. + extern int _gdbm_free (gdbm_file_info *dbf, long file_adr, int num_bytes);
  529. + extern int _gdbm_put_av_elem (avail_elem new_el, avail_elem *av_table, int *av_count);
  530. + extern char *_gdbm_read_entry (gdbm_file_info *dbf, int elem_loc);
  531. + extern int _gdbm_findkey (gdbm_file_info *dbf, datum key, char **dptr, long *new_hash_val);
  532. + extern long _gdbm_hash (datum key);
  533. + extern void _gdbm_end_update (gdbm_file_info *dbf);
  534. + extern void _gdbm_fatal (gdbm_file_info *dbf, char *val);
  535. + extern  int dbminit (char *file);
  536. + extern datum fetch(datum key);
  537. + extern int store (datum key, datum content);
  538. + extern int delete (datum key);
  539. + extern datum firstkey (void);
  540. + extern datum nextkey (datum key);
  541. + extern gdbm_file_info *dbm_open (char *file, int flags, int mode);
  542. + extern void dbm_close (gdbm_file_info *dbf);
  543. + extern datum dbm_fetch (gdbm_file_info *dbf, datum key);
  544. + extern int dbm_store (gdbm_file_info *dbf, datum key, datum content, int flags);
  545. + extern int dbm_delete (gdbm_file_info *dbf, datum key);
  546. + extern datum dbm_firstkey (gdbm_file_info *dbf);
  547. + extern datum dbm_nextkey (gdbm_file_info *dbf);
  548. + extern int dbm_dirfno (gdbm_file_info *dbf);
  549. + extern int dbm_pagfno (gdbm_file_info *dbf);
  550. + #endif /* __STDC__ */
  551. diff -cb orig/gdbmdelete.c gdbm/gdbmdelete.c
  552. *** orig/gdbmdelete.c    Sun Jan 19 14:44:22 1992
  553. --- gdbm/gdbmdelete.c    Sun Jan 19 14:43:18 1992
  554. ***************
  555. *** 79,86 ****
  556.     while (elem_loc != last_loc
  557.        && dbf->bucket->h_table[elem_loc].hash_value != -1)
  558.       {
  559. !       home = dbf->bucket->h_table[elem_loc].hash_value
  560. !          % dbf->header->bucket_elems;
  561.         if ( (last_loc < elem_loc && (home <= last_loc || home > elem_loc))
  562.         || (last_loc > elem_loc && home <= last_loc && home > elem_loc))
  563.   
  564. --- 79,86 ----
  565.     while (elem_loc != last_loc
  566.        && dbf->bucket->h_table[elem_loc].hash_value != -1)
  567.       {
  568. !       home = (int) (dbf->bucket->h_table[elem_loc].hash_value
  569. !             % dbf->header->bucket_elems);
  570.         if ( (last_loc < elem_loc && (home <= last_loc || home > elem_loc))
  571.         || (last_loc > elem_loc && home <= last_loc && home > elem_loc))
  572.   
  573. diff -cb orig/gdbmopen.c gdbm/gdbmopen.c
  574. *** orig/gdbmopen.c    Sun Jan 19 14:44:24 1992
  575. --- gdbm/gdbmopen.c    Sun Jan 19 14:43:20 1992
  576. ***************
  577. *** 110,130 ****
  578.     need_trunc = FALSE;
  579.     if (read_write == GDBM_READER)
  580.       {
  581. !       dbf->desc = open (dbf->name, O_RDONLY, 0);
  582.       }
  583.     else if (read_write == GDBM_WRITER)
  584.       {
  585. !       dbf->desc = open (dbf->name, O_RDWR, 0);
  586.       }
  587.     else if (read_write == GDBM_NEWDB)
  588.       {
  589. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode);
  590.         read_write = GDBM_WRITER;
  591.         need_trunc = TRUE;
  592.       }
  593.     else
  594.       {
  595. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode);
  596.         read_write = GDBM_WRITER;
  597.       }
  598.     if (dbf->desc < 0)
  599. --- 110,130 ----
  600.     need_trunc = FALSE;
  601.     if (read_write == GDBM_READER)
  602.       {
  603. !       dbf->desc = open (dbf->name, O_RDONLY|O_BINARY, 0);
  604.       }
  605.     else if (read_write == GDBM_WRITER)
  606.       {
  607. !       dbf->desc = open (dbf->name, O_RDWR|O_BINARY, 0);
  608.       }
  609.     else if (read_write == GDBM_NEWDB)
  610.       {
  611. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT|O_BINARY, mode);
  612.         read_write = GDBM_WRITER;
  613.         need_trunc = TRUE;
  614.       }
  615.     else
  616.       {
  617. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT|O_BINARY, mode);
  618.         read_write = GDBM_WRITER;
  619.       }
  620.     if (dbf->desc < 0)
  621. ***************
  622. *** 206,212 ****
  623.         dbf->header->block_size = file_block_size;
  624.   
  625.         /* Create the initial hash table directory.  */
  626. !       dbf->header->dir_size = 8 * sizeof (int);
  627.         dbf->header->dir_bits = 3;
  628.         while (dbf->header->dir_size < dbf->header->block_size)
  629.       {
  630. --- 206,212 ----
  631.         dbf->header->block_size = file_block_size;
  632.   
  633.         /* Create the initial hash table directory.  */
  634. !       dbf->header->dir_size = 8 * sizeof (long);
  635.         dbf->header->dir_bits = 3;
  636.         while (dbf->header->dir_size < dbf->header->block_size)
  637.       {
  638. ***************
  639. *** 223,229 ****
  640.       }
  641.   
  642.         /* Allocate the space for the directory. */
  643. !       dbf->dir = (int *) malloc (dbf->header->dir_size);
  644.         if (dbf->dir == NULL)
  645.       {
  646.         gdbm_close (dbf);
  647. --- 223,229 ----
  648.       }
  649.   
  650.         /* Allocate the space for the directory. */
  651. !       dbf->dir = (long *) malloc (dbf->header->dir_size);
  652.         if (dbf->dir == NULL)
  653.       {
  654.         gdbm_close (dbf);
  655. ***************
  656. *** 250,256 ****
  657.         dbf->bucket->bucket_avail[0].av_size = dbf->header->block_size;
  658.   
  659.         /* Set table entries to point to hash buckets. */
  660. !       for (index = 0; index < dbf->header->dir_size / sizeof (int); index++)
  661.       dbf->dir[index] = 2*dbf->header->block_size;
  662.   
  663.         /* Initialize the active avail block. */
  664. --- 250,256 ----
  665.         dbf->bucket->bucket_avail[0].av_size = dbf->header->block_size;
  666.   
  667.         /* Set table entries to point to hash buckets. */
  668. !       for (index = 0; index < dbf->header->dir_size / sizeof (long); index++)
  669.       dbf->dir[index] = 2*dbf->header->block_size;
  670.   
  671.         /* Initialize the active avail block. */
  672. ***************
  673. *** 310,316 ****
  674.       }
  675.   
  676.         /* Is the magic number good? */
  677. !       if (partial_header.header_magic != 0x13579ace)
  678.       {
  679.         gdbm_close (dbf);
  680.         gdbm_errno = GDBM_BAD_MAGIC_NUMBER;
  681. --- 310,316 ----
  682.       }
  683.   
  684.         /* Is the magic number good? */
  685. !       if (partial_header.header_magic != 0x13579ACEL)
  686.       {
  687.         gdbm_close (dbf);
  688.         gdbm_errno = GDBM_BAD_MAGIC_NUMBER;
  689. ***************
  690. *** 336,342 ****
  691.       }
  692.   
  693.         /* Allocate space for the hash table directory.  */
  694. !       dbf->dir = (int *) malloc (dbf->header->dir_size);
  695.         if (dbf->dir == NULL)
  696.       {
  697.         gdbm_close (dbf);
  698. --- 336,342 ----
  699.       }
  700.   
  701.         /* Allocate space for the hash table directory.  */
  702. !       dbf->dir = (long *) malloc (dbf->header->dir_size);
  703.         if (dbf->dir == NULL)
  704.       {
  705.         gdbm_close (dbf);
  706. diff -cb orig/gdbmreorg.c gdbm/gdbmreorg.c
  707. *** orig/gdbmreorg.c    Sun Jan 19 14:44:26 1992
  708. --- gdbm/gdbmreorg.c    Sun Jan 19 14:43:20 1992
  709. ***************
  710. *** 74,79 ****
  711. --- 74,80 ----
  712.     gdbm_file_info *new_dbf;        /* The new file. */
  713.     char *new_name;            /* A temporary name. */
  714.     int  len;                /* Used in new_name construction. */
  715. +   int new_desc;                /* Used to avoid walking file desc */
  716.     datum key, nextkey, data;        /* For the sequential sweep. */
  717.     struct stat fileinfo;            /* Information about the file. */
  718.     int  index;                /* Use in moving the bucket cache. */
  719. ***************
  720. *** 131,139 ****
  721.             gdbm_close (new_dbf);
  722.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  723.             unlink (new_name);
  724.             return -1;
  725. -         };
  726.        }
  727.         else
  728.        {
  729.         /* ERROR! Abort and don't finish reorganize. */
  730. --- 132,141 ----
  731.             gdbm_close (new_dbf);
  732.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  733.             unlink (new_name);
  734. +           free(new_name);
  735.             return -1;
  736.           }
  737. +      }
  738.         else
  739.        {
  740.         /* ERROR! Abort and don't finish reorganize. */
  741. ***************
  742. *** 140,164 ****
  743.         gdbm_close (new_dbf);
  744.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  745.         unlink (new_name);
  746.         return -1;
  747.        }
  748.         nextkey = gdbm_nextkey (dbf, key);
  749.         free (key.dptr);
  750.         key = nextkey;
  751.       }
  752.   
  753.       /* Move the new file to old name. */
  754.   
  755.     if (rename (new_name, dbf->name) != 0)
  756.       {
  757.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  758.         gdbm_close (new_dbf);
  759.         return -1;
  760.       }
  761.   
  762.     /* Fix up DBF to have the correct information for the new file. */
  763.     UNLOCK_FILE(dbf);
  764. !   close (dbf->desc);
  765.     free (dbf->header);
  766.     free (dbf->dir);
  767.     for (index = 0; index < CACHE_SIZE; index++)
  768. --- 142,186 ----
  769.         gdbm_close (new_dbf);
  770.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  771.         unlink (new_name);
  772. +       free(new_name);
  773.         return -1;
  774.        }
  775.         nextkey = gdbm_nextkey (dbf, key);
  776.         free (key.dptr);
  777. +       free (data.dptr);
  778.         key = nextkey;
  779.       }
  780.   
  781.       /* Move the new file to old name. */
  782.   
  783. + #ifdef OS2
  784. +   if (close (new_dbf->desc)
  785. +       || unlink (dbf->name)
  786. +       || rename (new_name, dbf->name)
  787. +       || (new_dbf->desc = open (dbf->name, O_RDWR|O_BINARY)) < 0)
  788. + #else /* not OS2 */
  789.     if (rename (new_name, dbf->name) != 0)
  790. + #endif /* not OS2 */
  791.       {
  792.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  793.         gdbm_close (new_dbf);
  794. +       unlink (new_name);
  795. +       free(new_name);
  796.         return -1;
  797.       }
  798.   
  799.     /* Fix up DBF to have the correct information for the new file. */
  800.     UNLOCK_FILE(dbf);
  801. !   /* close (dbf->desc); */
  802. !   if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0)
  803. !     {
  804. !       gdbm_close(new_dbf);
  805. !       gdbm_errno = GDBM_REORGANIZE_FAILED;
  806. !       unlink (new_name);
  807. !       free(new_name);
  808. !       return -1;
  809. !     }
  810. !   dbf->desc = new_desc;
  811.     free (dbf->header);
  812.     free (dbf->dir);
  813.     for (index = 0; index < CACHE_SIZE; index++)
  814. ***************
  815. *** 169,180 ****
  816.       free (dbf->bucket_cache[index].ca_data.dptr);
  817.       }
  818.   
  819. !   dbf->desc           = new_dbf->desc;
  820.     dbf->header         = new_dbf->header;
  821.     dbf->dir            = new_dbf->dir;
  822.     dbf->bucket         = new_dbf->bucket;
  823.     dbf->bucket_dir     = new_dbf->bucket_dir;
  824. !   dbf->cache_entry    = new_dbf->cache_entry;
  825.     dbf->last_read      = new_dbf->last_read;
  826.     for (index = 0; index < CACHE_SIZE; index++)
  827.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  828. --- 191,203 ----
  829.       free (dbf->bucket_cache[index].ca_data.dptr);
  830.       }
  831.   
  832. !   /* dbf->desc           = new_dbf->desc; */
  833.     dbf->header         = new_dbf->header;
  834.     dbf->dir            = new_dbf->dir;
  835.     dbf->bucket         = new_dbf->bucket;
  836.     dbf->bucket_dir     = new_dbf->bucket_dir;
  837. !   /* dbf->cache_entry    = new_dbf->cache_entry; */
  838. !   dbf->cache_entry    = &dbf->bucket_cache[new_dbf->last_read];
  839.     dbf->last_read      = new_dbf->last_read;
  840.     for (index = 0; index < CACHE_SIZE; index++)
  841.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  842. ***************
  843. *** 187,192 ****
  844. --- 210,217 ----
  845.   
  846.     /* Make sure the new database is all on disk. */
  847.     fsync (dbf->desc);
  848. +   free(new_name);
  849.   
  850.     return 0;
  851.   }
  852. diff -cb orig/gdbmseq.c gdbm/gdbmseq.c
  853. *** orig/gdbmseq.c    Sun Jan 19 14:44:26 1992
  854. --- gdbm/gdbmseq.c    Thu May 23 19:54:52 1991
  855. ***************
  856. *** 30,35 ****
  857. --- 30,41 ----
  858.   
  859.   #include "gdbmdefs.h"
  860.   
  861. + #ifdef __STDC__
  862. + static void get_next_key (gdbm_file_info *dbf, int elem_loc, datum *return_val);
  863. + #endif /* not __STDC__ */
  864.   /* Special extern for this file. */
  865.   extern char *_gdbm_read_entry ();
  866.   
  867. ***************
  868. *** 60,71 ****
  869.   
  870.         /* Find the next bucket.  It is possible several entries in
  871.            the bucket directory point to the same bucket. */
  872. !       while (dbf->bucket_dir < dbf->header->dir_size / sizeof (int)
  873.            && dbf->cache_entry->ca_adr == dbf->dir[dbf->bucket_dir])
  874.           dbf->bucket_dir++;
  875.   
  876.         /* Check to see if there was a next bucket. */
  877. !       if (dbf->bucket_dir < dbf->header->dir_size / sizeof (int))
  878.           _gdbm_get_bucket (dbf, dbf->bucket_dir);
  879.         else
  880.           /* No next key, just return. */
  881. --- 66,77 ----
  882.   
  883.         /* Find the next bucket.  It is possible several entries in
  884.            the bucket directory point to the same bucket. */
  885. !       while (dbf->bucket_dir < dbf->header->dir_size / sizeof (long)
  886.            && dbf->cache_entry->ca_adr == dbf->dir[dbf->bucket_dir])
  887.           dbf->bucket_dir++;
  888.   
  889.         /* Check to see if there was a next bucket. */
  890. !       if (dbf->bucket_dir < dbf->header->dir_size / sizeof (long))
  891.           _gdbm_get_bucket (dbf, dbf->bucket_dir);
  892.         else
  893.           /* No next key, just return. */
  894. diff -cb orig/gdbmstore.c gdbm/gdbmstore.c
  895. *** orig/gdbmstore.c    Sun Jan 19 14:44:28 1992
  896. --- gdbm/gdbmstore.c    Sun Jan 19 14:43:20 1992
  897. ***************
  898. *** 123,129 ****
  899.       }
  900.   
  901.         /* Find space to insert into bucket and set elem_loc to that place. */
  902. !       elem_loc = new_hash_val % dbf->header->bucket_elems;
  903.         while (dbf->bucket->h_table[elem_loc].hash_value != -1)
  904.       {  elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; }
  905.   
  906. --- 123,129 ----
  907.       }
  908.   
  909.         /* Find space to insert into bucket and set elem_loc to that place. */
  910. !       elem_loc = (int) (new_hash_val % dbf->header->bucket_elems);
  911.         while (dbf->bucket->h_table[elem_loc].hash_value != -1)
  912.       {  elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; }
  913.   
  914. ***************
  915. *** 142,147 ****
  916. --- 142,154 ----
  917.   
  918.     /* Prepare write_data. The key is written first.  */
  919.     write_data = (char *) alloca (key.dsize+content.dsize);
  920. + #ifdef OS2
  921. +   if (write_data == (char *) 0)
  922. +     {
  923. +       fprintf (stderr, "Error: alloca() failed in gdbm (%s).\n", __FILE__);
  924. +       exit (-2);
  925. +     }
  926. + #endif /* OS2 */
  927.     dst = write_data;
  928.     src = key.dptr;
  929.     for (cnt=0; cnt < key.dsize; cnt++)
  930. diff -cb orig/getopt.c gdbm/getopt.c
  931. *** orig/getopt.c    Sun Dec 09 23:59:50 1990
  932. --- gdbm/getopt.c    Sun Jan 19 14:43:20 1992
  933. ***************
  934. *** 15,26 ****
  935.      along with this program; if not, write to the Free Software
  936.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  937.   
  938. ! #if defined(__STDC__) || defined(MSDOS)
  939.   #define CONST const
  940.   #else
  941.   #define CONST
  942.   #endif
  943. ! #ifdef MSDOS
  944.   #define STDC_HEADERS
  945.   #endif
  946.   
  947. --- 15,26 ----
  948.      along with this program; if not, write to the Free Software
  949.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  950.   
  951. ! #if defined(__STDC__) || defined(OS2)
  952.   #define CONST const
  953.   #else
  954.   #define CONST
  955.   #endif
  956. ! #ifdef OS2
  957.   #define STDC_HEADERS
  958.   #endif
  959.   
  960. ***************
  961. *** 47,53 ****
  962.   #ifdef sparc
  963.   #include <alloca.h>
  964.   #else
  965. ! #ifdef MSDOS
  966.   #include <malloc.h>
  967.   #else
  968.   char *alloca ();
  969. --- 47,53 ----
  970.   #ifdef sparc
  971.   #include <alloca.h>
  972.   #else
  973. ! #ifdef OS2
  974.   #include <malloc.h>
  975.   #else
  976.   char *alloca ();
  977. diff -cb orig/getopt.h gdbm/getopt.h
  978. *** orig/getopt.h    Sun Oct 28 10:50:34 1990
  979. --- gdbm/getopt.h    Sun Jan 19 14:37:08 1992
  980. ***************
  981. *** 73,79 ****
  982.     int val;
  983.   };
  984.   
  985. ! #if defined(__STDC__) || defined(MSDOS)
  986.   extern const struct option *_getopt_long_options;
  987.   #else
  988.   extern struct option *_getopt_long_options;
  989. --- 73,79 ----
  990.     int val;
  991.   };
  992.   
  993. ! #if defined(__STDC__) || defined(OS2)
  994.   extern const struct option *_getopt_long_options;
  995.   #else
  996.   extern struct option *_getopt_long_options;
  997. ***************
  998. *** 90,96 ****
  999.   
  1000.   extern int option_index;
  1001.   
  1002. ! #if defined(__STDC__) || defined(MSDOS)
  1003.   int getopt (int argc, char **argv, const char *shortopts);
  1004.   int getopt_long (int argc, char **argv, const char *shortopts,
  1005.            const struct option *longopts, int *longind);
  1006. --- 90,96 ----
  1007.   
  1008.   extern int option_index;
  1009.   
  1010. ! #if defined(__STDC__) || defined(OS2)
  1011.   int getopt (int argc, char **argv, const char *shortopts);
  1012.   int getopt_long (int argc, char **argv, const char *shortopts,
  1013.            const struct option *longopts, int *longind);
  1014. diff -cb orig/getopt1.c gdbm/getopt1.c
  1015. *** orig/getopt1.c    Sun Dec 09 23:59:50 1990
  1016. --- gdbm/getopt1.c    Sun Jan 19 14:43:20 1992
  1017. ***************
  1018. *** 17,23 ****
  1019.   
  1020.   #include "getopt.h"
  1021.   
  1022. ! #if defined(__STDC__) || defined(MSDOS)
  1023.   #define CONST const
  1024.   #else
  1025.   #define CONST
  1026. --- 17,23 ----
  1027.   
  1028.   #include "getopt.h"
  1029.   
  1030. ! #if defined(__STDC__) || defined(OS2)
  1031.   #define CONST const
  1032.   #else
  1033.   #define CONST
  1034. diff -cb orig/global.c gdbm/global.c
  1035. *** orig/global.c    Sun Jan 19 14:44:28 1992
  1036. --- gdbm/global.c    Sun Jan 19 14:43:20 1992
  1037. ***************
  1038. *** 41,44 ****
  1039.   char *_gdbm_fetch_val = NULL;    /* Used by fetch. */
  1040.   
  1041.   /* The dbm error number is placed in the variable GDBM_ERRNO. */
  1042. ! gdbm_error gdbm_errno;
  1043. --- 41,45 ----
  1044.   char *_gdbm_fetch_val = NULL;    /* Used by fetch. */
  1045.   
  1046.   /* The dbm error number is placed in the variable GDBM_ERRNO. */
  1047. ! /* won't go into library if not initialized!  */
  1048. ! gdbm_error gdbm_errno = GDBM_NO_ERROR;
  1049. diff -cb orig/ndbm.h gdbm/ndbm.h
  1050. *** orig/ndbm.h    Sun Jan 19 14:44:30 1992
  1051. --- gdbm/ndbm.h    Thu May 23 19:27:24 1991
  1052. ***************
  1053. *** 33,70 ****
  1054.   
  1055.   
  1056.   /* The data and key structure.  This structure is defined for compatibility. */
  1057.   typedef struct {
  1058.       char *dptr;
  1059.       int   dsize;
  1060.         } datum;
  1061.   
  1062.   /* The file information header. This is good enough for most applications. */
  1063.   typedef struct {int dummy[10];} DBM;
  1064.   
  1065.   /* These are the routines (with some macros defining them!) */
  1066.   
  1067.   extern DBM     *dbm_open ();
  1068.   extern void     dbm_close ();
  1069.   extern datum     dbm_fetch ();
  1070.   extern int     dbm_store ();
  1071. - extern int     dbm_delete ();
  1072.   extern int     dbm_delete ();
  1073.   extern datum     dbm_firstkey ();
  1074.   extern datum     dbm_nextkey ();
  1075.   
  1076.   #define         dbm_error(dbf)  0
  1077.   #define         dbm_clearerr(dbf)
  1078.   
  1079. - extern int     dbm_dirfno ();
  1080.   
  1081. - extern int     dbm_pagfno ();
  1082. --- 33,79 ----
  1083.   
  1084.   
  1085.   /* The data and key structure.  This structure is defined for compatibility. */
  1086. + #ifdef __STDC__
  1087. + #include "gdbmdefs.h"
  1088. + #else /* not __STDC__ */
  1089.   typedef struct {
  1090.       char *dptr;
  1091.       int   dsize;
  1092.         } datum;
  1093. + #endif /* not __STDC__ */
  1094.   
  1095.   /* The file information header. This is good enough for most applications. */
  1096. + #ifdef __STDC__
  1097. + #define DBM gdbm_file_info
  1098. + #else /* not __STDC__ */
  1099.   typedef struct {int dummy[10];} DBM;
  1100. ! #endif /* not __STDC__ */
  1101.   
  1102.   /* These are the routines (with some macros defining them!) */
  1103.   
  1104. + #ifdef __STDC__
  1105. + extern DBM *dbm_open (char *file, int flags, int mode);
  1106. + extern void dbm_close (DBM *dbf);
  1107. + extern datum dbm_fetch (DBM *dbf, datum key);
  1108. + extern int dbm_store (DBM *dbf, datum key, datum content, int flags);
  1109. + extern int dbm_delete (DBM *dbf, datum key);
  1110. + extern datum dbm_firstkey (DBM *dbf);
  1111. + extern datum dbm_nextkey (DBM *dbf);
  1112. + extern int dbm_dirfno (DBM *dbf);
  1113. + extern int dbm_pagfno (DBM *dbf);
  1114. + #else /* not __STDC__ */
  1115.   extern DBM     *dbm_open ();
  1116.   extern void     dbm_close ();
  1117.   extern datum     dbm_fetch ();
  1118.   extern int     dbm_store ();
  1119.   extern int     dbm_delete ();
  1120.   extern datum     dbm_firstkey ();
  1121.   extern datum     dbm_nextkey ();
  1122. + extern int     dbm_dirfno ();
  1123. + extern int     dbm_pagfno ();
  1124. + #endif /* not __STDC__ */
  1125.   
  1126.   #define         dbm_error(dbf)  0
  1127.   #define         dbm_clearerr(dbf)
  1128.   
  1129.   
  1130. diff -cb orig/readme gdbm/readme
  1131. *** orig/readme    Sun Jan 19 14:44:32 1992
  1132. --- gdbm/readme    Thu May 23 21:55:46 1991
  1133. ***************
  1134. *** 1,3 ****
  1135. --- 1,26 ----
  1136. + /*
  1137. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1138. +  *
  1139. +  * To this port, the same copying conditions apply as to the
  1140. +  * original release.
  1141. +  *
  1142. +  * IMPORTANT:
  1143. +  * These files are not identical to the original GNU release!
  1144. +  * You should have received this code as patch to the official
  1145. +  * GNU release.
  1146. +  *
  1147. +  * MORE IMPORTANT:
  1148. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1149. +  */
  1150. + Note: This port was done for 1.4.
  1151. + I have applied a part of it to 1.5 and made some minor further changes
  1152. + Kai Uwe Rommel
  1153. + rommel@lan.informatik.tu-muenchen.dbp.de
  1154. + -----------
  1155.   This is release 1.5 of GNU dbm.  Better documentation will be written
  1156.   soon.  For now, this file briefly describes the contents of this
  1157.   release and how to use it.
  1158. diff -cb orig/systems.h gdbm/systems.h
  1159. *** orig/systems.h    Sun Jan 19 14:44:32 1992
  1160. --- gdbm/systems.h    Sun Jan 19 14:37:08 1992
  1161. ***************
  1162. *** 27,33 ****
  1163.   
  1164.   *************************************************************************/
  1165.   
  1166.   
  1167.   /*         System V changes and defines.          */
  1168.   /**************************************************/
  1169. --- 27,37 ----
  1170.   
  1171.   *************************************************************************/
  1172.   
  1173. ! #ifdef OS2
  1174. ! #ifndef SYSV
  1175. ! #define SYSV
  1176. ! #endif
  1177. ! #endif
  1178.   
  1179.   /*         System V changes and defines.          */
  1180.   /**************************************************/
  1181. ***************
  1182. *** 35,45 ****
  1183. --- 39,59 ----
  1184.   #ifdef SYSV
  1185.   
  1186.   /* File seeking needs L_SET defined .*/
  1187. + #ifdef OS2
  1188. + #include <malloc.h>
  1189. + #include <io.h>
  1190. + #else /* not OS2 */
  1191.   #include <unistd.h>
  1192. + #endif /* not OS2 */
  1193.   #define L_SET SEEK_SET
  1194.   
  1195.   /* Some files need fcntl.h for locking. */
  1196.   #include <fcntl.h>
  1197. + #ifdef OS2
  1198. + #define UNLOCK_FILE(dbf)    /* later !!!  */
  1199. + #define READLOCK_FILE(dbf)    lock_val = 0;
  1200. + #define WRITELOCK_FILE(dbf)    lock_val = 0;
  1201. + #else /* not OS2 */
  1202.   #define UNLOCK_FILE(dbf) \
  1203.       {                    \
  1204.         struct flock flock;            \
  1205. ***************
  1206. *** 64,69 ****
  1207. --- 78,84 ----
  1208.         flock.l_start = flock.l_len = 0L;    \
  1209.         lock_val = fcntl (dbf->desc, F_SETLK, &flock);    \
  1210.       }
  1211. + #endif /* not OS2 */
  1212.   
  1213.   /* Send bcmp to the right place. */
  1214.   #include <memory.h>
  1215. ***************
  1216. *** 71,83 ****
  1217. --- 86,104 ----
  1218.   #define bcopy(d1, d2, n) memcpy(d2, d1, n)
  1219.   
  1220.   /* Sys V does not have fsync. */
  1221. + #ifdef OS2
  1222. + #define fsync(f)
  1223. + #else /* not OS2 */
  1224.   #define fsync(f) sync(); sync()
  1225. + #endif /* not OS2 */
  1226.   
  1227.   /* Stat does not have a st_blksize field. */
  1228.   #define STATBLKSIZE 512
  1229.   
  1230.   /* Does not have rename(). */
  1231. + #ifndef OS2
  1232.   #define NEED_RENAME
  1233. + #endif /* not OS2 */
  1234.   
  1235.   /* Get string definitions. */
  1236.   #include <string.h>
  1237. ***************
  1238. *** 92,98 ****
  1239.   /**************************************************/
  1240.   
  1241.   
  1242.   /* Alloca is builtin in gcc.  Use the builtin alloca if compiled with gcc. */
  1243.   #ifdef __GNUC__
  1244.   #define BUILTIN_ALLOCA
  1245. --- 113,119 ----
  1246.   /**************************************************/
  1247.   
  1248.   
  1249. ! #ifndef OS2
  1250.   /* Alloca is builtin in gcc.  Use the builtin alloca if compiled with gcc. */
  1251.   #ifdef __GNUC__
  1252.   #define BUILTIN_ALLOCA
  1253. ***************
  1254. *** 114,119 ****
  1255. --- 135,141 ----
  1256.   
  1257.   /* Malloc definition. */
  1258.   extern char *malloc();
  1259. + #endif /* not OS2 */
  1260.   
  1261.   /* String definitions. */
  1262.   #ifndef _HAVE_STRING
  1263. diff -cb orig/testdbm.c gdbm/testdbm.c
  1264. *** orig/testdbm.c    Sun Jan 19 14:44:34 1992
  1265. --- gdbm/testdbm.c    Sun Jan 19 14:43:20 1992
  1266. ***************
  1267. *** 30,41 ****
  1268. --- 30,48 ----
  1269.   
  1270.   #include <stdio.h>
  1271.   #include <sys/types.h>
  1272. + #ifndef OS2
  1273.   #include <sys/file.h>
  1274. + #endif /* not OS2 */
  1275.   #include <sys/stat.h>
  1276.   
  1277.   #define TRUE  1
  1278.   #define FALSE 0
  1279.   
  1280. + #ifdef __STDC__
  1281. + #include <stdlib.h>
  1282. + #include <string.h>
  1283. + #include "dbm.h"
  1284. + #else /* not __STDC__ */
  1285.   typedef struct {
  1286.     char *dptr;
  1287.     int   dsize;
  1288. ***************
  1289. *** 44,49 ****
  1290. --- 51,57 ----
  1291.   extern datum fetch ();
  1292.   extern datum firstkey ();
  1293.   extern datum nextkey ();
  1294. + #endif /* not __STDC__ */
  1295.   
  1296.   /* The test program allows one to call all the routines plus the hash function.
  1297.      The commands are single letter commands.  The user is prompted for all other
  1298. ***************
  1299. *** 50,61 ****
  1300.      information.  The commands are q (quit), f (fetch), s (store), d (delete),
  1301.      1 (firstkey), n (nextkey) and h (hash function). */
  1302.   
  1303.   main (argc, argv)
  1304.        int argc;
  1305.        char *argv[];
  1306.   {
  1307.   
  1308. !   char  cmd_ch;
  1309.   
  1310.     datum key_data;
  1311.     datum data_data;
  1312. --- 58,70 ----
  1313.      information.  The commands are q (quit), f (fetch), s (store), d (delete),
  1314.      1 (firstkey), n (nextkey) and h (hash function). */
  1315.   
  1316. + void
  1317.   main (argc, argv)
  1318.        int argc;
  1319.        char *argv[];
  1320.   {
  1321.   
  1322. !   int  cmd_ch;
  1323.   
  1324.     datum key_data;
  1325.     datum data_data;
  1326. diff -cb orig/testgdbm.c gdbm/testgdbm.c
  1327. *** orig/testgdbm.c    Sun Jan 19 14:44:38 1992
  1328. --- gdbm/testgdbm.c    Sun Jan 19 14:43:20 1992
  1329. ***************
  1330. *** 43,49 ****
  1331. --- 43,132 ----
  1332.   
  1333.   gdbm_file_info *gdbm_file;
  1334.   
  1335. + #ifdef __STDC__
  1336. + void _gdbm_print_bucket_cache (gdbm_file_info *dbf);
  1337. + static void print_bucket (hash_bucket *bucket, char *mesg);
  1338. + static void _gdbm_print_avail_list (gdbm_file_info *dbf);
  1339. + void main (int argc, char **argv);
  1340. + void usage (char *s);
  1341. + void gdbm_perror (char *msg);
  1342. + extern int getopt (int argc, char **argv, const char *shortopts);
  1343. + #endif /* __STDC__ */
  1344. + /* access GDBM_ERRNO.  [tho]  */
  1345. + void
  1346. + gdbm_perror (char *msg)
  1347. + {
  1348. +   char *err_msg;
  1349. +   switch (gdbm_errno)
  1350. +     {
  1351. +     case GDBM_NO_ERROR:
  1352. +       err_msg = "no error";
  1353. +       break;
  1354. +     case GDBM_MALLOC_ERROR:
  1355. +       err_msg = "can't malloc";
  1356. +       break;
  1357. +     case GDBM_BLOCK_SIZE_ERROR:
  1358. +       err_msg = "bad block size";
  1359. +       break;
  1360. +     case GDBM_FILE_OPEN_ERROR:
  1361. +       err_msg = "can't open file";
  1362. +       break;
  1363. +     case GDBM_FILE_WRITE_ERROR:
  1364. +       err_msg = "can't write file";
  1365. +       break;
  1366. +     case GDBM_FILE_SEEK_ERROR:
  1367. +       err_msg = "can't seek file";
  1368. +       break;
  1369. +     case GDBM_FILE_READ_ERROR:
  1370. +       err_msg = "can't read file";
  1371. +       break;
  1372. +     case GDBM_BAD_MAGIC_NUMBER:
  1373. +       err_msg = "bad magic number";
  1374. +       break;
  1375. +     case GDBM_EMPTY_DATABASE:
  1376. +       err_msg = "empty database";
  1377. +       break;
  1378. +     case GDBM_CANT_BE_READER:
  1379. +       err_msg = "can't be reader";
  1380. +       break;
  1381. +     case GDBM_CANT_BE_WRITER:
  1382. +       err_msg = "can't be writer";
  1383. +       break;
  1384. +     case GDBM_READER_CANT_DELETE:
  1385. +       err_msg = "can't delete";
  1386. +       break;
  1387. +     case GDBM_READER_CANT_STORE:
  1388. +       err_msg = "can't store";
  1389. +       break;
  1390. +     case GDBM_READER_CANT_REORGANIZE:
  1391. +       err_msg = "can't reorganize";
  1392. +       break;
  1393. +     case GDBM_UNKNOWN_UPDATE:
  1394. +       err_msg = "unkown update";
  1395. +       break;
  1396. +     case GDBM_ITEM_NOT_FOUND:
  1397. +       err_msg = "item not found";
  1398. +       break;
  1399. +     case GDBM_REORGANIZE_FAILED:
  1400. +       err_msg = "reorganization failed";
  1401. +       break;
  1402. +     case GDBM_CANNOT_REPLACE:
  1403. +       err_msg = "can't replace";
  1404. +       break;
  1405. +     default:
  1406. +       err_msg = "unknown error";
  1407. +     }
  1408. +   fprintf (stderr, "%s (GDBM error: %s)\n", msg, err_msg);
  1409. + }
  1410.   /* Debug procedure to print the contents of the current hash bucket. */
  1411. + void
  1412.   print_bucket (bucket, mesg)
  1413.        hash_bucket *bucket;
  1414.        char *mesg;
  1415. ***************
  1416. *** 54,78 ****
  1417.        mesg, bucket->bucket_bits, bucket->count);
  1418.     printf ("     #    hash value     key size    data size     data adr  home\n");
  1419.     for (index = 0; index < gdbm_file->header->bucket_elems; index++)
  1420. !     printf ("  %4d  %12x  %11d  %11d  %11d %5d\n", index,
  1421.          bucket->h_table[index].hash_value,
  1422.          bucket->h_table[index].key_size,
  1423.          bucket->h_table[index].data_size,
  1424.          bucket->h_table[index].data_pointer,
  1425. !        bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems);
  1426.   
  1427.     printf ("\nAvail count = %1d\n", bucket->av_count);
  1428.     printf ("Avail  adr     size\n");
  1429.     for (index = 0; index < bucket->av_count; index++)
  1430. !     printf ("%9d%9d\n", bucket->bucket_avail[index].av_adr,
  1431.                       bucket->bucket_avail[index].av_size);
  1432.   }
  1433.   
  1434.   
  1435.   _gdbm_print_avail_list (dbf)
  1436.        gdbm_file_info *dbf;
  1437.   {
  1438. !   int temp;
  1439.     int size;
  1440.     avail_block *av_stk;
  1441.   
  1442. --- 137,162 ----
  1443.        mesg, bucket->bucket_bits, bucket->count);
  1444.     printf ("     #    hash value     key size    data size     data adr  home\n");
  1445.     for (index = 0; index < gdbm_file->header->bucket_elems; index++)
  1446. !     printf ("  %4d  %12lx  %11d  %11d  %11ld %5d\n", index,
  1447.          bucket->h_table[index].hash_value,
  1448.          bucket->h_table[index].key_size,
  1449.          bucket->h_table[index].data_size,
  1450.          bucket->h_table[index].data_pointer,
  1451. !        (int) (bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems));
  1452.   
  1453.     printf ("\nAvail count = %1d\n", bucket->av_count);
  1454.     printf ("Avail  adr     size\n");
  1455.     for (index = 0; index < bucket->av_count; index++)
  1456. !     printf ("%9ld%9d\n", bucket->bucket_avail[index].av_adr,
  1457.                       bucket->bucket_avail[index].av_size);
  1458.   }
  1459.   
  1460.   
  1461. + void
  1462.   _gdbm_print_avail_list (dbf)
  1463.        gdbm_file_info *dbf;
  1464.   {
  1465. !   long temp;
  1466.     int size;
  1467.     avail_block *av_stk;
  1468.   
  1469. ***************
  1470. *** 81,87 ****
  1471.         dbf->header->avail.size, dbf->header->avail.count);
  1472.     for (temp = 0; temp < dbf->header->avail.count; temp++)
  1473.       {
  1474. !       printf ("  %15d   %10d \n", dbf->header->avail.av_table[temp].av_size,
  1475.             dbf->header->avail.av_table[temp].av_adr);
  1476.       }
  1477.   
  1478. --- 165,171 ----
  1479.         dbf->header->avail.size, dbf->header->avail.count);
  1480.     for (temp = 0; temp < dbf->header->avail.count; temp++)
  1481.       {
  1482. !       printf ("  %15d   %10ld \n", dbf->header->avail.av_table[temp].av_size,
  1483.             dbf->header->avail.av_table[temp].av_adr);
  1484.       }
  1485.   
  1486. ***************
  1487. *** 90,95 ****
  1488. --- 174,186 ----
  1489.     size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1)
  1490.         + sizeof (avail_block));
  1491.     av_stk = (avail_block *) alloca (size);
  1492. + #ifdef OS2
  1493. +   if (av_stk == (avail_block *) 0)
  1494. +     {
  1495. +       fprintf (stderr, "Error: alloca() failed in gdbm (%s).\n", __FILE__);
  1496. +       exit (-2);
  1497. +     }
  1498. + #endif /* OS2 */
  1499.   
  1500.     /* Print the stack. */
  1501.     while (FALSE)
  1502. ***************
  1503. *** 102,108 ****
  1504.             av_stk->size, av_stk->count);
  1505.         for (temp = 0; temp < av_stk->count; temp++)
  1506.       {
  1507. !       printf ("  %15d   %10d \n", av_stk->av_table[temp].av_size,
  1508.           av_stk->av_table[temp].av_adr);
  1509.       }
  1510.         temp = av_stk->next_block;
  1511. --- 193,199 ----
  1512.             av_stk->size, av_stk->count);
  1513.         for (temp = 0; temp < av_stk->count; temp++)
  1514.       {
  1515. !       printf ("  %15d   %10ld \n", av_stk->av_table[temp].av_size,
  1516.           av_stk->av_table[temp].av_adr);
  1517.       }
  1518.         temp = av_stk->next_block;
  1519. ***************
  1520. *** 109,115 ****
  1521.       }
  1522.   }
  1523.   
  1524. ! _gdbm_print_bucket_cache (dbf)
  1525.        gdbm_file_info *dbf;
  1526.   {
  1527.     int index;
  1528. --- 200,206 ----
  1529.       }
  1530.   }
  1531.   
  1532. ! void _gdbm_print_bucket_cache (dbf)
  1533.        gdbm_file_info *dbf;
  1534.   {
  1535.     int index;
  1536. ***************
  1537. *** 119,125 ****
  1538.     for (index=0; index < CACHE_SIZE; index++)
  1539.       {
  1540.         changed = dbf->bucket_cache[index].ca_changed;
  1541. !       printf ("  %5d:  %7d  %7s  %x\n",
  1542.             index,
  1543.             dbf->bucket_cache[index].ca_adr,
  1544.             (changed ? "True" : "False"),
  1545. --- 210,216 ----
  1546.     for (index=0; index < CACHE_SIZE; index++)
  1547.       {
  1548.         changed = dbf->bucket_cache[index].ca_changed;
  1549. !       printf ("  %5d:  %7ld  %7s  %lx\n",
  1550.             index,
  1551.             dbf->bucket_cache[index].ca_adr,
  1552.             (changed ? "True" : "False"),
  1553. ***************
  1554. *** 139,144 ****
  1555. --- 230,236 ----
  1556.      The commands are single letter commands.  The user is prompted for all other
  1557.      information.  See the help command (?) for a list of all commands. */
  1558.   
  1559. + void
  1560.   main (argc, argv)
  1561.        int argc;
  1562.        char *argv[];
  1563. ***************
  1564. *** 145,151 ****
  1565.   
  1566.   {
  1567.   
  1568. !   char  cmd_ch;
  1569.   
  1570.     datum key_data;
  1571.     datum data_data;
  1572. --- 237,244 ----
  1573.   
  1574.   {
  1575.   
  1576. !   int  cmd_ch;
  1577. !   int  opt;
  1578.   
  1579.     datum key_data;
  1580.     datum data_data;
  1581. ***************
  1582. *** 155,161 ****
  1583.     char data_line[1000];
  1584.   
  1585.     char done = FALSE;
  1586. -   char opt;
  1587.     char reader = FALSE;
  1588.     char newdb = FALSE;
  1589.   
  1590. --- 248,253 ----
  1591. ***************
  1592. *** 180,186 ****
  1593. --- 272,282 ----
  1594.       }
  1595.     else
  1596.       {
  1597. + #ifdef OS2
  1598. +       file_name = "junk.gdb";
  1599. + #else
  1600.         file_name = "junk.gdbm";
  1601. + #endif
  1602.       }
  1603.   
  1604.     /* Initialize variables. */
  1605. ***************
  1606. *** 195,204 ****
  1607.       gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL);
  1608.     if (gdbm_file == NULL)
  1609.       {
  1610. !       if (gdbm_errno != GDBM_CANT_BE_WRITER)
  1611. !     printf ("gdbm_open failed.\n");
  1612. !       else
  1613. !     printf ("Can't open as a writer. \n");
  1614.         exit (2);
  1615.       }
  1616.   
  1617. --- 291,297 ----
  1618.       gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL);
  1619.     if (gdbm_file == NULL)
  1620.       {
  1621. !       gdbm_perror ("gdbm_open failed");
  1622.         exit (2);
  1623.       }
  1624.   
  1625. ***************
  1626. *** 208,219 ****
  1627.     while (!done)
  1628.       {
  1629.         printf ("com -> ");
  1630. !       cmd_ch = getchar ();
  1631.         if (cmd_ch != '\n')
  1632.       {
  1633.         char temp;
  1634.         do
  1635. !           temp = getchar ();
  1636.         while (temp != '\n' && temp != EOF);
  1637.       }
  1638.         if (cmd_ch == EOF) cmd_ch = 'q';
  1639. --- 301,312 ----
  1640.     while (!done)
  1641.       {
  1642.         printf ("com -> ");
  1643. !       cmd_ch = (char) getchar ();
  1644.         if (cmd_ch != '\n')
  1645.       {
  1646.         char temp;
  1647.         do
  1648. !           temp = (char) getchar ();
  1649.         while (temp != '\n' && temp != EOF);
  1650.       }
  1651.         if (cmd_ch == EOF) cmd_ch = 'q';
  1652. ***************
  1653. *** 250,256 ****
  1654.         key_data.dptr = key_line;
  1655.         key_data.dsize = strlen (key_line)+1;
  1656.         if (gdbm_delete (gdbm_file, key_data) != 0)
  1657. !         printf ("Item not found or deleted\n");
  1658.         printf ("\n");
  1659.         key_data.dptr = NULL;
  1660.         break;
  1661. --- 343,349 ----
  1662.         key_data.dptr = key_line;
  1663.         key_data.dsize = strlen (key_line)+1;
  1664.         if (gdbm_delete (gdbm_file, key_data) != 0)
  1665. !         gdbm_perror ("Item not found or deleted");
  1666.         printf ("\n");
  1667.         key_data.dptr = NULL;
  1668.         break;
  1669. ***************
  1670. *** 289,295 ****
  1671.           }
  1672.         else
  1673.           {
  1674. !           printf ("No such item found.\n\n");
  1675.             key_data.dptr = NULL;
  1676.           }
  1677.         break;
  1678. --- 382,388 ----
  1679.           }
  1680.         else
  1681.           {
  1682. !           gdbm_perror ("No such item found");
  1683.             key_data.dptr = NULL;
  1684.           }
  1685.         break;
  1686. ***************
  1687. *** 308,314 ****
  1688.         gets (data_line);
  1689.         data_data.dsize = strlen (data_line)+1;
  1690.         if (gdbm_store (gdbm_file, key_data, data_data, GDBM_REPLACE) != 0)
  1691. !         printf ("Item not inserted. \n");
  1692.         printf ("\n");
  1693.         key_data.dptr = NULL;
  1694.         break;
  1695. --- 401,407 ----
  1696.         gets (data_line);
  1697.         data_data.dsize = strlen (data_line)+1;
  1698.         if (gdbm_store (gdbm_file, key_data, data_data, GDBM_REPLACE) != 0)
  1699. !         gdbm_perror ("Item not inserted");
  1700.         printf ("\n");
  1701.         key_data.dptr = NULL;
  1702.         break;
  1703. ***************
  1704. *** 324,330 ****
  1705.             free (return_data.dptr);
  1706.           }
  1707.         else
  1708. !         printf ("No such item found.\n\n");
  1709.         break;
  1710.   
  1711.       case '2':
  1712. --- 417,423 ----
  1713.             free (return_data.dptr);
  1714.           }
  1715.         else
  1716. !         gdbm_perror ("No such item found");
  1717.         break;
  1718.   
  1719.       case '2':
  1720. ***************
  1721. *** 339,345 ****
  1722.             free (return_data.dptr);
  1723.           }
  1724.         else
  1725. !         printf ("No such item found.\n\n");
  1726.         break;
  1727.   
  1728.   
  1729. --- 432,438 ----
  1730.             free (return_data.dptr);
  1731.           }
  1732.         else
  1733. !         gdbm_perror ("No such item found");
  1734.         break;
  1735.   
  1736.   
  1737. ***************
  1738. *** 347,353 ****
  1739.       case 'r':
  1740.         {
  1741.           if (gdbm_reorganize (gdbm_file))
  1742. !           printf ("Reorganization failed. \n\n");
  1743.           else
  1744.             printf ("Reorganization succeeded. \n\n");
  1745.         }
  1746. --- 440,446 ----
  1747.       case 'r':
  1748.         {
  1749.           if (gdbm_reorganize (gdbm_file))
  1750. !           gdbm_perror ("Reorganization failed");
  1751.           else
  1752.             printf ("Reorganization succeeded. \n\n");
  1753.         }
  1754. ***************
  1755. *** 369,375 ****
  1756.   
  1757.           if (temp >= gdbm_file->header->dir_size /4)
  1758.             {
  1759. !         printf ("Not a bucket. \n\n");
  1760.           break;
  1761.             }
  1762.           _gdbm_get_bucket (gdbm_file, temp);
  1763. --- 462,468 ----
  1764.   
  1765.           if (temp >= gdbm_file->header->dir_size /4)
  1766.             {
  1767. !         gdbm_perror ("Not a bucket");
  1768.           break;
  1769.             }
  1770.           _gdbm_get_bucket (gdbm_file, temp);
  1771. ***************
  1772. *** 379,385 ****
  1773.       case 'C':
  1774.         print_bucket (gdbm_file->bucket, "Current bucket");
  1775.         printf ("\n current directory entry = %d.\n", gdbm_file->bucket_dir);
  1776. !       printf (" current bucket address  = %d.\n\n",
  1777.             gdbm_file->cache_entry->ca_adr);
  1778.         break;
  1779.   
  1780. --- 472,478 ----
  1781.       case 'C':
  1782.         print_bucket (gdbm_file->bucket, "Current bucket");
  1783.         printf ("\n current directory entry = %d.\n", gdbm_file->bucket_dir);
  1784. !       printf (" current bucket address  = %ld.\n\n",
  1785.             gdbm_file->cache_entry->ca_adr);
  1786.         break;
  1787.   
  1788. ***************
  1789. *** 392,398 ****
  1790.   
  1791.           for (temp = 0; temp < gdbm_file->header->dir_size / 4; temp++)
  1792.             {
  1793. !         printf ("  %10d:  %12d\n", temp, gdbm_file->dir[temp]);
  1794.           if ( (temp+1) % 20 == 0 && isatty (0))
  1795.             {
  1796.               printf ("*** CR to continue: ");
  1797. --- 485,491 ----
  1798.   
  1799.           for (temp = 0; temp < gdbm_file->header->dir_size / 4; temp++)
  1800.             {
  1801. !         printf ("  %10d:  %12ld\n", temp, gdbm_file->dir[temp]);
  1802.           if ( (temp+1) % 20 == 0 && isatty (0))
  1803.             {
  1804.               printf ("*** CR to continue: ");
  1805. ***************
  1806. *** 406,418 ****
  1807.       case 'F':
  1808.         {
  1809.           printf ("\nFile Header: \n\n");
  1810. !         printf ("  table        = %d\n", gdbm_file->header->dir);
  1811.           printf ("  table size   = %d\n", gdbm_file->header->dir_size);
  1812.           printf ("  table bits   = %d\n", gdbm_file->header->dir_bits);
  1813.           printf ("  block size   = %d\n", gdbm_file->header->block_size);
  1814.           printf ("  bucket elems = %d\n", gdbm_file->header->bucket_elems);
  1815.           printf ("  bucket size  = %d\n", gdbm_file->header->bucket_size);
  1816. !         printf ("  header magic = %x\n", gdbm_file->header->header_magic);
  1817.           printf ("  next block   = %d\n", gdbm_file->header->next_block);
  1818.           printf ("  avail size   = %d\n", gdbm_file->header->avail.size);
  1819.           printf ("  avail count  = %d\n", gdbm_file->header->avail.count);
  1820. --- 499,511 ----
  1821.       case 'F':
  1822.         {
  1823.           printf ("\nFile Header: \n\n");
  1824. !         printf ("  table        = %ld\n", gdbm_file->header->dir);
  1825.           printf ("  table size   = %d\n", gdbm_file->header->dir_size);
  1826.           printf ("  table bits   = %d\n", gdbm_file->header->dir_bits);
  1827.           printf ("  block size   = %d\n", gdbm_file->header->block_size);
  1828.           printf ("  bucket elems = %d\n", gdbm_file->header->bucket_elems);
  1829.           printf ("  bucket size  = %d\n", gdbm_file->header->bucket_size);
  1830. !         printf ("  header magic = %lx\n", gdbm_file->header->header_magic);
  1831.           printf ("  next block   = %d\n", gdbm_file->header->next_block);
  1832.           printf ("  avail size   = %d\n", gdbm_file->header->avail.size);
  1833.           printf ("  avail count  = %d\n", gdbm_file->header->avail.count);
  1834. ***************
  1835. *** 427,433 ****
  1836.         gets (key_line);
  1837.         key_data.dptr = key_line;
  1838.         key_data.dsize = strlen (key_line)+1;
  1839. !       printf ("hash value = %x. \n\n", _gdbm_hash (key_data));
  1840.         key_data.dptr = NULL;
  1841.         break;
  1842.   
  1843. --- 520,526 ----
  1844.         gets (key_line);
  1845.         key_data.dptr = key_line;
  1846.         key_data.dsize = strlen (key_line)+1;
  1847. !       printf ("hash value = %lx. \n\n", _gdbm_hash (key_data));
  1848.         key_data.dptr = NULL;
  1849.         break;
  1850.   
  1851. diff -cb orig/testndbm.c gdbm/testndbm.c
  1852. *** orig/testndbm.c    Sun Jan 19 14:44:38 1992
  1853. --- gdbm/testndbm.c    Sun Jan 19 14:43:20 1992
  1854. ***************
  1855. *** 30,36 ****
  1856. --- 30,38 ----
  1857.   
  1858.   #include <stdio.h>
  1859.   #include <sys/types.h>
  1860. + #ifndef OS2
  1861.   #include <sys/file.h>
  1862. + #endif /* not OS2 */
  1863.   #include <sys/stat.h>
  1864.   #ifdef SYSV
  1865.   #include <fcntl.h>
  1866. ***************
  1867. *** 50,61 ****
  1868.      information.  The commands are q (quit), f (fetch), s (store), d (delete),
  1869.      1 (firstkey), n (nextkey) and h (hash function). */
  1870.   
  1871.   main (argc, argv)
  1872.        int argc;
  1873.        char *argv[];
  1874.   {
  1875.   
  1876. !   char  cmd_ch;
  1877.   
  1878.     datum key_data;
  1879.     datum data_data;
  1880. --- 52,64 ----
  1881.      information.  The commands are q (quit), f (fetch), s (store), d (delete),
  1882.      1 (firstkey), n (nextkey) and h (hash function). */
  1883.   
  1884. + void
  1885.   main (argc, argv)
  1886.        int argc;
  1887.        char *argv[];
  1888.   {
  1889.   
  1890. !   int  cmd_ch;
  1891.   
  1892.     datum key_data;
  1893.     datum data_data;
  1894. diff -cb orig/update.c gdbm/update.c
  1895. *** orig/update.c    Sun Jan 19 14:44:40 1992
  1896. --- gdbm/update.c    Thu May 23 20:01:20 1991
  1897. ***************
  1898. *** 31,39 ****
  1899.   #include "gdbmdefs.h"
  1900.   
  1901.   
  1902.   /* This procedure writes the header back to the file described by DBF. */
  1903.   
  1904. ! static
  1905.   write_header (dbf)
  1906.        gdbm_file_info *dbf;
  1907.   {
  1908. --- 31,44 ----
  1909.   #include "gdbmdefs.h"
  1910.   
  1911.   
  1912. + #ifdef __STDC__
  1913. + static void write_header (gdbm_file_info *dbf);
  1914. + #endif /* __STDC__ */
  1915.   /* This procedure writes the header back to the file described by DBF. */
  1916.   
  1917. ! static void
  1918.   write_header (dbf)
  1919.        gdbm_file_info *dbf;
  1920.   {
  1921. ***************
  1922. *** 53,58 ****
  1923. --- 58,64 ----
  1924.   
  1925.   /* After all changes have been made in memory, we now write them
  1926.      all to disk. */
  1927. + void
  1928.   _gdbm_end_update (dbf)
  1929.        gdbm_file_info *dbf;
  1930.   {
  1931. ***************
  1932. *** 103,108 ****
  1933. --- 109,115 ----
  1934.   
  1935.   /* If a fatal error is detected, come here and exit. VAL tells which fatal
  1936.      error occured. */
  1937. + void
  1938.   _gdbm_fatal (dbf, val)
  1939.        gdbm_file_info *dbf;
  1940.        char *val;
  1941.