From 5f8ba9f35bd3c9aeafe26613021f2edd141b8611 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 9 Sep 1997 13:37:52 +0000 Subject: [PATCH] Partial port to WIN95/NT. --- bfile/bfile.c | 9 ++++++++- bfile/mfile.c | 12 ++++++++++-- dfa/agrep.c | 12 +++++++++--- dict/dclose.c | 6 ++++-- dict/dopen.c | 7 ++++++- dict/drdwr.c | 7 ++++++- include/direntz.h | 25 +++++++++++++++++++++++++ index/dir.c | 9 +++++++-- index/dirs.c | 6 +++++- index/extract.c | 9 ++++++++- index/kdump.c | 10 +++++++++- index/kinput.c | 13 ++++++++++++- index/lockidx.c | 9 ++++++++- index/lockutil.c | 9 ++++++++- index/main.c | 9 ++++++++- index/recstat.c | 8 ++++++-- index/symtab.c | 6 +++++- index/trav.c | 13 ++++++++++--- isam/issh.c | 2 +- isam/memory.c | 7 ++++++- isam/physical.c | 6 +++++- recctrl/recgrs.c | 7 ++++++- rset/rsbool.c | 7 ++++++- rset/rsm_or.c | 8 ++++++-- rset/rsrel.c | 6 +++++- rset/rssbool.c | 8 ++++++-- rset/rstemp.c | 10 +++++++++- util/dirent.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ util/res.c | 13 ++++++++++++- 29 files changed, 266 insertions(+), 37 deletions(-) create mode 100644 include/direntz.h create mode 100644 util/dirent.c diff --git a/bfile/bfile.c b/bfile/bfile.c index d1a684a..993f3b2 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: bfile.c,v $ - * Revision 1.21 1996-10-29 13:56:13 adam + * Revision 1.22 1997-09-09 13:37:52 adam + * Partial port to WIN95/NT. + * + * Revision 1.21 1996/10/29 13:56:13 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.20 1996/03/26 15:59:04 adam @@ -72,7 +75,11 @@ #include #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include diff --git a/bfile/mfile.c b/bfile/mfile.c index b2f3012..a87ac69 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: mfile.c,v $ - * Revision 1.22 1997-09-04 13:56:39 adam + * Revision 1.23 1997-09-09 13:37:53 adam + * Partial port to WIN95/NT. + * + * Revision 1.22 1997/09/04 13:56:39 adam * Added O_BINARY to open calls. * * Revision 1.21 1996/10/29 13:56:18 adam @@ -80,8 +83,13 @@ #include #include +#ifdef WINDOWS +#include +#else #include -#include +#endif +#include +#include #include #include #include diff --git a/dfa/agrep.c b/dfa/agrep.c index f63e7da..2214fb5 100644 --- a/dfa/agrep.c +++ b/dfa/agrep.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: agrep.c,v $ - * Revision 1.9 1996-10-29 13:57:18 adam + * Revision 1.10 1997-09-09 13:37:57 adam + * Partial port to WIN95/NT. + * + * Revision 1.9 1996/10/29 13:57:18 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.8 1996/01/08 09:09:16 adam @@ -43,9 +46,12 @@ #include #include -#include +#include +#ifdef WINDOWS +#include +#else #include - +#endif #include #include diff --git a/dict/dclose.c b/dict/dclose.c index 8120d90..eb2d1d2 100644 --- a/dict/dclose.c +++ b/dict/dclose.c @@ -4,14 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dclose.c,v $ - * Revision 1.3 1994-09-01 17:49:36 adam + * Revision 1.4 1997-09-09 13:38:01 adam + * Partial port to WIN95/NT. + * + * Revision 1.3 1994/09/01 17:49:36 adam * Removed stupid line. Work on insertion in dictionary. Not finished yet. * */ #include #include -#include #include #include diff --git a/dict/dopen.c b/dict/dopen.c index 8418239..192a3ce 100644 --- a/dict/dopen.c +++ b/dict/dopen.c @@ -4,14 +4,19 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dopen.c,v $ - * Revision 1.3 1994-09-01 17:49:37 adam + * Revision 1.4 1997-09-09 13:38:01 adam + * Partial port to WIN95/NT. + * + * Revision 1.3 1994/09/01 17:49:37 adam * Removed stupid line. Work on insertion in dictionary. Not finished yet. * */ #include #include +#ifndef WINDOWS #include +#endif #include #include diff --git a/dict/drdwr.c b/dict/drdwr.c index 42ca3b9..45015fb 100644 --- a/dict/drdwr.c +++ b/dict/drdwr.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: drdwr.c,v $ - * Revision 1.8 1995-01-24 11:25:11 adam + * Revision 1.9 1997-09-09 13:38:01 adam + * Partial port to WIN95/NT. + * + * Revision 1.8 1995/01/24 11:25:11 adam * Removed stupid assertion. * * Revision 1.7 1994/10/05 10:47:15 adam @@ -22,7 +25,9 @@ #include #include +#ifndef WINDOWS #include +#endif #include #include #include diff --git a/include/direntz.h b/include/direntz.h new file mode 100644 index 0000000..25477d5 --- /dev/null +++ b/include/direntz.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 1997, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: direntz.h,v $ + * Revision 1.1 1997-09-09 13:38:03 adam + * Partial port to WIN95/NT. + * + * + */ +#ifdef WINDOWS +#include +struct dirent { + char d_name[MAX_PATH+1]; +}; + +typedef struct DIR DIR; + +DIR *opendir (const char *path); +struct dirent *readdir (DIR *dd); +void closedir (DIR *dd); +#else +#include +#endif diff --git a/index/dir.c b/index/dir.c index 490ec72..39332a4 100644 --- a/index/dir.c +++ b/index/dir.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dir.c,v $ - * Revision 1.16 1996-10-29 14:06:45 adam + * Revision 1.17 1997-09-09 13:38:06 adam + * Partial port to WIN95/NT. + * + * Revision 1.16 1996/10/29 14:06:45 adam * Include zebrautl.h instead of alexutil.h. * * Revision 1.15 1996/06/04 10:18:58 adam @@ -58,8 +61,10 @@ #include #include #include +#ifndef WINDOWS #include -#include +#endif +#include #include #include #include diff --git a/index/dirs.c b/index/dirs.c index c5636ee..4497e6a 100644 --- a/index/dirs.c +++ b/index/dirs.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dirs.c,v $ - * Revision 1.12 1996-11-08 11:10:13 adam + * Revision 1.13 1997-09-09 13:38:06 adam + * Partial port to WIN95/NT. + * + * Revision 1.12 1996/11/08 11:10:13 adam * Buffers used during file match got bigger. * Compressed ISAM support everywhere. * Bug fixes regarding masking characters in queries. @@ -47,6 +50,7 @@ * Started work on virtual directory structure. */ #include +#include #include #include #include diff --git a/index/extract.c b/index/extract.c index aa69550..4978551 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.73 1997-09-04 13:57:20 adam + * Revision 1.74 1997-09-09 13:38:06 adam + * Partial port to WIN95/NT. + * + * Revision 1.73 1997/09/04 13:57:20 adam * New file extract/retrieve method tellf (added). * Added O_BINARY for open calls. * @@ -266,7 +269,11 @@ */ #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include diff --git a/index/kdump.c b/index/kdump.c index f3f242f..c4a7279 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kdump.c,v $ - * Revision 1.12 1997-09-05 09:52:32 adam + * Revision 1.13 1997-09-09 13:38:07 adam + * Partial port to WIN95/NT. + * + * Revision 1.12 1997/09/05 09:52:32 adam * Extra argument added to function chr_read_maptab (tab path). * * Revision 1.11 1996/10/29 14:06:49 adam @@ -44,8 +47,13 @@ * */ #include +#include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include diff --git a/index/kinput.c b/index/kinput.c index eb7b251..4da9460 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.23 1997-09-04 13:57:39 adam + * Revision 1.24 1997-09-09 13:38:07 adam + * Partial port to WIN95/NT. + * + * Revision 1.23 1997/09/04 13:57:39 adam * Added O_BINARY for open calls. * * Revision 1.22 1997/02/12 20:39:45 adam @@ -88,7 +91,11 @@ */ #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include #include @@ -568,6 +575,10 @@ void progressFunc (struct key_file *keyp, void *info) p->totalOffset += keyp->buf_size; } +#ifndef R_OK +#define R_OK 4 +#endif + void key_input (int nkeys, int cache) { diff --git a/index/lockidx.c b/index/lockidx.c index 1a0262c..f2c418c 100644 --- a/index/lockidx.c +++ b/index/lockidx.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lockidx.c,v $ - * Revision 1.9 1997-09-04 13:58:04 adam + * Revision 1.10 1997-09-09 13:38:07 adam + * Partial port to WIN95/NT. + * + * Revision 1.9 1997/09/04 13:58:04 adam * Added O_BINARY for open calls. * * Revision 1.8 1997/02/12 20:39:46 adam @@ -42,7 +45,11 @@ */ #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include #include diff --git a/index/lockutil.c b/index/lockutil.c index 5cd6f86..afed16d 100644 --- a/index/lockutil.c +++ b/index/lockutil.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lockutil.c,v $ - * Revision 1.6 1996-10-29 14:08:14 adam + * Revision 1.7 1997-09-09 13:38:08 adam + * Partial port to WIN95/NT. + * + * Revision 1.6 1996/10/29 14:08:14 adam * Uses resource lockDir instead of lockPath. * * Revision 1.5 1996/03/26 16:01:13 adam @@ -33,7 +36,11 @@ #include #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include "index.h" diff --git a/index/main.c b/index/main.c index a4e72d4..d238bb9 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.47 1997-02-12 20:39:46 adam + * Revision 1.48 1997-09-09 13:38:08 adam + * Partial port to WIN95/NT. + * + * Revision 1.47 1997/02/12 20:39:46 adam * Implemented options -f that limits the log to the first * records. * Changed some log messages also. @@ -177,7 +180,11 @@ */ #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include "index.h" diff --git a/index/recstat.c b/index/recstat.c index c5cd78d..882f228 100644 --- a/index/recstat.c +++ b/index/recstat.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recstat.c,v $ - * Revision 1.3 1996-06-04 10:19:00 adam + * Revision 1.4 1997-09-09 13:38:08 adam + * Partial port to WIN95/NT. + * + * Revision 1.3 1996/06/04 10:19:00 adam * Minor changes - removed include of ctype.h. * * Revision 1.2 1996/05/14 14:04:34 adam @@ -22,8 +25,9 @@ #include #include #include +#ifndef WINDOWS #include - +#endif #include "recindxp.h" void rec_prstat (void) diff --git a/index/symtab.c b/index/symtab.c index 1e8238d..1ed1e57 100644 --- a/index/symtab.c +++ b/index/symtab.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: symtab.c,v $ - * Revision 1.3 1996-10-29 14:06:54 adam + * Revision 1.4 1997-09-09 13:38:09 adam + * Partial port to WIN95/NT. + * + * Revision 1.3 1996/10/29 14:06:54 adam * Include zebrautl.h instead of alexutil.h. * * Revision 1.2 1995/09/28 09:19:44 adam @@ -17,6 +20,7 @@ */ #include #include +#include #include #include "index.h" diff --git a/index/trav.c b/index/trav.c index b3ffb45..9b5ecec 100644 --- a/index/trav.c +++ b/index/trav.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trav.c,v $ - * Revision 1.29 1997-02-12 20:39:47 adam + * Revision 1.30 1997-09-09 13:38:09 adam + * Partial port to WIN95/NT. + * + * Revision 1.29 1997/02/12 20:39:47 adam * Implemented options -f that limits the log to the first * records. * Changed some log messages also. @@ -111,10 +114,14 @@ */ #include #include +#ifdef WINDOWS +#include +#else #include -#include -#include +#endif +#include #include +#include #include #include diff --git a/isam/issh.c b/isam/issh.c index 5f6181e..b511e72 100644 --- a/isam/issh.c +++ b/isam/issh.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/isam/memory.c b/isam/memory.c index c6b7ed0..898465d 100644 --- a/isam/memory.c +++ b/isam/memory.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: memory.c,v $ - * Revision 1.14 1996-10-29 13:56:56 adam + * Revision 1.15 1997-09-09 13:38:11 adam + * Partial port to WIN95/NT. + * + * Revision 1.14 1996/10/29 13:56:56 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.13 1996/03/20 13:29:16 quinn @@ -56,6 +59,8 @@ #include #include +#include +#include #include #include diff --git a/isam/physical.c b/isam/physical.c index f10f23b..9837e00 100644 --- a/isam/physical.c +++ b/isam/physical.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: physical.c,v $ - * Revision 1.13 1996-10-29 13:56:57 adam + * Revision 1.14 1997-09-09 13:38:12 adam + * Partial port to WIN95/NT. + * + * Revision 1.13 1996/10/29 13:56:57 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.12 1996/03/20 16:17:11 quinn @@ -52,6 +55,7 @@ #include #include +#include #include #include diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index 3ca02e7..1531b04 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recgrs.c,v $ - * Revision 1.7 1997-09-05 15:30:10 adam + * Revision 1.8 1997-09-09 13:38:14 adam + * Partial port to WIN95/NT. + * + * Revision 1.7 1997/09/05 15:30:10 adam * Changed prototype for chr_map_input - added const. * Added support for C++, headers uses extern "C" for public definitions. * @@ -115,7 +118,9 @@ #include #include #include +#ifndef WINDOWS #include +#endif #include #include diff --git a/rset/rsbool.c b/rset/rsbool.c index 2a72743..2a363f1 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsbool.c,v $ - * Revision 1.10 1996-10-29 13:55:20 adam + * Revision 1.11 1997-09-09 13:38:15 adam + * Partial port to WIN95/NT. + * + * Revision 1.10 1996/10/29 13:55:20 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.9 1995/12/11 09:15:22 adam @@ -45,6 +48,8 @@ */ #include +#include +#include #include #include diff --git a/rset/rsm_or.c b/rset/rsm_or.c index 2ecf7e0..69d0ca5 100644 --- a/rset/rsm_or.c +++ b/rset/rsm_or.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsm_or.c,v $ - * Revision 1.2 1996-12-23 15:30:49 adam + * Revision 1.3 1997-09-09 13:38:16 adam + * Partial port to WIN95/NT. + * + * Revision 1.2 1996/12/23 15:30:49 adam * Work on truncation. * * Revision 1.1 1996/12/20 11:07:21 adam @@ -12,9 +15,10 @@ * */ +#include #include #include -#include +#include #include #include diff --git a/rset/rsrel.c b/rset/rsrel.c index cf945f4..a2e87a9 100644 --- a/rset/rsrel.c +++ b/rset/rsrel.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsrel.c,v $ - * Revision 1.14 1996-11-08 11:15:58 adam + * Revision 1.15 1997-09-09 13:38:16 adam + * Partial port to WIN95/NT. + * + * Revision 1.14 1996/11/08 11:15:58 adam * Compressed isam fully supported. * * Revision 1.13 1996/10/29 13:55:26 adam @@ -54,6 +57,7 @@ #include #include +#include #include #include diff --git a/rset/rssbool.c b/rset/rssbool.c index 235b104..c640952 100644 --- a/rset/rssbool.c +++ b/rset/rssbool.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rssbool.c,v $ - * Revision 1.4 1996-10-29 13:55:27 adam + * Revision 1.5 1997-09-09 13:38:16 adam + * Partial port to WIN95/NT. + * + * Revision 1.4 1996/10/29 13:55:27 adam * Include of zebrautl.h instead of alexutil.h. * * Revision 1.3 1996/10/08 13:00:41 adam @@ -23,8 +26,9 @@ * */ -#include #include +#include +#include #include #include diff --git a/rset/rstemp.c b/rset/rstemp.c index 8e3ff84..aa7b9b1 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rstemp.c,v $ - * Revision 1.19 1997-09-04 13:58:57 adam + * Revision 1.20 1997-09-09 13:38:17 adam + * Partial port to WIN95/NT. + * + * Revision 1.19 1997/09/04 13:58:57 adam * Added O_BINARY for open calls. * * Revision 1.18 1996/10/29 13:54:52 adam @@ -73,7 +76,12 @@ #include #include +#ifdef WINDOWS +#include +#else #include +#endif +#include #include #include diff --git a/util/dirent.c b/util/dirent.c new file mode 100644 index 0000000..047c930 --- /dev/null +++ b/util/dirent.c @@ -0,0 +1,50 @@ + +#ifdef WINDOWS +#include +#include +#include +#include + +#include + +struct DIR { + HANDLE handle; + WIN32_FIND_DATA find_data; + struct dirent entry; +}; + +DIR *opendir (const char *name) +{ + char fullName[MAX_PATH+1]; + DIR *dd = malloc (sizeof(*dd)); + + if (!dd) + return NULL; + strcpy (fullName, name); + strcat (fullName, "\\*.*"); + dd->handle = FindFirstFile(fullName, &dd->find_data); + return dd; +} + +struct dirent *readdir (DIR *dd) +{ + if (dd->handle == INVALID_HANDLE_VALUE) + return NULL; + strcpy (dd->entry.d_name, dd->find_data.cFileName); + if (!FindNextFile(dd->handle, &dd->find_data)) + { + FindClose (dd->handle); + dd->handle = INVALID_HANDLE_VALUE; + } + return &dd->entry; +} + +void closedir(DIR *dd) +{ + if (dd->handle != INVALID_HANDLE_VALUE) + FindClose (dd->handle); + if (dd) + free (dd); +} + +#endif diff --git a/util/res.c b/util/res.c index 10b600e..78457d5 100644 --- a/util/res.c +++ b/util/res.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: res.c,v $ - * Revision 1.16 1996-10-29 13:47:49 adam + * Revision 1.17 1997-09-09 13:38:19 adam + * Partial port to WIN95/NT. + * + * Revision 1.16 1996/10/29 13:47:49 adam * Implemented res_get_match. Updated to use zebrautl instead of alexpath. * * Revision 1.15 1996/05/22 08:23:43 adam @@ -57,7 +60,11 @@ #include #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include @@ -189,7 +196,11 @@ static void reread (Res r) Res res_open (const char *name) { Res r; +#ifdef WINDOWS + if (access (name, 4)) +#else if (access (name, R_OK)) +#endif logf (LOG_LOG|LOG_ERRNO, "Cannot access `%s'", name); r = xmalloc (sizeof(*r)); r->init = 0; -- 1.7.10.4