home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / gnuish / gdbm14.arc / patches < prev    next >
Encoding:
Text File  |  1990-09-22  |  107.2 KB  |  3,518 lines

  1. diff -cBdNp e:/gnu/gdbm/gnu/bucket.c ./bucket.c
  2. *** e:/gnu/gdbm/gnu/bucket.c    Thu Aug 16 10:48:58 1990
  3. --- ./bucket.c    Thu Aug 16 10:50:08 1990
  4. ***************
  5. *** 27,36 ****
  6. --- 27,54 ----
  7.          
  8.   *************************************************************************/
  9.   
  10. + /*
  11. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  12. +  *
  13. +  * To this port, the same copying conditions apply as to the
  14. +  * original release.
  15. +  *
  16. +  * IMPORTANT:
  17. +  * This file is not identical to the original GNU release!
  18. +  * You should have received this code as patch to the official
  19. +  * GNU release.
  20. +  *
  21. +  * MORE IMPORTANT:
  22. +  * This port comes with ABSOLUTELY NO WARRANTY.
  23. +  *
  24. +  * $Header: e:/gnu/gdbm/RCS/bucket.c'v 1.4.0.1 90/08/16 09:22:04 tho Exp $
  25. +  */
  26.   
  27.   #include <stdio.h>
  28.   #include <sys/types.h>
  29. + #ifndef MSDOS
  30.   #include <sys/file.h>
  31. + #endif /* not MSDOS */
  32.   #include <sys/stat.h>
  33.   #include "gdbmdefs.h"
  34.   #include "systems.h"
  35. ***************
  36. *** 37,42 ****
  37. --- 55,61 ----
  38.   
  39.   
  40.   /* Initializing a new hash buckets sets all bucket entries to -1 hash value. */
  41. + VOID
  42.   _gdbm_new_bucket (dbf, bucket, bits)
  43.        gdbm_file_info *dbf;
  44.        hash_bucket *bucket;
  45. *************** _gdbm_new_bucket (dbf, bucket, bits)
  46. *** 63,75 ****
  47.      is already in memory.  If not, a bucket may be tossed to read the new
  48.      bucket.  In any case, the requested bucket is make the "current" bucket
  49.      and dbf->bucket points to the correct bucket. */
  50. ! int
  51.   _gdbm_get_bucket (dbf, dir_index)
  52.        gdbm_file_info *dbf;
  53.        int dir_index;
  54.   {
  55. !   int  bucket_adr;    /* The address of the correct hash bucket.  */
  56. !   int  num_bytes;    /* The number of bytes read. */
  57.     int  index;        /* Loop index. */
  58.   
  59.     /* Initial set up. */
  60. --- 82,94 ----
  61.      is already in memory.  If not, a bucket may be tossed to read the new
  62.      bucket.  In any case, the requested bucket is make the "current" bucket
  63.      and dbf->bucket points to the correct bucket. */
  64. ! VOID
  65.   _gdbm_get_bucket (dbf, dir_index)
  66.        gdbm_file_info *dbf;
  67.        int dir_index;
  68.   {
  69. !   LONG bucket_adr;    /* The address of the correct hash bucket.  */
  70. !   LONG num_bytes;    /* The number of bytes read. */
  71.     int  index;        /* Loop index. */
  72.   
  73.     /* Initial set up. */
  74. *************** _gdbm_get_bucket (dbf, dir_index)
  75. *** 101,107 ****
  76. --- 120,131 ----
  77.         if (num_bytes != bucket_adr)
  78.       _gdbm_fatal (dbf, "lseek error");
  79.   
  80. + #ifdef MSDOS            /* shut up the compiler!  */
  81. +       num_bytes = read (dbf->desc,
  82. +             (char *)dbf->bucket, dbf->header->bucket_size);
  83. + #else /* not MSDOS */
  84.         num_bytes = read (dbf->desc, dbf->bucket, dbf->header->bucket_size);
  85. + #endif /* not MSDOS */
  86.         if (num_bytes != dbf->header->bucket_size)
  87.       _gdbm_fatal (dbf, "read error");
  88.       }
  89. *************** _gdbm_get_bucket (dbf, dir_index)
  90. *** 115,123 ****
  91.      are stored in the buckets.  Splitting the current bucket may require
  92.      doubling the size of the hash directory.  */
  93.   
  94.   _gdbm_split_bucket (dbf, next_insert)
  95.        gdbm_file_info *dbf;
  96. !      int next_insert;
  97.   {
  98.     hash_bucket *bucket[2];     /* Pointers to the new buckets. */
  99.   
  100. --- 139,148 ----
  101.      are stored in the buckets.  Splitting the current bucket may require
  102.      doubling the size of the hash directory.  */
  103.   
  104. + VOID
  105.   _gdbm_split_bucket (dbf, next_insert)
  106.        gdbm_file_info *dbf;
  107. !      LONG next_insert;
  108.   {
  109.     hash_bucket *bucket[2];     /* Pointers to the new buckets. */
  110.   
  111. *************** _gdbm_split_bucket (dbf, next_insert)
  112. *** 124,131 ****
  113.     int          new_bits;    /* The number of bits for the new buckets. */
  114.     int           cache_0;        /* Location in the cache for the buckets. */
  115.     int           cache_1;
  116. !   int           adr_0;        /* File address of the new bucket 0. */
  117. !   int           adr_1;        /* File address of the new bucket 1. */
  118.     avail_elem   old_bucket;    /* Avail Struct for the old bucket. */
  119.   
  120.     int          dir_start0;    /* Used in updating the directory. */
  121. --- 149,156 ----
  122.     int          new_bits;    /* The number of bits for the new buckets. */
  123.     int           cache_0;        /* Location in the cache for the buckets. */
  124.     int           cache_1;
  125. !   LONG           adr_0;        /* File address of the new bucket 0. */
  126. !   LONG           adr_1;        /* File address of the new bucket 1. */
  127.     avail_elem   old_bucket;    /* Avail Struct for the old bucket. */
  128.   
  129.     int          dir_start0;    /* Used in updating the directory. */
  130. *************** _gdbm_split_bucket (dbf, next_insert)
  131. *** 132,141 ****
  132.     int          dir_start1;
  133.     int          dir_end;
  134.   
  135. !   int          *new_dir;        /* Pointer to the new directory. */
  136. !   int          dir_adr;     /* Address of the new directory. */
  137.     int          dir_size;    /* Size of the new directory. */
  138. !   int          old_adr[31];     /* Address of the old directories. */
  139.     int          old_size[31];     /* Size of the old directories. */
  140.     int           old_count;    /* Number of old directories. */
  141.   
  142. --- 157,166 ----
  143.     int          dir_start1;
  144.     int          dir_end;
  145.   
  146. !   LONG          *new_dir;        /* Pointer to the new directory. */
  147. !   LONG         dir_adr;     /* Address of the new directory. */
  148.     int          dir_size;    /* Size of the new directory. */
  149. !   LONG         old_adr[31];     /* Address of the old directories. */
  150.     int          old_size[31];     /* Size of the old directories. */
  151.     int           old_count;    /* Number of old directories. */
  152.   
  153. *************** _gdbm_split_bucket (dbf, next_insert)
  154. *** 185,193 ****
  155.       {
  156.         dir_size = dbf->header->dir_size * 2;
  157.         dir_adr  = _gdbm_alloc (dbf, dir_size);
  158. !       new_dir  = (int *) malloc (dir_size);
  159.         if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error");
  160. !       for (index = 0; index < dbf->header->dir_size/sizeof (int); index++)
  161.           {
  162.             new_dir[2*index]   = dbf->dir[index];
  163.             new_dir[2*index+1] = dbf->dir[index];
  164. --- 210,218 ----
  165.       {
  166.         dir_size = dbf->header->dir_size * 2;
  167.         dir_adr  = _gdbm_alloc (dbf, dir_size);
  168. !       new_dir  = (LONG *) malloc (dir_size);
  169.         if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error");
  170. !       for (index = 0; index < dbf->header->dir_size/sizeof (LONG); index++)
  171.           {
  172.             new_dir[2*index]   = dbf->dir[index];
  173.             new_dir[2*index+1] = dbf->dir[index];
  174. *************** _gdbm_split_bucket (dbf, next_insert)
  175. *** 212,219 ****
  176. --- 237,249 ----
  177.         for (index = 0; index < dbf->header->bucket_elems; index++)
  178.       {
  179.         old_el = & (dbf->bucket->h_table[index]);
  180. + #ifdef MSDOS
  181. +       select = (int) (old_el->hash_value >> (31-new_bits)) & 1;
  182. +       elem_loc = (int) (old_el->hash_value % dbf->header->bucket_elems);
  183. + #else /* not MSDOS */
  184.         select = (old_el->hash_value >> (31-new_bits)) & 1;
  185.         elem_loc = old_el->hash_value % dbf->header->bucket_elems;
  186. + #endif /* not MSDOS */
  187.         while (bucket[select]->h_table[elem_loc].hash_value != -1)
  188.           elem_loc = (elem_loc + 1) % dbf->header->bucket_elems;
  189.         bucket[select]->h_table[elem_loc] = *old_el;
  190. *************** _gdbm_split_bucket (dbf, next_insert)
  191. *** 263,269 ****
  192. --- 293,303 ----
  193.         dbf->second_changed = TRUE;
  194.         
  195.         /* Update the cache! */
  196. + #ifdef MSDOS
  197. +       dbf->bucket_dir = (int) (next_insert >> (31-dbf->header->dir_bits));
  198. + #else /* not MSDOS */
  199.         dbf->bucket_dir = next_insert >> (31-dbf->header->dir_bits);
  200. + #endif /* not MSDOS */
  201.         
  202.         /* Invalidate old cache entry. */
  203.         old_bucket.av_adr  = dbf->cache_entry->ca_adr;
  204. *************** _gdbm_split_bucket (dbf, next_insert)
  205. *** 300,315 ****
  206.   /* The only place where a bucket is written.  CA_ENTRY is the
  207.      cache entry containing the bucket to be written. */
  208.   
  209.   _gdbm_write_bucket (dbf, ca_entry)
  210.        gdbm_file_info *dbf;
  211.        cache_elem *ca_entry;
  212.   {
  213. !   int num_bytes;    /* The return value for lseek and write. */
  214.     
  215.     num_bytes = lseek (dbf->desc, ca_entry->ca_adr, L_SET);
  216.     if (num_bytes != ca_entry->ca_adr)
  217.       _gdbm_fatal (dbf, "lseek error");
  218.     num_bytes = write (dbf->desc, ca_entry->ca_bucket, dbf->header->bucket_size);
  219.     if (num_bytes != dbf->header->bucket_size)
  220.       _gdbm_fatal (dbf, "write error");
  221.     ca_entry->ca_changed = FALSE;
  222. --- 334,355 ----
  223.   /* The only place where a bucket is written.  CA_ENTRY is the
  224.      cache entry containing the bucket to be written. */
  225.   
  226. + VOID
  227.   _gdbm_write_bucket (dbf, ca_entry)
  228.        gdbm_file_info *dbf;
  229.        cache_elem *ca_entry;
  230.   {
  231. !   LONG num_bytes;    /* The return value for lseek and write. */
  232.     
  233.     num_bytes = lseek (dbf->desc, ca_entry->ca_adr, L_SET);
  234.     if (num_bytes != ca_entry->ca_adr)
  235.       _gdbm_fatal (dbf, "lseek error");
  236. + #ifdef MSDOS            /* shut up the compiler!   */
  237. +   num_bytes = write (dbf->desc,
  238. +              (char *)ca_entry->ca_bucket, dbf->header->bucket_size);
  239. + #else /* not MSDOS */
  240.     num_bytes = write (dbf->desc, ca_entry->ca_bucket, dbf->header->bucket_size);
  241. + #endif /* not MSDOS */
  242.     if (num_bytes != dbf->header->bucket_size)
  243.       _gdbm_fatal (dbf, "write error");
  244.     ca_entry->ca_changed = FALSE;
  245. diff -cBdNp e:/gnu/gdbm/gnu/dbm.h ./dbm.h
  246. *** e:/gnu/gdbm/gnu/dbm.h    Thu Aug 16 10:49:02 1990
  247. --- ./dbm.h    Thu Aug 16 10:50:10 1990
  248. ***************
  249. *** 27,32 ****
  250. --- 27,49 ----
  251.          
  252.   *************************************************************************/
  253.   
  254. + /*
  255. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  256. +  *
  257. +  * To this port, the same copying conditions apply as to the
  258. +  * original release.
  259. +  *
  260. +  * IMPORTANT:
  261. +  * This file is not identical to the original GNU release!
  262. +  * You should have received this code as patch to the official
  263. +  * GNU release.
  264. +  *
  265. +  * MORE IMPORTANT:
  266. +  * This port comes with ABSOLUTELY NO WARRANTY.
  267. +  *
  268. +  * $Header: e:/gnu/gdbm/RCS/dbm.h'v 1.4.0.1 90/08/16 09:22:56 tho Exp $
  269. +  */
  270.   /* The data and key structure.  This structure is defined for compatibility. */
  271.   typedef struct {
  272.       char *dptr;
  273. *************** typedef struct {
  274. *** 34,55 ****
  275.         } datum;
  276.   
  277.   
  278. - /* These are the routines in dbm. */
  279.   
  280. ! extern int    dbminit ();
  281.   
  282.   extern datum    fetch ();
  283.   extern int    store ();
  284. - extern int    delete ();
  285.   extern int    delete ();
  286.   extern datum    firstkey ();
  287.   extern datum    nextkey ();
  288. ! /* To make some versions work we need the following define. */
  289. ! #define dbmclose()
  290. --- 51,73 ----
  291.         } datum;
  292.   
  293.   
  294.   
  295. ! /* To make some versions work we need the following define. */
  296.   
  297. + #define dbmclose()
  298. + /* These are the routines in dbm. */
  299. + #ifdef __STDC__
  300. + extern  int dbminit (char *file);
  301. + extern datum fetch(datum key);
  302. + extern int store (datum key, datum content);
  303. + extern int delete (datum key);
  304. + extern datum firstkey (void);
  305. + extern datum nextkey (datum key);
  306. + #else /* not __STDC__ */
  307. + extern int    dbminit ();
  308.   extern datum    fetch ();
  309.   extern int    store ();
  310.   extern int    delete ();
  311.   extern datum    firstkey ();
  312.   extern datum    nextkey ();
  313. ! #endif /* not __STDC__ */
  314. diff -cBdNp e:/gnu/gdbm/gnu/dbmclose.c ./dbmclose.c
  315. *** e:/gnu/gdbm/gnu/dbmclose.c    Thu Aug 16 10:49:04 1990
  316. --- ./dbmclose.c    Thu Aug 16 10:50:12 1990
  317. ***************
  318. *** 27,36 ****
  319. --- 27,54 ----
  320.          
  321.   *************************************************************************/
  322.   
  323. + /*
  324. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  325. +  *
  326. +  * To this port, the same copying conditions apply as to the
  327. +  * original release.
  328. +  *
  329. +  * IMPORTANT:
  330. +  * This file is not identical to the original GNU release!
  331. +  * You should have received this code as patch to the official
  332. +  * GNU release.
  333. +  *
  334. +  * MORE IMPORTANT:
  335. +  * This port comes with ABSOLUTELY NO WARRANTY.
  336. +  *
  337. +  * $Header: e:/gnu/gdbm/RCS/dbmclose.c'v 1.4.0.1 90/08/16 09:22:06 tho Exp $
  338. +  */
  339.   
  340.   #include <stdio.h>
  341.   #include <sys/types.h>
  342. + #ifndef MSDOS
  343.   #include <sys/file.h>
  344. + #endif /* not MSDOS */
  345.   #include <sys/stat.h>
  346.   #include "gdbmdefs.h"
  347.   #include "systems.h"
  348. diff -cBdNp e:/gnu/gdbm/gnu/dbmdelet.c ./dbmdelet.c
  349. *** e:/gnu/gdbm/gnu/dbmdelet.c    Thu Aug 16 10:49:04 1990
  350. --- ./dbmdelet.c    Thu Aug 16 10:50:14 1990
  351. ***************
  352. *** 28,37 ****
  353. --- 28,55 ----
  354.          
  355.   *************************************************************************/
  356.   
  357. + /*
  358. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  359. +  *
  360. +  * To this port, the same copying conditions apply as to the
  361. +  * original release.
  362. +  *
  363. +  * IMPORTANT:
  364. +  * This file is not identical to the original GNU release!
  365. +  * You should have received this code as patch to the official
  366. +  * GNU release.
  367. +  *
  368. +  * MORE IMPORTANT:
  369. +  * This port comes with ABSOLUTELY NO WARRANTY.
  370. +  *
  371. +  * $Header: e:/gnu/gdbm/RCS/dbmdelet.c'v 1.4.0.1 90/08/16 09:22:08 tho Exp $
  372. +  */
  373.   
  374.   #include <stdio.h>
  375.   #include <sys/types.h>
  376. + #ifndef MSDOS
  377.   #include <sys/file.h>
  378. + #endif /* not MSDOS */
  379.   #include <sys/stat.h>
  380.   #include "gdbmdefs.h"
  381.   #include "extern.h"
  382. diff -cBdNp e:/gnu/gdbm/gnu/dbmdirfn.c ./dbmdirfn.c
  383. *** e:/gnu/gdbm/gnu/dbmdirfn.c    Thu Aug 16 10:49:06 1990
  384. --- ./dbmdirfn.c    Thu Aug 16 10:50:16 1990
  385. ***************
  386. *** 27,36 ****
  387. --- 27,54 ----
  388.          
  389.   *************************************************************************/
  390.   
  391. + /*
  392. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  393. +  *
  394. +  * To this port, the same copying conditions apply as to the
  395. +  * original release.
  396. +  *
  397. +  * IMPORTANT:
  398. +  * This file is not identical to the original GNU release!
  399. +  * You should have received this code as patch to the official
  400. +  * GNU release.
  401. +  *
  402. +  * MORE IMPORTANT:
  403. +  * This port comes with ABSOLUTELY NO WARRANTY.
  404. +  *
  405. +  * $Header: e:/gnu/gdbm/RCS/dbmdirfn.c'v 1.4.0.1 90/08/16 09:22:09 tho Exp $
  406. +  */
  407.   
  408.   #include <stdio.h>
  409.   #include <sys/types.h>
  410. + #ifndef MSDOS
  411.   #include <sys/file.h>
  412. + #endif /* not MSDOS */
  413.   #include <sys/stat.h>
  414.   #include "gdbmdefs.h"
  415.   #include "systems.h"
  416. diff -cBdNp e:/gnu/gdbm/gnu/dbmfetch.c ./dbmfetch.c
  417. *** e:/gnu/gdbm/gnu/dbmfetch.c    Thu Aug 16 10:49:08 1990
  418. --- ./dbmfetch.c    Thu Aug 16 10:50:18 1990
  419. ***************
  420. *** 27,36 ****
  421. --- 27,54 ----
  422.          
  423.   *************************************************************************/
  424.   
  425. + /*
  426. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  427. +  *
  428. +  * To this port, the same copying conditions apply as to the
  429. +  * original release.
  430. +  *
  431. +  * IMPORTANT:
  432. +  * This file is not identical to the original GNU release!
  433. +  * You should have received this code as patch to the official
  434. +  * GNU release.
  435. +  *
  436. +  * MORE IMPORTANT:
  437. +  * This port comes with ABSOLUTELY NO WARRANTY.
  438. +  *
  439. +  * $Header: e:/gnu/gdbm/RCS/dbmfetch.c'v 1.4.0.1 90/08/16 09:22:10 tho Exp $
  440. +  */
  441.   
  442.   #include <stdio.h>
  443.   #include <sys/types.h>
  444. + #ifndef MSDOS
  445.   #include <sys/file.h>
  446. + #endif /* not MSDOS */
  447.   #include <sys/stat.h>
  448.   #include "gdbmdefs.h"
  449.   #include "extern.h"
  450. diff -cBdNp e:/gnu/gdbm/gnu/dbminit.c ./dbminit.c
  451. *** e:/gnu/gdbm/gnu/dbminit.c    Thu Aug 16 10:49:10 1990
  452. --- ./dbminit.c    Thu Aug 16 10:50:20 1990
  453. ***************
  454. *** 28,37 ****
  455. --- 28,55 ----
  456.          
  457.   *************************************************************************/
  458.   
  459. + /*
  460. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  461. +  *
  462. +  * To this port, the same copying conditions apply as to the
  463. +  * original release.
  464. +  *
  465. +  * IMPORTANT:
  466. +  * This file is not identical to the original GNU release!
  467. +  * You should have received this code as patch to the official
  468. +  * GNU release.
  469. +  *
  470. +  * MORE IMPORTANT:
  471. +  * This port comes with ABSOLUTELY NO WARRANTY.
  472. +  *
  473. +  * $Header: e:/gnu/gdbm/RCS/dbminit.c'v 1.4.0.1 90/08/16 09:22:11 tho Exp $
  474. +  */
  475.   
  476.   #include <stdio.h>
  477.   #include <sys/types.h>
  478. + #ifndef MSDOS
  479.   #include <sys/file.h>
  480. + #endif /* not MSDOS */
  481.   #include <sys/stat.h>
  482.   #include "gdbmdefs.h"
  483.   #include "systems.h"
  484. *************** dbminit (file)
  485. *** 92,98 ****
  486. --- 110,120 ----
  487.     if (stat (dir_file, &dir_stat) == 0)
  488.       {
  489.         if (dir_stat.st_size == 0)
  490. + #ifdef MSDOS
  491. +         if (open (dir_file, O_RDWR|O_TRUNC, S_IREAD|S_IWRITE) < 0)
  492. + #else /* not MSDOS */
  493.       if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0)
  494. + #endif /* not MSDOS */
  495.         {
  496.           gdbm_errno = GDBM_FILE_OPEN_ERROR;
  497.           gdbm_close (_gdbm_file);
  498. *************** dbminit (file)
  499. *** 103,109 ****
  500. --- 125,135 ----
  501.       {
  502.         /* Since we can't stat it, we assume it is not there and try
  503.            to link the dir_file to the pag_file. */
  504. + #ifdef MSDOS
  505. +       if (open (dir_file, O_RDWR|O_CREAT, S_IREAD|S_IWRITE) < 0)
  506. + #else /* not MSDOS */
  507.         if (link (pag_file, dir_file) != 0)
  508. + #endif /* not MSDOS */
  509.       {
  510.         gdbm_errno = GDBM_FILE_OPEN_ERROR;
  511.         gdbm_close (_gdbm_file);
  512. *************** dbminit (file)
  513. *** 110,115 ****
  514.         return -1;
  515.       }
  516.       }
  517. !         
  518.     return 0;
  519.   }
  520. --- 136,141 ----
  521.         return -1;
  522.       }
  523.       }
  524.     return 0;
  525.   }
  526. diff -cBdNp e:/gnu/gdbm/gnu/dbmopen.c ./dbmopen.c
  527. *** e:/gnu/gdbm/gnu/dbmopen.c    Thu Aug 16 10:49:12 1990
  528. --- ./dbmopen.c    Thu Aug 16 10:50:22 1990
  529. ***************
  530. *** 28,37 ****
  531. --- 28,55 ----
  532.          
  533.   *************************************************************************/
  534.   
  535. + /*
  536. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  537. +  *
  538. +  * To this port, the same copying conditions apply as to the
  539. +  * original release.
  540. +  *
  541. +  * IMPORTANT:
  542. +  * This file is not identical to the original GNU release!
  543. +  * You should have received this code as patch to the official
  544. +  * GNU release.
  545. +  *
  546. +  * MORE IMPORTANT:
  547. +  * This port comes with ABSOLUTELY NO WARRANTY.
  548. +  *
  549. +  * $Header: e:/gnu/gdbm/RCS/dbmopen.c'v 1.4.0.1 90/08/16 09:22:12 tho Exp $
  550. +  */
  551.   
  552.   #include <stdio.h>
  553.   #include <sys/types.h>
  554. + #ifndef MSDOS
  555.   #include <sys/file.h>
  556. + #endif /* not MSDOS */
  557.   #include <sys/stat.h>
  558.   #include "gdbmdefs.h"
  559.   #include "systems.h"
  560. *************** dbm_open (file, flags, mode)
  561. *** 110,116 ****
  562. --- 129,139 ----
  563.     if (stat (dir_file, &dir_stat) == 0)
  564.       {
  565.         if (dir_stat.st_size == 0)
  566. + #ifdef MSDOS
  567. +         if (open (dir_file, O_RDWR|O_TRUNC, S_IREAD|S_IWRITE) < 0)
  568. + #else /* not MSDOS */
  569.       if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0)
  570. + #endif /* not MSDOS */
  571.         {
  572.           gdbm_errno = GDBM_FILE_OPEN_ERROR;
  573.           gdbm_close (temp_dbf);
  574. *************** dbm_open (file, flags, mode)
  575. *** 121,127 ****
  576. --- 144,154 ----
  577.       {
  578.         /* Since we can't stat it, we assume it is not there and try
  579.            to link the dir_file to the pag_file. */
  580. + #ifdef MSDOS
  581. +       if (open (dir_file, O_RDWR|O_CREAT, S_IREAD|S_IWRITE) < 0)
  582. + #else /* not MSDOS */
  583.         if (link (pag_file, dir_file) != 0)
  584. + #endif /* not MSDOS */
  585.       {
  586.         gdbm_errno = GDBM_FILE_OPEN_ERROR;
  587.         gdbm_close (temp_dbf);
  588. *************** dbm_open (file, flags, mode)
  589. *** 128,133 ****
  590.         return NULL;
  591.       }
  592.       }
  593. !         
  594.     return temp_dbf;
  595.   }
  596. --- 155,160 ----
  597.         return NULL;
  598.       }
  599.       }
  600.     return temp_dbf;
  601.   }
  602. diff -cBdNp e:/gnu/gdbm/gnu/dbmpagfn.c ./dbmpagfn.c
  603. *** e:/gnu/gdbm/gnu/dbmpagfn.c    Thu Aug 16 10:49:12 1990
  604. --- ./dbmpagfn.c    Thu Aug 16 10:50:24 1990
  605. ***************
  606. *** 27,36 ****
  607. --- 27,54 ----
  608.          
  609.   *************************************************************************/
  610.   
  611. + /*
  612. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  613. +  *
  614. +  * To this port, the same copying conditions apply as to the
  615. +  * original release.
  616. +  *
  617. +  * IMPORTANT:
  618. +  * This file is not identical to the original GNU release!
  619. +  * You should have received this code as patch to the official
  620. +  * GNU release.
  621. +  *
  622. +  * MORE IMPORTANT:
  623. +  * This port comes with ABSOLUTELY NO WARRANTY.
  624. +  *
  625. +  * $Header: e:/gnu/gdbm/RCS/dbmpagfn.c'v 1.4.0.1 90/08/16 09:22:14 tho Exp $
  626. +  */
  627.   
  628.   #include <stdio.h>
  629.   #include <sys/types.h>
  630. + #ifndef MSDOS
  631.   #include <sys/file.h>
  632. + #endif /* not MSDOS */
  633.   #include <sys/stat.h>
  634.   #include "gdbmdefs.h"
  635.   #include "systems.h"
  636. diff -cBdNp e:/gnu/gdbm/gnu/dbmseq.c ./dbmseq.c
  637. *** e:/gnu/gdbm/gnu/dbmseq.c    Thu Aug 16 10:49:14 1990
  638. --- ./dbmseq.c    Thu Aug 16 10:50:26 1990
  639. ***************
  640. *** 28,37 ****
  641. --- 28,55 ----
  642.          
  643.   *************************************************************************/
  644.   
  645. + /*
  646. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  647. +  *
  648. +  * To this port, the same copying conditions apply as to the
  649. +  * original release.
  650. +  *
  651. +  * IMPORTANT:
  652. +  * This file is not identical to the original GNU release!
  653. +  * You should have received this code as patch to the official
  654. +  * GNU release.
  655. +  *
  656. +  * MORE IMPORTANT:
  657. +  * This port comes with ABSOLUTELY NO WARRANTY.
  658. +  *
  659. +  * $Header: e:/gnu/gdbm/RCS/dbmseq.c'v 1.4.0.1 90/08/16 09:22:15 tho Exp $
  660. +  */
  661.   
  662.   #include <stdio.h>
  663.   #include <sys/types.h>
  664. + #ifndef MSDOS
  665.   #include <sys/file.h>
  666. + #endif /* not MSDOS */
  667.   #include <sys/stat.h>
  668.   #include "gdbmdefs.h"
  669.   #include "extern.h"
  670. diff -cBdNp e:/gnu/gdbm/gnu/dbmstore.c ./dbmstore.c
  671. *** e:/gnu/gdbm/gnu/dbmstore.c    Thu Aug 16 10:49:16 1990
  672. --- ./dbmstore.c    Thu Aug 16 10:50:28 1990
  673. ***************
  674. *** 27,36 ****
  675. --- 27,54 ----
  676.          
  677.   *************************************************************************/
  678.   
  679. + /*
  680. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  681. +  *
  682. +  * To this port, the same copying conditions apply as to the
  683. +  * original release.
  684. +  *
  685. +  * IMPORTANT:
  686. +  * This file is not identical to the original GNU release!
  687. +  * You should have received this code as patch to the official
  688. +  * GNU release.
  689. +  *
  690. +  * MORE IMPORTANT:
  691. +  * This port comes with ABSOLUTELY NO WARRANTY.
  692. +  *
  693. +  * $Header: e:/gnu/gdbm/RCS/dbmstore.c'v 1.4.0.1 90/08/16 09:22:17 tho Exp $
  694. +  */
  695.   
  696.   #include <stdio.h>
  697.   #include <sys/types.h>
  698. + #ifndef MSDOS
  699.   #include <sys/file.h>
  700. + #endif /* not MSDOS */
  701.   #include <sys/stat.h>
  702.   #include "gdbmdefs.h"
  703.   #include "extern.h"
  704. diff -cBdNp e:/gnu/gdbm/gnu/delete.c ./delete.c
  705. *** e:/gnu/gdbm/gnu/delete.c    Thu Aug 16 10:49:18 1990
  706. --- ./delete.c    Thu Aug 16 10:50:30 1990
  707. ***************
  708. *** 28,37 ****
  709. --- 28,55 ----
  710.          
  711.   *************************************************************************/
  712.   
  713. + /*
  714. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  715. +  *
  716. +  * To this port, the same copying conditions apply as to the
  717. +  * original release.
  718. +  *
  719. +  * IMPORTANT:
  720. +  * This file is not identical to the original GNU release!
  721. +  * You should have received this code as patch to the official
  722. +  * GNU release.
  723. +  *
  724. +  * MORE IMPORTANT:
  725. +  * This port comes with ABSOLUTELY NO WARRANTY.
  726. +  *
  727. +  * $Header: e:/gnu/gdbm/RCS/delete.c'v 1.4.0.1 90/08/16 09:22:18 tho Exp $
  728. +  */
  729.   
  730.   #include <stdio.h>
  731.   #include <sys/types.h>
  732. + #ifndef MSDOS
  733.   #include <sys/file.h>
  734. + #endif /* not MSDOS */
  735.   #include <sys/stat.h>
  736.   #include "gdbmdefs.h"
  737.   #include "extern.h"
  738. diff -cBdNp e:/gnu/gdbm/gnu/extern.h ./extern.h
  739. *** e:/gnu/gdbm/gnu/extern.h    Thu Aug 16 10:49:20 1990
  740. --- ./extern.h    Thu Aug 16 10:50:32 1990
  741. ***************
  742. *** 27,32 ****
  743. --- 27,48 ----
  744.          
  745.   *************************************************************************/
  746.   
  747. + /*
  748. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  749. +  *
  750. +  * To this port, the same copying conditions apply as to the
  751. +  * original release.
  752. +  *
  753. +  * IMPORTANT:
  754. +  * This file is not identical to the original GNU release!
  755. +  * You should have received this code as patch to the official
  756. +  * GNU release.
  757. +  *
  758. +  * MORE IMPORTANT:
  759. +  * This port comes with ABSOLUTELY NO WARRANTY.
  760. +  *
  761. +  * $Header: e:/gnu/gdbm/RCS/extern.h'v 1.4.0.1 90/08/16 09:22:57 tho Exp $
  762. +  */
  763.   
  764.   /* The global variables used for the "original" interface. */
  765.   extern gdbm_file_info  *_gdbm_file;
  766. *************** extern char *_gdbm_fetch_val;
  767. *** 37,51 ****
  768.   
  769.   
  770.   /* External routines used. */
  771.   extern gdbm_file_info *gdbm_open ();
  772.   extern datum gdbm_fetch ();
  773.   extern datum gdbm_firstkey ();
  774.   extern datum gdbm_nextkey ();
  775.   extern int gdbm_delete ();
  776.   extern int gdbm_store ();
  777. --- 53,70 ----
  778.   
  779.   
  780.   /* External routines used. */
  781. ! #ifdef __STDC__
  782. ! extern gdbm_file_info *gdbm_open (char *file, int block_size, int read_write, int mode, void (*fatal_func)());
  783. ! extern datum gdbm_fetch (gdbm_file_info *dbf, datum key);
  784. ! extern datum gdbm_firstkey (gdbm_file_info *dbf);
  785. ! extern datum gdbm_nextkey (gdbm_file_info *dbf, datum key);
  786. ! extern int gdbm_delete (gdbm_file_info *dbf, datum key);
  787. ! extern int gdbm_reorganize (gdbm_file_info *dbf);
  788. ! #else /* not __STDC__ */
  789.   extern gdbm_file_info *gdbm_open ();
  790.   extern datum gdbm_fetch ();
  791.   extern datum gdbm_firstkey ();
  792.   extern datum gdbm_nextkey ();
  793.   extern int gdbm_delete ();
  794.   extern int gdbm_store ();
  795. + #endif /* not __STDC__ */
  796. diff -cBdNp e:/gnu/gdbm/gnu/falloc.c ./falloc.c
  797. *** e:/gnu/gdbm/gnu/falloc.c    Thu Aug 16 10:49:22 1990
  798. --- ./falloc.c    Thu Aug 16 10:50:36 1990
  799. ***************
  800. *** 27,45 ****
  801. --- 27,72 ----
  802.          
  803.   *************************************************************************/
  804.   
  805. + /*
  806. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  807. +  *
  808. +  * To this port, the same copying conditions apply as to the
  809. +  * original release.
  810. +  *
  811. +  * IMPORTANT:
  812. +  * This file is not identical to the original GNU release!
  813. +  * You should have received this code as patch to the official
  814. +  * GNU release.
  815. +  *
  816. +  * MORE IMPORTANT:
  817. +  * This port comes with ABSOLUTELY NO WARRANTY.
  818. +  *
  819. +  * $Header: e:/gnu/gdbm/RCS/falloc.c'v 1.4.0.1 90/08/16 09:22:19 tho Exp $
  820. +  */
  821.   #include <stdio.h>
  822.   #include <sys/types.h>
  823. + #ifndef MSDOS
  824.   #include <sys/file.h>
  825. + #endif /* not MSDOS */
  826.   #include <sys/stat.h>
  827.   #include "gdbmdefs.h"
  828.   #include "systems.h"
  829.   
  830.   
  831. + #ifdef __STDC__
  832. + static avail_elem get_elem (int size, avail_elem *av_table, int *av_count);
  833. + static avail_elem get_block (int size, gdbm_file_info *dbf);
  834. + static VOID push_avail_block (gdbm_file_info *dbf);
  835. + static VOID pop_avail_block (gdbm_file_info *dbf);
  836. + static VOID adjust_bucket_avail (gdbm_file_info *dbf);
  837. + #else /* not __STDC__ */
  838.   static avail_elem get_elem ();    /* Get avail_elems from a list. */
  839.   static avail_elem get_block ();
  840.   static push_avail_block ();
  841.   static pop_avail_block ();
  842.   static adjust_bucket_avail ();
  843. + #endif /* not __STDC__ */
  844.   
  845.   /* Allocate space in the file DBF for a block NUM_BYTES in length.  Return
  846.      the file address of the start of the block.  
  847. *************** static adjust_bucket_avail ();
  848. *** 57,68 ****
  849.      changed by this routine if a change is needed.  If an error occurs,
  850.      the value of 0 will be returned.  */
  851.   
  852. ! int
  853.   _gdbm_alloc (dbf, num_bytes)
  854.        gdbm_file_info *dbf;
  855.        int num_bytes;
  856.   {
  857. !   int file_adr;            /* The address of the block. */
  858.     avail_elem av_el;        /* For temporary use. */
  859.   
  860.     /* The current bucket is the first place to look for space. */
  861. --- 84,95 ----
  862.      changed by this routine if a change is needed.  If an error occurs,
  863.      the value of 0 will be returned.  */
  864.   
  865. ! LONG
  866.   _gdbm_alloc (dbf, num_bytes)
  867.        gdbm_file_info *dbf;
  868.        int num_bytes;
  869.   {
  870. !   LONG file_adr;            /* The address of the block. */
  871.     avail_elem av_el;        /* For temporary use. */
  872.   
  873.     /* The current bucket is the first place to look for space. */
  874. *************** _gdbm_alloc (dbf, num_bytes)
  875. *** 104,110 ****
  876.   
  877.   _gdbm_free (dbf, file_adr, num_bytes)
  878.        gdbm_file_info *dbf;
  879. !      int file_adr;
  880.        int num_bytes;
  881.   {
  882.     avail_elem temp;
  883. --- 131,137 ----
  884.   
  885.   _gdbm_free (dbf, file_adr, num_bytes)
  886.        gdbm_file_info *dbf;
  887. !      LONG file_adr;
  888.        int num_bytes;
  889.   {
  890.     avail_elem temp;
  891. *************** _gdbm_free (dbf, file_adr, num_bytes)
  892. *** 111,117 ****
  893.   
  894.     /* Is it too small to worry about? */
  895.     if (num_bytes <= IGNORE_SIZE)
  896. !     return;
  897.   
  898.     /* Initialize the avail element. */
  899.     temp.av_size = num_bytes;
  900. --- 138,144 ----
  901.   
  902.     /* Is it too small to worry about? */
  903.     if (num_bytes <= IGNORE_SIZE)
  904. !     return TRUE;        /* is that correct (was "return;")? -tho */
  905.   
  906.     /* Initialize the avail element. */
  907.     temp.av_size = num_bytes;
  908. *************** _gdbm_free (dbf, file_adr, num_bytes)
  909. *** 150,156 ****
  910.       adjust_bucket_avail (dbf);
  911.   
  912.     /* All work is done. */
  913. !   return;
  914.   }
  915.   
  916.   
  917. --- 177,183 ----
  918.       adjust_bucket_avail (dbf);
  919.   
  920.     /* All work is done. */
  921. !   return TRUE;            /* is that correct (was "return;")? -tho */
  922.   }
  923.   
  924.   
  925. *************** _gdbm_free (dbf, file_adr, num_bytes)
  926. *** 162,172 ****
  927.   /* Gets the avail block at the top of the stack and loads it into the
  928.      active avail block.  It does a "free" for itself! */
  929.   
  930. ! static
  931.   pop_avail_block (dbf)
  932.        gdbm_file_info *dbf;
  933.   {
  934. !   int num_bytes;        /* For reading. */
  935.     avail_elem temp;
  936.   
  937.     /* Set up variables. */
  938. --- 189,199 ----
  939.   /* Gets the avail block at the top of the stack and loads it into the
  940.      active avail block.  It does a "free" for itself! */
  941.   
  942. ! static VOID
  943.   pop_avail_block (dbf)
  944.        gdbm_file_info *dbf;
  945.   {
  946. !   LONG num_bytes;        /* For reading. */
  947.     avail_elem temp;
  948.   
  949.     /* Set up variables. */
  950. *************** pop_avail_block (dbf)
  951. *** 177,183 ****
  952. --- 204,215 ----
  953.     /* Read the block. */
  954.     num_bytes = lseek (dbf->desc, temp.av_adr, L_SET);
  955.     if (num_bytes != temp.av_adr)  _gdbm_fatal (dbf, "lseek error");
  956. + #ifdef MSDOS            /* shut up the compiler!  */
  957. +   num_bytes = read (dbf->desc,
  958. +             (char *) &dbf->header->avail, temp.av_size);
  959. + #else /* not MSDOS */
  960.     num_bytes = read (dbf->desc, &dbf->header->avail, temp.av_size);
  961. + #endif /* not MSDOS */
  962.     if (num_bytes != temp.av_size) _gdbm_fatal (dbf, "read error");
  963.   
  964.     /* We changed the header. */
  965. *************** pop_avail_block (dbf)
  966. *** 191,203 ****
  967.   
  968.   /* Splits the header avail block and pushes half onto the avail stack. */
  969.   
  970. ! static
  971.   push_avail_block (dbf)
  972.        gdbm_file_info *dbf;
  973.   {
  974. !   int num_bytes;
  975.     int av_size;
  976. !   int av_adr;
  977.     int index;
  978.     avail_block *temp;
  979.     avail_elem  new_loc;
  980. --- 223,235 ----
  981.   
  982.   /* Splits the header avail block and pushes half onto the avail stack. */
  983.   
  984. ! static VOID
  985.   push_avail_block (dbf)
  986.        gdbm_file_info *dbf;
  987.   {
  988. !   LONG num_bytes;
  989.     int av_size;
  990. !   LONG av_adr;
  991.     int index;
  992.     avail_block *temp;
  993.     avail_elem  new_loc;
  994. *************** push_avail_block (dbf)
  995. *** 217,222 ****
  996. --- 249,261 ----
  997.   
  998.     /* Split the header block. */
  999.     temp = (avail_block *) alloca (av_size);
  1000. + #ifdef MSDOS
  1001. +   if (temp == (avail_block *) 0)
  1002. +     {
  1003. +       fprintf (stderr, "alloca failed.\n");
  1004. +       exit (-2);
  1005. +     }
  1006. + #endif /* MSDOS */
  1007.     /* Set the size to be correct AFTER the pop_avail_block. */
  1008.     temp->size = dbf->header->avail.size;
  1009.     temp->count = 0;
  1010. *************** push_avail_block (dbf)
  1011. *** 241,247 ****
  1012. --- 280,291 ----
  1013.     /* Update the disk. */
  1014.     num_bytes = lseek (dbf->desc, av_adr, L_SET);
  1015.     if (num_bytes != av_adr) _gdbm_fatal (dbf, "lseek error");
  1016. + #ifdef MSDOS            /* shut up the compiler!   */
  1017. +   num_bytes = write (dbf->desc, (char *) temp, av_size);
  1018. + #else /* not MSDOS */
  1019.     num_bytes = write (dbf->desc, temp, av_size);
  1020. + #endif /* not MSDOS */
  1021.     if (num_bytes != av_size) _gdbm_fatal (dbf, "write error");
  1022.   
  1023.   }
  1024. *************** get_block (size, dbf)
  1025. *** 368,374 ****
  1026.   
  1027.   /*  When the header already needs writing, we can make sure the current
  1028.       bucket has its avail block as close to 1/2 full as possible. */
  1029. ! static
  1030.   adjust_bucket_avail (dbf)
  1031.        gdbm_file_info *dbf;
  1032.   {
  1033. --- 412,418 ----
  1034.   
  1035.   /*  When the header already needs writing, we can make sure the current
  1036.       bucket has its avail block as close to 1/2 full as possible. */
  1037. ! static VOID
  1038.   adjust_bucket_avail (dbf)
  1039.        gdbm_file_info *dbf;
  1040.   {
  1041. diff -cBdNp e:/gnu/gdbm/gnu/fetch.c ./fetch.c
  1042. *** e:/gnu/gdbm/gnu/fetch.c    Thu Aug 16 10:49:24 1990
  1043. --- ./fetch.c    Thu Aug 16 10:50:38 1990
  1044. ***************
  1045. *** 27,36 ****
  1046. --- 27,54 ----
  1047.          
  1048.   *************************************************************************/
  1049.   
  1050. + /*
  1051. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1052. +  *
  1053. +  * To this port, the same copying conditions apply as to the
  1054. +  * original release.
  1055. +  *
  1056. +  * IMPORTANT:
  1057. +  * This file is not identical to the original GNU release!
  1058. +  * You should have received this code as patch to the official
  1059. +  * GNU release.
  1060. +  *
  1061. +  * MORE IMPORTANT:
  1062. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1063. +  *
  1064. +  * $Header: e:/gnu/gdbm/RCS/fetch.c'v 1.4.0.1 90/08/16 09:22:21 tho Exp $
  1065. +  */
  1066.   
  1067.   #include <stdio.h>
  1068.   #include <sys/types.h>
  1069. + #ifndef MSDOS
  1070.   #include <sys/file.h>
  1071. + #endif /* not MSDOS */
  1072.   #include <sys/stat.h>
  1073.   #include "gdbmdefs.h"
  1074.   #include "extern.h"
  1075. diff -cBdNp e:/gnu/gdbm/gnu/findkey.c ./findkey.c
  1076. *** e:/gnu/gdbm/gnu/findkey.c    Thu Aug 16 10:49:26 1990
  1077. --- ./findkey.c    Thu Aug 16 10:50:40 1990
  1078. ***************
  1079. *** 27,36 ****
  1080. --- 27,54 ----
  1081.          
  1082.   *************************************************************************/
  1083.   
  1084. + /*
  1085. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1086. +  *
  1087. +  * To this port, the same copying conditions apply as to the
  1088. +  * original release.
  1089. +  *
  1090. +  * IMPORTANT:
  1091. +  * This file is not identical to the original GNU release!
  1092. +  * You should have received this code as patch to the official
  1093. +  * GNU release.
  1094. +  *
  1095. +  * MORE IMPORTANT:
  1096. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1097. +  *
  1098. +  * $Header: e:/gnu/gdbm/RCS/findkey.c'v 1.4.0.1 90/08/16 09:22:23 tho Exp $
  1099. +  */
  1100.   
  1101.   #include <stdio.h>
  1102.   #include <sys/types.h>
  1103. + #ifndef MSDOS
  1104.   #include <sys/file.h>
  1105. + #endif /* not MSDOS */
  1106.   #include <sys/stat.h>
  1107.   #include "gdbmdefs.h"
  1108.   #include "systems.h"
  1109. *************** _gdbm_read_entry (dbf, elem_loc)
  1110. *** 44,50 ****
  1111.        gdbm_file_info *dbf;
  1112.        int elem_loc;
  1113.   {
  1114. !   int num_bytes;        /* For seeking and reading. */
  1115.     int key_size;
  1116.     int data_size;
  1117.     data_cache_elem *data_ca;
  1118. --- 62,68 ----
  1119.        gdbm_file_info *dbf;
  1120.        int elem_loc;
  1121.   {
  1122. !   LONG num_bytes;        /* For seeking and reading. */
  1123.     int key_size;
  1124.     int data_size;
  1125.     data_cache_elem *data_ca;
  1126. *************** _gdbm_read_entry (dbf, elem_loc)
  1127. *** 74,81 ****
  1128.     if (num_bytes != dbf->bucket->h_table[elem_loc].data_pointer)
  1129.       _gdbm_fatal (dbf, "lseek error");
  1130.     num_bytes = read (dbf->desc, data_ca->dptr, key_size+data_size);
  1131.     if (num_bytes != key_size+data_size) _gdbm_fatal (dbf, "read error");
  1132. !   
  1133.     return data_ca->dptr;
  1134.   }
  1135.   
  1136. --- 92,100 ----
  1137.     if (num_bytes != dbf->bucket->h_table[elem_loc].data_pointer)
  1138.       _gdbm_fatal (dbf, "lseek error");
  1139.     num_bytes = read (dbf->desc, data_ca->dptr, key_size+data_size);
  1140.     if (num_bytes != key_size+data_size) _gdbm_fatal (dbf, "read error");
  1141.     return data_ca->dptr;
  1142.   }
  1143.   
  1144. *************** _gdbm_findkey (dbf, key, dptr, new_hash_
  1145. *** 91,99 ****
  1146.        gdbm_file_info *dbf;
  1147.        datum key;
  1148.        char **dptr;
  1149. !      int   *new_hash_val;        /* The new hash value. */
  1150.   {
  1151. !   int    bucket_hash_val;    /* The hash value from the bucket. */
  1152.     char  *file_key;        /* The complete key as stored in the file. */
  1153.     int    elem_loc;        /* The location in the bucket. */
  1154.     int    home_loc;        /* The home location in the bucket. */
  1155. --- 110,118 ----
  1156.        gdbm_file_info *dbf;
  1157.        datum key;
  1158.        char **dptr;
  1159. !      LONG   *new_hash_val;        /* The new hash value. */
  1160.   {
  1161. !   LONG   bucket_hash_val;    /* The hash value from the bucket. */
  1162.     char  *file_key;        /* The complete key as stored in the file. */
  1163.     int    elem_loc;        /* The location in the bucket. */
  1164.     int    home_loc;        /* The home location in the bucket. */
  1165. *************** _gdbm_findkey (dbf, key, dptr, new_hash_
  1166. *** 101,107 ****
  1167. --- 120,130 ----
  1168.   
  1169.     /* Compute hash value and load proper bucket.  */
  1170.     *new_hash_val = _gdbm_hash (key);
  1171. + #ifdef MSDOS            /* careful!!!! */
  1172. +   _gdbm_get_bucket (dbf, (int) (*new_hash_val>> (31-dbf->header->dir_bits)));
  1173. + #else /* not MSDOS */
  1174.     _gdbm_get_bucket (dbf, *new_hash_val>> (31-dbf->header->dir_bits));
  1175. + #endif /* not MSDOS */
  1176.   
  1177.     /* Is the element the last one found for this bucket? */
  1178.     if (*new_hash_val == dbf->cache_entry->ca_data.hash_val
  1179. *************** _gdbm_findkey (dbf, key, dptr, new_hash_
  1180. *** 115,121 ****
  1181. --- 138,148 ----
  1182.       }
  1183.         
  1184.     /* It is not the cached value, search for element in the bucket. */
  1185. + #ifdef MSDOS            /* careful!!!  */
  1186. +   elem_loc = (int) (*new_hash_val % dbf->header->bucket_elems);
  1187. + #else /* not MSDOS */
  1188.     elem_loc = *new_hash_val % dbf->header->bucket_elems;
  1189. + #endif /* not MSDOS */
  1190.     home_loc = elem_loc;
  1191.     bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value;
  1192.     while (bucket_hash_val != -1)
  1193. diff -cBdNp e:/gnu/gdbm/gnu/gdbm.pro ./gdbm.pro
  1194. *** e:/gnu/gdbm/gnu/gdbm.pro    Thu Aug 16 10:49:28 1990
  1195. --- ./gdbm.pro    Thu Aug 16 10:50:40 1990
  1196. ***************
  1197. *** 1,72 ****
  1198. - /* gdbm.h  -  The include file for dbm users.  */
  1199. - /*  This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
  1200. -     Copyright (C) 1990  Free Software Foundation, Inc.
  1201. -     GDBM is free software; you can redistribute it and/or modify
  1202. -     it under the terms of the GNU General Public License as published by
  1203. -     the Free Software Foundation; either version 1, or (at your option)
  1204. -     any later version.
  1205. -     GDBM is distributed in the hope that it will be useful,
  1206. -     but WITHOUT ANY WARRANTY; without even the implied warranty of
  1207. -     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1208. -     GNU General Public License for more details.
  1209. -     You should have received a copy of the GNU General Public License
  1210. -     along with GDBM; see the file COPYING.  If not, write to
  1211. -     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1212. -     You may contact the author by:
  1213. -        e-mail:  phil@wwu.edu
  1214. -       us-mail:  Philip A. Nelson
  1215. -                 Computer Science Department
  1216. -                 Western Washington University
  1217. -                 Bellingham, WA 98226
  1218. -         phone:  (206) 676-3035
  1219. -        
  1220. - *************************************************************************/
  1221. - /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
  1222. -    can create the database. */
  1223. - #define  GDBM_READER  0        /* A reader. */
  1224. - #define  GDBM_WRITER  1        /* A writer. */
  1225. - #define  GDBM_WRCREAT 2        /* A writer.  Create the db if needed. */
  1226. - #define  GDBM_NEWDB   3        /* A writer.  Always create a new db. */
  1227. - /* Parameters to gdbm_store for simple insertion or replacement in the
  1228. -    case that the key is already in the database. */
  1229. - #define  GDBM_INSERT  0        /* Never replace old data with new. */
  1230. - #define  GDBM_REPLACE 1        /* Always replace old data with new. */
  1231. - /* The data and key structure.  This structure is defined for compatibility. */
  1232. - typedef struct {
  1233. -     char *dptr;
  1234. -     int   dsize;
  1235. -       } datum;
  1236. - /* The file information header. This is good enough for most applications. */
  1237. - typedef struct {int dummy[10];} *GDBM_FILE;
  1238. - /* These are the routines! */
  1239. - extern GDBM_FILE gdbm_open ();
  1240. - extern void     gdbm_close ();
  1241. - extern datum     gdbm_fetch ();
  1242. - extern int     gdbm_store ();
  1243. - extern int     gdbm_delete ();
  1244. - extern datum     gdbm_firstkey ();
  1245. - extern datum     gdbm_nextkey ();
  1246. - extern int     gdbm_reorganize ();
  1247. --- 0 ----
  1248. diff -cBdNp e:/gnu/gdbm/gnu/gdbmclos.c ./gdbmclos.c
  1249. *** e:/gnu/gdbm/gnu/gdbmclos.c    Thu Aug 16 10:49:28 1990
  1250. --- ./gdbmclos.c    Thu Aug 16 10:50:44 1990
  1251. ***************
  1252. *** 27,37 ****
  1253.          
  1254.   *************************************************************************/
  1255.   
  1256.   
  1257.   #include <stdio.h>
  1258.   #include <sys/types.h>
  1259.   #include <sys/file.h>
  1260.   #include "gdbmdefs.h"
  1261.   #include "systems.h"
  1262.   
  1263. --- 27,54 ----
  1264.          
  1265.   *************************************************************************/
  1266.   
  1267. ! /*
  1268. !  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1269. !  *
  1270. !  * To this port, the same copying conditions apply as to the
  1271. !  * original release.
  1272. !  *
  1273. !  * IMPORTANT:
  1274. !  * This file is not identical to the original GNU release!
  1275. !  * You should have received this code as patch to the official
  1276. !  * GNU release.
  1277. !  *
  1278. !  * MORE IMPORTANT:
  1279. !  * This port comes with ABSOLUTELY NO WARRANTY.
  1280. !  *
  1281. !  * $Header: e:/gnu/gdbm/RCS/gdbmclos.c'v 1.4.0.1 90/08/16 09:22:24 tho Exp $
  1282. !  */
  1283.   
  1284.   #include <stdio.h>
  1285.   #include <sys/types.h>
  1286. + #ifndef MSDOS
  1287.   #include <sys/file.h>
  1288. + #endif /* not MSDOS */
  1289.   #include "gdbmdefs.h"
  1290.   #include "systems.h"
  1291.   
  1292. diff -cBdNp e:/gnu/gdbm/gnu/gdbmdefs.h ./gdbmdefs.h
  1293. *** e:/gnu/gdbm/gnu/gdbmdefs.h    Thu Aug 16 10:49:32 1990
  1294. --- ./gdbmdefs.h    Thu Aug 16 10:50:46 1990
  1295. ***************
  1296. *** 27,33 ****
  1297. --- 27,63 ----
  1298.          
  1299.   *************************************************************************/
  1300.   
  1301. + /*
  1302. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1303. +  *
  1304. +  * To this port, the same copying conditions apply as to the
  1305. +  * original release.
  1306. +  *
  1307. +  * IMPORTANT:
  1308. +  * This file is not identical to the original GNU release!
  1309. +  * You should have received this code as patch to the official
  1310. +  * GNU release.
  1311. +  *
  1312. +  * MORE IMPORTANT:
  1313. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1314. +  *
  1315. +  * $Header: e:/gnu/gdbm/RCS/gdbmdefs.h'v 1.4.0.1 90/08/16 09:22:58 tho Exp $
  1316. +  */
  1317. + #ifdef __STDC__
  1318. + #include <stdio.h>
  1319. + #include <stdlib.h>
  1320. + #include <string.h>
  1321. + #define VOID void
  1322. + #else /* not __STDC__ */
  1323. + #define VOID
  1324. + #endif /*not __STDC__ */
  1325.   
  1326. + #ifdef MSDOS
  1327. + #define LONG long
  1328. + #else /* not MSDOS */
  1329. + #define LONG int
  1330. + #endif /* not MSDOS */
  1331.   
  1332.   /* Start with the constant definitions.  */
  1333.   #define  TRUE    1
  1334. *************** typedef struct {
  1335. *** 64,70 ****
  1336.   /* The following structure is the element of the avaliable table.  */
  1337.   typedef struct {
  1338.         int  av_size;        /* The size of the available block. */
  1339. !     int  av_adr;        /* The file address of the available block. */
  1340.         } avail_elem;
  1341.   
  1342.   /* This is the actual table. The in-memory images of the avail blocks are
  1343. --- 94,100 ----
  1344.   /* The following structure is the element of the avaliable table.  */
  1345.   typedef struct {
  1346.         int  av_size;        /* The size of the available block. */
  1347. !     LONG av_adr;        /* The file address of the available block. */
  1348.         } avail_elem;
  1349.   
  1350.   /* This is the actual table. The in-memory images of the avail blocks are
  1351. *************** typedef struct {
  1352. *** 72,78 ****
  1353.   typedef struct {
  1354.       int  size;        /* The number of avail elements in the table.*/
  1355.       int  count;        /* The number of entries in the table. */
  1356. !     int  next_block;    /* The file address of the next avail block. */
  1357.       avail_elem av_table[1]; /* The table.  Make it look like an array.  */
  1358.         } avail_block;
  1359.   
  1360. --- 102,108 ----
  1361.   typedef struct {
  1362.       int  size;        /* The number of avail elements in the table.*/
  1363.       int  count;        /* The number of entries in the table. */
  1364. !     LONG next_block;    /* The file address of the next avail block. */
  1365.       avail_elem av_table[1]; /* The table.  Make it look like an array.  */
  1366.         } avail_block;
  1367.   
  1368. *************** typedef struct {
  1369. *** 85,98 ****
  1370.      directory and the free space in the file.  */
  1371.   
  1372.   typedef struct {
  1373. !     int   header_magic;  /* 0x13579ace to make sure the header is good. */
  1374.       int   block_size;    /* The  optimal i/o blocksize from stat. */
  1375. !     int   dir;         /* File address of hash directory table. */
  1376.       int   dir_size;         /* Size in bytes of the table.  */
  1377.       int   dir_bits;         /* The number of address bits used in the table.*/
  1378.       int   bucket_size;   /* Size in bytes of a hash bucket struct. */
  1379.       int   bucket_elems;  /* Number of elements in a hash bucket. */
  1380. !     int   next_block;    /* The next unallocated block address. */
  1381.       avail_block avail;   /* This must be last because of the psuedo
  1382.                   array in avail.  This avail grows to fill
  1383.                   the entire block. */
  1384. --- 115,128 ----
  1385.      directory and the free space in the file.  */
  1386.   
  1387.   typedef struct {
  1388. !     LONG  header_magic;  /* 0x13579ace to make sure the header is good. */
  1389.       int   block_size;    /* The  optimal i/o blocksize from stat. */
  1390. !     LONG  dir;         /* File address of hash directory table. */
  1391.       int   dir_size;         /* Size in bytes of the table.  */
  1392.       int   dir_bits;         /* The number of address bits used in the table.*/
  1393.       int   bucket_size;   /* Size in bytes of a hash bucket struct. */
  1394.       int   bucket_elems;  /* Number of elements in a hash bucket. */
  1395. !     LONG  next_block;    /* The next unallocated block address. */
  1396.       avail_block avail;   /* This must be last because of the psuedo
  1397.                   array in avail.  This avail grows to fill
  1398.                   the entire block. */
  1399. *************** typedef struct {
  1400. *** 108,116 ****
  1401.   #define SMALL    4
  1402.   
  1403.   typedef struct {
  1404. !     int   hash_value;    /* The complete 31 bit value. */
  1405.       char  key_start[SMALL];    /* Up to the first SMALL bytes of the key.  */
  1406. !     int   data_pointer;    /* The file address of the key record. The
  1407.                      data record directly follows the key.  */
  1408.       int   key_size;        /* Size of key data in the file. */
  1409.       int   data_size;    /* Size of associated data in the file. */
  1410. --- 138,146 ----
  1411.   #define SMALL    4
  1412.   
  1413.   typedef struct {
  1414. !     LONG  hash_value;    /* The complete 31 bit value. */
  1415.       char  key_start[SMALL];    /* Up to the first SMALL bytes of the key.  */
  1416. !     LONG  data_pointer;    /* The file address of the key record. The
  1417.                      data record directly follows the key.  */
  1418.       int   key_size;        /* Size of key data in the file. */
  1419.       int   data_size;    /* Size of associated data in the file. */
  1420. *************** typedef struct {
  1421. *** 151,157 ****
  1422.      cache.  */
  1423.   
  1424.   typedef struct {
  1425. !         int   hash_val;
  1426.       int   data_size;
  1427.       int   key_size;
  1428.       char *dptr;
  1429. --- 181,187 ----
  1430.      cache.  */
  1431.   
  1432.   typedef struct {
  1433. !         LONG  hash_val;
  1434.       int   data_size;
  1435.       int   key_size;
  1436.       char *dptr;
  1437. *************** typedef struct {
  1438. *** 162,168 ****
  1439.   
  1440.   typedef struct {
  1441.           hash_bucket *   ca_bucket;
  1442. !     int             ca_adr;
  1443.       char        ca_changed;   /* Data in the bucket changed. */
  1444.       data_cache_elem ca_data;
  1445.         } cache_elem;
  1446. --- 192,198 ----
  1447.   
  1448.   typedef struct {
  1449.           hash_bucket *   ca_bucket;
  1450. !     LONG            ca_adr;
  1451.       char        ca_changed;   /* Data in the bucket changed. */
  1452.       data_cache_elem ca_data;
  1453.         } cache_elem;
  1454. *************** typedef struct {
  1455. *** 194,200 ****
  1456.   
  1457.       /* The hash table directory from extendible hashing.  See Fagin et al, 
  1458.          ACM Trans on Database Systems, Vol 4, No 3. Sept 1979, 315-344 */
  1459. !     int  *dir;
  1460.   
  1461.       /* The bucket cache. */
  1462.       cache_elem bucket_cache [CACHE_SIZE];
  1463. --- 224,230 ----
  1464.   
  1465.       /* The hash table directory from extendible hashing.  See Fagin et al, 
  1466.          ACM Trans on Database Systems, Vol 4, No 3. Sept 1979, 315-344 */
  1467. !     LONG  *dir;
  1468.   
  1469.       /* The bucket cache. */
  1470.       cache_elem bucket_cache [CACHE_SIZE];
  1471. *************** typedef struct {
  1472. *** 218,222 ****
  1473. --- 248,294 ----
  1474.       char  second_changed;
  1475.       
  1476.         } gdbm_file_info;
  1477. + #ifdef __STDC__
  1478. + extern void gdbm_close (gdbm_file_info *dbf);
  1479. + extern int gdbm_delete (gdbm_file_info *dbf, datum key);
  1480. + extern datum gdbm_fetch (gdbm_file_info *dbf, datum key);
  1481. + extern gdbm_file_info *gdbm_open (char *file, int block_size, int read_write, int mode, void (*fatal_func)());
  1482. + extern int gdbm_reorganize (gdbm_file_info *dbf);
  1483. + extern datum gdbm_firstkey (gdbm_file_info *dbf);
  1484. + extern datum gdbm_nextkey (gdbm_file_info *dbf, datum key);
  1485. + extern int gdbm_store (gdbm_file_info *dbf, datum key, datum content, int flags);
  1486. + extern VOID _gdbm_new_bucket (gdbm_file_info *dbf, hash_bucket *bucket, int bits);
  1487. + extern VOID _gdbm_get_bucket (gdbm_file_info *dbf, int dir_index);
  1488. + extern VOID _gdbm_split_bucket (gdbm_file_info *dbf, LONG next_insert);
  1489. + extern VOID _gdbm_write_bucket (gdbm_file_info *dbf, cache_elem *ca_entry);
  1490. + extern LONG _gdbm_alloc (gdbm_file_info *dbf, int num_bytes);
  1491. + extern int _gdbm_free (gdbm_file_info *dbf, LONG file_adr, int num_bytes);
  1492. + extern int _gdbm_put_av_elem (avail_elem new_el, avail_elem *av_table, int *av_count);
  1493. + extern char *_gdbm_read_entry (gdbm_file_info *dbf, int elem_loc);
  1494. + extern int _gdbm_findkey (gdbm_file_info *dbf, datum key, char **dptr, LONG *new_hash_val);
  1495. + extern LONG _gdbm_hash (datum key);
  1496. + extern VOID _gdbm_end_update (gdbm_file_info *dbf);
  1497. + extern VOID _gdbm_fatal (gdbm_file_info *dbf, char *val);
  1498. + extern  int dbminit (char *file);
  1499. + extern datum fetch(datum key);
  1500. + extern int store (datum key, datum content);
  1501. + extern int delete (datum key);
  1502. + extern datum firstkey (void);
  1503. + extern datum nextkey (datum key);
  1504. + extern gdbm_file_info *dbm_open (char *file, int flags, int mode);
  1505. + extern void dbm_close (gdbm_file_info *dbf);
  1506. + extern datum dbm_fetch (gdbm_file_info *dbf, datum key);
  1507. + extern int dbm_store (gdbm_file_info *dbf, datum key, datum content, int flags);
  1508. + extern int dbm_delete (gdbm_file_info *dbf, datum key);
  1509. + extern datum dbm_firstkey (gdbm_file_info *dbf);
  1510. + extern datum dbm_nextkey (gdbm_file_info *dbf);
  1511. + extern int dbm_dirfno (gdbm_file_info *dbf);
  1512. + extern int dbm_pagfno (gdbm_file_info *dbf);
  1513. + #endif /* __STDC__ */
  1514.   
  1515.   
  1516. diff -cBdNp e:/gnu/gdbm/gnu/gdbmdele.c ./gdbmdele.c
  1517. *** e:/gnu/gdbm/gnu/gdbmdele.c    Thu Aug 16 10:49:34 1990
  1518. --- ./gdbmdele.c    Thu Aug 16 10:50:48 1990
  1519. ***************
  1520. *** 27,37 ****
  1521.          
  1522.   *************************************************************************/
  1523.   
  1524.   
  1525.   #include <stdio.h>
  1526.   #include <sys/types.h>
  1527.   #include <sys/file.h>
  1528.   #include <sys/stat.h>
  1529.   #include "gdbmdefs.h"
  1530.   #include "systems.h"
  1531. --- 27,54 ----
  1532.          
  1533.   *************************************************************************/
  1534.   
  1535. ! /*
  1536. !  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1537. !  *
  1538. !  * To this port, the same copying conditions apply as to the
  1539. !  * original release.
  1540. !  *
  1541. !  * IMPORTANT:
  1542. !  * This file is not identical to the original GNU release!
  1543. !  * You should have received this code as patch to the official
  1544. !  * GNU release.
  1545. !  *
  1546. !  * MORE IMPORTANT:
  1547. !  * This port comes with ABSOLUTELY NO WARRANTY.
  1548. !  *
  1549. !  * $Header: e:/gnu/gdbm/RCS/gdbmdele.c'v 1.4.0.1 90/08/16 09:22:26 tho Exp $
  1550. !  */
  1551.   
  1552.   #include <stdio.h>
  1553.   #include <sys/types.h>
  1554. + #ifndef MSDOS
  1555.   #include <sys/file.h>
  1556. + #endif /* not MSDOS */
  1557.   #include <sys/stat.h>
  1558.   #include "gdbmdefs.h"
  1559.   #include "systems.h"
  1560. *************** gdbm_delete (dbf, key)
  1561. *** 52,59 ****
  1562.     int home;        /* Home position of an item. */
  1563.     bucket_element elem;  /* The element to be deleted. */
  1564.     char *find_data;    /* Return pointer from findkey. */
  1565. !   int   hash_val;    /* Returned by findkey. */
  1566. !   int   free_adr;       /* Temporary stroage for address and size. */
  1567.     int   free_size;
  1568.   
  1569.     /* First check to make sure this guy is a writer. */
  1570. --- 69,76 ----
  1571.     int home;        /* Home position of an item. */
  1572.     bucket_element elem;  /* The element to be deleted. */
  1573.     char *find_data;    /* Return pointer from findkey. */
  1574. !   LONG  hash_val;    /* Returned by findkey. */
  1575. !   LONG  free_adr;       /* Temporary stroage for address and size. */
  1576.     int   free_size;
  1577.   
  1578.     /* First check to make sure this guy is a writer. */
  1579. *************** gdbm_delete (dbf, key)
  1580. *** 84,91 ****
  1581. --- 101,113 ----
  1582.     while (elem_loc != last_loc
  1583.        && dbf->bucket->h_table[elem_loc].hash_value != -1)
  1584.       {
  1585. + #ifdef MSDOS
  1586. +       home = (int) (dbf->bucket->h_table[elem_loc].hash_value
  1587. +             % dbf->header->bucket_elems);
  1588. + #else /* not MSDOS */
  1589.         home = dbf->bucket->h_table[elem_loc].hash_value
  1590.            % dbf->header->bucket_elems;
  1591. + #endif /* not MSDOS */
  1592.         if ( (last_loc < elem_loc && (home <= last_loc || home > elem_loc))
  1593.         || (last_loc > elem_loc && home <= last_loc && home > elem_loc))
  1594.       
  1595. diff -cBdNp e:/gnu/gdbm/gnu/gdbmfetc.c ./gdbmfetc.c
  1596. *** e:/gnu/gdbm/gnu/gdbmfetc.c    Thu Aug 16 10:49:36 1990
  1597. --- ./gdbmfetc.c    Thu Aug 16 10:50:54 1990
  1598. ***************
  1599. *** 27,36 ****
  1600. --- 27,54 ----
  1601.          
  1602.   *************************************************************************/
  1603.   
  1604. + /*
  1605. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1606. +  *
  1607. +  * To this port, the same copying conditions apply as to the
  1608. +  * original release.
  1609. +  *
  1610. +  * IMPORTANT:
  1611. +  * This file is not identical to the original GNU release!
  1612. +  * You should have received this code as patch to the official
  1613. +  * GNU release.
  1614. +  *
  1615. +  * MORE IMPORTANT:
  1616. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1617. +  *
  1618. +  * $Header: e:/gnu/gdbm/RCS/gdbmfetc.c'v 1.4.0.1 90/08/16 09:22:27 tho Exp $
  1619. +  */
  1620.   
  1621.   #include <stdio.h>
  1622.   #include <sys/types.h>
  1623. + #ifndef MSDOS
  1624.   #include <sys/file.h>
  1625. + #endif /* not MSDOS */
  1626.   #include <sys/stat.h>
  1627.   #include "gdbmdefs.h"
  1628.   #include "systems.h"
  1629. *************** gdbm_fetch (dbf, key)
  1630. *** 49,55 ****
  1631.     datum  return_val;        /* The return value. */
  1632.     int    elem_loc;        /* The location in the bucket. */
  1633.     char  *find_data;        /* Returned from find_key. */
  1634. !   int     hash_val;        /* Returned from find_key. */
  1635.   
  1636.     /* Set the default return value. */
  1637.     return_val.dptr = NULL;
  1638. --- 67,73 ----
  1639.     datum  return_val;        /* The return value. */
  1640.     int    elem_loc;        /* The location in the bucket. */
  1641.     char  *find_data;        /* Returned from find_key. */
  1642. !   LONG     hash_val;        /* Returned from find_key. */
  1643.   
  1644.     /* Set the default return value. */
  1645.     return_val.dptr = NULL;
  1646. diff -cBdNp e:/gnu/gdbm/gnu/gdbmopen.c ./gdbmopen.c
  1647. *** e:/gnu/gdbm/gnu/gdbmopen.c    Thu Aug 16 10:49:40 1990
  1648. --- ./gdbmopen.c    Thu Aug 16 10:50:56 1990
  1649. ***************
  1650. *** 27,36 ****
  1651. --- 27,54 ----
  1652.          
  1653.   *************************************************************************/
  1654.   
  1655. + /*
  1656. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1657. +  *
  1658. +  * To this port, the same copying conditions apply as to the
  1659. +  * original release.
  1660. +  *
  1661. +  * IMPORTANT:
  1662. +  * This file is not identical to the original GNU release!
  1663. +  * You should have received this code as patch to the official
  1664. +  * GNU release.
  1665. +  *
  1666. +  * MORE IMPORTANT:
  1667. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1668. +  *
  1669. +  * $Header: e:/gnu/gdbm/RCS/gdbmopen.c'v 1.4.0.1 90/08/16 09:22:29 tho Exp $
  1670. +  */
  1671.   
  1672.   #include <stdio.h>
  1673.   #include <sys/types.h>
  1674. + #ifndef MSDOS
  1675.   #include <sys/file.h>
  1676. + #endif /* not MSDOS */
  1677.   #include <sys/stat.h>
  1678.   #include "gdbmdefs.h"
  1679.   #include "systems.h"
  1680. *************** gdbm_open (file, block_size, read_write,
  1681. *** 71,77 ****
  1682.     gdbm_file_info *dbf;        /* The record to return. */
  1683.     struct stat file_stat;    /* Space for the stat information. */
  1684.     int         len;        /* Length of the file name. */
  1685. !   int         num_bytes;    /* Used in reading and writing. */
  1686.     int          lock_val;         /* Returned by the flock call. */
  1687.     int          file_block_size;    /* Block size to use for a new file. */
  1688.     int           index;        /* Used as a loop index. */
  1689. --- 89,95 ----
  1690.     gdbm_file_info *dbf;        /* The record to return. */
  1691.     struct stat file_stat;    /* Space for the stat information. */
  1692.     int         len;        /* Length of the file name. */
  1693. !   LONG        num_bytes;    /* Used in reading and writing. */
  1694.     int          lock_val;         /* Returned by the flock call. */
  1695.     int          file_block_size;    /* Block size to use for a new file. */
  1696.     int           index;        /* Used as a loop index. */
  1697. *************** gdbm_open (file, block_size, read_write,
  1698. *** 111,130 ****
  1699.     /* Open the file. */
  1700.     if (read_write == GDBM_READER)
  1701.       {
  1702. !       dbf->desc = open (dbf->name, O_RDONLY, 0);
  1703.       }
  1704.     else if (read_write == GDBM_WRITER)
  1705.       {
  1706. !       dbf->desc = open (dbf->name, O_RDWR, 0);
  1707.       }
  1708.     else if (read_write == GDBM_NEWDB)
  1709.       {
  1710. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT|O_TRUNC, mode);
  1711.         read_write = GDBM_WRITER;
  1712.       }
  1713.     else
  1714.       {
  1715. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode);
  1716.         read_write = GDBM_WRITER;
  1717.       }
  1718.     if (dbf->desc < 0)
  1719. --- 129,148 ----
  1720.     /* Open the file. */
  1721.     if (read_write == GDBM_READER)
  1722.       {
  1723. !       dbf->desc = open (dbf->name, O_RDONLY|O_BINARY, 0);
  1724.       }
  1725.     else if (read_write == GDBM_WRITER)
  1726.       {
  1727. !       dbf->desc = open (dbf->name, O_RDWR|O_BINARY, 0);
  1728.       }
  1729.     else if (read_write == GDBM_NEWDB)
  1730.       {
  1731. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, mode);
  1732.         read_write = GDBM_WRITER;
  1733.       }
  1734.     else
  1735.       {
  1736. !       dbf->desc = open (dbf->name, O_RDWR|O_CREAT|O_BINARY, mode);
  1737.         read_write = GDBM_WRITER;
  1738.       }
  1739.     if (dbf->desc < 0)
  1740. *************** gdbm_open (file, block_size, read_write,
  1741. *** 198,204 ****
  1742.         dbf->header->block_size = file_block_size;
  1743.        
  1744.         /* Create the initial hash table directory.  */
  1745. !       dbf->header->dir_size = 8 * sizeof (int);
  1746.         dbf->header->dir_bits = 3;
  1747.         while (dbf->header->dir_size < dbf->header->block_size)
  1748.       {
  1749. --- 216,222 ----
  1750.         dbf->header->block_size = file_block_size;
  1751.        
  1752.         /* Create the initial hash table directory.  */
  1753. !       dbf->header->dir_size = 8 * sizeof (LONG);
  1754.         dbf->header->dir_bits = 3;
  1755.         while (dbf->header->dir_size < dbf->header->block_size)
  1756.       {
  1757. *************** gdbm_open (file, block_size, read_write,
  1758. *** 215,221 ****
  1759.       }
  1760.   
  1761.         /* Allocate the space for the directory. */
  1762. !       dbf->dir = (int *) malloc (dbf->header->dir_size);
  1763.         if (dbf->dir == NULL)
  1764.       {
  1765.         gdbm_close (dbf);
  1766. --- 233,239 ----
  1767.       }
  1768.   
  1769.         /* Allocate the space for the directory. */
  1770. !       dbf->dir = (LONG *) malloc (dbf->header->dir_size);
  1771.         if (dbf->dir == NULL)
  1772.       {
  1773.         gdbm_close (dbf);
  1774. *************** gdbm_open (file, block_size, read_write,
  1775. *** 242,248 ****
  1776.         dbf->bucket->bucket_avail[0].av_size = dbf->header->block_size;
  1777.   
  1778.         /* Set table entries to point to hash buckets. */
  1779. !       for (index = 0; index < dbf->header->dir_size / sizeof (int); index++)
  1780.       dbf->dir[index] = 2*dbf->header->block_size;
  1781.   
  1782.         /* Initialize the active avail block. */
  1783. --- 260,266 ----
  1784.         dbf->bucket->bucket_avail[0].av_size = dbf->header->block_size;
  1785.   
  1786.         /* Set table entries to point to hash buckets. */
  1787. !       for (index = 0; index < dbf->header->dir_size / sizeof (LONG); index++)
  1788.       dbf->dir[index] = 2*dbf->header->block_size;
  1789.   
  1790.         /* Initialize the active avail block. */
  1791. *************** gdbm_open (file, block_size, read_write,
  1792. *** 255,261 ****
  1793. --- 273,284 ----
  1794.   
  1795.         /* Write initial configuration to the file. */
  1796.         /* Block 0 is the file header and active avail block. */
  1797. + #ifdef MSDOS            /* shut up the compiler!  */
  1798. +       num_bytes = write (dbf->desc,
  1799. +              (char *) dbf->header, dbf->header->block_size);
  1800. + #else /* not MSDOS */
  1801.         num_bytes = write (dbf->desc, dbf->header, dbf->header->block_size);
  1802. + #endif /* not MSDOS */
  1803.         if (num_bytes != dbf->header->block_size)
  1804.       {
  1805.         gdbm_close (dbf);
  1806. *************** gdbm_open (file, block_size, read_write,
  1807. *** 264,270 ****
  1808. --- 287,297 ----
  1809.       }
  1810.   
  1811.         /* Block 1 is the initial bucket directory. */
  1812. + #ifdef MSDOS            /* shut up the compiler!  */
  1813. +       num_bytes = write (dbf->desc, (char *) dbf->dir, dbf->header->dir_size);
  1814. + #else /* not MSDOS */
  1815.         num_bytes = write (dbf->desc, dbf->dir, dbf->header->dir_size);
  1816. + #endif /* not MSDOS */
  1817.         if (num_bytes != dbf->header->dir_size)
  1818.       {
  1819.         gdbm_close (dbf);
  1820. *************** gdbm_open (file, block_size, read_write,
  1821. *** 273,279 ****
  1822. --- 300,311 ----
  1823.       }
  1824.   
  1825.         /* Block 2 is the only bucket. */
  1826. + #ifdef MSDOS            /* shut up the compiler!  */
  1827. +       num_bytes = write (dbf->desc,
  1828. +              (char *) dbf->bucket, dbf->header->bucket_size);
  1829. + #else /* not MSDOS */
  1830.         num_bytes = write (dbf->desc, dbf->bucket, dbf->header->bucket_size);
  1831. + #endif /* not MSDOS */
  1832.         if (num_bytes != dbf->header->bucket_size)
  1833.       {
  1834.         gdbm_close (dbf);
  1835. *************** gdbm_open (file, block_size, read_write,
  1836. *** 293,299 ****
  1837. --- 325,336 ----
  1838.         gdbm_file_header partial_header;  /* For the first part of it. */
  1839.   
  1840.         /* Read the partial file header. */
  1841. + #ifdef MSDOS            /* shut up the compiler!  */
  1842. +       num_bytes = read (dbf->desc,
  1843. +             (char *)&partial_header, sizeof (gdbm_file_header));
  1844. + #else /* not MSDOS */
  1845.         num_bytes = read (dbf->desc, &partial_header, sizeof (gdbm_file_header));
  1846. + #endif /* not MSDOS */
  1847.         if (num_bytes != sizeof (gdbm_file_header))
  1848.       {
  1849.         gdbm_close (dbf);
  1850. *************** gdbm_open (file, block_size, read_write,
  1851. *** 302,308 ****
  1852. --- 339,349 ----
  1853.       }
  1854.   
  1855.         /* Is the magic number good? */
  1856. + #ifdef MSDOS
  1857. +       if (partial_header.header_magic != 0x13579aceL)
  1858. + #else /* not MSDOS */
  1859.         if (partial_header.header_magic != 0x13579ace)
  1860. + #endif /* not MSDOS */
  1861.       {
  1862.         gdbm_close (dbf);
  1863.         gdbm_errno = GDBM_BAD_MAGIC_NUMBER;
  1864. *************** gdbm_open (file, block_size, read_write,
  1865. *** 318,325 ****
  1866. --- 359,371 ----
  1867.         return NULL;
  1868.       }
  1869.         bcopy (&partial_header, dbf->header, sizeof (gdbm_file_header));
  1870. + #ifdef MSDOS            /* shut up the compiler!  */
  1871. +       num_bytes = read (dbf->desc, (char *) &dbf->header->avail.av_table[1],
  1872. +             dbf->header->block_size-sizeof (gdbm_file_header));
  1873. + #else /* not MSDOS */
  1874.         num_bytes = read (dbf->desc, &dbf->header->avail.av_table[1],
  1875.               dbf->header->block_size-sizeof (gdbm_file_header));
  1876. + #endif /* not MSDOS */
  1877.         if (num_bytes != dbf->header->block_size-sizeof (gdbm_file_header))
  1878.       {
  1879.         gdbm_close (dbf);
  1880. *************** gdbm_open (file, block_size, read_write,
  1881. *** 328,334 ****
  1882.       }
  1883.       
  1884.         /* Allocate space for the hash table directory.  */
  1885. !       dbf->dir = (int *) malloc (dbf->header->dir_size);
  1886.         if (dbf->dir == NULL)
  1887.       {
  1888.         gdbm_close (dbf);
  1889. --- 374,380 ----
  1890.       }
  1891.       
  1892.         /* Allocate space for the hash table directory.  */
  1893. !       dbf->dir = (LONG *) malloc (dbf->header->dir_size);
  1894.         if (dbf->dir == NULL)
  1895.       {
  1896.         gdbm_close (dbf);
  1897. *************** gdbm_open (file, block_size, read_write,
  1898. *** 345,351 ****
  1899. --- 391,401 ----
  1900.         return NULL;
  1901.       }
  1902.   
  1903. + #ifdef MSDOS            /* shut up the compiler!  */
  1904. +       num_bytes = read (dbf->desc, (char *) dbf->dir, dbf->header->dir_size);
  1905. + #else /* not MSDOS */
  1906.         num_bytes = read (dbf->desc, dbf->dir, dbf->header->dir_size);
  1907. + #endif /* not MSDOS */
  1908.         if (num_bytes != dbf->header->dir_size)
  1909.       {
  1910.         gdbm_close (dbf);
  1911. diff -cBdNp e:/gnu/gdbm/gnu/gdbmreor.c ./gdbmreor.c
  1912. *** e:/gnu/gdbm/gnu/gdbmreor.c    Thu Aug 16 10:49:40 1990
  1913. --- ./gdbmreor.c    Thu Aug 16 10:50:58 1990
  1914. ***************
  1915. *** 27,36 ****
  1916. --- 27,54 ----
  1917.          
  1918.   ************************************************************************/
  1919.   
  1920. + /*
  1921. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1922. +  *
  1923. +  * To this port, the same copying conditions apply as to the
  1924. +  * original release.
  1925. +  *
  1926. +  * IMPORTANT:
  1927. +  * This file is not identical to the original GNU release!
  1928. +  * You should have received this code as patch to the official
  1929. +  * GNU release.
  1930. +  *
  1931. +  * MORE IMPORTANT:
  1932. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1933. +  *
  1934. +  * $Header: e:/gnu/gdbm/RCS/gdbmreor.c'v 1.4.0.1 90/08/16 09:22:31 tho Exp $
  1935. +  */
  1936.   
  1937.   #include <stdio.h>
  1938.   #include <sys/types.h>
  1939. + #ifndef MSDOS
  1940.   #include <sys/file.h>
  1941. + #endif /* not MSDOS */
  1942.   #include <sys/stat.h>
  1943.   #include "gdbmdefs.h"
  1944.   #include "systems.h"
  1945. *************** gdbm_reorganize (dbf)
  1946. *** 154,160 ****
  1947. --- 172,185 ----
  1948.   
  1949.       /* Move the new file to old name. */
  1950.   
  1951. + #ifdef MSDOS
  1952. +   if (close (new_dbf->desc)
  1953. +       || unlink (dbf->name)
  1954. +       || rename (new_name, dbf->name)
  1955. +       || (new_dbf->desc = open (dbf->name, O_RDWR|O_BINARY)) < 0)
  1956. + #else /* not MSDOS */
  1957.     if (rename (new_name, dbf->name) != 0)
  1958. + #endif /* not MSDOS */
  1959.       {
  1960.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  1961.         gdbm_close (new_dbf);
  1962. diff -cBdNp e:/gnu/gdbm/gnu/gdbmseq.c ./gdbmseq.c
  1963. *** e:/gnu/gdbm/gnu/gdbmseq.c    Thu Aug 16 10:49:42 1990
  1964. --- ./gdbmseq.c    Thu Aug 16 10:51:02 1990
  1965. ***************
  1966. *** 27,40 ****
  1967. --- 27,62 ----
  1968.          
  1969.   *************************************************************************/
  1970.   
  1971. + /*
  1972. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  1973. +  *
  1974. +  * To this port, the same copying conditions apply as to the
  1975. +  * original release.
  1976. +  *
  1977. +  * IMPORTANT:
  1978. +  * This file is not identical to the original GNU release!
  1979. +  * You should have received this code as patch to the official
  1980. +  * GNU release.
  1981. +  *
  1982. +  * MORE IMPORTANT:
  1983. +  * This port comes with ABSOLUTELY NO WARRANTY.
  1984. +  *
  1985. +  * $Header: e:/gnu/gdbm/RCS/gdbmseq.c'v 1.4.0.1 90/08/16 09:22:33 tho Exp $
  1986. +  */
  1987.   
  1988.   #include <stdio.h>
  1989.   #include <sys/types.h>
  1990. + #ifndef MSDOS
  1991.   #include <sys/file.h>
  1992. + #endif /* not MSDOS */
  1993.   #include <sys/stat.h>
  1994.   #include "gdbmdefs.h"
  1995.   #include "systems.h"
  1996.   
  1997. + #ifdef __STDC__
  1998. + static void get_next_key (gdbm_file_info *dbf, int elem_loc, datum *return_val);
  1999. + #endif /* not __STDC__ */
  2000.   /* Special extern for this file. */
  2001.   extern char *_gdbm_read_entry ();
  2002.   
  2003. *************** get_next_key (dbf, elem_loc, return_val)
  2004. *** 65,76 ****
  2005.   
  2006.         /* Find the next bucket.  It is possible several entries in
  2007.            the bucket directory point to the same bucket. */
  2008. !       while (dbf->bucket_dir < dbf->header->dir_size / sizeof (int)
  2009.            && dbf->cache_entry->ca_adr == dbf->dir[dbf->bucket_dir])
  2010.           dbf->bucket_dir++;
  2011.   
  2012.         /* Check to see if there was a next bucket. */
  2013. !       if (dbf->bucket_dir < dbf->header->dir_size / sizeof (int))
  2014.           _gdbm_get_bucket (dbf, dbf->bucket_dir);          
  2015.         else
  2016.           /* No next key, just return. */
  2017. --- 87,98 ----
  2018.   
  2019.         /* Find the next bucket.  It is possible several entries in
  2020.            the bucket directory point to the same bucket. */
  2021. !       while (dbf->bucket_dir < dbf->header->dir_size / sizeof (LONG)
  2022.            && dbf->cache_entry->ca_adr == dbf->dir[dbf->bucket_dir])
  2023.           dbf->bucket_dir++;
  2024.   
  2025.         /* Check to see if there was a next bucket. */
  2026. !       if (dbf->bucket_dir < dbf->header->dir_size / sizeof (LONG))
  2027.           _gdbm_get_bucket (dbf, dbf->bucket_dir);          
  2028.         else
  2029.           /* No next key, just return. */
  2030. *************** gdbm_nextkey (dbf, key)
  2031. *** 120,126 ****
  2032.     datum  return_val;        /* The return value. */
  2033.     int    elem_loc;        /* The location in the bucket. */
  2034.     char  *find_data;        /* Data pointer returned by _gdbm_findkey. */
  2035. !   int     hash_val;        /* Returned by _gdbm_findkey. */
  2036.   
  2037.     /* Set the default return value for no next entry. */
  2038.     return_val.dptr = NULL;
  2039. --- 142,148 ----
  2040.     datum  return_val;        /* The return value. */
  2041.     int    elem_loc;        /* The location in the bucket. */
  2042.     char  *find_data;        /* Data pointer returned by _gdbm_findkey. */
  2043. !   LONG     hash_val;        /* Returned by _gdbm_findkey. */
  2044.   
  2045.     /* Set the default return value for no next entry. */
  2046.     return_val.dptr = NULL;
  2047. diff -cBdNp e:/gnu/gdbm/gnu/gdbmstor.c ./gdbmstor.c
  2048. *** e:/gnu/gdbm/gnu/gdbmstor.c    Thu Aug 16 10:49:44 1990
  2049. --- ./gdbmstor.c    Thu Aug 16 10:51:04 1990
  2050. ***************
  2051. *** 27,36 ****
  2052. --- 27,54 ----
  2053.          
  2054.   *************************************************************************/
  2055.   
  2056. + /*
  2057. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2058. +  *
  2059. +  * To this port, the same copying conditions apply as to the
  2060. +  * original release.
  2061. +  *
  2062. +  * IMPORTANT:
  2063. +  * This file is not identical to the original GNU release!
  2064. +  * You should have received this code as patch to the official
  2065. +  * GNU release.
  2066. +  *
  2067. +  * MORE IMPORTANT:
  2068. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2069. +  *
  2070. +  * $Header: e:/gnu/gdbm/RCS/gdbmstor.c'v 1.4.0.1 90/08/16 09:22:35 tho Exp $
  2071. +  */
  2072.   
  2073.   #include <stdio.h>
  2074.   #include <sys/types.h>
  2075. + #ifndef MSDOS
  2076.   #include <sys/file.h>
  2077. + #endif /* not MSDOS */
  2078.   #include <sys/stat.h>
  2079.   #include "gdbmdefs.h"
  2080.   #include "systems.h"
  2081. *************** gdbm_store (dbf, key, content, flags)
  2082. *** 58,68 ****
  2083.        datum content;
  2084.        int flags;
  2085.   {
  2086. !   int new_hash_val;        /* The new hash value. */
  2087.     int elem_loc;            /* The location in hash bucket. */
  2088. !   int file_adr;            /* The address of new space in the file.  */
  2089. !   int num_bytes;        /* Used for error detection. */
  2090. !   int free_adr;            /* For keeping track of a freed section. */
  2091.     int free_size;
  2092.   
  2093.     char *write_data;        /* To write both key and data in 1 call. */
  2094. --- 76,86 ----
  2095.        datum content;
  2096.        int flags;
  2097.   {
  2098. !   LONG new_hash_val;        /* The new hash value. */
  2099.     int elem_loc;            /* The location in hash bucket. */
  2100. !   LONG file_adr;        /* The address of new space in the file.  */
  2101. !   LONG num_bytes;        /* Used for error detection. */
  2102. !   LONG free_adr;        /* For keeping track of a freed section. */
  2103.     int free_size;
  2104.   
  2105.     char *write_data;        /* To write both key and data in 1 call. */
  2106. *************** gdbm_store (dbf, key, content, flags)
  2107. *** 119,125 ****
  2108. --- 137,147 ----
  2109.       }
  2110.         
  2111.         /* Find space to insert into bucket and set elem_loc to that place. */
  2112. + #ifdef MSDOS
  2113. +       elem_loc = (int) (new_hash_val % dbf->header->bucket_elems);
  2114. + #else /* not MSDOS */
  2115.         elem_loc = new_hash_val % dbf->header->bucket_elems;
  2116. + #endif /* not MSDOS */
  2117.         while (dbf->bucket->h_table[elem_loc].hash_value != -1)
  2118.       {  elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; }
  2119.   
  2120. *************** gdbm_store (dbf, key, content, flags)
  2121. *** 138,143 ****
  2122. --- 161,173 ----
  2123.   
  2124.     /* Prepare write_data. The key is written first.  */
  2125.     write_data = (char *) alloca (key.dsize+content.dsize);
  2126. + #ifdef MSDOS
  2127. +   if (write_data == (char *) 0)
  2128. +     {
  2129. +       fprintf (stderr, "alloca failed.\n");
  2130. +       exit (-2);
  2131. +     }
  2132. + #endif /* MSDOS */
  2133.     dst = write_data;
  2134.     src = key.dptr;
  2135.     for (cnt=0; cnt < key.dsize; cnt++)
  2136. diff -cBdNp e:/gnu/gdbm/gnu/global.c ./global.c
  2137. *** e:/gnu/gdbm/gnu/global.c    Thu Aug 16 10:49:46 1990
  2138. --- ./global.c    Thu Aug 16 10:51:08 1990
  2139. ***************
  2140. *** 28,33 ****
  2141. --- 28,49 ----
  2142.          
  2143.   *************************************************************************/
  2144.   
  2145. + /*
  2146. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2147. +  *
  2148. +  * To this port, the same copying conditions apply as to the
  2149. +  * original release.
  2150. +  *
  2151. +  * IMPORTANT:
  2152. +  * This file is not identical to the original GNU release!
  2153. +  * You should have received this code as patch to the official
  2154. +  * GNU release.
  2155. +  *
  2156. +  * MORE IMPORTANT:
  2157. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2158. +  *
  2159. +  * $Header: e:/gnu/gdbm/RCS/global.c'v 1.4.0.1 90/08/16 09:22:36 tho Exp $
  2160. +  */
  2161.   
  2162.   #include <stdio.h>
  2163.   #include "gdbmdefs.h"
  2164. *************** datum _gdbm_memory = {NULL, 0};    /* Used 
  2165. *** 42,45 ****
  2166. --- 58,65 ----
  2167.   char *_gdbm_fetch_val = NULL;    /* Used by fetch. */
  2168.   
  2169.   /* The dbm error number is placed in the variable GDBM_ERRNO. */
  2170. + #ifdef MSDOS        /* won't go into library if not initialized!  */
  2171. + gdbm_error gdbm_errno = GDBM_NO_ERROR;
  2172. + #else /* not MSDOS */
  2173.   gdbm_error gdbm_errno;
  2174. + #endif /* not MSDOS */
  2175. diff -cBdNp e:/gnu/gdbm/gnu/hash.c ./hash.c
  2176. *** e:/gnu/gdbm/gnu/hash.c    Thu Aug 16 10:49:48 1990
  2177. --- ./hash.c    Thu Aug 16 10:51:10 1990
  2178. ***************
  2179. *** 27,37 ****
  2180.          
  2181.   *************************************************************************/
  2182.   
  2183.   
  2184.   #include <stdio.h>
  2185.   #include <sys/types.h>
  2186.   #include <sys/file.h>
  2187.   #include <sys/stat.h>
  2188.   #include "gdbmdefs.h"
  2189.   
  2190. --- 27,54 ----
  2191.          
  2192.   *************************************************************************/
  2193.   
  2194. ! /*
  2195. !  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2196. !  *
  2197. !  * To this port, the same copying conditions apply as to the
  2198. !  * original release.
  2199. !  *
  2200. !  * IMPORTANT:
  2201. !  * This file is not identical to the original GNU release!
  2202. !  * You should have received this code as patch to the official
  2203. !  * GNU release.
  2204. !  *
  2205. !  * MORE IMPORTANT:
  2206. !  * This port comes with ABSOLUTELY NO WARRANTY.
  2207. !  *
  2208. !  * $Header: e:/gnu/gdbm/RCS/hash.c'v 1.4.0.1 90/08/16 09:22:38 tho Exp $
  2209. !  */
  2210.   
  2211.   #include <stdio.h>
  2212.   #include <sys/types.h>
  2213. + #ifndef MSDOS
  2214.   #include <sys/file.h>
  2215. + #endif /* not MSDOS */
  2216.   #include <sys/stat.h>
  2217.   #include "gdbmdefs.h"
  2218.   
  2219. ***************
  2220. *** 41,51 ****
  2221.      to find the home position of the element by taking the value modulo the
  2222.      bucket hash table size. */
  2223.   
  2224. ! int
  2225.   _gdbm_hash (key)
  2226.        datum key;
  2227.   {
  2228. !   int  value;        /* Used to compute the hash value.  */
  2229.     int  index;        /* Used to cycle through random values. */
  2230.   
  2231.   
  2232. --- 58,68 ----
  2233.      to find the home position of the element by taking the value modulo the
  2234.      bucket hash table size. */
  2235.   
  2236. ! LONG
  2237.   _gdbm_hash (key)
  2238.        datum key;
  2239.   {
  2240. !   LONG value;        /* Used to compute the hash value.  */
  2241.     int  index;        /* Used to cycle through random values. */
  2242.   
  2243.   
  2244. diff -cBdNp e:/gnu/gdbm/gnu/makefile ./makefile
  2245. *** e:/gnu/gdbm/gnu/makefile    Thu Aug 16 10:51:54 1990
  2246. --- ./makefile    Thu Aug 16 10:51:40 1990
  2247. ***************
  2248. *** 0 ****
  2249. --- 1,153 ----
  2250. + # Makefile for gdbm.
  2251. + # MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2252. + #
  2253. + # To this port, the same copying conditions apply as to the
  2254. + # original release.
  2255. + #
  2256. + # IMPORTANT:
  2257. + # This file is not identical to the original GNU release!
  2258. + # You should have received this code as patch to the official
  2259. + # GNU release.
  2260. + #
  2261. + # MORE IMPORTANT:
  2262. + # This port comes with ABSOLUTELY NO WARRANTY.
  2263. + #
  2264. + # $Header: e:/gnu/gdbm/RCS/makefile.'v 1.4.0.2 90/08/16 10:40:52 tho Exp $
  2265. + BINDIR = c:/bin
  2266. + LIBDIR = d:/usr/lib
  2267. + INCDIR = d:/usr/include
  2268. + INSTALL = cp -v
  2269. + DISK    = b:
  2270. + ZIPFILE = gdbm.zip
  2271. + MODEL    = L
  2272. + CFLAGS    = -Ox -W4 -A$(MODEL) -DSYSV -Za
  2273. + LDFLAGS    = /st:0x8000 /e
  2274. + AR    = lib
  2275. + ARFLAGS    = -+
  2276. + GDBMLIB    = $(MODEL)gdbm.lib
  2277. + DBM_CF = dbminit.c delete.c fetch.c store.c seq.c
  2278. + NDBM_CF = dbmopen.c dbmdelet.c dbmfetch.c dbmstore.c dbmseq.c \
  2279. +     dbmclose.c dbmdirfn.c dbmpagfn.c
  2280. + GDBM_CF = gdbmopen.c gdbmdele.c gdbmfetc.c  gdbmstor.c gdbmclos.c \
  2281. +     gdbmreor.c gdbmseq.c \
  2282. +     bucket.c falloc.c findkey.c global.c hash.c update.c version.c
  2283. + HFILES = gdbmdefs.h extern.h gdbmerrn.h systems.h dbm.h ndbm.h
  2284. + MSCFILES = copying changelo makefile readme gdbm.pro conv2gdb.c
  2285. + TESTFILES = testdbm.c testndbm.c testgdbm.c
  2286. + RCSFILES= $(patsubst %, RCS/%'v, $(DBM_CF) $(NBM_CF) $(GBM_CF)) \
  2287. +       RCS/makefile.'v
  2288. + MISC    = RCS/readme'v changelo RCS/changelo.'v makepat mkpatch
  2289. + DBM_OF = dbminit.obj delete.obj fetch.obj store.obj seq.obj
  2290. + NDBM_OF = dbmopen.obj dbmdelet.obj dbmfetch.obj dbmstore.obj dbmseq.obj \
  2291. +     dbmclose.obj dbmdirfn.obj dbmpagfn.obj
  2292. + GDBM_OF = gdbmopen.obj gdbmdele.obj gdbmfetc.obj  gdbmstor.obj gdbmclos.obj \
  2293. +     gdbmreor.obj gdbmseq.obj \
  2294. +     bucket.obj falloc.obj findkey.obj global.obj hash.obj update.obj
  2295. + .PHONY: allgdbm
  2296. + allgdbm: $(GDBMLIB) testgdbm.exe testdbm.exe testndbm.exe
  2297. + .PHONY: install
  2298. + install: $(GDBMLIB) gdbmdefs.h
  2299. +     cp $(GDBMLIB) $(LIBDIR)
  2300. +     cp gdbmdefs.h $(INCDIR)
  2301. + $(GDBMLIB): version.c $(GDBM_OF) $(NDBM_OF) $(DBM_OF)
  2302. +     $(CC) $(CFLAGS) -c version.c
  2303. +     $(AR) $@ $(ARFLAGS) version $(subst version.c,,$?);
  2304. + gdbm.h:    gdbm.pro gdbmerrn.h
  2305. +     cp gdbm.pro gdbm.h
  2306. +     grep _ gdbmerrn.h >> gdbm.h
  2307. + gdbm.pro: RCS/gdbm.p'v
  2308. +     $(CO) $(COFLAGS) $@
  2309. + testgdbm.exe: testgdbm.obj $(GDBMLIB)
  2310. +     $(LINK) $(LDFLAGS) testgdbm, $@,, $(GDBMLIB);
  2311. + testdbm.exe: testdbm.obj $(GDBMLIB)
  2312. +     $(LINK) $(LDFLAGS) testdbm, $@,, $(GDBMLIB);
  2313. + testndbm.obj: testndbm.c
  2314. +     $(CC) -c $(CFLAGS) -DGNU testndbm.c
  2315. + testndbm.exe: testndbm.obj $(GDBMLIB)
  2316. +     $(LINK) $(LDFLAGS) testndbm, $@,, $(GDBMLIB);
  2317. + .PHONY: zip disk
  2318. + zip: $(ZIPFILE)
  2319. + disk: $(DISK)/$(ZIPFILE)
  2320. + $(ZIPFILE): $(RCSFILES) $(MISC)
  2321. +     pkzip -frp $@
  2322. + $(DISK)/$(ZIPFILE): $(ZIPFILE)
  2323. +     cp $< $@
  2324. +     pkunzip -t $@ | grep -vw OK
  2325. + .PHONY: clean
  2326. + clean:
  2327. +     rm -f gdbm.h *.obj *.map *.bak tags
  2328. +     rcsclean *.c *.h *.pro makefile
  2329. + tags: $(GDBM_CF) $(HFILES) $(TESTFILES) $(NDBM_CF) $(DBM_CF) 
  2330. +     etags -t *.c *.h
  2331. + # dbm files
  2332. + dbminit.obj:    gdbmdefs.h extern.h gdbmerrn.h systems.h
  2333. + delete.obj:    gdbmdefs.h extern.h
  2334. + fetch.obj:    gdbmdefs.h extern.h
  2335. + store.obj:    gdbmdefs.h extern.h
  2336. + seq.obj:    gdbmdefs.h extern.h
  2337. + # ndbm files
  2338. + dbmopen.obj:    gdbmdefs.h extern.h gdbmerrn.h systems.h
  2339. + dbmdelet.obj:    gdbmdefs.h extern.h
  2340. + dbmfetch.obj:    gdbmdefs.h extern.h
  2341. + dbmstore.obj:    gdbmdefs.h extern.h
  2342. + dbmseq.obj:    gdbmdefs.h extern.h
  2343. + dbmclose.obj:    gdbmdefs.h systems.h
  2344. + dbmpagfn.obj:    gdbmdefs.h extern.h
  2345. + dbmdirfn.obj:    gdbmdefs.h extern.h
  2346. + # gdbm files
  2347. + gdbmclos.obj:    gdbmdefs.h systems.h
  2348. + gdbmdele.obj:    gdbmdefs.h gdbmerrn.h systems.h
  2349. + gdbmfetc.obj:    gdbmdefs.h gdbmerrn.h systems.h
  2350. + gdbmopen.obj:    gdbmdefs.h gdbmerrn.h systems.h 
  2351. + gdbmreor.obj:    gdbmdefs.h gdbmerrn.h systems.h extern.h
  2352. + gdbmseq.obj:    gdbmdefs.h systems.h
  2353. + gdbmstor.obj:    gdbmdefs.h gdbmerrn.h systems.h
  2354. + # gdbm support files
  2355. + bucket.obj:    gdbmdefs.h systems.h
  2356. + falloc.obj:    gdbmdefs.h systems.h
  2357. + findkey.obj:    gdbmdefs.h systems.h
  2358. + global.obj:    gdbmdefs.h gdbmerrn.h 
  2359. + hash.obj:        gdbmdefs.h
  2360. + update.obj:    gdbmdefs.h systems.h
  2361. + version.obj:
  2362. + extern.h:    
  2363. + # other programs
  2364. + testgdbm.obj:    gdbmdefs.h extern.h gdbmerrn.h systems.h
  2365. + testdbm.obj:    dbm.h
  2366. + testndbm.obj:    ndbm.h
  2367. + conv2gdb.obj:    gdbm.h
  2368. diff -cBdNp e:/gnu/gdbm/gnu/ndbm.h ./ndbm.h
  2369. *** e:/gnu/gdbm/gnu/ndbm.h    Thu Aug 16 10:49:50 1990
  2370. --- ./ndbm.h    Thu Aug 16 10:51:12 1990
  2371. ***************
  2372. *** 27,32 ****
  2373. --- 27,49 ----
  2374.          
  2375.   *************************************************************************/
  2376.   
  2377. + /*
  2378. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2379. +  *
  2380. +  * To this port, the same copying conditions apply as to the
  2381. +  * original release.
  2382. +  *
  2383. +  * IMPORTANT:
  2384. +  * This file is not identical to the original GNU release!
  2385. +  * You should have received this code as patch to the official
  2386. +  * GNU release.
  2387. +  *
  2388. +  * MORE IMPORTANT:
  2389. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2390. +  *
  2391. +  * $Header: e:/gnu/gdbm/RCS/ndbm.h'v 1.4.0.1 90/08/16 09:23:06 tho Exp $
  2392. +  */
  2393.   /* Parameters to dbm_store for simple insertion or replacement. */
  2394.   #define  DBM_INSERT  0
  2395.   #define  DBM_REPLACE 1
  2396. ***************
  2397. *** 33,70 ****
  2398.   
  2399.   
  2400.   /* The data and key structure.  This structure is defined for compatibility. */
  2401.   typedef struct {
  2402.       char *dptr;
  2403.       int   dsize;
  2404.         } datum;
  2405.   
  2406.   /* The file information header. This is good enough for most applications. */
  2407.   typedef struct {int dummy[10];} DBM;
  2408.   
  2409.   /* These are the routines (with some macros defining them!) */
  2410.   
  2411.   extern DBM     *dbm_open ();
  2412.   extern void     dbm_close ();
  2413.   extern datum     dbm_fetch ();
  2414.   extern int     dbm_store ();
  2415. - extern int     dbm_delete ();
  2416.   extern int     dbm_delete ();
  2417.   extern datum     dbm_firstkey ();
  2418.   extern datum     dbm_nextkey ();
  2419.   
  2420.   #define         dbm_error(dbf)  0
  2421.   #define         dbm_clearerr(dbf)
  2422.   
  2423. - extern int     dbm_dirfno ();
  2424.   
  2425. - extern int     dbm_pagfno ();
  2426. --- 50,96 ----
  2427.   
  2428.   
  2429.   /* The data and key structure.  This structure is defined for compatibility. */
  2430. + #ifdef __STDC__
  2431. + #include "gdbmdefs.h"
  2432. + #else /* not __STDC__ */
  2433.   typedef struct {
  2434.       char *dptr;
  2435.       int   dsize;
  2436.         } datum;
  2437. ! #endif /* not __STDC__ */
  2438.   
  2439.   /* The file information header. This is good enough for most applications. */
  2440. + #ifdef __STDC__
  2441. + #define DBM gdbm_file_info
  2442. + #else /* not __STDC__ */
  2443.   typedef struct {int dummy[10];} DBM;
  2444. ! #endif /* not __STDC__ */
  2445.   
  2446.   /* These are the routines (with some macros defining them!) */
  2447.   
  2448. + #ifdef __STDC__
  2449. + extern DBM *dbm_open (char *file, int flags, int mode);
  2450. + extern void dbm_close (DBM *dbf);
  2451. + extern datum dbm_fetch (DBM *dbf, datum key);
  2452. + extern int dbm_store (DBM *dbf, datum key, datum content, int flags);
  2453. + extern int dbm_delete (DBM *dbf, datum key);
  2454. + extern datum dbm_firstkey (DBM *dbf);
  2455. + extern datum dbm_nextkey (DBM *dbf);
  2456. + extern int dbm_dirfno (DBM *dbf);
  2457. + extern int dbm_pagfno (DBM *dbf);
  2458. + #else /* not __STDC__ */
  2459.   extern DBM     *dbm_open ();
  2460.   extern void     dbm_close ();
  2461.   extern datum     dbm_fetch ();
  2462.   extern int     dbm_store ();
  2463.   extern int     dbm_delete ();
  2464.   extern datum     dbm_firstkey ();
  2465.   extern datum     dbm_nextkey ();
  2466. + extern int     dbm_dirfno ();
  2467. + extern int     dbm_pagfno ();
  2468. + #endif /* not __STDC__ */
  2469.   
  2470.   #define         dbm_error(dbf)  0
  2471.   #define         dbm_clearerr(dbf)
  2472.   
  2473.   
  2474. diff -cBdNp e:/gnu/gdbm/gnu/seq.c ./seq.c
  2475. *** e:/gnu/gdbm/gnu/seq.c    Thu Aug 16 10:49:50 1990
  2476. --- ./seq.c    Thu Aug 16 10:51:16 1990
  2477. ***************
  2478. *** 28,37 ****
  2479. --- 28,55 ----
  2480.          
  2481.   *************************************************************************/
  2482.   
  2483. + /*
  2484. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2485. +  *
  2486. +  * To this port, the same copying conditions apply as to the
  2487. +  * original release.
  2488. +  *
  2489. +  * IMPORTANT:
  2490. +  * This file is not identical to the original GNU release!
  2491. +  * You should have received this code as patch to the official
  2492. +  * GNU release.
  2493. +  *
  2494. +  * MORE IMPORTANT:
  2495. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2496. +  *
  2497. +  * $Header: e:/gnu/gdbm/RCS/seq.c'v 1.4.0.1 90/08/16 09:22:39 tho Exp $
  2498. +  */
  2499.   
  2500.   #include <stdio.h>
  2501.   #include <sys/types.h>
  2502. + #ifndef MSDOS
  2503.   #include <sys/file.h>
  2504. + #endif /* not MSDOS */
  2505.   #include <sys/stat.h>
  2506.   #include "gdbmdefs.h"
  2507.   #include "extern.h"
  2508. diff -cBdNp e:/gnu/gdbm/gnu/store.c ./store.c
  2509. *** e:/gnu/gdbm/gnu/store.c    Thu Aug 16 10:49:52 1990
  2510. --- ./store.c    Thu Aug 16 10:51:18 1990
  2511. ***************
  2512. *** 27,36 ****
  2513. --- 27,54 ----
  2514.          
  2515.   *************************************************************************/
  2516.   
  2517. + /*
  2518. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2519. +  *
  2520. +  * To this port, the same copying conditions apply as to the
  2521. +  * original release.
  2522. +  *
  2523. +  * IMPORTANT:
  2524. +  * This file is not identical to the original GNU release!
  2525. +  * You should have received this code as patch to the official
  2526. +  * GNU release.
  2527. +  *
  2528. +  * MORE IMPORTANT:
  2529. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2530. +  *
  2531. +  * $Header: e:/gnu/gdbm/RCS/store.c'v 1.4.0.1 90/08/16 09:22:40 tho Exp $
  2532. +  */
  2533.   
  2534.   #include <stdio.h>
  2535.   #include <sys/types.h>
  2536. + #ifndef MSDOS
  2537.   #include <sys/file.h>
  2538. + #endif /* not MSDOS */
  2539.   #include <sys/stat.h>
  2540.   #include "gdbmdefs.h"
  2541.   #include "extern.h"
  2542. diff -cBdNp e:/gnu/gdbm/gnu/systems.h ./systems.h
  2543. *** e:/gnu/gdbm/gnu/systems.h    Thu Aug 16 10:49:54 1990
  2544. --- ./systems.h    Thu Aug 16 10:51:24 1990
  2545. ***************
  2546. *** 27,32 ****
  2547. --- 27,48 ----
  2548.          
  2549.   *************************************************************************/
  2550.   
  2551. + /*
  2552. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2553. +  *
  2554. +  * To this port, the same copying conditions apply as to the
  2555. +  * original release.
  2556. +  *
  2557. +  * IMPORTANT:
  2558. +  * This file is not identical to the original GNU release!
  2559. +  * You should have received this code as patch to the official
  2560. +  * GNU release.
  2561. +  *
  2562. +  * MORE IMPORTANT:
  2563. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2564. +  *
  2565. +  * $Header: e:/gnu/gdbm/RCS/systems.h'v 1.4.0.1 90/08/16 09:23:07 tho Exp $
  2566. +  */
  2567.   
  2568.   /* To use this file, you must have included <sys/types.h>.  */
  2569.   
  2570. ***************
  2571. *** 37,47 ****
  2572. --- 53,73 ----
  2573.   #ifdef SYSV
  2574.   
  2575.   /* File seeking needs L_SET defined .*/
  2576. + #ifdef MSDOS
  2577. + #include <malloc.h>
  2578. + #include <io.h>
  2579. + #else /* not MSDOS */
  2580.   #include <unistd.h>
  2581. + #endif /* not MSDOS */
  2582.   #define L_SET SEEK_SET
  2583.   
  2584.   /* Some files need fcntl.h for locking. */
  2585.   #include <fcntl.h>
  2586. + #ifdef MSDOS
  2587. + #define UNLOCK_FILE(dbf)    /* later !!!  */
  2588. + #define READLOCK_FILE(dbf)    lock_val = 0;
  2589. + #define WRITELOCK_FILE(dbf)    lock_val = 0;
  2590. + #else /* not MSDOS */
  2591.   #define UNLOCK_FILE(dbf) \
  2592.       {                    \
  2593.         struct flock flock;            \
  2594. ***************
  2595. *** 66,71 ****
  2596. --- 92,98 ----
  2597.         flock.l_start = flock.l_len = 0L;    \
  2598.         lock_val = fcntl (dbf->desc, F_SETLK, &flock);    \
  2599.       }
  2600. + #endif /* not MSDOS */
  2601.   
  2602.   /* Send bcmp to the right place. */
  2603.   #include <memory.h>
  2604. ***************
  2605. *** 73,85 ****
  2606. --- 100,118 ----
  2607.   #define bcopy(d1, d2, n) memcpy(d2, d1, n)
  2608.   
  2609.   /* Sys V does not have fsync. */
  2610. + #ifdef MSDOS
  2611. + #define fsync(f)
  2612. + #else /* not MSDOS */
  2613.   #define fsync(f) sync(); sync()
  2614. + #endif /* not MSDOS */
  2615.   
  2616.   /* Stat does not have a st_blksize field. */
  2617.   #define STATBLKSIZE 512
  2618.   
  2619.   /* Does not have rename(). */
  2620. + #ifndef MSDOS
  2621.   #define NEED_RENAME
  2622. + #endif /* not MSDOS */
  2623.   #endif
  2624.   
  2625.   /*      End of System V changes and defines.      */
  2626. ***************
  2627. *** 86,92 ****
  2628.   /**************************************************/
  2629.   
  2630.   
  2631.   /* Alloca is builtin in gcc.  Use the builtin alloca if compiled with gcc. */
  2632.   #ifdef __GNUC__
  2633.   #define BUILTIN_ALLOCA
  2634. --- 119,125 ----
  2635.   /**************************************************/
  2636.   
  2637.   
  2638. ! #ifndef MSDOS
  2639.   /* Alloca is builtin in gcc.  Use the builtin alloca if compiled with gcc. */
  2640.   #ifdef __GNUC__
  2641.   #define BUILTIN_ALLOCA
  2642. *************** extern char *alloca();
  2643. *** 108,113 ****
  2644. --- 141,147 ----
  2645.   
  2646.   /* Malloc definition. */
  2647.   extern char *malloc();
  2648. + #endif /* not MSDOS */
  2649.   
  2650.   
  2651.   /* The BSD defines are the default defines.  If something is not
  2652. diff -cBdNp e:/gnu/gdbm/gnu/testdbm.c ./testdbm.c
  2653. *** e:/gnu/gdbm/gnu/testdbm.c    Thu Aug 16 10:49:56 1990
  2654. --- ./testdbm.c    Thu Aug 16 10:51:26 1990
  2655. ***************
  2656. *** 27,41 ****
  2657. --- 27,64 ----
  2658.          
  2659.   *************************************************************************/
  2660.   
  2661. + /*
  2662. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2663. +  *
  2664. +  * To this port, the same copying conditions apply as to the
  2665. +  * original release.
  2666. +  *
  2667. +  * IMPORTANT:
  2668. +  * This file is not identical to the original GNU release!
  2669. +  * You should have received this code as patch to the official
  2670. +  * GNU release.
  2671. +  *
  2672. +  * MORE IMPORTANT:
  2673. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2674. +  *
  2675. +  * $Header: e:/gnu/gdbm/RCS/testdbm.c'v 1.4.0.1 90/08/16 09:22:42 tho Exp $
  2676. +  */
  2677.   
  2678.   #include <stdio.h>
  2679.   #include <sys/types.h>
  2680. + #ifndef MSDOS
  2681.   #include <sys/file.h>
  2682. + #endif /* not MSDOS */
  2683.   #include <sys/stat.h>
  2684.   
  2685.   #define TRUE  1
  2686.   #define FALSE 0
  2687.   
  2688. + #ifdef __STDC__
  2689. + #include <stdlib.h>
  2690. + #include <string.h>
  2691. + #include "dbm.h"
  2692. + #else /* not __STDC__ */
  2693.   typedef struct {
  2694.     char *dptr;
  2695.     int   dsize;
  2696. *************** typedef struct {
  2697. *** 44,49 ****
  2698. --- 67,73 ----
  2699.   extern datum fetch ();
  2700.   extern datum firstkey ();
  2701.   extern datum nextkey ();
  2702. + #endif /* not __STDC__ */
  2703.   
  2704.   /* The test program allows one to call all the routines plus the hash function.
  2705.      The commands are single letter commands.  The user is prompted for all other
  2706. diff -cBdNp e:/gnu/gdbm/gnu/testgdbm.c ./testgdbm.c
  2707. *** e:/gnu/gdbm/gnu/testgdbm.c    Thu Aug 16 10:49:58 1990
  2708. --- ./testgdbm.c    Thu Aug 16 10:51:30 1990
  2709. ***************
  2710. *** 28,37 ****
  2711. --- 28,55 ----
  2712.          
  2713.   *************************************************************************/
  2714.   
  2715. + /*
  2716. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  2717. +  *
  2718. +  * To this port, the same copying conditions apply as to the
  2719. +  * original release.
  2720. +  *
  2721. +  * IMPORTANT:
  2722. +  * This file is not identical to the original GNU release!
  2723. +  * You should have received this code as patch to the official
  2724. +  * GNU release.
  2725. +  *
  2726. +  * MORE IMPORTANT:
  2727. +  * This port comes with ABSOLUTELY NO WARRANTY.
  2728. +  *
  2729. +  * $Header: e:/gnu/gdbm/RCS/testgdbm.c'v 1.4.0.2 90/08/16 09:55:48 tho Exp $
  2730. +  */
  2731.   
  2732.   #include <stdio.h>
  2733.   #include <sys/types.h>
  2734. + #ifndef MSDOS
  2735.   #include <sys/file.h>
  2736. + #endif /* not MSDOS */
  2737.   #include <sys/stat.h>
  2738.   #include "gdbmdefs.h"
  2739.   #include "systems.h"
  2740. *************** extern char * gdbm_version;
  2741. *** 44,50 ****
  2742. --- 62,148 ----
  2743.   
  2744.   gdbm_file_info *gdbm_file;
  2745.   
  2746. + #ifdef __STDC__
  2747. + static void print_bucket (hash_bucket *bucket, char *mesg);
  2748. + static void _gdbm_print_avail_list (gdbm_file_info *dbf);
  2749. + extern void main (int argc, char **argv);
  2750. + void gdbm_perror (char *msg);
  2751. + #endif /* __STDC__ */
  2752. + /* access GDBM_ERRNO.  [tho]  */
  2753. + void
  2754. + gdbm_perror (char *msg)
  2755. + {
  2756. +   char *err_msg;
  2757. +   switch (gdbm_errno)
  2758. +     {
  2759. +     case GDBM_NO_ERROR:
  2760. +       err_msg = "no error";
  2761. +       break;
  2762. +     case GDBM_MALLOC_ERROR:
  2763. +       err_msg = "can't malloc";
  2764. +       break;
  2765. +     case GDBM_BLOCK_SIZE_ERROR:
  2766. +       err_msg = "bad block size";
  2767. +       break;
  2768. +     case GDBM_FILE_OPEN_ERROR:
  2769. +       err_msg = "can't open file";
  2770. +       break;
  2771. +     case GDBM_FILE_WRITE_ERROR:
  2772. +       err_msg = "can't write file";
  2773. +       break;
  2774. +     case GDBM_FILE_SEEK_ERROR:
  2775. +       err_msg = "can't seek file";
  2776. +       break;
  2777. +     case GDBM_FILE_READ_ERROR:
  2778. +       err_msg = "can't read file";
  2779. +       break;
  2780. +     case GDBM_BAD_MAGIC_NUMBER:
  2781. +       err_msg = "bad magic number";
  2782. +       break;
  2783. +     case GDBM_EMPTY_DATABASE:
  2784. +       err_msg = "empty database";
  2785. +       break;
  2786. +     case GDBM_CANT_BE_READER:
  2787. +       err_msg = "can't be reader";
  2788. +       break;
  2789. +     case GDBM_CANT_BE_WRITER:
  2790. +       err_msg = "can't be writer";
  2791. +       break;
  2792. +     case GDBM_READER_CANT_DELETE:
  2793. +       err_msg = "can't delete";
  2794. +       break;
  2795. +     case GDBM_READER_CANT_STORE:
  2796. +       err_msg = "can't store";
  2797. +       break;
  2798. +     case GDBM_READER_CANT_REORGANIZE:
  2799. +       err_msg = "can't reorganize";
  2800. +       break;
  2801. +     case GDBM_UNKNOWN_UPDATE:
  2802. +       err_msg = "unkown update";
  2803. +       break;
  2804. +     case GDBM_ITEM_NOT_FOUND:
  2805. +       err_msg = "item not found";
  2806. +       break;
  2807. +     case GDBM_REORGANIZE_FAILED:
  2808. +       err_msg = "reorganization failed";
  2809. +       break;
  2810. +     case GDBM_CANNOT_REPLACE:
  2811. +       err_msg = "can't replace";
  2812. +       break;
  2813. +     default:
  2814. +       err_msg = "unknown error";
  2815. +     }
  2816. +   fprintf (stderr, "%s (GDBM error: %s)\n", msg, err_msg);
  2817. + }
  2818.   /* Debug procedure to print the contents of the current hash bucket. */
  2819. + VOID
  2820.   print_bucket (bucket, mesg)
  2821.        hash_bucket *bucket;
  2822.        char *mesg;
  2823. *************** print_bucket (bucket, mesg)
  2824. *** 55,60 ****
  2825. --- 153,166 ----
  2826.        mesg, bucket->bucket_bits, bucket->count);
  2827.     printf ("     #    hash value     key size    data size     data adr  home\n");
  2828.     for (index = 0; index < gdbm_file->header->bucket_elems; index++)
  2829. + #ifdef MSDOS
  2830. +     printf ("  %4d  %12lx  %11d  %11d  %11ld %5d\n", index,
  2831. +        bucket->h_table[index].hash_value,
  2832. +        bucket->h_table[index].key_size,
  2833. +        bucket->h_table[index].data_size,
  2834. +        bucket->h_table[index].data_pointer,
  2835. +        (int) (bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems));
  2836. + #else /* not MSDOS */
  2837.       printf ("  %4d  %12x  %11d  %11d  %11d %5d\n", index,
  2838.          bucket->h_table[index].hash_value,
  2839.          bucket->h_table[index].key_size,
  2840. *************** print_bucket (bucket, mesg)
  2841. *** 61,79 ****
  2842.          bucket->h_table[index].data_size,
  2843.          bucket->h_table[index].data_pointer,
  2844.          bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems);
  2845.   
  2846.     printf ("\nAvail count = %1d\n", bucket->av_count);
  2847.     printf ("Avail  adr     size\n");
  2848.     for (index = 0; index < bucket->av_count; index++)
  2849.       printf ("%9d%9d\n", bucket->bucket_avail[index].av_adr,
  2850.                       bucket->bucket_avail[index].av_size);
  2851.   }
  2852.   
  2853.   
  2854.   _gdbm_print_avail_list (dbf)
  2855.        gdbm_file_info *dbf;
  2856.   {
  2857. !   int temp;
  2858.     int size;
  2859.     avail_block *av_stk;
  2860.    
  2861. --- 167,191 ----
  2862.          bucket->h_table[index].data_size,
  2863.          bucket->h_table[index].data_pointer,
  2864.          bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems);
  2865. + #endif /* not MSDOS */
  2866.   
  2867.     printf ("\nAvail count = %1d\n", bucket->av_count);
  2868.     printf ("Avail  adr     size\n");
  2869.     for (index = 0; index < bucket->av_count; index++)
  2870. + #ifdef MSDOS
  2871. +     printf ("%9ld%9d\n", bucket->bucket_avail[index].av_adr,
  2872. + #else /* not MSDOS */
  2873.       printf ("%9d%9d\n", bucket->bucket_avail[index].av_adr,
  2874. + #endif /* not MSDOS */
  2875.                       bucket->bucket_avail[index].av_size);
  2876.   }
  2877.   
  2878.   
  2879. + VOID
  2880.   _gdbm_print_avail_list (dbf)
  2881.        gdbm_file_info *dbf;
  2882.   {
  2883. !   LONG temp;
  2884.     int size;
  2885.     avail_block *av_stk;
  2886.    
  2887. *************** _gdbm_print_avail_list (dbf)
  2888. *** 82,88 ****
  2889. --- 194,204 ----
  2890.         dbf->header->avail.size, dbf->header->avail.count);
  2891.     for (temp = 0; temp < dbf->header->avail.count; temp++)
  2892.       {
  2893. + #ifdef MSDOS
  2894. +       printf ("  %15d   %10ld \n", dbf->header->avail.av_table[temp].av_size,
  2895. + #else /* not MSDOS */
  2896.         printf ("  %15d   %10d \n", dbf->header->avail.av_table[temp].av_size,
  2897. + #endif /* not MSDOS */
  2898.             dbf->header->avail.av_table[temp].av_adr);
  2899.       }
  2900.   
  2901. *************** _gdbm_print_avail_list (dbf)
  2902. *** 91,102 ****
  2903. --- 207,229 ----
  2904.     size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1)
  2905.         + sizeof (avail_block));
  2906.     av_stk = (avail_block *) alloca (size);
  2907. + #ifdef MSDOS
  2908. +   if (av_stk == (avail_block *) 0)
  2909. +     {
  2910. +       fprintf (stderr, "alloca failed.\n");
  2911. +       exit (-2);
  2912. +     }
  2913. + #endif /* MSDOS */
  2914.   
  2915.     /* Print the stack. */
  2916.     while (FALSE)
  2917.       {
  2918.         lseek (dbf->desc, temp, L_SET);
  2919. + #ifdef MSDOS
  2920. +       read  (dbf->desc, (char *) av_stk, size);
  2921. + #else /* not MSDOS */
  2922.         read  (dbf->desc, av_stk, size);
  2923. + #endif /* not MSDOS */
  2924.   
  2925.         /* Print the block! */
  2926.         printf ("\nblock = %d\nsize  = %d\ncount = %d\n", temp,
  2927. *************** _gdbm_print_avail_list (dbf)
  2928. *** 103,109 ****
  2929. --- 230,240 ----
  2930.             av_stk->size, av_stk->count);
  2931.         for (temp = 0; temp < av_stk->count; temp++)
  2932.       {
  2933. + #ifdef MSDOS
  2934. +       printf ("  %15d   %10ld \n", av_stk->av_table[temp].av_size,
  2935. + #else /* not MSDOS */
  2936.         printf ("  %15d   %10d \n", av_stk->av_table[temp].av_size,
  2937. + #endif /* not MSDOS */
  2938.           av_stk->av_table[temp].av_adr);
  2939.       }
  2940.         temp = av_stk->next_block;
  2941. *************** _gdbm_print_bucket_cache (dbf)
  2942. *** 120,126 ****
  2943. --- 251,261 ----
  2944.     for (index=0; index < CACHE_SIZE; index++)
  2945.       {
  2946.         changed = dbf->bucket_cache[index].ca_changed;
  2947. + #ifdef MSDOS
  2948. +       printf ("  %5d:  %7ld  %7s  %lx\n",
  2949. + #else /* not MSDOS */
  2950.         printf ("  %5d:  %7d  %7s  %x\n",
  2951. + #endif /* not MSDOS */
  2952.             index,
  2953.             dbf->bucket_cache[index].ca_adr,
  2954.             (changed ? "True" : "False"),
  2955. *************** _gdbm_print_bucket_cache (dbf)
  2956. *** 133,138 ****
  2957. --- 268,274 ----
  2958.      The commands are single letter commands.  The user is prompted for all other
  2959.      information.  See the help command (?) for a list of all commands. */
  2960.   
  2961. + VOID
  2962.   main (argc, argv)
  2963.        int argc;
  2964.        char *argv[];
  2965. *************** main (argc, argv)
  2966. *** 176,185 ****
  2967.     gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL);
  2968.     if (gdbm_file == NULL)
  2969.       {
  2970. !       if (gdbm_errno != GDBM_CANT_BE_WRITER)
  2971. !     printf ("gdbm_open failed.\n");
  2972. !       else
  2973. !     printf ("Can't open as a writer. \n");
  2974.         exit (2);
  2975.       }
  2976.   
  2977. --- 312,318 ----
  2978.     gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL);
  2979.     if (gdbm_file == NULL)
  2980.       {
  2981. !       gdbm_perror ("gdbm_open failed");
  2982.         exit (2);
  2983.       }
  2984.   
  2985. *************** main (argc, argv)
  2986. *** 189,200 ****
  2987. --- 322,341 ----
  2988.     while (!done)
  2989.       {
  2990.         printf ("com -> ");
  2991. + #ifdef MSDOS            /* shut up the compiler */
  2992. +       cmd_ch = (char) getchar ();
  2993. + #else /* not MSDOS */
  2994.         cmd_ch = getchar ();
  2995. + #endif /* not MSDOS */
  2996.         if (cmd_ch != '\n')
  2997.       {
  2998.         char temp;
  2999.         do
  3000. + #ifdef MSDOS            /* shut up the compiler */
  3001. +           temp = (char) getchar ();
  3002. + #else /* not MSDOS */
  3003.             temp = getchar ();
  3004. + #endif /* not MSDOS */
  3005.         while (temp != '\n' && temp != EOF);
  3006.       }
  3007.         if (cmd_ch == EOF) cmd_ch = 'q';
  3008. *************** main (argc, argv)
  3009. *** 230,236 ****
  3010.         key_data.dptr = key_line;
  3011.         key_data.dsize = strlen (key_line)+1;
  3012.         if (gdbm_delete (gdbm_file, key_data) != 0)
  3013. !         printf ("Item not found or deleted\n");
  3014.         printf ("\n");
  3015.         key_data.dptr = NULL;
  3016.         break;
  3017. --- 371,377 ----
  3018.         key_data.dptr = key_line;
  3019.         key_data.dsize = strlen (key_line)+1;
  3020.         if (gdbm_delete (gdbm_file, key_data) != 0)
  3021. !         gdbm_perror ("Item not found or deleted");
  3022.         printf ("\n");
  3023.         key_data.dptr = NULL;
  3024.         break;
  3025. *************** main (argc, argv)
  3026. *** 269,275 ****
  3027.           }
  3028.         else
  3029.           {
  3030. !           printf ("No such item found.\n\n");
  3031.             key_data.dptr = NULL;
  3032.           }
  3033.         break;
  3034. --- 410,416 ----
  3035.           }
  3036.         else
  3037.           {
  3038. !           gdbm_perror ("No such item found");
  3039.             key_data.dptr = NULL;
  3040.           }
  3041.         break;
  3042. *************** main (argc, argv)
  3043. *** 288,294 ****
  3044.         gets (data_line);
  3045.         data_data.dsize = strlen (data_line)+1;
  3046.         if (gdbm_store (gdbm_file, key_data, data_data, GDBM_REPLACE) != 0)
  3047. !         printf ("Item not inserted. \n");
  3048.         printf ("\n");
  3049.         key_data.dptr = NULL;
  3050.         break;
  3051. --- 429,435 ----
  3052.         gets (data_line);
  3053.         data_data.dsize = strlen (data_line)+1;
  3054.         if (gdbm_store (gdbm_file, key_data, data_data, GDBM_REPLACE) != 0)
  3055. !         gdbm_perror ("Item not inserted");
  3056.         printf ("\n");
  3057.         key_data.dptr = NULL;
  3058.         break;
  3059. *************** main (argc, argv)
  3060. *** 304,310 ****
  3061.             free (return_data.dptr);
  3062.           }
  3063.         else
  3064. !         printf ("No such item found.\n\n");
  3065.         break;
  3066.   
  3067.       case '2':
  3068. --- 445,451 ----
  3069.             free (return_data.dptr);
  3070.           }
  3071.         else
  3072. !         gdbm_perror ("No such item found");
  3073.         break;
  3074.   
  3075.       case '2':
  3076. *************** main (argc, argv)
  3077. *** 319,325 ****
  3078.             free (return_data.dptr);
  3079.           }
  3080.         else
  3081. !         printf ("No such item found.\n\n");
  3082.         break;
  3083.   
  3084.   
  3085. --- 460,466 ----
  3086.             free (return_data.dptr);
  3087.           }
  3088.         else
  3089. !         gdbm_perror ("No such item found");
  3090.         break;
  3091.   
  3092.   
  3093. *************** main (argc, argv)
  3094. *** 327,333 ****
  3095.       case 'r':
  3096.         {
  3097.           if (gdbm_reorganize (gdbm_file))
  3098. !           printf ("Reorganization failed. \n\n");
  3099.           else
  3100.             printf ("Reorganization succeeded. \n\n");
  3101.         }
  3102. --- 468,474 ----
  3103.       case 'r':
  3104.         {
  3105.           if (gdbm_reorganize (gdbm_file))
  3106. !           gdbm_perror ("Reorganization failed");
  3107.           else
  3108.             printf ("Reorganization succeeded. \n\n");
  3109.         }
  3110. *************** main (argc, argv)
  3111. *** 349,355 ****
  3112.   
  3113.           if (temp >= gdbm_file->header->dir_size /4)
  3114.             {
  3115. !         printf ("Not a bucket. \n\n");
  3116.           break;
  3117.             }
  3118.           _gdbm_get_bucket (gdbm_file, temp);
  3119. --- 490,496 ----
  3120.   
  3121.           if (temp >= gdbm_file->header->dir_size /4)
  3122.             {
  3123. !         gdbm_perror ("Not a bucket");
  3124.           break;
  3125.             }
  3126.           _gdbm_get_bucket (gdbm_file, temp);
  3127. *************** main (argc, argv)
  3128. *** 359,365 ****
  3129. --- 500,510 ----
  3130.       case 'C':
  3131.         print_bucket (gdbm_file->bucket, "Current bucket");
  3132.         printf ("\n current directory entry = %d.\n", gdbm_file->bucket_dir);
  3133. + #ifdef MSDOS
  3134. +       printf (" current bucket address  = %ld.\n\n",
  3135. + #else /* not MSDOS */
  3136.         printf (" current bucket address  = %d.\n\n",
  3137. + #endif /* not MSDOS */
  3138.             gdbm_file->cache_entry->ca_adr);
  3139.         break;
  3140.   
  3141. *************** main (argc, argv)
  3142. *** 372,378 ****
  3143. --- 517,527 ----
  3144.   
  3145.           for (temp = 0; temp < gdbm_file->header->dir_size / 4; temp++)
  3146.             {
  3147. + #ifdef MSDOS
  3148. +         printf ("  %10d:  %12ld\n", temp, gdbm_file->dir[temp]);
  3149. + #else /* not MSDOS */
  3150.           printf ("  %10d:  %12d\n", temp, gdbm_file->dir[temp]);
  3151. + #endif /* not MSDOS */
  3152.           if ( (temp+1) % 20 == 0 && isatty (0))
  3153.             {
  3154.               printf ("*** CR to continue: ");
  3155. *************** main (argc, argv)
  3156. *** 385,400 ****
  3157.   
  3158.       case 'F':
  3159.         {
  3160. !         int temp;
  3161.   
  3162.           printf ("\nFile Header: \n\n");
  3163.           printf ("  table        = %d\n", gdbm_file->header->dir);
  3164.           printf ("  table size   = %d\n", gdbm_file->header->dir_size);
  3165.           printf ("  table bits   = %d\n", gdbm_file->header->dir_bits);
  3166.           printf ("  block size   = %d\n", gdbm_file->header->block_size);
  3167.           printf ("  bucket elems = %d\n", gdbm_file->header->bucket_elems);
  3168.           printf ("  bucket size  = %d\n", gdbm_file->header->bucket_size);
  3169.           printf ("  header magic = %x\n", gdbm_file->header->header_magic);
  3170.           printf ("  next block   = %d\n", gdbm_file->header->next_block);
  3171.           printf ("  avail size   = %d\n", gdbm_file->header->avail.size);
  3172.           printf ("  avail count  = %d\n", gdbm_file->header->avail.count);
  3173. --- 534,559 ----
  3174.   
  3175.       case 'F':
  3176.         {
  3177. ! #ifndef MSDOS            /* shut up the compiler */
  3178. !           int temp;
  3179. ! #endif /* not MSDOS */
  3180.   
  3181.           printf ("\nFile Header: \n\n");
  3182. + #ifdef MSDOS
  3183. +         printf ("  table        = %ld\n", gdbm_file->header->dir);
  3184. + #else /* not MSDOS */
  3185.           printf ("  table        = %d\n", gdbm_file->header->dir);
  3186. + #endif /* not MSDOS */
  3187.           printf ("  table size   = %d\n", gdbm_file->header->dir_size);
  3188.           printf ("  table bits   = %d\n", gdbm_file->header->dir_bits);
  3189.           printf ("  block size   = %d\n", gdbm_file->header->block_size);
  3190.           printf ("  bucket elems = %d\n", gdbm_file->header->bucket_elems);
  3191.           printf ("  bucket size  = %d\n", gdbm_file->header->bucket_size);
  3192. + #ifdef MSDOS
  3193. +         printf ("  header magic = %lx\n", gdbm_file->header->header_magic);
  3194. + #else /* not MSDOS */
  3195.           printf ("  header magic = %x\n", gdbm_file->header->header_magic);
  3196. + #endif /* not MSDOS */
  3197.           printf ("  next block   = %d\n", gdbm_file->header->next_block);
  3198.           printf ("  avail size   = %d\n", gdbm_file->header->avail.size);
  3199.           printf ("  avail count  = %d\n", gdbm_file->header->avail.count);
  3200. *************** main (argc, argv)
  3201. *** 409,415 ****
  3202. --- 568,578 ----
  3203.         gets (key_line);
  3204.         key_data.dptr = key_line;
  3205.         key_data.dsize = strlen (key_line)+1;
  3206. + #ifdef MSDOS
  3207. +       printf ("hash value = %lx. \n\n", _gdbm_hash (key_data));
  3208. + #else /* not MSDOS */
  3209.         printf ("hash value = %x. \n\n", _gdbm_hash (key_data));
  3210. + #endif /* not MSDOS */
  3211.         key_data.dptr = NULL;
  3212.         break;
  3213.   
  3214. diff -cBdNp e:/gnu/gdbm/gnu/testndbm.c ./testndbm.c
  3215. *** e:/gnu/gdbm/gnu/testndbm.c    Thu Aug 16 10:50:02 1990
  3216. --- ./testndbm.c    Thu Aug 16 10:51:32 1990
  3217. ***************
  3218. *** 27,36 ****
  3219. --- 27,54 ----
  3220.          
  3221.   *************************************************************************/
  3222.   
  3223. + /*
  3224. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  3225. +  *
  3226. +  * To this port, the same copying conditions apply as to the
  3227. +  * original release.
  3228. +  *
  3229. +  * IMPORTANT:
  3230. +  * This file is not identical to the original GNU release!
  3231. +  * You should have received this code as patch to the official
  3232. +  * GNU release.
  3233. +  *
  3234. +  * MORE IMPORTANT:
  3235. +  * This port comes with ABSOLUTELY NO WARRANTY.
  3236. +  *
  3237. +  * $Header: e:/gnu/gdbm/RCS/testndbm.c'v 1.4.0.1 90/08/16 09:22:51 tho Exp $
  3238. +  */
  3239.   
  3240.   #include <stdio.h>
  3241.   #include <sys/types.h>
  3242. + #ifndef MSDOS
  3243.   #include <sys/file.h>
  3244. + #endif /* not MSDOS */
  3245.   #include <sys/stat.h>
  3246.   #ifdef SYSV
  3247.   #include <fcntl.h>
  3248. diff -cBdNp e:/gnu/gdbm/gnu/update.c ./update.c
  3249. *** e:/gnu/gdbm/gnu/update.c    Thu Aug 16 10:50:02 1990
  3250. --- ./update.c    Thu Aug 16 10:51:34 1990
  3251. ***************
  3252. *** 27,51 ****
  3253.          
  3254.   *************************************************************************/
  3255.   
  3256.   
  3257.   #include <stdio.h>
  3258.   #include <sys/types.h>
  3259.   #include <sys/file.h>
  3260.   #include "gdbmdefs.h"
  3261.   #include "systems.h"
  3262.   
  3263.   
  3264.   /* This procedure writes the header back to the file described by DBF. */
  3265.   
  3266. ! static 
  3267.   write_header (dbf)
  3268.        gdbm_file_info *dbf;
  3269.   {
  3270. !   int num_bytes;
  3271.   
  3272. !   num_bytes = lseek (dbf->desc, 0, L_SET);
  3273.     if (num_bytes != 0) _gdbm_fatal (dbf, "lseek error");
  3274.     num_bytes = write (dbf->desc, dbf->header, dbf->header->block_size);
  3275.     if (num_bytes != dbf->header->block_size)
  3276.       _gdbm_fatal (dbf, "write error");
  3277.   
  3278. --- 27,76 ----
  3279.          
  3280.   *************************************************************************/
  3281.   
  3282. + /*
  3283. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  3284. +  *
  3285. +  * To this port, the same copying conditions apply as to the
  3286. +  * original release.
  3287. +  *
  3288. +  * IMPORTANT:
  3289. +  * This file is not identical to the original GNU release!
  3290. +  * You should have received this code as patch to the official
  3291. +  * GNU release.
  3292. +  *
  3293. +  * MORE IMPORTANT:
  3294. +  * This port comes with ABSOLUTELY NO WARRANTY.
  3295. +  *
  3296. +  * $Header: e:/gnu/gdbm/RCS/update.c'v 1.4.0.1 90/08/16 09:22:53 tho Exp $
  3297. +  */
  3298.   
  3299.   #include <stdio.h>
  3300.   #include <sys/types.h>
  3301. + #ifndef MSDOS
  3302.   #include <sys/file.h>
  3303. + #endif /* not MSDOS */
  3304.   #include "gdbmdefs.h"
  3305.   #include "systems.h"
  3306.   
  3307. + #ifdef __STDC__
  3308. + static void write_header (gdbm_file_info *dbf);
  3309. + #endif /* __STDC__ */
  3310.   
  3311.   /* This procedure writes the header back to the file described by DBF. */
  3312.   
  3313. ! static VOID
  3314.   write_header (dbf)
  3315.        gdbm_file_info *dbf;
  3316.   {
  3317. !   LONG num_bytes;
  3318.   
  3319. !   num_bytes = lseek (dbf->desc, (LONG) 0, L_SET);
  3320.     if (num_bytes != 0) _gdbm_fatal (dbf, "lseek error");
  3321. + #ifdef MSDOS
  3322. +   num_bytes = write (dbf->desc, (char *) dbf->header, dbf->header->block_size);
  3323. + #else /* not MSDOS */
  3324.     num_bytes = write (dbf->desc, dbf->header, dbf->header->block_size);
  3325. + #endif /* not MSDOS */
  3326.     if (num_bytes != dbf->header->block_size)
  3327.       _gdbm_fatal (dbf, "write error");
  3328.   
  3329. *************** write_header (dbf)
  3330. *** 56,65 ****
  3331.   
  3332.   /* After all changes have been made in memory, we now write them
  3333.      all to disk. */
  3334.   _gdbm_end_update (dbf)
  3335.        gdbm_file_info *dbf;
  3336.   {
  3337. !   int num_bytes;    /* Return value for lseek and write. */
  3338.     
  3339.     /* Write the current bucket. */
  3340.     if (dbf->bucket_changed)
  3341. --- 81,91 ----
  3342.   
  3343.   /* After all changes have been made in memory, we now write them
  3344.      all to disk. */
  3345. + VOID
  3346.   _gdbm_end_update (dbf)
  3347.        gdbm_file_info *dbf;
  3348.   {
  3349. !   LONG num_bytes;    /* Return value for lseek and write. */
  3350.     
  3351.     /* Write the current bucket. */
  3352.     if (dbf->bucket_changed)
  3353. *************** _gdbm_end_update (dbf)
  3354. *** 86,92 ****
  3355. --- 112,122 ----
  3356.       {
  3357.         num_bytes = lseek (dbf->desc, dbf->header->dir, L_SET);
  3358.         if (num_bytes != dbf->header->dir) _gdbm_fatal (dbf, "lseek error");
  3359. + #ifdef MSDOS            /* shut up the compiler!  */
  3360. +       num_bytes = write (dbf->desc, (char *) dbf->dir, dbf->header->dir_size);
  3361. + #else /* not MSDOS */
  3362.         num_bytes = write (dbf->desc, dbf->dir, dbf->header->dir_size);
  3363. + #endif /* not MSDOS */
  3364.         if (num_bytes != dbf->header->dir_size)
  3365.       _gdbm_fatal (dbf, "write error");
  3366.         dbf->directory_changed = FALSE;
  3367. *************** _gdbm_end_update (dbf)
  3368. *** 104,109 ****
  3369. --- 134,140 ----
  3370.   
  3371.   /* If a fatal error is detected, come here and exit. VAL tells which fatal
  3372.      error occured. */
  3373. + VOID
  3374.   _gdbm_fatal (dbf, val)
  3375.        gdbm_file_info *dbf;
  3376.        char *val;
  3377. diff -cBdNp e:/gnu/gdbm/gnu/version.c ./version.c
  3378. *** e:/gnu/gdbm/gnu/version.c    Thu Aug 16 10:50:04 1990
  3379. --- ./version.c    Thu Aug 16 10:51:36 1990
  3380. ***************
  3381. *** 27,32 ****
  3382. --- 27,54 ----
  3383.          
  3384.   *************************************************************************/
  3385.   
  3386. + /*
  3387. +  * MS-DOS port (c) 1990 by Thorsten Ohl, td12@@ddagsi3.bitnet
  3388. +  *
  3389. +  * To this port, the same copying conditions apply as to the
  3390. +  * original release.
  3391. +  *
  3392. +  * IMPORTANT:
  3393. +  * This file is not identical to the original GNU release!
  3394. +  * You should have received this code as patch to the official
  3395. +  * GNU release.
  3396. +  *
  3397. +  * MORE IMPORTANT:
  3398. +  * This port comes with ABSOLUTELY NO WARRANTY.
  3399. +  *
  3400. +  * $Header: e:/gnu/gdbm/RCS/version.c'v 1.4.0.1 90/08/16 09:28:34 tho Exp $
  3401. +  */
  3402.   /* Keep a string with the version number in it! */
  3403. + #ifdef MSDOS
  3404. + char * gdbm_version = "This is GDBM version 1.4, as of August 14, 1990. "\
  3405. +               "(Compiled for MS-DOS: " __DATE__ " " __TIME__ ")";
  3406. + #else /* not MSDOS */
  3407.   char * gdbm_version = "This is GDBM version 1.4, as of August 14, 1990.";
  3408. + #endif /* not MSDOS */
  3409.   
  3410.