From: Adam Dickmeiss Date: Wed, 26 May 1999 07:49:12 +0000 (+0000) Subject: C++ compilation. X-Git-Tag: ZEBRA.1.0~109 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=ef696645cc3b7e0f4027008d1dc589c0f0f90c1f C++ compilation. --- diff --git a/bfile/bfile.c b/bfile/bfile.c index 5c0dec2..91e8fe2 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: bfile.c,v $ - * Revision 1.28 1999-05-12 13:08:05 adam + * Revision 1.29 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.28 1999/05/12 13:08:05 adam * First version of ISAMS. * * Revision 1.27 1999/02/02 14:50:01 adam @@ -112,7 +115,7 @@ struct BFiles_struct { BFiles bfs_create (const char *spec) { - BFiles bfs = xmalloc (sizeof(*bfs)); + BFiles bfs = (BFiles) xmalloc (sizeof(*bfs)); bfs->commit_area = NULL; bfs->register_area = mf_init("register", spec); bfs->lockDir = NULL; @@ -155,7 +158,7 @@ void bf_lockDir (BFiles bfs, const char *lockDir) if (lockDir == NULL) lockDir = ""; len = strlen(lockDir); - bfs->lockDir = xmalloc (len+2); + bfs->lockDir = (char *) xmalloc (len+2); strcpy (bfs->lockDir, lockDir); if (len > 0 && bfs->lockDir[len-1] != '/') @@ -184,7 +187,7 @@ int bf_close (BFile bf) BFile bf_open (BFiles bfs, const char *name, int block_size, int wflag) { - BFile tmp = xmalloc(sizeof(BFile_struct)); + BFile tmp = (BFile) xmalloc(sizeof(BFile_struct)); if (bfs->commit_area) { diff --git a/bfile/cfile.c b/bfile/cfile.c index 542b096..d7626b6 100644 --- a/bfile/cfile.c +++ b/bfile/cfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: cfile.c,v $ - * Revision 1.24 1999-05-12 13:08:06 adam + * Revision 1.25 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.24 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.23 1998/10/15 13:09:29 adam @@ -99,7 +102,7 @@ static int write_head (CFile cf) if (!tab) return 0; - while (left >= HASH_BSIZE) + while (left >= (int) HASH_BSIZE) { mf_write (cf->hash_mf, bno++, 0, 0, tab); tab += HASH_BSIZE; @@ -118,7 +121,7 @@ static int read_head (CFile cf) if (!tab) return 0; - while (left >= HASH_BSIZE) + while (left >= (int) HASH_BSIZE) { mf_read (cf->hash_mf, bno++, 0, 0, tab); tab += HASH_BSIZE; @@ -166,7 +169,7 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, cf->head.next_block = 1; if (wflag) mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head); - cf->array = xmalloc (hash_bytes); + cf->array = (int *) xmalloc (hash_bytes); for (i = 0; ihead.hash_size; i++) cf->array[i] = 0; if (wflag) @@ -181,14 +184,15 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, assert (cf->head.next_bucket > 0); assert (cf->head.next_block > 0); if (cf->head.state == 1) - cf->array = xmalloc (hash_bytes); + cf->array = (int *) xmalloc (hash_bytes); else cf->array = NULL; read_head (cf); } if (cf->head.state == 1) { - cf->parray = xmalloc (cf->head.hash_size * sizeof(*cf->parray)); + cf->parray = (struct CFile_hash_bucket **) + xmalloc (cf->head.hash_size * sizeof(*cf->parray)); for (i = 0; ihead.hash_size; i++) cf->parray[i] = NULL; } @@ -198,7 +202,7 @@ CFile cf_open (MFile mf, MFile_area area, const char *fname, cf->bucket_in_memory = 0; cf->max_bucket_in_memory = 100; cf->dirty = 0; - cf->iobuf = xmalloc (cf->head.block_size); + cf->iobuf = (char *) xmalloc (cf->head.block_size); memset (cf->iobuf, 0, cf->head.block_size); cf->no_hits = 0; cf->no_miss = 0; @@ -256,7 +260,7 @@ static struct CFile_hash_bucket *alloc_bucket (CFile cf, int block_no, int hno) flush_bucket (cf, 1); assert (cf->bucket_in_memory < cf->max_bucket_in_memory); ++(cf->bucket_in_memory); - p = xmalloc (sizeof(*p)); + p = (struct CFile_hash_bucket *) xmalloc (sizeof(*p)); p->lru_next = NULL; p->lru_prev = cf->bucket_lru_front; @@ -393,7 +397,7 @@ static void cf_moveto_flat (CFile cf) assert (cf->head.state == 1); flush_bucket (cf, -1); assert (cf->bucket_in_memory == 0); - p = xmalloc (sizeof(*p)); + p = (struct CFile_hash_bucket *) xmalloc (sizeof(*p)); for (i = cf->head.first_bucket; i < cf->head.next_bucket; i++) { if (!mf_read (cf->hash_mf, i, 0, 0, &p->ph)) diff --git a/bfile/cfile.h b/bfile/cfile.h index 68ee552..0f22c29 100644 --- a/bfile/cfile.h +++ b/bfile/cfile.h @@ -3,12 +3,16 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: cfile.h,v 1.11 1999-05-12 13:08:06 adam Exp $ + * $Id: cfile.h,v 1.12 1999-05-26 07:49:12 adam Exp $ */ #ifndef CFILE_H #define CFILE_H +#ifdef __cplusplus +extern "C" { +#endif + #define HASH_BUCKET 15 struct CFile_ph_bucket { /* structure on disc */ @@ -62,4 +66,8 @@ int cf_write (CFile cf, int no, int offset, int nbytes, const void *buf); void cf_unlink (CFile cf); void cf_commit (CFile cf); +#ifdef __cplusplus +} +#endif + #endif diff --git a/bfile/commit.c b/bfile/commit.c index f2816a5..ee95df3 100644 --- a/bfile/commit.c +++ b/bfile/commit.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: commit.c,v $ - * Revision 1.14 1998-08-07 15:07:16 adam + * Revision 1.15 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.14 1998/08/07 15:07:16 adam * Fixed but in cf_commit_flat. * * Revision 1.13 1996/10/29 13:56:16 adam @@ -177,7 +180,7 @@ static void cf_commit_hash (CFile cf) m_p = map_cache_init (cf); #endif - p = xmalloc (sizeof(*p)); + p = (struct CFile_ph_bucket *) xmalloc (sizeof(*p)); hash_bytes = cf->head.hash_size * sizeof(int); bucket_no = cf->head.first_bucket; for (; bucket_no < cf->head.next_bucket; bucket_no++) @@ -221,10 +224,10 @@ static void cf_commit_flat (CFile cf) #if CF_OPTIMIZE_COMMIT m_p = map_cache_init (cf); #endif - fp = xmalloc (HASH_BSIZE); + fp = (int *) xmalloc (HASH_BSIZE); for (hno = cf->head.next_bucket; hno < cf->head.flat_bucket; hno++) { - for (i = 0; i < (HASH_BSIZE/sizeof(int)); i++) + for (i = 0; i < (int) (HASH_BSIZE/sizeof(int)); i++) fp[i] = 0; if (!mf_read (cf->hash_mf, hno, 0, 0, fp) && hno != cf->head.flat_bucket-1) @@ -232,7 +235,7 @@ static void cf_commit_flat (CFile cf) logf (LOG_FATAL, "read index block hno=%d (%d-%d) commit", hno, cf->head.next_bucket, cf->head.flat_bucket-1); } - for (i = 0; i < (HASH_BSIZE/sizeof(int)); i++) + for (i = 0; i < (int) (HASH_BSIZE/sizeof(int)); i++) { if (fp[i]) { diff --git a/bfile/mfile.c b/bfile/mfile.c index 7720bf9..6b7be96 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: mfile.c,v $ - * Revision 1.33 1999-05-12 13:08:06 adam + * Revision 1.34 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.33 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.32 1999/04/28 14:53:07 adam @@ -200,7 +203,7 @@ static int scan_areadef(MFile_area ma, const char *name, const char *ad) return -1; } ad++; - *dp = dir = xmalloc(sizeof(mf_dir)); + *dp = dir = (mf_dir *) xmalloc(sizeof(mf_dir)); dir->next = 0; strcpy(dir->name, dirname); dir->max_bytes = dir->avail_bytes = fact * size * multi; @@ -255,7 +258,7 @@ static int cmp_part_file(const void *p1, const void *p2) */ MFile_area mf_init(const char *name, const char *spec) { - MFile_area ma = xmalloc(sizeof(*ma)); + MFile_area ma = (MFile_area) xmalloc(sizeof(*ma)); mf_dir *dirp; meta_file *meta_f; part_file *part_f = 0; @@ -303,7 +306,7 @@ MFile_area mf_init(const char *name, const char *spec) /* new metafile */ if (!meta_f) { - meta_f = xmalloc(sizeof(*meta_f)); + meta_f = (meta_file *) xmalloc(sizeof(*meta_f)); meta_f->ma = ma; meta_f->next = ma->mfiles; meta_f->open = 0; @@ -383,7 +386,7 @@ void mf_destroy(MFile_area ma) */ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag) { - struct meta_file *mnew; + meta_file *mnew; int i; char tmp[FILENAME_MAX+1]; mf_dir *dp; @@ -401,7 +404,7 @@ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag) } if (!mnew) { - mnew = xmalloc(sizeof(*mnew)); + mnew = (meta_file *) xmalloc(sizeof(*mnew)); strcpy(mnew->name, name); /* allocate one, empty file */ mnew->no_files = 1; diff --git a/configure b/configure index 83a0dac..8b0399f 100755 --- a/configure +++ b/configure @@ -523,17 +523,14 @@ else fi -# ------ Substitutions -# -# ------ Checking programs # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:537: checking for $ac_word" >&5 +echo "configure:534: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -563,7 +560,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:567: checking for $ac_word" >&5 +echo "configure:564: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -614,7 +611,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:618: checking for $ac_word" >&5 +echo "configure:615: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -646,7 +643,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:650: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:647: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -657,12 +654,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 661 "configure" +#line 658 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -688,12 +685,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:692: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:689: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:697: checking whether we are using GNU C" >&5 +echo "configure:694: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -702,7 +699,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:706: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:703: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -721,7 +718,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:725: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:722: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -753,7 +750,7 @@ else fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:757: checking how to run the C preprocessor" >&5 +echo "configure:754: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -768,13 +765,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -785,13 +782,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:795: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:792: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -802,13 +799,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -863,7 +860,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:867: checking for a BSD compatible install" >&5 +echo "configure:864: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -918,7 +915,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:922: checking for $ac_word" >&5 +echo "configure:919: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -945,8 +942,6 @@ else echo "$ac_t""no" 1>&6 fi -# -# look for Tcl TCL_LIB="" TCL_INCLUDE="" tclconfig=NONE @@ -963,7 +958,7 @@ echo $ac_n "checking for prefix by $ac_c" 1>&6 # Extract the first word of "tclsh", so it can be a program name with args. set dummy tclsh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:967: checking for $ac_word" >&5 +echo "configure:962: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1005,7 +1000,7 @@ fi fi if test -r ${tclconfig}/tclConfig.sh; then echo $ac_n "checking for Tcl""... $ac_c" 1>&6 -echo "configure:1009: checking for Tcl" >&5 +echo "configure:1004: checking for Tcl" >&5 . ${tclconfig}/tclConfig.sh if test -r ${tclconfig}/../generic/tcl.h; then TCL_INCLUDE=-I${tclconfig}/../generic @@ -1023,16 +1018,14 @@ echo "configure:1009: checking for Tcl" >&5 else ODEFS="-DHAVE_TCL_H=0" fi -# -# sockets checkBoth=0 echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:1031: checking for connect" >&5 +echo "configure:1024: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -1076,7 +1069,7 @@ fi if test "$ac_cv_func_connect" = "no"; then echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:1080: checking for main in -lsocket" >&5 +echo "configure:1073: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1084,14 +1077,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1117,12 +1110,12 @@ if test "$checkBoth" = "1"; then oldLibs=$LIBS LIBS="$LIBS -lsocket -lnsl" echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:1121: checking for accept" >&5 +echo "configure:1114: checking for accept" >&5 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1142: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_accept=yes" else @@ -1167,12 +1160,12 @@ fi fi echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:1171: checking for gethostbyname" >&5 +echo "configure:1164: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -1213,7 +1206,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:1217: checking for main in -lnsl" >&5 +echo "configure:1210: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1221,14 +1214,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1250,10 +1243,8 @@ fi fi -# -# tcpd wrapper echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6 -echo "configure:1257: checking for main in -lwrap" >&5 +echo "configure:1248: checking for main in -lwrap" >&5 ac_lib_var=`echo wrap'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1261,14 +1252,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lwrap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1263: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1288,15 +1279,13 @@ else echo "$ac_t""no" 1>&6 fi -# -# headers echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1295: checking for ANSI C header files" >&5 +echo "configure:1284: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1304,7 +1293,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1308: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1321,7 +1310,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1339,7 +1328,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1360,7 +1349,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1371,7 +1360,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1397,8 +1386,6 @@ fi if test "$ac_cv_header_stdc" = "no"; then echo "configure: warning: Your system doesn't seem to support ANSI C" 1>&2 fi -# -# makefiles trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure diff --git a/configure.in b/configure.in index 2c0dc13..0121ac6 100644 --- a/configure.in +++ b/configure.in @@ -1,21 +1,21 @@ -# Zebra, Index Data Aps, 1994-1999 -# $Id: configure.in,v 1.7 1999-05-21 12:00:17 adam Exp $ -# See the file LICENSE.2 for details. -# +dnl Zebra, Index Data Aps, 1994-1999 +dnl $Id: configure.in,v 1.8 1999-05-26 07:49:12 adam Exp $ +dnl See the file LICENSE.2 for details. +dnl AC_INIT(include/zebraver.h) -# ------ Substitutions +dnl ------ Substitutions AC_SUBST(ODEFS) AC_SUBST(DEFS) AC_SUBST(TCL_INCLUDE) AC_SUBST(TCL_LIB) -# -# ------ Checking programs +dnl +dnl ------ Checking programs AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_RANLIB -# -# look for Tcl +dnl +dnl ------ Look for Tcl TCL_LIB="" TCL_INCLUDE="" tclconfig=NONE @@ -45,8 +45,8 @@ if test -r ${tclconfig}/tclConfig.sh; then else ODEFS="-DHAVE_TCL_H=0" fi -# -# sockets +dnl +dnl ------ Socket libraries checkBoth=0 AC_CHECK_FUNC(connect) if test "$ac_cv_func_connect" = "no"; then @@ -58,15 +58,15 @@ if test "$checkBoth" = "1"; then AC_CHECK_FUNC(accept, , [LIBS=$oldLibs]) fi AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])) -# -# tcpd wrapper +dnl +dnl ------ TCP wrapper (for Linux) AC_CHECK_LIB(wrap, main, [LIBS="$LIBS -lwrap"]) -# -# headers +dnl +dnl ------ ANSI C Header files AC_STDC_HEADERS if test "$ac_cv_header_stdc" = "no"; then AC_MSG_WARN(Your system doesn't seem to support ANSI C) fi -# -# makefiles +dnl +dnl ------ Create Makefiles AC_OUTPUT(Makefile util/Makefile bfile/Makefile dfa/Makefile dict/Makefile isam/Makefile isamc/Makefile recctrl/Makefile rset/Makefile index/Makefile) diff --git a/dfa/Makefile.in b/dfa/Makefile.in index 011e600..a4e32c0 100644 --- a/dfa/Makefile.in +++ b/dfa/Makefile.in @@ -1,10 +1,15 @@ -# Copyright (C) 1994-1996, Index Data ApS +# Copyright (C) 1994-1999, Index Data ApS # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.2 1998-10-28 15:20:45 adam Exp $ +# $Id: Makefile.in,v 1.3 1999-05-26 07:49:12 adam Exp $ SHELL=/bin/sh -RANLIB=ranlib + +CC=@CC@ +CPP=@CPP@ +RANLIB=@RANLIB@ +CDEFS=@DEFS@ @ODEFS@ +LIBS=@LIBS@ YAZLIB=../../yaz/lib/libyaz.a YAZINC=-I../../yaz/z39.50 -I../../yaz/include @@ -13,10 +18,9 @@ INCLUDE=-I../include $(YAZINC) TPROG1=agrep TPROG2=lexer TPROG3=grepper -DEFS=$(INCLUDE) +DEFS=$(CDEFS) $(INCLUDE) LIB=../lib/dfa.a PO = dfa.o imalloc.o states.o set.o bset.o -CPP=$(CC) -E all: $(LIB) diff --git a/dfa/agrep.c b/dfa/agrep.c index 5614080..39d0f69 100644 --- a/dfa/agrep.c +++ b/dfa/agrep.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: agrep.c,v $ - * Revision 1.11 1999-02-02 14:50:03 adam + * Revision 1.12 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.11 1999/02/02 14:50:03 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.10 1997/09/09 13:37:57 adam @@ -283,6 +286,7 @@ char **argv; return i; while (--argc > 0) if (**++argv != '-' && **argv) + { if (!pattern) { pattern = *argv; @@ -308,6 +312,7 @@ char **argv; if (i) return i; } + } if (!no) { fprintf (stderr, "usage:\n " diff --git a/dfa/dfa.c b/dfa/dfa.c index 73730c8..dba686d 100644 --- a/dfa/dfa.c +++ b/dfa/dfa.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dfa.c,v $ - * Revision 1.25 1999-02-02 14:50:05 adam + * Revision 1.26 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.25 1999/02/02 14:50:05 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.24 1998/10/28 10:48:55 adam @@ -988,7 +991,8 @@ void dfa_parse_cmap_clean (struct DFA *d) if (!dfa->charMap) { dfa->charMapSize = 7; - dfa->charMap = imalloc (dfa->charMapSize * sizeof(*dfa->charMap)); + dfa->charMap = (int *) + imalloc (dfa->charMapSize * sizeof(*dfa->charMap)); } dfa->charMap[0] = 0; } @@ -1008,7 +1012,7 @@ void dfa_parse_cmap_new (struct DFA *d, const int *cmap) if (dfa->charMap) ifree (dfa->charMap); dfa->charMapSize = size; - dfa->charMap = imalloc (size * sizeof(*dfa->charMap)); + dfa->charMap = (int *) imalloc (size * sizeof(*dfa->charMap)); } memcpy (dfa->charMap, cmap, size * sizeof(*dfa->charMap)); } @@ -1048,7 +1052,7 @@ void dfa_parse_cmap_add (struct DFA *d, int from, int to) size = dfa->charMapSize; if (indx >= size) { - int *cn = imalloc ((size+16) * sizeof(*dfa->charMap)); + int *cn = (int *) imalloc ((size+16) * sizeof(*dfa->charMap)); memcpy (cn, dfa->charMap, indx*sizeof(*dfa->charMap)); ifree (dfa->charMap); dfa->charMap = cn; @@ -1129,7 +1133,7 @@ static struct DFA_states *mk_dfas (struct DFA_parse *dfap, int poset_chunk) if (debug_dfa_followpos) pr_followpos(parse_info); - init_DFA_states (&dfas, parse_info->poset, STATE_HASH); + init_DFA_states (&dfas, parse_info->poset, (int) (STATE_HASH)); mk_dfa_tran (parse_info, dfas); if (debug_dfa_tran) pr_tran (parse_info, dfas); @@ -1145,7 +1149,7 @@ struct DFA *dfa_init (void) { struct DFA *dfa; - dfa = imalloc (sizeof(*dfa)); + dfa = (struct DFA *) imalloc (sizeof(*dfa)); dfa->parse_info = dfa_parse_init (); dfa->state_info = NULL; dfa->states = NULL; diff --git a/dfa/dfap.h b/dfa/dfap.h index 7e160c3..fd8bf93 100644 --- a/dfa/dfap.h +++ b/dfa/dfap.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dfap.h,v $ - * Revision 1.8 1999-02-02 14:50:06 adam + * Revision 1.9 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.8 1999/02/02 14:50:06 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.7 1997/09/29 09:05:17 adam @@ -40,6 +43,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + struct DFA_parse { struct Tnode *root; /* root of regular syntax tree */ int position; /* no of positions so far */ @@ -96,4 +103,7 @@ void sort_DFA_states (struct DFA_states *dfas); void add_DFA_tran (struct DFA_states *, struct DFA_state *, int, int, int); +#ifdef __cplusplus +} +#endif #endif diff --git a/dfa/imalloc.h b/dfa/imalloc.h index 45fcd61..a53a4e8 100644 --- a/dfa/imalloc.h +++ b/dfa/imalloc.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: imalloc.h,v $ - * Revision 1.4 1999-02-02 14:50:09 adam + * Revision 1.5 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.4 1999/02/02 14:50:09 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.3 1997/10/27 14:27:13 adam @@ -19,6 +22,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + void *imalloc (size_t); void *icalloc (size_t); void ifree (void *); @@ -33,4 +40,7 @@ extern int free_calls; #endif +#ifdef __cplusplus +} +#endif diff --git a/dfa/lexer.h b/dfa/lexer.h index 050e998..305223e 100644 --- a/dfa/lexer.h +++ b/dfa/lexer.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lexer.h,v $ - * Revision 1.3 1999-02-02 14:50:11 adam + * Revision 1.4 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.3 1999/02/02 14:50:11 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.2 1995/01/24 16:00:22 adam @@ -17,9 +20,16 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif int read_file ( const char *, struct DFA * ); void error ( const char *, ... ); extern int ccluse; +#ifdef __cplusplus +} +#endif + diff --git a/dfa/set.c b/dfa/set.c index 4a593d1..aaf9313 100644 --- a/dfa/set.c +++ b/dfa/set.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: set.c,v $ - * Revision 1.6 1999-02-02 14:50:13 adam + * Revision 1.7 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.6 1999/02/02 14:50:13 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.5 1996/10/29 13:57:29 adam @@ -140,16 +143,16 @@ Set rm_Set (SetType st, Set s) Set add_Set (SetType st, Set s, int n) { SetElement dummy; - Set p = &dummy, new; + Set p = &dummy, snew; p->next = s; while (p->next && p->next->value < n) p = p->next; assert (p); if (!(p->next && p->next->value == n)) { - new = mk_SetElement (st, n); - new->next = p->next; - p->next = new; + snew = mk_SetElement (st, n); + snew->next = p->next; + p->next = snew; } return dummy.next; } diff --git a/dict/dcompact.c b/dict/dcompact.c index 800b654..3f8999a 100644 --- a/dict/dcompact.c +++ b/dict/dcompact.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dcompact.c,v $ - * Revision 1.4 1999-05-15 14:36:37 adam + * Revision 1.5 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.4 1999/05/15 14:36:37 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.3 1999/05/12 13:08:06 adam @@ -92,7 +95,7 @@ int dict_copy_compact (BFiles bfs, const char *from_name, const char *to_name) dict_from = dict_open (bfs, from_name, 0, 0, 0); if (!dict_from) return -1; - map = xmalloc ((dict_from->head.last+1) * sizeof(*map)); + map = (int *) xmalloc ((dict_from->head.last+1) * sizeof(*map)); for (i = 0; i <= (int) (dict_from->head.last); i++) map[i] = -1; dict_to = dict_open (bfs, to_name, 0, 1, 1); @@ -131,7 +134,7 @@ int dict_copy_compact (BFiles bfs, const char *from_name, const char *to_name) DICT_backptr(new_p) = map[i-1]; DICT_bsize(new_p) = map[i+1] - map[i]; - dict_copy_page(dict_from, new_p, old_p, map); + dict_copy_page(dict_from, (char*) new_p, (char*) old_p, map); } dict_close (dict_from); dict_close (dict_to); diff --git a/dict/dopen.c b/dict/dopen.c index 0a3e63c..ecd742f 100644 --- a/dict/dopen.c +++ b/dict/dopen.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dopen.c,v $ - * Revision 1.7 1999-05-15 14:36:37 adam + * Revision 1.8 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.7 1999/05/15 14:36:37 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.6 1999/02/02 14:50:20 adam @@ -47,12 +50,14 @@ static void common_init (Dict_BFile bf, int block_size, int cache) bf->all_data = xmalloc (block_size * cache); /* Allocate and initialize hash array (as empty) */ - bf->hash_array = xmalloc(sizeof(*bf->hash_array) * bf->hash_size); + bf->hash_array = (struct Dict_file_block **) + xmalloc(sizeof(*bf->hash_array) * bf->hash_size); for (i=bf->hash_size; --i >= 0; ) bf->hash_array[i] = NULL; /* Allocate all block descriptors in one chunk */ - bf->all_blocks = xmalloc (sizeof(*bf->all_blocks) * cache); + bf->all_blocks = (struct Dict_file_block *) + xmalloc (sizeof(*bf->all_blocks) * cache); /* Initialize the free list */ bf->free_list = bf->all_blocks; @@ -75,7 +80,7 @@ Dict_BFile dict_bf_open (BFiles bfs, const char *name, int block_size, { Dict_BFile dbf; - dbf = xmalloc (sizeof(*dbf)); + dbf = (Dict_BFile) xmalloc (sizeof(*dbf)); dbf->bf = bf_open (bfs, name, block_size, rw); if (!dbf->bf) return NULL; diff --git a/dict/insert.c b/dict/insert.c index 6fd334e..1057d67 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: insert.c,v $ - * Revision 1.20 1999-05-15 14:36:37 adam + * Revision 1.21 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.20 1999/05/15 14:36:37 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.19 1999/02/02 14:50:22 adam @@ -198,7 +201,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) static void clean_page (Dict dict, Dict_ptr ptr, void *p, Dict_char *out, Dict_ptr subptr, char *userinfo) { - char *np = xmalloc (dict->head.page_size); + char *np = (char *) xmalloc (dict->head.page_size); int i, slen, no = 0; short *indxp1, *indxp2; char *info1, *info2; @@ -439,7 +442,7 @@ static int dict_ins (Dict dict, const Dict_char *str, --indxp; slen = (dict_strlen(str)+1)*sizeof(Dict_char); if (DICT_size(p)+slen+userlen >= - DICT_bsize(p) - (1+DICT_nodir(p))*sizeof(short)) /* overflow? */ + (int)(DICT_bsize(p) - (1+DICT_nodir(p))*sizeof(short)))/* overflow? */ { if (DICT_type(p)) { diff --git a/dict/lookgrep.c b/dict/lookgrep.c index 4b651dc..bde3771 100644 --- a/dict/lookgrep.c +++ b/dict/lookgrep.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookgrep.c,v $ - * Revision 1.23 1999-05-15 14:36:37 adam + * Revision 1.24 1999-05-26 07:49:12 adam + * C++ compilation. + * + * Revision 1.23 1999/05/15 14:36:37 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.22 1999/02/02 14:50:23 adam @@ -124,13 +127,13 @@ static INLINE MatchWord get_bit (MatchContext *mc, MatchWord *m, int ch, static MatchContext *mk_MatchContext (struct DFA *dfa, int range) { - MatchContext *mc = xmalloc (sizeof(*mc)); + MatchContext *mc = (MatchContext *) xmalloc (sizeof(*mc)); int s; mc->n = (dfa->no_states+WORD_BITS) / WORD_BITS; mc->range = range; mc->fact = (range+1)*mc->n; - mc->match_mask = xcalloc (mc->n, sizeof(*mc->match_mask)); + mc->match_mask = (MatchWord *) xcalloc (mc->n, sizeof(*mc->match_mask)); for (s = 0; sno_states; s++) if (dfa->states[s]->rule_no) @@ -454,7 +457,7 @@ int dict_lookup_grep (Dict dict, const char *pattern, int range, void *client, mc = mk_MatchContext (dfa, range); - Rj = xcalloc ((MAX_LENGTH+1) * mc->n, sizeof(*Rj)); + Rj = (MatchWord *) xcalloc ((MAX_LENGTH+1) * mc->n, sizeof(*Rj)); set_bit (mc, Rj, 0, 0); for (d = 1; d<=mc->range; d++) diff --git a/dict/lookupec.c b/dict/lookupec.c index 70e28a6..975e834 100644 --- a/dict/lookupec.c +++ b/dict/lookupec.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookupec.c,v $ - * Revision 1.8 1999-05-15 14:36:37 adam + * Revision 1.9 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.8 1999/05/15 14:36:37 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.7 1999/02/02 14:50:26 adam @@ -149,9 +152,9 @@ static MatchInfo *prepare_match (Dict_char *pattern) MatchWord *s; MatchInfo *mi; - mi = xmalloc (sizeof(*mi)); + mi = (MatchInfo *) xmalloc (sizeof(*mi)); mi->m = dict_strlen (pattern); - mi->s = s = xmalloc (sizeof(*s)*256); /* 256 !!! */ + mi->s = s = (MatchWord *) xmalloc (sizeof(*s)*256); /* 256 !!! */ for (i=0; i<256; i++) s[i] = 0; for (i=0; pattern[i]; i++) @@ -172,8 +175,8 @@ int dict_lookup_ec (Dict dict, char *pattern, int range, mi = prepare_match ((Dict_char*) pattern); - ri = xmalloc ((dict_strlen((Dict_char*) pattern)+range+2) - * (range+1)*sizeof(*ri)); + ri = (MatchWord *) xmalloc ((dict_strlen((Dict_char*) pattern)+range+2) + * (range+1)*sizeof(*ri)); for (i=0; i<=range; i++) ri[i] = (2< + +#ifdef __cplusplus +extern "C" { +#endif + struct dirent { char d_name[MAX_PATH]; }; @@ -30,6 +38,11 @@ typedef struct DIR DIR; DIR *opendir (const char *path); struct dirent *readdir (DIR *dd); void closedir (DIR *dd); + +#ifdef __cplusplus +} +#endif + #else /* include UNIX version */ #include diff --git a/include/passwddb.h b/include/passwddb.h index 034a24d..357bfe4 100644 --- a/include/passwddb.h +++ b/include/passwddb.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: passwddb.h,v $ - * Revision 1.2 1998-06-25 09:55:47 adam + * Revision 1.3 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.2 1998/06/25 09:55:47 adam * Minor changes - fixex headers. * */ @@ -12,6 +15,10 @@ #ifndef PASSWDDB_H #define PASSWDDB_H +#ifdef __cplusplus +extern "C" { +#endif + typedef struct passwd_db *Passwd_db; Passwd_db passwd_db_open (void); @@ -20,5 +27,9 @@ int passwd_db_file (Passwd_db db, const char *fname); void passwd_db_close (Passwd_db db); void passwd_db_show (Passwd_db db); +#ifdef __cplusplus +} +#endif + #endif diff --git a/index/dir.c b/index/dir.c index 1eccbfb..35c64f1 100644 --- a/index/dir.c +++ b/index/dir.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dir.c,v $ - * Revision 1.20 1999-02-02 14:50:50 adam + * Revision 1.21 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.20 1999/02/02 14:50:50 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.19 1998/11/03 10:16:11 adam @@ -99,7 +102,7 @@ struct dir_entry *dir_open (const char *rep) exit (1); return NULL; } - entry = xmalloc (sizeof(*entry) * entry_max); + entry = (struct dir_entry *) xmalloc (sizeof(*entry) * entry_max); strcpy (path, rep); pathpos = strlen(path); if (!pathpos || path[pathpos-1] != '/') @@ -114,7 +117,8 @@ struct dir_entry *dir_open (const char *rep) { struct dir_entry *entry_n; - entry_n = xmalloc (sizeof(*entry) * (entry_max += 1000)); + entry_n = (struct dir_entry *) + xmalloc (sizeof(*entry) * (entry_max += 1000)); memcpy (entry_n, entry, idx * sizeof(*entry)); xfree (entry); entry = entry_n; @@ -126,14 +130,14 @@ struct dir_entry *dir_open (const char *rep) case S_IFREG: entry[idx].kind = dirs_file; entry[idx].mtime = finfo.st_mtime; - entry[idx].name = xmalloc (strlen(dent->d_name)+1); + entry[idx].name = (char *) xmalloc (strlen(dent->d_name)+1); strcpy (entry[idx].name, dent->d_name); idx++; break; case S_IFDIR: entry[idx].kind = dirs_dir; entry[idx].mtime = finfo.st_mtime; - entry[idx].name = xmalloc (strlen(dent->d_name)+2); + entry[idx].name = (char *) xmalloc (strlen(dent->d_name)+2); strcpy (entry[idx].name, dent->d_name); strcat (entry[idx].name, "/"); idx++; diff --git a/index/dirs.c b/index/dirs.c index 17b64c1..6176452 100644 --- a/index/dirs.c +++ b/index/dirs.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dirs.c,v $ - * Revision 1.15 1999-02-02 14:50:51 adam + * Revision 1.16 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.15 1999/02/02 14:50:51 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.14 1998/01/12 15:04:07 adam @@ -81,7 +84,7 @@ struct dirs_info { static int dirs_client_proc (char *name, const char *info, int pos, void *client) { - struct dirs_info *ci = client; + struct dirs_info *ci = (struct dirs_info *) client; struct dirs_entry *entry; if (memcmp (name, ci->prefix, ci->prelen)) @@ -121,7 +124,7 @@ struct dirs_info *dirs_open (Dict dict, const char *rep, int rw) int before = 0, after; logf (LOG_DEBUG, "dirs_open %s", rep); - p = xmalloc (sizeof (*p)); + p = (struct dirs_info *) xmalloc (sizeof (*p)); p->dict = dict; p->rw = rw; strcpy (p->prefix, rep); @@ -129,7 +132,8 @@ struct dirs_info *dirs_open (Dict dict, const char *rep, int rw) strcpy (p->nextpath, rep); p->no_read = p->no_cur = 0; after = p->no_max = 100; - p->entries = xmalloc (sizeof(*p->entries) * (p->no_max)); + p->entries = (struct dirs_entry *) + xmalloc (sizeof(*p->entries) * (p->no_max)); logf (LOG_DEBUG, "dirs_open first scan"); dict_scan (p->dict, p->nextpath, &before, &after, p, dirs_client_proc); return p; @@ -141,10 +145,10 @@ struct dirs_info *dirs_fopen (Dict dict, const char *path) struct dirs_entry *entry; char *info; - p = xmalloc (sizeof(*p)); + p = (struct dirs_info *) xmalloc (sizeof(*p)); p->dict = dict; *p->prefix = '\0'; - p->entries = xmalloc (sizeof(*p->entries)); + p->entries = (struct dirs_entry *) xmalloc (sizeof(*p->entries)); p->no_read = 0; p->no_cur = 0; p->no_max = 2; diff --git a/index/extract.c b/index/extract.c index da261e2..4309b60 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.95 1999-05-21 12:00:17 adam + * Revision 1.96 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.95 1999/05/21 12:00:17 adam * Better diagnostics for extraction process. * * Revision 1.94 1999/05/20 12:57:18 adam @@ -407,7 +410,7 @@ int key_open (struct recordGroup *rGroup, int mem) mem = atoi(res_get_def (common_resource, "memMax", "4"))*1024*1024; if (mem < 50000) mem = 50000; - key_buf = xmalloc (mem); + key_buf = (char **) xmalloc (mem); ptr_top = mem/sizeof(char*); ptr_i = 0; @@ -666,7 +669,7 @@ static void addIndexString (RecWord *p, const char *string, int length) { char *b; - b = xmalloc (reckeys.buf_max += 128000); + b = (char *) xmalloc (reckeys.buf_max += 128000); if (reckeys.buf_used > 0) memcpy (b, reckeys.buf, reckeys.buf_used); xfree (reckeys.buf); @@ -728,11 +731,11 @@ static void addSortString (RecWord *p, const char *string, int length) if (sk->attrSet == p->attrSet && sk->attrUse == p->attrUse) return; - sk = xmalloc (sizeof(*sk)); + sk = (struct sortKey *) xmalloc (sizeof(*sk)); sk->next = sortKeys; sortKeys = sk; - sk->string = xmalloc (length); + sk->string = (char *) xmalloc (length); sk->length = length; memcpy (sk->string, string, length); @@ -996,7 +999,8 @@ struct file_read_info { static struct file_read_info *file_read_start (int fd) { - struct file_read_info *fi = xmalloc (sizeof(*fi)); + struct file_read_info *fi = (struct file_read_info *) + xmalloc (sizeof(*fi)); fi->fd = fd; fi->file_max = 0; @@ -1013,7 +1017,7 @@ static void file_read_stop (struct file_read_info *fi) static off_t file_seek (void *handle, off_t offset) { - struct file_read_info *p = handle; + struct file_read_info *p = (struct file_read_info *) handle; p->file_offset = offset; if (p->sdrbuf) return offset; @@ -1022,13 +1026,13 @@ static off_t file_seek (void *handle, off_t offset) static off_t file_tell (void *handle) { - struct file_read_info *p = handle; + struct file_read_info *p = (struct file_read_info *) handle; return p->file_offset; } static int file_read (void *handle, char *buf, size_t count) { - struct file_read_info *p = handle; + struct file_read_info *p = (struct file_read_info *) handle; int fd = p->fd; int r; if (p->sdrbuf) @@ -1052,7 +1056,7 @@ static int file_read (void *handle, char *buf, size_t count) static void file_begin (void *handle) { - struct file_read_info *p = handle; + struct file_read_info *p = (struct file_read_info *) handle; p->file_offset = p->file_moffset; if (!p->sdrbuf && p->file_moffset) @@ -1062,7 +1066,7 @@ static void file_begin (void *handle) static void file_end (void *handle, off_t offset) { - struct file_read_info *p = handle; + struct file_read_info *p = (struct file_read_info *) handle; assert (p->file_more == 0); p->file_more = 1; @@ -1226,7 +1230,7 @@ struct recordLogInfo { static void recordLogPreamble (int level, const char *msg, void *info) { - struct recordLogInfo *p = info; + struct recordLogInfo *p = (struct recordLogInfo *) info; FILE *outf = log_file (); if (level & LOG_LOG) @@ -1491,7 +1495,8 @@ static int recordExtract (SYSNO *sysno, const char *fname, if (rGroup->flagStoreData == 1) { rec->size[recInfo_storeData] = recordAttr->recordSize; - rec->info[recInfo_storeData] = xmalloc (recordAttr->recordSize); + rec->info[recInfo_storeData] = (char *) + xmalloc (recordAttr->recordSize); if (lseek (fi->fd, recordOffset, SEEK_SET) < 0) { logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", diff --git a/index/index.h b/index/index.h index 9608973..91b868b 100644 --- a/index/index.h +++ b/index/index.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: index.h,v $ - * Revision 1.62 1999-05-12 13:08:06 adam + * Revision 1.63 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.62 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.61 1999/03/09 16:27:49 adam @@ -235,6 +238,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define IT_MAX_WORD 256 #define IT_KEY_HAVE_SEQNO 1 #define IT_KEY_HAVE_FIELD 0 @@ -361,3 +368,7 @@ void zebra_lock_prefix (Res res, char *dst); void zebra_load_atts (data1_handle dh, Res res); extern Res common_resource; + +#ifdef __cplusplus +} +#endif diff --git a/index/kcompare.c b/index/kcompare.c index ba8a6ef..1636ab7 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kcompare.c,v $ - * Revision 1.27 1999-05-12 13:08:06 adam + * Revision 1.28 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.27 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.26 1999/02/02 14:50:54 adam @@ -183,7 +186,8 @@ struct iscz1_code_info { static void *iscz1_code_start (int mode) { - struct iscz1_code_info *p = xmalloc (sizeof(*p)); + struct iscz1_code_info *p = (struct iscz1_code_info *) + xmalloc (sizeof(*p)); p->key.sysno = 0; p->key.seqno = 0; return p; @@ -243,7 +247,7 @@ int iscz1_decode_int (unsigned char **src) static void iscz1_code_item (int mode, void *vp, char **dst, char **src) { - struct iscz1_code_info *p = vp; + struct iscz1_code_info *p = (struct iscz1_code_info *) vp; struct it_key tkey; int d; diff --git a/index/kinput.c b/index/kinput.c index c560591..ee8b87c 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.33 1999-05-15 14:36:38 adam + * Revision 1.34 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.33 1999/05/15 14:36:38 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.32 1999/05/12 13:08:06 adam @@ -214,7 +217,7 @@ struct key_file *key_file_init (int no, int chunk) { struct key_file *f; - f = xmalloc (sizeof(*f)); + f = (struct key_file *) xmalloc (sizeof(*f)); f->sysno = 0; f->seqno = 0; f->no = no; @@ -222,8 +225,8 @@ struct key_file *key_file_init (int no, int chunk) f->offset = 0; f->length = 0; f->readHandler = NULL; - f->buf = xmalloc (f->chunk); - f->prev_name = xmalloc (INP_NAME_MAX); + f->buf = (unsigned char *) xmalloc (f->chunk); + f->prev_name = (char *) xmalloc (INP_NAME_MAX); *f->prev_name = '\0'; key_file_chunk_read (f); return f; @@ -327,16 +330,17 @@ struct heap_info *key_heap_init (int nkeys, struct heap_info *hi; int i; - hi = xmalloc (sizeof(*hi)); - hi->info.file = xmalloc (sizeof(*hi->info.file) * (1+nkeys)); - hi->info.buf = xmalloc (sizeof(*hi->info.buf) * (1+nkeys)); + hi = (struct heap_info *) xmalloc (sizeof(*hi)); + hi->info.file = (struct key_file **) + xmalloc (sizeof(*hi->info.file) * (1+nkeys)); + hi->info.buf = (char **) xmalloc (sizeof(*hi->info.buf) * (1+nkeys)); hi->heapnum = 0; - hi->ptr = xmalloc (sizeof(*hi->ptr) * (1+nkeys)); + hi->ptr = (int *) xmalloc (sizeof(*hi->ptr) * (1+nkeys)); hi->cmp = cmp; for (i = 0; i<= nkeys; i++) { hi->ptr[i] = i; - hi->info.buf[i] = xmalloc (INP_NAME_MAX); + hi->info.buf[i] = (char *) xmalloc (INP_NAME_MAX); } return hi; } @@ -426,7 +430,7 @@ struct heap_cread_info { int heap_cread_item (void *vp, char **dst, int *insertMode) { - struct heap_cread_info *p = vp; + struct heap_cread_info *p = (struct heap_cread_info *) vp; struct heap_info *hi = p->hi; if (p->mode == 1) @@ -454,9 +458,9 @@ int heap_cread_item (void *vp, char **dst, int *insertMode) int heap_inpc (struct heap_info *hi) { struct heap_cread_info hci; - ISAMC_I isamc_i = xmalloc (sizeof(*isamc_i)); + ISAMC_I isamc_i = (ISAMC_I) xmalloc (sizeof(*isamc_i)); - hci.key = xmalloc (KEY_SIZE); + hci.key = (char *) xmalloc (KEY_SIZE); hci.mode = 1; hci.hi = hi; hci.more = heap_read_one (hi, hci.cur_name, hci.key); @@ -505,9 +509,9 @@ int heap_inpc (struct heap_info *hi) int heap_inps (struct heap_info *hi) { struct heap_cread_info hci; - ISAMS_I isams_i = xmalloc (sizeof(*isams_i)); + ISAMS_I isams_i = (ISAMS_I) xmalloc (sizeof(*isams_i)); - hci.key = xmalloc (KEY_SIZE); + hci.key = (char *) xmalloc (KEY_SIZE); hci.mode = 1; hci.hi = hi; hci.more = heap_read_one (hi, hci.cur_name, hci.key); @@ -549,8 +553,8 @@ int heap_inp (struct heap_info *hi) char *key_buf; int more; - next_key = xmalloc (KEY_SIZE); - key_buf = xmalloc (key_buf_size); + next_key = (char *) xmalloc (KEY_SIZE); + key_buf = (char *) xmalloc (key_buf_size); more = heap_read_one (hi, cur_name, key_buf); while (more) /* EOF ? */ { @@ -567,7 +571,7 @@ int heap_inp (struct heap_info *hi) if (key_buf_ptr+(int) KEY_SIZE >= key_buf_size) { char *new_key_buf; - new_key_buf = xmalloc (key_buf_size + INP_BUF_ADD); + new_key_buf = (char *) xmalloc (key_buf_size + INP_BUF_ADD); memcpy (new_key_buf, key_buf, key_buf_size); key_buf_size += INP_BUF_ADD; xfree (key_buf); @@ -617,7 +621,7 @@ struct progressInfo { void progressFunc (struct key_file *keyp, void *info) { - struct progressInfo *p = info; + struct progressInfo *p = (struct progressInfo *) info; time_t now, remaining; if (keyp->buf_size <= 0 || p->totalBytes <= 0) @@ -706,7 +710,7 @@ void key_input (BFiles bfs, int nkeys, int cache) exit (1); } } - kf = xmalloc ((1+nkeys) * sizeof(*kf)); + kf = (struct key_file **) xmalloc ((1+nkeys) * sizeof(*kf)); progressInfo.totalBytes = 0; progressInfo.totalOffset = 0; time (&progressInfo.startTime); diff --git a/index/locksrv.c b/index/locksrv.c index 7591349..22ea3b5 100644 --- a/index/locksrv.c +++ b/index/locksrv.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: locksrv.c,v $ - * Revision 1.12 1999-02-02 14:50:58 adam + * Revision 1.13 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.12 1999/02/02 14:50:58 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.11 1998/03/05 08:45:12 adam @@ -70,7 +73,7 @@ int zebra_server_lock_init (ZebraHandle zi) zi->server_lock_org = NULL; zebra_lock_prefix (zi->res, path_prefix); - zi->server_path_prefix = xmalloc (strlen(path_prefix)+1); + zi->server_path_prefix = (char *) xmalloc (strlen(path_prefix)+1); strcpy (zi->server_path_prefix, path_prefix); logf (LOG_DEBUG, "Locking system initialized"); diff --git a/index/lockutil.c b/index/lockutil.c index 431cb9c..123f7e6 100644 --- a/index/lockutil.c +++ b/index/lockutil.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lockutil.c,v $ - * Revision 1.11 1999-02-02 14:50:59 adam + * Revision 1.12 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.11 1999/02/02 14:50:59 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.10 1997/09/29 09:08:36 adam @@ -65,7 +68,7 @@ struct zebra_lock_info { ZebraLockHandle zebra_lock_create (const char *name, int excl_flag) { - ZebraLockHandle h = xmalloc (sizeof(*h)); + ZebraLockHandle h = (ZebraLockHandle) xmalloc (sizeof(*h)); h->excl_flag = excl_flag; h->fd = -1; #ifdef WIN32 diff --git a/index/rank1.c b/index/rank1.c index 17f8616..84d4159 100644 --- a/index/rank1.c +++ b/index/rank1.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rank1.c,v $ - * Revision 1.4 1999-02-02 14:51:01 adam + * Revision 1.5 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.4 1999/02/02 14:51:01 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.3 1998/06/12 12:21:53 adam @@ -61,7 +64,8 @@ static int log2_int (unsigned g) */ static void *create (ZebraHandle zh) { - struct rank_class_info *ci = xmalloc (sizeof(*ci)); + struct rank_class_info *ci = (struct rank_class_info *) + xmalloc (sizeof(*ci)); logf (LOG_DEBUG, "rank-1 create"); return ci; @@ -74,7 +78,7 @@ static void *create (ZebraHandle zh) */ static void destroy (ZebraHandle zh, void *class_handle) { - struct rank_class_info *ci = class_handle; + struct rank_class_info *ci = (struct rank_class_info *) class_handle; logf (LOG_DEBUG, "rank-1 destroy"); xfree (ci); @@ -88,13 +92,14 @@ static void destroy (ZebraHandle zh, void *class_handle) */ static void *begin (ZebraHandle zh, void *class_handle, RSET rset) { - struct rank_set_info *si = xmalloc (sizeof(*si)); + struct rank_set_info *si = (struct rank_set_info *) xmalloc (sizeof(*si)); int i; logf (LOG_DEBUG, "rank-1 begin"); si->no_entries = rset->no_rset_terms; si->no_rank_entries = 0; - si->entries = xmalloc (sizeof(*si->entries)*si->no_entries); + si->entries = (struct rank_term_info *) + xmalloc (sizeof(*si->entries)*si->no_entries); for (i = 0; i < si->no_entries; i++) { int g = rset->rset_terms[i]->nn; @@ -119,7 +124,7 @@ static void *begin (ZebraHandle zh, void *class_handle, RSET rset) */ static void end (ZebraHandle zh, void *set_handle) { - struct rank_set_info *si = set_handle; + struct rank_set_info *si = (struct rank_set_info *) set_handle; logf (LOG_DEBUG, "rank-1 end"); xfree (si->entries); xfree (si); @@ -132,7 +137,7 @@ static void end (ZebraHandle zh, void *set_handle) */ static void add (void *set_handle, int seqno, int term_index) { - struct rank_set_info *si = set_handle; + struct rank_set_info *si = (struct rank_set_info *) set_handle; logf (LOG_DEBUG, "rank-1 add seqno=%d term_index=%d", seqno, term_index); si->last_pos = seqno; si->entries[term_index].local_occur++; @@ -147,7 +152,7 @@ static void add (void *set_handle, int seqno, int term_index) static int calc (void *set_handle, int sysno) { int i, lo, divisor, score = 0; - struct rank_set_info *si = set_handle; + struct rank_set_info *si = (struct rank_set_info *) set_handle; logf (LOG_DEBUG, "rank-1 calc sysno=%d", sysno); diff --git a/index/recindex.c b/index/recindex.c index 8f3005c..17e6734 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recindex.c,v $ - * Revision 1.22 1999-02-18 12:49:34 adam + * Revision 1.23 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.22 1999/02/18 12:49:34 adam * Changed file naming scheme for register files as well as record * store/index files. * @@ -122,7 +125,7 @@ static void rec_tmp_expand (Records p, int size, int dst_type) { xfree (p->tmp_buf); p->tmp_size = size + p->head.block_size[dst_type]*2 + 2048; - p->tmp_buf = xmalloc (p->tmp_size); + p->tmp_buf = (char *) xmalloc (p->tmp_size); } } @@ -280,10 +283,10 @@ Records rec_open (BFiles bfs, int rw) Records p; int i, r; - p = xmalloc (sizeof(*p)); + p = (Records) xmalloc (sizeof(*p)); p->rw = rw; p->tmp_size = 1024; - p->tmp_buf = xmalloc (p->tmp_size); + p->tmp_buf = (char *) xmalloc (p->tmp_size); p->index_fname = "reci"; p->index_BFile = bf_open (bfs, p->index_fname, 128, rw); if (p->index_BFile == NULL) @@ -329,7 +332,7 @@ Records rec_open (BFiles bfs, int rw) { char str[80]; sprintf (str, "recd%c", i + 'A'); - p->data_fname[i] = xmalloc (strlen(str)+1); + p->data_fname[i] = (char *) xmalloc (strlen(str)+1); strcpy (p->data_fname[i], str); p->data_BFile[i] = NULL; } @@ -345,7 +348,8 @@ Records rec_open (BFiles bfs, int rw) } p->cache_max = 10; p->cache_cur = 0; - p->record_cache = xmalloc (sizeof(*p->record_cache)*p->cache_max); + p->record_cache = (struct record_cache_entry *) + xmalloc (sizeof(*p->record_cache)*p->cache_max); return p; } @@ -477,7 +481,7 @@ Record rec_get (Records p, int sysno) assert (freeblock > 0); - rec = xmalloc (sizeof(*rec)); + rec = (Record) xmalloc (sizeof(*rec)); rec_tmp_expand (p, entry.size, dst_type); cptr = p->tmp_buf; @@ -504,7 +508,7 @@ Record rec_get (Records p, int sysno) nptr += sizeof(*rec->size); if (rec->size[i]) { - rec->info[i] = xmalloc (rec->size[i]); + rec->info[i] = (char *) xmalloc (rec->size[i]); memcpy (rec->info[i], nptr, rec->size[i]); nptr += rec->size[i]; } @@ -521,7 +525,7 @@ Record rec_new (Records p) Record rec; assert (p); - rec = xmalloc (sizeof(*rec)); + rec = (Record) xmalloc (sizeof(*rec)); if (1 || p->head.index_free == 0) sysno = (p->head.index_last)++; else @@ -595,7 +599,7 @@ Record rec_cp (Record rec) Record n; int i; - n = xmalloc (sizeof(*n)); + n = (Record) xmalloc (sizeof(*n)); n->sysno = rec->sysno; for (i = 0; i < REC_NO_INFO; i++) if (!rec->info[i]) @@ -606,7 +610,7 @@ Record rec_cp (Record rec) else { n->size[i] = rec->size[i]; - n->info[i] = xmalloc (rec->size[i]); + n->info[i] = (char *) xmalloc (rec->size[i]); memcpy (n->info[i], rec->info[i], rec->size[i]); } return n; @@ -623,7 +627,7 @@ char *rec_strdup (const char *s, size_t *len) return NULL; } *len = strlen(s)+1; - p = xmalloc (*len); + p = (char *) xmalloc (*len); strcpy (p, s); return p; } diff --git a/index/recindex.h b/index/recindex.h index 5fada63..2bc17e6 100644 --- a/index/recindex.h +++ b/index/recindex.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recindex.h,v $ - * Revision 1.14 1999-02-02 14:51:04 adam + * Revision 1.15 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.14 1999/02/02 14:51:04 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.13 1998/03/05 08:45:12 adam @@ -62,6 +65,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define REC_NO_INFO 8 typedef struct record_info { @@ -93,3 +100,6 @@ enum { recInfo_attr }; +#ifdef __cplusplus +} +#endif diff --git a/index/recindxp.h b/index/recindxp.h index d371eea..43e7399 100644 --- a/index/recindxp.h +++ b/index/recindxp.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recindxp.h,v $ - * Revision 1.5 1999-02-02 14:51:05 adam + * Revision 1.6 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.5 1999/02/02 14:51:05 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.4 1998/03/05 08:45:12 adam @@ -33,6 +36,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define REC_BLOCK_TYPES 2 #define REC_HEAD_MAGIC "recindx" @@ -82,3 +89,6 @@ struct record_index_entry { int size; /* size of record or 0 if free entry */ }; +#ifdef __cplusplus +} +#endif diff --git a/index/retrieve.c b/index/retrieve.c index eb2331a..00d1d9e 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: retrieve.c,v $ - * Revision 1.9 1999-05-20 12:57:18 adam + * Revision 1.10 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.9 1999/05/20 12:57:18 adam * Implemented TCL filter. Updated recctrl system. * * Revision 1.8 1999/03/09 16:27:49 adam @@ -66,37 +69,37 @@ struct fetch_control { static int record_ext_read (void *fh, char *buf, size_t count) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; return read (fc->fd, buf, count); } static off_t record_ext_seek (void *fh, off_t offset) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; return lseek (fc->fd, offset + fc->record_offset, SEEK_SET); } static off_t record_ext_tell (void *fh) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; return lseek (fc->fd, 0, SEEK_CUR) - fc->record_offset; } static off_t record_int_seek (void *fh, off_t offset) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; return (off_t) (fc->record_int_pos = offset); } static off_t record_int_tell (void *fh) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; return (off_t) fc->record_int_pos; } static int record_int_read (void *fh, char *buf, size_t count) { - struct fetch_control *fc = fh; + struct fetch_control *fc = (struct fetch_control *) fh; int l = fc->record_int_len - fc->record_int_pos; if (l <= 0) return 0; @@ -131,7 +134,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, file_type = rec->info[recInfo_fileType]; fname = rec->info[recInfo_filename]; basename = rec->info[recInfo_databaseName]; - *basenamep = odr_malloc (stream, strlen(basename)+1); + *basenamep = (char *) odr_malloc (stream, strlen(basename)+1); strcpy (*basenamep, basename); if (!(rt = recType_byName (zh->recTypes, file_type, subType, &clientData))) @@ -246,7 +249,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, retrieveCtrl.res = zh->res; (*rt->retrieve)(clientData, &retrieveCtrl); *output_format = retrieveCtrl.output_format; - *rec_bufp = retrieveCtrl.rec_buf; + *rec_bufp = (char *) retrieveCtrl.rec_buf; *rec_lenp = retrieveCtrl.rec_len; if (fc.fd != -1) close (fc.fd); diff --git a/index/sortidx.c b/index/sortidx.c index 8993d1b..c9366f1 100644 --- a/index/sortidx.c +++ b/index/sortidx.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: sortidx.c,v $ - * Revision 1.2 1998-06-25 09:55:50 adam + * Revision 1.3 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.2 1998/06/25 09:55:50 adam * Minor changes - fixex headers. * */ @@ -39,12 +42,12 @@ struct sortIdx { SortIdx sortIdx_open (BFiles bfs, int write_flag) { - SortIdx si = xmalloc (sizeof(*si)); + SortIdx si = (SortIdx) xmalloc (sizeof(*si)); si->bfs = bfs; si->write_flag = write_flag; si->current_file = NULL; si->files = NULL; - si->entry_buf = xmalloc (SORT_IDX_ENTRYSIZE); + si->entry_buf = (char *) xmalloc (SORT_IDX_ENTRYSIZE); return si; } @@ -75,7 +78,7 @@ int sortIdx_type (SortIdx si, int type) si->current_file = sf; return 0; } - sf = xmalloc (sizeof(*sf)); + sf = (struct sortFile *) xmalloc (sizeof(*sf)); sf->type = type; sf->bf = NULL; sf->next = si->files; diff --git a/index/symtab.c b/index/symtab.c index d3d7e6a..2d60aeb 100644 --- a/index/symtab.c +++ b/index/symtab.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: symtab.c,v $ - * Revision 1.5 1999-02-02 14:51:08 adam + * Revision 1.6 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.5 1999/02/02 14:51:08 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.4 1997/09/09 13:38:09 adam @@ -43,7 +46,7 @@ struct strtab { struct strtab *strtab_mk (void) { int i; - struct strtab *p = xmalloc (sizeof (*p)); + struct strtab *p = (struct strtab *) xmalloc (sizeof (*p)); for (i=0; iar[i] = NULL; return p; @@ -64,8 +67,8 @@ int strtab_src (struct strtab *t, const char *name, void ***infop) *infop = &e->info; return 1; } - e = xmalloc (sizeof(*e)); - e->name = xmalloc (strlen(name)+1); + e = (struct strentry *) xmalloc (sizeof(*e)); + e->name = (char *) xmalloc (strlen(name)+1); strcpy (e->name, name); e->next = t->ar[hash]; t->ar[hash] = e; diff --git a/index/trunc.c b/index/trunc.c index c5113ac..c523bd3 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trunc.c,v $ - * Revision 1.13 1999-05-12 13:08:06 adam + * Revision 1.14 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.13 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.12 1999/02/02 14:51:10 adam @@ -130,19 +133,19 @@ static struct trunc_info *heap_init (int size, int key_size, int (*cmp)(const void *p1, const void *p2)) { - struct trunc_info *ti = xmalloc (sizeof(*ti)); + struct trunc_info *ti = (struct trunc_info *) xmalloc (sizeof(*ti)); int i; ++size; ti->heapnum = 0; ti->keysize = key_size; ti->cmp = cmp; - ti->indx = xmalloc (size * sizeof(*ti->indx)); - ti->heap = xmalloc (size * sizeof(*ti->heap)); - ti->ptr = xmalloc (size * sizeof(*ti->ptr)); - ti->swapbuf = xmalloc (ti->keysize); - ti->tmpbuf = xmalloc (ti->keysize); - ti->buf = xmalloc (size * ti->keysize); + ti->indx = (int *) xmalloc (size * sizeof(*ti->indx)); + ti->heap = (char **) xmalloc (size * sizeof(*ti->heap)); + ti->ptr = (int *) xmalloc (size * sizeof(*ti->ptr)); + ti->swapbuf = (char *) xmalloc (ti->keysize); + ti->tmpbuf = (char *) xmalloc (ti->keysize); + ti->buf = (char *) xmalloc (size * ti->keysize); for (i = size; --i >= 0; ) { ti->ptr[i] = i; @@ -186,8 +189,8 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int rscur = 0; int rsmax = (to-from)/i_add + 1; - rset = xmalloc (sizeof(*rset) * rsmax); - rsfd = xmalloc (sizeof(*rsfd) * rsmax); + rset = (RSET *) xmalloc (sizeof(*rset) * rsmax); + rsfd = (RSFD *) xmalloc (sizeof(*rsfd) * rsmax); for (i = from; i < to; i += i_add) { @@ -244,7 +247,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISPT *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); @@ -296,7 +299,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISAMC_PP *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); @@ -348,7 +351,7 @@ static RSET rset_trunc_r (ZebraHandle zi, const char *term, int length, int i; struct trunc_info *ti; - ispt = xmalloc (sizeof(*ispt) * (to-from)); + ispt = (ISAMS_PP *) xmalloc (sizeof(*ispt) * (to-from)); ti = heap_init (to-from, sizeof(struct it_key), key_compare_it); diff --git a/index/zebraapi.c b/index/zebraapi.c index 8120ebe..cf81adc 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.18 1999-05-15 14:36:38 adam + * Revision 1.19 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.18 1999/05/15 14:36:38 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.17 1999/05/12 13:08:06 adam @@ -213,7 +216,7 @@ static void zebra_register_unlock (ZebraHandle zh) ZebraHandle zebra_open (const char *configName) { - ZebraHandle zh = xmalloc (sizeof(*zh)); + ZebraHandle zh = (ZebraHandle) xmalloc (sizeof(*zh)); if (!(zh->res = res_open (configName))) { @@ -298,7 +301,7 @@ struct map_baseinfo { void map_basenames_func (void *vp, const char *name, const char *value) { - struct map_baseinfo *p = vp; + struct map_baseinfo *p = (struct map_baseinfo *) vp; int i, no; char fromdb[128], todb[8][128]; @@ -379,7 +382,7 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream, zh->errCode = 0; zh->errString = NULL; - pos_array = xmalloc (num_recs * sizeof(*pos_array)); + pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array)); for (i = 0; inmem, sizeof(*ao)); + ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao)); ao->handle = NULL; ao->sysno = 1; ao->oid = oid; @@ -415,7 +418,8 @@ void zebraExplain_mergeAccessInfo (ZebraExplainInfo zei, data1_node *n, if (!n) { - *accessInfo = nmem_malloc (zei->nmem, sizeof(**accessInfo)); + *accessInfo = (zebAccessInfo) + nmem_malloc (zei->nmem, sizeof(**accessInfo)); (*accessInfo)->attributeSetIds = NULL; (*accessInfo)->schemas = NULL; } @@ -446,7 +450,7 @@ ZebraExplainInfo zebraExplain_open ( struct tm *tm; logf (LOG_DEBUG, "zebraExplain_open wr=%d", writeFlag); - zei = xmalloc (sizeof(*zei)); + zei = (ZebraExplainInfo) xmalloc (sizeof(*zei)); zei->updateHandle = updateHandle; zei->updateFunc = updateFunc; zei->dirty = 0; @@ -456,8 +460,8 @@ ZebraExplainInfo zebraExplain_open ( zei->dh = dh; zei->attsets = NULL; zei->res = res; - zei->categoryList = nmem_malloc (zei->nmem, - sizeof(*zei->categoryList)); + zei->categoryList = (struct zebraCategoryListInfo *) + nmem_malloc (zei->nmem, sizeof(*zei->categoryList)); zei->categoryList->sysno = 0; zei->categoryList->dirty = 0; zei->categoryList->data1_categoryList = NULL; @@ -511,8 +515,8 @@ ZebraExplainInfo zebraExplain_open ( } assert (node_id && node_name && node_aid); - *zdip = nmem_malloc (zei->nmem, sizeof(**zdip)); - + *zdip = (struct zebDatabaseInfoB *) + nmem_malloc (zei->nmem, sizeof(**zdip)); (*zdip)->readFlag = 1; (*zdip)->dirty = 0; (*zdip)->data1_database = NULL; @@ -520,14 +524,14 @@ ZebraExplainInfo zebraExplain_open ( (*zdip)->recordBytes = 0; zebraExplain_mergeAccessInfo (zei, 0, &(*zdip)->accessInfo); - (*zdip)->databaseName = nmem_malloc (zei->nmem, - 1+node_name->u.data.len); + (*zdip)->databaseName = (char *) + nmem_malloc (zei->nmem, 1+node_name->u.data.len); memcpy ((*zdip)->databaseName, node_name->u.data.data, node_name->u.data.len); (*zdip)->databaseName[node_name->u.data.len] = '\0'; (*zdip)->sysno = atoi_n (node_id->u.data.data, node_id->u.data.len); - (*zdip)->attributeDetails = + (*zdip)->attributeDetails = (zebAttributeDetails) nmem_malloc (zei->nmem, sizeof(*(*zdip)->attributeDetails)); (*zdip)->attributeDetails->sysno = atoi_n (node_aid->u.data.data, node_aid->u.data.len); @@ -586,7 +590,7 @@ ZebraExplainInfo zebraExplain_open ( rec_strdup ("IR-Explain-1", &trec->size[recInfo_databaseName]); sgml_buf = data1_nodetoidsgml(dh, zei->data1_target, 0, &sgml_len); - trec->info[recInfo_storeData] = xmalloc (sgml_len); + trec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (trec->info[recInfo_storeData], sgml_buf, sgml_len); trec->size[recInfo_storeData] = sgml_len; @@ -660,12 +664,13 @@ static void zebraExplain_readAttributeDetails (ZebraExplainInfo zei, assert (node_set && node_use && node_ordinal); oid_str_len = node_set->u.data.len; - if (oid_str_len >= sizeof(oid_str)) + if (oid_str_len >= (int) sizeof(oid_str)) oid_str_len = sizeof(oid_str)-1; memcpy (oid_str, node_set->u.data.data, oid_str_len); oid_str[oid_str_len] = '\0'; - - *zsuip = nmem_malloc (zei->nmem, sizeof(**zsuip)); + + *zsuip = (struct zebSUInfoB *) + nmem_malloc (zei->nmem, sizeof(**zsuip)); (*zsuip)->info.set = oid_getvalbyname (oid_str); (*zsuip)->info.use = atoi_n (node_use->u.data.data, @@ -817,7 +822,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, if (zdi) return -1; /* it's new really. make it */ - zdi = nmem_malloc (zei->nmem, sizeof(*zdi)); + zdi = (struct zebDatabaseInfoB *) nmem_malloc (zei->nmem, sizeof(*zdi)); zdi->next = zei->databaseInfo; zei->databaseInfo = zdi; zdi->sysno = 0; @@ -863,7 +868,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, zei->dirty = 1; zei->curDatabaseInfo = zdi; - zdi->attributeDetails = + zdi->attributeDetails = (zebAttributeDetails) nmem_malloc (zei->nmem, sizeof(*zdi->attributeDetails)); zdi->attributeDetails->readFlag = 0; zdi->attributeDetails->sysno = 0; @@ -962,9 +967,8 @@ static void zebraExplain_writeCategoryList (ZebraExplainInfo zei, #if ZINFO_DEBUG data1_pr_tree (zei->dh, node_categoryList, stderr); #endif - sgml_buf = data1_nodetoidsgml(zei->dh, node_categoryList, - 0, &sgml_len); - drec->info[recInfo_storeData] = xmalloc (sgml_len); + sgml_buf = data1_nodetoidsgml(zei->dh, node_categoryList, 0, &sgml_len); + drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; @@ -1038,7 +1042,7 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, oe.proto = PROTO_Z3950; oe.oclass = CLASS_ATTSET; - oe.value = set_ordinal; + oe.value = (enum oid_value) set_ordinal; if (oid_ent_to_oid (&oe, oid)) { @@ -1073,7 +1077,7 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, oident.proto = PROTO_Z3950; oident.oclass = CLASS_ATTSET; - oident.value = zsui->info.set; + oident.value = (enum oid_value) zsui->info.set; oid_ent_to_oid (&oident, oid); data1_add_tagdata_text (zei->dh, node_attr, "set", @@ -1089,7 +1093,7 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, #endif sgml_buf = data1_nodetoidsgml(zei->dh, zad->data1_tree, 0, &sgml_len); - drec->info[recInfo_storeData] = xmalloc (sgml_len); + drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; @@ -1141,7 +1145,7 @@ static void zebraExplain_writeDatabase (ZebraExplainInfo zei, #endif sgml_buf = data1_nodetoidsgml(zei->dh, zdi->data1_database, 0, &sgml_len); - drec->info[recInfo_storeData] = xmalloc (sgml_len); + drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; @@ -1237,7 +1241,7 @@ static void zebraExplain_writeAttributeSet (ZebraExplainInfo zei, data1_pr_tree (zei->dh, node_root, stderr); #endif sgml_buf = data1_nodetoidsgml(zei->dh, node_root, 0, &sgml_len); - drec->info[recInfo_storeData] = xmalloc (sgml_len); + drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len); drec->size[recInfo_storeData] = sgml_len; @@ -1299,7 +1303,7 @@ static void zebraExplain_writeTarget (ZebraExplainInfo zei, int key_flush) #endif sgml_buf = data1_nodetoidsgml(zei->dh, zei->data1_target, 0, &sgml_len); - trec->info[recInfo_storeData] = xmalloc (sgml_len); + trec->info[recInfo_storeData] = (char *) xmalloc (sgml_len); memcpy (trec->info[recInfo_storeData], sgml_buf, sgml_len); trec->size[recInfo_storeData] = sgml_len; @@ -1329,7 +1333,7 @@ zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei, break; if (!ao) { - ao = nmem_malloc (zei->nmem, sizeof(*ao)); + ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao)); ao->handle = NULL; ao->sysno = 0; ao->oid = odr_oiddup_nmem (zei->nmem, oid); @@ -1346,7 +1350,7 @@ void zebraExplain_addAttributeSet (ZebraExplainInfo zei, int set) oe.proto = PROTO_Z3950; oe.oclass = CLASS_ATTSET; - oe.value = set; + oe.value = (enum oid_value) set; if (oid_ent_to_oid (&oe, oid)) { @@ -1366,7 +1370,7 @@ int zebraExplain_addSU (ZebraExplainInfo zei, int set, int use) if (zsui->info.use == use && zsui->info.set == set) return -1; zebraExplain_addAttributeSet (zei, set); - zsui = nmem_malloc (zei->nmem, sizeof(*zsui)); + zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui)); zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo; zei->curDatabaseInfo->attributeDetails->SUInfo = zsui; zei->curDatabaseInfo->attributeDetails->dirty = 1; @@ -1419,7 +1423,7 @@ RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec) if (rec->info[recInfo_attr]) return (RecordAttr *) rec->info[recInfo_attr]; - recordAttr = xmalloc (sizeof(*recordAttr)); + recordAttr = (RecordAttr *) xmalloc (sizeof(*recordAttr)); rec->info[recInfo_attr] = (char *) recordAttr; rec->size[recInfo_attr] = sizeof(*recordAttr); @@ -1431,7 +1435,7 @@ RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec) static void att_loadset(void *p, const char *n, const char *name) { - data1_handle dh = p; + data1_handle dh = (data1_handle) p; if (!data1_get_attset (dh, name)) logf (LOG_WARN, "Couldn't load attribute set %s", name); } diff --git a/index/zinfo.h b/index/zinfo.h index 73e4baa..fea0349 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zinfo.h,v $ - * Revision 1.6 1999-02-02 14:51:12 adam + * Revision 1.7 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.6 1999/02/02 14:51:12 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.5 1998/06/08 14:43:16 adam @@ -33,6 +36,10 @@ #include #include "recindex.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct zebraExplainInfo *ZebraExplainInfo; typedef struct zebDatabaseInfo ZebDatabaseInfo; ZebraExplainInfo zebraExplain_open (Records records, data1_handle dh, @@ -62,4 +69,8 @@ typedef struct { } RecordAttr; RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec); +#ifdef __cplusplus +} +#endif + #endif diff --git a/index/zrpn.c b/index/zrpn.c index fdb31e9..ca8e014 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.91 1999-02-02 14:51:13 adam + * Revision 1.92 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.91 1999/02/02 14:51:13 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.90 1998/11/16 16:03:43 adam @@ -340,7 +343,7 @@ struct rpn_char_map_info { static const char **rpn_char_map_handler (void *vp, const char **from, int len) { - struct rpn_char_map_info *p = vp; + struct rpn_char_map_info *p = (struct rpn_char_map_info *) vp; return zebra_maps_input (p->zm, p->reg_type, from, len); } @@ -459,8 +462,8 @@ static void add_isam_p (const char *name, const char *info, int *new_term_no; #endif p->isam_p_size = 2*p->isam_p_size + 100; - new_isam_p_buf = xmalloc (sizeof(*new_isam_p_buf) * - p->isam_p_size); + new_isam_p_buf = (ISAM_P *) xmalloc (sizeof(*new_isam_p_buf) * + p->isam_p_size); if (p->isam_p_buf) { memcpy (new_isam_p_buf, p->isam_p_buf, @@ -470,8 +473,8 @@ static void add_isam_p (const char *name, const char *info, p->isam_p_buf = new_isam_p_buf; #ifdef TERM_COUNT - new_term_no = xmalloc (sizeof(*new_term_no) * - p->isam_p_size); + new_term_no = (int *) xmalloc (sizeof(*new_term_no) * + p->isam_p_size); if (p->term_no) { memcpy (new_term_no, p->isam_p_buf, @@ -493,7 +496,7 @@ static void add_isam_p (const char *name, const char *info, static int grep_handle (char *name, const char *info, void *p) { - add_isam_p (name, info, p); + add_isam_p (name, info, (struct grep_info *) p); return 0; } @@ -1273,14 +1276,14 @@ static RSET rpn_prox (ZebraHandle zh, RSET *rset, int rset_no) int term_index; const char *flags = NULL; - rsfd = xmalloc (sizeof(*rsfd)*rset_no); - more = xmalloc (sizeof(*more)*rset_no); - buf = xmalloc (sizeof(*buf)*rset_no); + rsfd = (RSFD *) xmalloc (sizeof(*rsfd)*rset_no); + more = (int *) xmalloc (sizeof(*more)*rset_no); + buf = (struct it_key **) xmalloc (sizeof(*buf)*rset_no); for (i = 0; i= sizeof(rset)/sizeof(*rset)) + if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset))) break; } #ifdef TERM_COUNT @@ -1474,7 +1477,7 @@ static RSET rpn_search_APT_or_list (ZebraHandle zh, grep_info.isam_p_indx, term_dst, strlen(term_dst), rank_type); assert (rset[rset_no]); - if (++rset_no >= sizeof(rset)/sizeof(*rset)) + if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset))) break; } #ifdef TERM_COUNT @@ -1539,7 +1542,7 @@ static RSET rpn_search_APT_and_list (ZebraHandle zh, grep_info.isam_p_indx, term_dst, strlen(term_dst), rank_type); assert (rset[rset_no]); - if (++rset_no >= sizeof(rset)/sizeof(*rset)) + if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset))) break; } #ifdef TERM_COUNT @@ -1749,7 +1752,7 @@ static RSET rpn_search_APT_numeric (ZebraHandle zh, grep_info.isam_p_indx, term_dst, strlen(term_dst), rank_type); assert (rset[rset_no]); - if (++rset_no >= sizeof(rset)/sizeof(*rset)) + if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset))) break; } #ifdef TERM_COUNT @@ -1829,15 +1832,17 @@ static RSET rpn_sort_spec (ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (!sort_sequence->specs) { sort_sequence->num_specs = 10; - sort_sequence->specs = nmem_malloc (stream, sort_sequence->num_specs * - sizeof(*sort_sequence->specs)); + sort_sequence->specs = (Z_SortKeySpec **) + nmem_malloc (stream, sort_sequence->num_specs * + sizeof(*sort_sequence->specs)); for (i = 0; inum_specs; i++) sort_sequence->specs[i] = 0; } if (zapt->term->which != Z_Term_general) i = 0; else - i = atoi_n (zapt->term->u.general->buf, zapt->term->u.general->len); + i = atoi_n ((char *) zapt->term->u.general->buf, + zapt->term->u.general->len); if (i >= sort_sequence->num_specs) i = 0; @@ -1847,29 +1852,35 @@ static RSET rpn_sort_spec (ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (!oid_ent_to_oid (&oe, oid)) return 0; - sks = nmem_malloc (stream, sizeof(*sks)); - sks->sortElement = nmem_malloc (stream, sizeof(*sks->sortElement)); + sks = (Z_SortKeySpec *) nmem_malloc (stream, sizeof(*sks)); + sks->sortElement = (Z_SortElement *) + nmem_malloc (stream, sizeof(*sks->sortElement)); sks->sortElement->which = Z_SortElement_generic; - sk = sks->sortElement->u.generic = nmem_malloc (stream, sizeof(*sk)); + sk = sks->sortElement->u.generic = (Z_SortKey *) + nmem_malloc (stream, sizeof(*sk)); sk->which = Z_SortKey_sortAttributes; - sk->u.sortAttributes = nmem_malloc (stream, sizeof(*sk->u.sortAttributes)); + sk->u.sortAttributes = (Z_SortAttributes *) + nmem_malloc (stream, sizeof(*sk->u.sortAttributes)); sk->u.sortAttributes->id = oid; - sk->u.sortAttributes->list = + sk->u.sortAttributes->list = (Z_AttributeList *) nmem_malloc (stream, sizeof(*sk->u.sortAttributes->list)); sk->u.sortAttributes->list->num_attributes = 1; - sk->u.sortAttributes->list->attributes = + sk->u.sortAttributes->list->attributes = (Z_AttributeElement **) nmem_malloc (stream, sizeof(*sk->u.sortAttributes->list->attributes)); - ae = *sk->u.sortAttributes->list->attributes = + ae = *sk->u.sortAttributes->list->attributes = (Z_AttributeElement *) nmem_malloc (stream, sizeof(**sk->u.sortAttributes->list->attributes)); ae->attributeSet = 0; - ae->attributeType = nmem_malloc (stream, sizeof(*ae->attributeType)); + ae->attributeType = (int *) + nmem_malloc (stream, sizeof(*ae->attributeType)); *ae->attributeType = 1; ae->which = Z_AttributeValue_numeric; - ae->value.numeric = nmem_malloc (stream, sizeof(*ae->value.numeric)); + ae->value.numeric = (int *) + nmem_malloc (stream, sizeof(*ae->value.numeric)); *ae->value.numeric = use_value; - sks->sortRelation = nmem_malloc (stream, sizeof(*sks->sortRelation)); + sks->sortRelation = (int *) + nmem_malloc (stream, sizeof(*sks->sortRelation)); if (sort_relation_value == 1) *sks->sortRelation = Z_SortRelation_ascending; else if (sort_relation_value == 2) @@ -1877,7 +1888,8 @@ static RSET rpn_sort_spec (ZebraHandle zh, Z_AttributesPlusTerm *zapt, else *sks->sortRelation = Z_SortRelation_ascending; - sks->caseSensitivity = nmem_malloc (stream, sizeof(*sks->caseSensitivity)); + sks->caseSensitivity = (int *) + nmem_malloc (stream, sizeof(*sks->caseSensitivity)); *sks->caseSensitivity = 0; #ifdef ASN_COMPILED @@ -2016,7 +2028,7 @@ static RSET rpn_search_structure (ZebraHandle zh, Z_RPNStructure *zs, #ifdef ASN_COMPILED if (*zop->u.prox->u.known != Z_ProxUnit_word) { - char *val = nmem_malloc (stream, 16); + char *val = (char *) nmem_malloc (stream, 16); zh->errCode = 132; zh->errString = val; sprintf (val, "%d", *zop->u.prox->u.known); @@ -2025,7 +2037,7 @@ static RSET rpn_search_structure (ZebraHandle zh, Z_RPNStructure *zs, #else if (*zop->u.prox->proximityUnitCode != Z_ProxUnit_word) { - char *val = nmem_malloc (stream, 16); + char *val = (char *) nmem_malloc (stream, 16); zh->errCode = 132; zh->errString = val; sprintf (val, "%d", *zop->u.prox->proximityUnitCode); @@ -2090,10 +2102,12 @@ RSET rpn_search (ZebraHandle zh, NMEM nmem, zh->errString = NULL; zh->hits = 0; - sort_sequence = nmem_malloc (nmem, sizeof(*sort_sequence)); + sort_sequence = (Z_SortKeySpecList *) + nmem_malloc (nmem, sizeof(*sort_sequence)); sort_sequence->num_specs = 10; - sort_sequence->specs = nmem_malloc (nmem, sort_sequence->num_specs * - sizeof(*sort_sequence->specs)); + sort_sequence->specs = (Z_SortKeySpec **) + nmem_malloc (nmem, sort_sequence->num_specs * + sizeof(*sort_sequence->specs)); for (i = 0; inum_specs; i++) sort_sequence->specs[i] = 0; @@ -2140,7 +2154,7 @@ struct scan_info { static int scan_handle (char *name, const char *info, int pos, void *client) { int len_prefix, idx; - struct scan_info *scan_info = client; + struct scan_info *scan_info = (struct scan_info *) client; len_prefix = strlen(scan_info->prefix); if (memcmp (name, scan_info->prefix, len_prefix)) @@ -2149,8 +2163,8 @@ static int scan_handle (char *name, const char *info, int pos, void *client) idx = scan_info->after - pos + scan_info->before; else idx = - pos - 1; - scan_info->list[idx].term = odr_malloc (scan_info->odr, - strlen(name + len_prefix)+1); + scan_info->list[idx].term = (char *) + odr_malloc (scan_info->odr, strlen(name + len_prefix)+1); strcpy (scan_info->list[idx].term, name + len_prefix); assert (*info == sizeof(ISAM_P)); memcpy (&scan_info->list[idx].isam_p, info+1, sizeof(ISAM_P)); @@ -2164,7 +2178,7 @@ static void scan_term_untrans (ZebraHandle zh, NMEM stream, int reg_type, term_untrans (zh, reg_type, term_dst, src); - *dst = nmem_malloc (stream, strlen(term_dst)+1); + *dst = (char *) nmem_malloc (stream, strlen(term_dst)+1); strcpy (*dst, term_dst); } @@ -2276,7 +2290,8 @@ void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, /* prepare dictionary scanning */ before = pos-1; after = 1+num-pos; - scan_info_array = odr_malloc (stream, ord_no * sizeof(*scan_info_array)); + scan_info_array = (struct scan_info *) + odr_malloc (stream, ord_no * sizeof(*scan_info_array)); for (i = 0; i < ord_no; i++) { int j, prefix_len = 0; @@ -2290,8 +2305,8 @@ void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, scan_info->after = after; scan_info->odr = stream; - scan_info->list = odr_malloc (stream, (before+after)* - sizeof(*scan_info->list)); + scan_info->list = (struct scan_info_entry *) + odr_malloc (stream, (before+after) * sizeof(*scan_info->list)); for (j = 0; jlist[j].term = NULL; @@ -2305,7 +2320,8 @@ void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, dict_scan (zh->dict, termz, &before_tmp, &after_tmp, scan_info, scan_handle); } - glist = odr_malloc (stream, (before+after)*sizeof(*glist)); + glist = (ZebraScanEntry *) + odr_malloc (stream, (before+after)*sizeof(*glist)); /* consider terms after main term */ for (i = 0; i < ord_no; i++) diff --git a/index/zserver.c b/index/zserver.c index 85ff5d9..3f10faf 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.67 1999-02-02 14:51:14 adam + * Revision 1.68 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.67 1999/02/02 14:51:14 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.66 1998/10/28 10:54:41 adam @@ -269,7 +272,8 @@ static int bend_sort (void *handle, bend_sort_rr *rr); bend_initresult *bend_init (bend_initrequest *q) { - bend_initresult *r = odr_malloc (q->stream, sizeof(*r)); + bend_initresult *r = (bend_initresult *) + odr_malloc (q->stream, sizeof(*r)); ZebraHandle zh; struct statserv_options_block *sob; char *user = NULL; @@ -316,8 +320,9 @@ bend_initresult *bend_init (bend_initrequest *q) bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd) { - ZebraHandle zh = handle; - bend_searchresult *r = odr_malloc (q->stream, sizeof(*r)); + ZebraHandle zh = (ZebraHandle) handle; + bend_searchresult *r = (bend_searchresult *) + odr_malloc (q->stream, sizeof(*r)); r->hits = 0; r->errcode = 0; @@ -345,8 +350,9 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd) bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) { - ZebraHandle zh = handle; - bend_fetchresult *r = odr_malloc (q->stream, sizeof(*r)); + ZebraHandle zh = (ZebraHandle) handle; + bend_fetchresult *r = (bend_fetchresult *) + odr_malloc (q->stream, sizeof(*r)); ZebraRetrievalRecord retrievalRecord; retrievalRecord.position = q->number; @@ -380,14 +386,16 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num) { ZebraScanEntry *entries; - ZebraHandle zh = handle; - bend_scanresult *r = odr_malloc (q->stream, sizeof(*r)); + ZebraHandle zh = (ZebraHandle) handle; + bend_scanresult *r = (bend_scanresult *) + odr_malloc (q->stream, sizeof(*r)); int is_partial, i; r->term_position = q->term_position; r->num_entries = q->num_entries; - r->entries = odr_malloc (q->stream, sizeof(*r->entries) * q->num_entries); + r->entries = (struct scan_entry *) + odr_malloc (q->stream, sizeof(*r->entries) * q->num_entries); zebra_scan (zh, q->stream, q->term, q->attributeset, q->num_bases, q->basenames, @@ -414,7 +422,7 @@ void bend_close (void *handle) int bend_sort (void *handle, bend_sort_rr *rr) { - ZebraHandle zh = handle; + ZebraHandle zh = (ZebraHandle) handle; zebra_sort (zh, rr->stream, rr->num_input_setnames, (const char **) rr->input_setnames, diff --git a/index/zserver.h b/index/zserver.h index b7a452f..e8f7905 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.41 1999-05-12 13:08:06 adam + * Revision 1.42 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.41 1999/05/12 13:08:06 adam * First version of ISAMS. * * Revision 1.40 1998/11/16 16:03:45 adam @@ -168,6 +171,10 @@ #include "zebraapi.h" #include "zinfo.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { int sysno; int score; @@ -288,3 +295,6 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, oid_value *output_format, char **rec_bufp, int *rec_lenp, char **basenamep); +#ifdef __cplusplus +} +#endif diff --git a/index/zsets.c b/index/zsets.c index 5deef63..6394f3d 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.22 1999-02-02 14:51:15 adam + * Revision 1.23 1999-05-26 07:49:13 adam + * C++ compilation. + * + * Revision 1.22 1999/02/02 14:51:15 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.21 1998/11/16 16:03:46 adam @@ -171,18 +174,19 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) else { logf (LOG_DEBUG, "adding result set %s", name); - s = xmalloc (sizeof(*s)); + s = (ZebraSet) xmalloc (sizeof(*s)); s->next = zh->sets; zh->sets = s; - s->name = xmalloc (strlen(name)+1); + s->name = (char *) xmalloc (strlen(name)+1); strcpy (s->name, name); - s->sort_info = xmalloc (sizeof(*s->sort_info)); + s->sort_info = (struct zset_sort_info *) + xmalloc (sizeof(*s->sort_info)); s->sort_info->max_entries = 1000; - s->sort_info->entries = + s->sort_info->entries = (struct zset_sort_entry **) xmalloc (sizeof(*s->sort_info->entries) * s->sort_info->max_entries); - s->sort_info->all_entries = + s->sort_info->all_entries = (struct zset_sort_entry *) xmalloc (sizeof(*s->sort_info->all_entries) * s->sort_info->max_entries); for (i = 0; i < s->sort_info->max_entries; i++) @@ -249,7 +253,7 @@ ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, return NULL; if (!(rset = sset->rset)) return NULL; - sr = xmalloc (sizeof(*sr) * num); + sr = (ZebraPosSet) xmalloc (sizeof(*sr) * num); for (i = 0; icontrol = xmalloc (sizeof(*p->control)); + ZebraRankClass p = (ZebraRankClass) xmalloc (sizeof(*p)); + p->control = (struct rank_control *) xmalloc (sizeof(*p->control)); memcpy (p->control, ctrl, sizeof(*p->control)); p->control->name = xstrdup (ctrl->name); p->init_flag = 0; diff --git a/isam/isam.c b/isam/isam.c index e2205b1..018edd1 100644 --- a/isam/isam.c +++ b/isam/isam.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isam.c,v $ - * Revision 1.25 1999-02-02 14:51:16 adam + * Revision 1.26 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.25 1999/02/02 14:51:16 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.24 1997/10/27 14:25:39 adam @@ -105,7 +108,7 @@ static struct int skipped_inserts; int delete_insert_noop; int delete_replace; - int delete; + int deletes; int remaps; int block_jumps; int tab_deletes; @@ -122,7 +125,7 @@ static ISPT ispt_alloc() ispt_freelist = ispt_freelist->next; } else - p = xmalloc(sizeof(ispt_struct)); + p = (ISPT) xmalloc(sizeof(ispt_struct)); return p; } @@ -162,7 +165,7 @@ ISAM is_open(BFiles bfs, const char *name, int (*cmp)(const void *p1, const void *p2), int writeflag, int keysize, Res res) { - ISAM new; + ISAM inew; char *nm, *r, *pp[IS_MAX_BLOCKTYPES+1], m[2]; int num, size, rs, tmp, i; is_type_header th; @@ -178,17 +181,17 @@ ISAM is_open(BFiles bfs, const char *name, statistics.skipped_inserts = 0; statistics.delete_insert_noop = 0; statistics.delete_replace = 0; - statistics.delete = 0; + statistics.deletes = 0; statistics.remaps = 0; statistics.new_tables = 0; statistics.block_jumps = 0; statistics.tab_deletes = 0; } - new = xmalloc(sizeof(*new)); - new->writeflag = writeflag; + inew = (ISAM) xmalloc(sizeof(*inew)); + inew->writeflag = writeflag; for (i = 0; i < IS_MAX_BLOCKTYPES; i++) - new->types[i].index = 0; /* dummy */ + inew->types[i].index = 0; /* dummy */ /* determine number and size of blocktypes */ if (!(r = res_get_def(res, @@ -199,7 +202,7 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Failed to locate resource %s", nm); return 0; } - new->num_types = num; + inew->num_types = num; for (i = 0; i < num; i++) { if ((rs = sscanf(pp[i], "%d%1[bBkKmM]", &size, m)) < 1) @@ -212,48 +215,48 @@ ISAM is_open(BFiles bfs, const char *name, switch (*m) { case 'b': case 'B': - new->types[i].blocksize = size; break; + inew->types[i].blocksize = size; break; case 'k': case 'K': - new->types[i].blocksize = size * 1024; break; + inew->types[i].blocksize = size * 1024; break; case 'm': case 'M': - new->types[i].blocksize = size * 1048576; break; + inew->types[i].blocksize = size * 1048576; break; default: logf (LOG_FATAL, "Illegal size suffix: %c", *m); return 0; } - new->types[i].dbuf = xmalloc(new->types[i].blocksize); + inew->types[i].dbuf = (char *) xmalloc(inew->types[i].blocksize); m[0] = 'A' + i; m[1] = '\0'; - if (!(new->types[i].bf = bf_open(bfs, strconcat(name, m, 0), - new->types[i].blocksize, writeflag))) + if (!(inew->types[i].bf = bf_open(bfs, strconcat(name, m, 0), + inew->types[i].blocksize, writeflag))) { logf (LOG_FATAL, "bf_open failed"); return 0; } - if ((rs = is_rb_read(&new->types[i], &th)) > 0) + if ((rs = is_rb_read(&inew->types[i], &th)) > 0) { - if (th.blocksize != new->types[i].blocksize) + if (th.blocksize != inew->types[i].blocksize) { logf (LOG_FATAL, "File blocksize mismatch in %s", name); exit(1); } - new->types[i].freelist = th.freelist; - new->types[i].top = th.top; + inew->types[i].freelist = th.freelist; + inew->types[i].top = th.top; } else if (writeflag) /* write dummy superblock to determine top */ { - if ((rs = is_rb_write(&new->types[i], &th)) <=0) /* dummy */ + if ((rs = is_rb_write(&inew->types[i], &th)) <=0) /* dummy */ { logf (LOG_FATAL, "Failed to write initial superblock."); exit(1); } - new->types[i].freelist = -1; - new->types[i].top = rs; + inew->types[i].freelist = -1; + inew->types[i].top = rs; } /* ELSE: this is an empty file opened in read-only mode. */ } if (keysize > 0) - new->keysize = keysize; + inew->keysize = keysize; else { if (!(r = res_get_def(res, nm = strconcat(name, ".", @@ -262,7 +265,7 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Failed to locate resource %s", nm); return 0; } - if ((new->keysize = atoi(r)) <= 0) + if ((inew->keysize = atoi(r)) <= 0) { logf (LOG_FATAL, "Must specify positive keysize."); return 0; @@ -276,7 +279,7 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Failed to locate resource %s", nm); return 0; } - new->repack = atoi(r); + inew->repack = atoi(r); /* determine max keys/blocksize */ if (!(r = res_get_def(res, @@ -287,7 +290,7 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Failed to locate resource %s", nm); return 0; } - if (num < new->num_types -1) + if (num < inew->num_types -1) { logf (LOG_FATAL, "Not enough elements in %s", nm); return 0; @@ -299,23 +302,23 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Error in resource %s: %s", r, pp[i]); return 0; } - new->types[i].max_keys = tmp; + inew->types[i].max_keys = tmp; } /* determine max keys/block */ - for (i = 0; i < new->num_types; i++) + for (i = 0; i < inew->num_types; i++) { - if (!new->types[i].index) + if (!inew->types[i].index) { - new->types[i].max_keys_block = (new->types[i].blocksize - 2 * - sizeof(int)) / new->keysize; - new->types[i].max_keys_block0 = (new->types[i].blocksize - 3 * - sizeof(int)) / new->keysize; + inew->types[i].max_keys_block = (inew->types[i].blocksize - 2 * + sizeof(int)) / inew->keysize; + inew->types[i].max_keys_block0 = (inew->types[i].blocksize - 3 * + sizeof(int)) / inew->keysize; } else - new->types[i].max_keys_block = new->types[i].max_keys_block0 / - new->keysize; - if (new->types[i].max_keys_block0 < 1) + inew->types[i].max_keys_block = inew->types[i].max_keys_block0 / + inew->keysize; + if (inew->types[i].max_keys_block0 < 1) { logf (LOG_FATAL, "Blocksize too small in %s", name); exit(1); @@ -331,7 +334,7 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Failed to locate resource %s", nm); return 0; } - if (num < new->num_types) + if (num < inew->num_types) { logf (LOG_FATAL, "Not enough elements in %s", nm); return 0; @@ -343,14 +346,14 @@ ISAM is_open(BFiles bfs, const char *name, logf (LOG_FATAL, "Error in resource %s: %s", r, pp[i]); return 0; } - new->types[i].nice_keys_block = (new->types[i].max_keys_block0 * tmp) / + inew->types[i].nice_keys_block = (inew->types[i].max_keys_block0 * tmp) / 100; - if (new->types[i].nice_keys_block < 1) - new->types[i].nice_keys_block = 1; + if (inew->types[i].nice_keys_block < 1) + inew->types[i].nice_keys_block = 1; } - new->cmp = cmp ? cmp : is_default_cmp; - return new; + inew->cmp = cmp ? cmp : is_default_cmp; + return inew; } /* @@ -401,7 +404,7 @@ int is_close(ISAM is) statistics.delete_insert_noop); logf(LOG_LOG, "delete_replace %d", statistics.delete_replace); - logf(LOG_LOG, "delete %d", statistics.delete); + logf(LOG_LOG, "delete %d", statistics.deletes); logf(LOG_LOG, "remaps %d", statistics.remaps); logf(LOG_LOG, "block_jumps %d", statistics.block_jumps); logf(LOG_LOG, "tab_deletes %d", statistics.tab_deletes); @@ -517,7 +520,7 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) } logf (LOG_DEBUG, "Deleting record."); is_m_delete_record(&tab); - statistics.delete++; + statistics.deletes++; } } } diff --git a/isam/isutil.h b/isam/isutil.h index 4c173fd..9b16540 100644 --- a/isam/isutil.h +++ b/isam/isutil.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isutil.h,v $ - * Revision 1.2 1999-02-02 14:51:18 adam + * Revision 1.3 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.2 1999/02/02 14:51:18 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.1 1994/09/12 08:02:14 quinn @@ -20,8 +23,16 @@ #ifndef ISUTIL_H #define ISUTIL_H +#ifdef __cplusplus +extern "C" { +#endif + char *strconcat(const char *s1, ...); int is_default_cmp(const void *k1, const void *k2); /* compare function */ +#ifdef __cplusplus +} +#endif + #endif diff --git a/isam/memory.c b/isam/memory.c index 8079f22..d6e3a62 100644 --- a/isam/memory.c +++ b/isam/memory.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: memory.c,v $ - * Revision 1.16 1999-02-02 14:51:20 adam + * Revision 1.17 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.16 1999/02/02 14:51:20 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.15 1997/09/09 13:38:11 adam @@ -82,7 +85,8 @@ is_mblock *xmalloc_mblock() if (!mblock_freelist) { - mblock_freelist = xmalloc(sizeof(is_mblock) * MALLOC_CHUNK); + mblock_freelist = (is_mblock *) + xmalloc(sizeof(is_mblock) * MALLOC_CHUNK); for (i = 0; i < MALLOC_CHUNK - 1; i++) mblock_freelist[i].next = &mblock_freelist[i+1]; mblock_freelist[i].next = 0; @@ -106,7 +110,7 @@ is_mbuf *xmalloc_mbuf(int type) } else { - tmp = xmalloc(sizeof(is_mbuf) + is_mbuf_size[type]); + tmp = (is_mbuf*) xmalloc(sizeof(is_mbuf) + is_mbuf_size[type]); tmp->type = type; } tmp->refcount = type ? 1 : 0; @@ -248,7 +252,7 @@ void is_m_replace_record(is_mtable *tab, const void *rec) */ void is_m_delete_record(is_mtable *tab) { - is_mbuf *mbuf, *new; + is_mbuf *mbuf, *inew; mbuf = tab->cur_mblock->cur_mbuf; if (mbuf->cur_record >= mbuf->num) /* top of mbuf */ @@ -265,19 +269,19 @@ void is_m_delete_record(is_mtable *tab) else /* middle of mbuf */ { /* insert block after current one */ - new = xmalloc_mbuf(IS_MBUF_TYPE_SMALL); - new->next = mbuf->next; - mbuf->next = new; + inew = xmalloc_mbuf(IS_MBUF_TYPE_SMALL); + inew->next = mbuf->next; + mbuf->next = inew; /* virtually transfer everything after current record to new one. */ - new->data = mbuf->data; + inew->data = mbuf->data; mbuf->refcount++; - new->offset = mbuf->offset + mbuf->cur_record * is_keysize(tab->is); - new->num = mbuf->num - mbuf->cur_record; + inew->offset = mbuf->offset + mbuf->cur_record * is_keysize(tab->is); + inew->num = mbuf->num - mbuf->cur_record; /* old buf now only contains stuff before current record */ mbuf->num = mbuf->cur_record -1; - tab->cur_mblock->cur_mbuf = new; + tab->cur_mblock->cur_mbuf = inew; } tab->num_records--; tab->cur_mblock->num_records--; diff --git a/isam/physical.c b/isam/physical.c index 3664ecf..09de594 100644 --- a/isam/physical.c +++ b/isam/physical.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: physical.c,v $ - * Revision 1.15 1999-02-02 14:51:22 adam + * Revision 1.16 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.15 1999/02/02 14:51:22 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.14 1997/09/09 13:38:12 adam @@ -268,7 +271,7 @@ void is_p_unmap(is_mtable *tab) static is_mbuf *mbuf_takehead(is_mbuf **mb, int *num, int keysize) { - is_mbuf *p = 0, **pp = &p, *new; + is_mbuf *p = 0, **pp = &p, *inew; int toget = *num; if (!toget) @@ -283,13 +286,13 @@ static is_mbuf *mbuf_takehead(is_mbuf **mb, int *num, int keysize) } if (toget > 0 && *mb) { - new = xmalloc_mbuf(IS_MBUF_TYPE_SMALL); - new->next = (*mb)->next; - (*mb)->next = new; - new->data = (*mb)->data; + inew = xmalloc_mbuf(IS_MBUF_TYPE_SMALL); + inew->next = (*mb)->next; + (*mb)->next = inew; + inew->data = (*mb)->data; (*mb)->refcount++; - new->offset = (*mb)->offset + toget * keysize; - new->num = (*mb)->num - toget; + inew->offset = (*mb)->offset + toget * keysize; + inew->num = (*mb)->num - toget; (*mb)->num = toget; *pp = *mb; *mb = (*mb)->next; @@ -307,7 +310,7 @@ static is_mbuf *mbuf_takehead(is_mbuf **mb, int *num, int keysize) */ void is_p_align(is_mtable *tab) { - is_mblock *mblock, *new, *last = 0, *next; + is_mblock *mblock, *inew, *last = 0, *next; is_mbuf *mbufs, *mbp; int blocks, recsblock; @@ -370,11 +373,11 @@ void is_p_align(is_mtable *tab) { if (mbufs) { - new = xmalloc_mblock(); - new->diskpos = -1; - new->state = IS_MBSTATE_DIRTY; - new->next = mblock->next; - mblock->next = new; + inew = xmalloc_mblock(); + inew->diskpos = -1; + inew->state = IS_MBSTATE_DIRTY; + inew->next = mblock->next; + mblock->next = inew; } mblock->data = mbp; mblock->num_records = recsblock; diff --git a/isam/rootblk.h b/isam/rootblk.h index 2ae6b0a..44937d8 100644 --- a/isam/rootblk.h +++ b/isam/rootblk.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rootblk.h,v $ - * Revision 1.2 1999-02-02 14:51:25 adam + * Revision 1.3 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.2 1999/02/02 14:51:25 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.1 1994/09/26 16:08:00 quinn @@ -17,6 +20,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct is_type_header { int blocksize; /* for sanity-checking */ @@ -25,9 +32,11 @@ typedef struct is_type_header int top; /* first unused block */ } is_type_header; - - int is_rb_write(isam_blocktype *ib, is_type_header *hd); int is_rb_read(isam_blocktype *ib, is_type_header *hd); +#ifdef __cplusplus +} +#endif + #endif diff --git a/isamc/isamc-p.h b/isamc/isamc-p.h index d9275b6..27c2454 100644 --- a/isamc/isamc-p.h +++ b/isamc/isamc-p.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isamc-p.h,v $ - * Revision 1.6 1998-03-18 09:23:55 adam + * Revision 1.7 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.6 1998/03/18 09:23:55 adam * Blocks are stored in chunks on free list - up to factor 2 in speed. * Fixed bug that could occur in block category rearrangemen. * @@ -29,6 +32,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { int lastblock; int freelist; @@ -90,3 +97,8 @@ int isc_alloc_block (ISAMC is, int cat); void isc_release_block (ISAMC is, int cat, int pos); int isc_read_block (ISAMC is, int cat, int pos, char *dst); int isc_write_block (ISAMC is, int cat, int pos, char *src); + +#ifdef __cplusplus +} +#endif + diff --git a/isamc/isamc.c b/isamc/isamc.c index 5ba69aa..4f5c8bc 100644 --- a/isamc/isamc.c +++ b/isamc/isamc.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isamc.c,v $ - * Revision 1.16 1998-05-27 14:32:03 adam + * Revision 1.17 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.16 1998/05/27 14:32:03 adam * Changed default block category layout. * * Revision 1.15 1998/05/20 10:12:25 adam @@ -100,7 +103,7 @@ ISAMC_M isc_getmethod (void) { 32768, 32000, 31000, 0 }, #endif }; - ISAMC_M m = xmalloc (sizeof(*m)); + ISAMC_M m = (ISAMC_M) xmalloc (sizeof(*m)); m->filecat = def_cat; m->code_start = NULL; @@ -124,9 +127,9 @@ ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method) int i = 0; int max_buf_size = 0; - is = xmalloc (sizeof(*is)); + is = (ISAMC) xmalloc (sizeof(*is)); - is->method = xmalloc (sizeof(*is->method)); + is->method = (ISAMC_M) xmalloc (sizeof(*is->method)); memcpy (is->method, method, sizeof(*method)); filecat = is->method->filecat; assert (filecat); @@ -153,10 +156,10 @@ ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method) logf (LOG_LOG, "isc: max_buf_size %d", max_buf_size); assert (is->no_files > 0); - is->files = xmalloc (sizeof(*is->files)*is->no_files); + is->files = (ISAMC_file) xmalloc (sizeof(*is->files)*is->no_files); if (writeflag) { - is->merge_buf = xmalloc (max_buf_size+256); + is->merge_buf = (char *) xmalloc (max_buf_size+256); memset (is->merge_buf, 0, max_buf_size+256); } else @@ -178,7 +181,8 @@ ISAMC isc_open (BFiles bfs, const char *name, int writeflag, ISAMC_M method) is->files[i].alloc_entries_num = 0; is->files[i].alloc_entries_max = is->method->filecat[i].bsize / sizeof(int) - 1; - is->files[i].alloc_buf = xmalloc (is->method->filecat[i].bsize); + is->files[i].alloc_buf = (char *) + xmalloc (is->method->filecat[i].bsize); is->files[i].no_writes = 0; is->files[i].no_reads = 0; is->files[i].no_skip_writes = 0; @@ -463,7 +467,8 @@ static void init_fc (ISAMC is, int cat) int j = 100; is->files[cat].fc_max = j; - is->files[cat].fc_list = xmalloc (sizeof(*is->files[0].fc_list) * j); + is->files[cat].fc_list = (int *) + xmalloc (sizeof(*is->files[0].fc_list) * j); while (--j >= 0) is->files[cat].fc_list[j] = 0; } @@ -491,13 +496,13 @@ void isc_pp_close (ISAMC_PP pp) ISAMC_PP isc_pp_open (ISAMC is, ISAMC_P ipos) { - ISAMC_PP pp = xmalloc (sizeof(*pp)); + ISAMC_PP pp = (ISAMC_PP) xmalloc (sizeof(*pp)); char *src; pp->cat = isc_type(ipos); pp->pos = isc_block(ipos); - src = pp->buf = xmalloc (is->method->filecat[pp->cat].bsize); + src = pp->buf = (char *) xmalloc (is->method->filecat[pp->cat].bsize); pp->next = 0; pp->size = 0; diff --git a/isamc/isams.c b/isamc/isams.c index d844198..7135685 100644 --- a/isamc/isams.c +++ b/isamc/isams.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isams.c,v $ - * Revision 1.3 1999-05-20 12:57:18 adam + * Revision 1.4 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.3 1999/05/20 12:57:18 adam * Implemented TCL filter. Updated recctrl system. * * Revision 1.2 1999/05/15 14:35:48 adam @@ -52,7 +55,7 @@ struct ISAMS_PP_s { ISAMS_M isams_getmethod (void) { - ISAMS_M m = xmalloc (sizeof(*m)); + ISAMS_M m = (ISAMS_M) xmalloc (sizeof(*m)); m->code_start = NULL; m->code_item = NULL; @@ -69,9 +72,9 @@ ISAMS_M isams_getmethod (void) ISAMS isams_open (BFiles bfs, const char *name, int writeflag, ISAMS_M method) { - ISAMS is = xmalloc (sizeof(*is)); + ISAMS is = (ISAMS) xmalloc (sizeof(*is)); - is->method = xmalloc (sizeof(*is->method)); + is->method = (ISAMS_M) xmalloc (sizeof(*is->method)); memcpy (is->method, method, sizeof(*method)); is->block_size = is->method->block_size; is->debug = is->method->debug; @@ -84,7 +87,7 @@ ISAMS isams_open (BFiles bfs, const char *name, int writeflag, is->head.last_offset = 0; } memcpy (&is->head_old, &is->head, sizeof(is->head)); - is->merge_buf = xmalloc(2*is->block_size); + is->merge_buf = (char *) xmalloc(2*is->block_size); memset(is->merge_buf, 0, 2*is->block_size); return is; } @@ -163,7 +166,7 @@ ISAMS_P isams_merge (ISAMS is, ISAMS_I data) assert (gap <= (int) sizeof(int)); if (gap > 0) { - if (gap < sizeof(int)) + if (gap < (int) sizeof(int)) bf_write(is->bf, first_block, first_offset, sizeof(int)-gap, &count); memcpy (is->merge_buf, ((char*)&count)+(sizeof(int)-gap), gap); @@ -180,7 +183,7 @@ ISAMS_P isams_merge (ISAMS is, ISAMS_I data) ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos) { - ISAMS_PP pp = xmalloc (sizeof(*pp)); + ISAMS_PP pp = (ISAMS_PP) xmalloc (sizeof(*pp)); if (is->debug > 1) logf (LOG_LOG, "isams: isams_pp_open pos=%ld", (long) pos); @@ -188,7 +191,7 @@ ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos) pp->decodeClientData = (*is->method->code_start)(ISAMC_DECODE); pp->numKeys = 0; pp->numRead = 0; - pp->buf = xmalloc(is->block_size*2); + pp->buf = (char *) xmalloc(is->block_size*2); pp->block_no = pos/is->block_size; pp->block_offset = pos - pp->block_no * is->block_size; logf (LOG_LOG, "isams: isams_pp_open off=%d no=%d", diff --git a/isamc/merge.c b/isamc/merge.c index 80ca911..e0b7fce 100644 --- a/isamc/merge.c +++ b/isamc/merge.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: merge.c,v $ - * Revision 1.10 1998-03-19 12:22:09 adam + * Revision 1.11 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.10 1998/03/19 12:22:09 adam * Minor change. * * Revision 1.9 1998/03/19 10:04:38 adam @@ -58,7 +61,8 @@ struct isc_merge_block { int dirty; /* block is different from that on file */ }; -static void opt_blocks (ISAMC is, struct isc_merge_block *mb, int ptr, int last) +static void opt_blocks (ISAMC is, struct isc_merge_block *mb, int ptr, + int last) { int i, no_dirty = 0; for (i = 0; i + +#ifdef __cplusplus +extern "C" { +#endif + struct grs_read_info { void *clientData; int (*readf)(void *, char *, size_t); @@ -54,4 +62,9 @@ extern RecTypeGrs recTypeGrs_sgml; extern RecTypeGrs recTypeGrs_regx; extern RecTypeGrs recTypeGrs_tcl; extern RecTypeGrs recTypeGrs_marc; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/recctrl/marcread.c b/recctrl/marcread.c index 0edc5d4..4e82a01 100644 --- a/recctrl/marcread.c +++ b/recctrl/marcread.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: marcread.c,v $ - * Revision 1.7 1999-05-20 12:57:18 adam + * Revision 1.8 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.7 1999/05/20 12:57:18 adam * Implemented TCL filter. Updated recctrl system. * * Revision 1.6 1999/02/02 14:51:27 adam @@ -71,7 +74,7 @@ data1_node *data1_mk_node_text (data1_handle dh, NMEM mem, data1_node *parent, res->u.data.what = DATA1I_text; res->u.data.len = len; if (res->u.data.len > DATA1_LOCALDATA) { - res->u.data.data = xmalloc (res->u.data.len); + res->u.data.data = (char *) xmalloc (res->u.data.len); res->destroy = destroy_data; } else @@ -170,7 +173,7 @@ data1_node *grs_read_marc (struct grs_read_info *p) } res_root = data1_mk_node_wp (p->dh, p->mem, NULL); res_root->which = DATA1N_root; - res_root->u.root.type = nmem_malloc (p->mem, strlen(absynName)+1); + res_root->u.root.type = (char *) nmem_malloc (p->mem, strlen(absynName)+1); strcpy (res_root->u.root.type, absynName); res_root->u.root.absyn = absyn; diff --git a/recctrl/recctrl.c b/recctrl/recctrl.c index 4879f8f..9530959 100644 --- a/recctrl/recctrl.c +++ b/recctrl/recctrl.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.c,v $ - * Revision 1.4 1999-05-20 12:57:18 adam + * Revision 1.5 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.4 1999/05/20 12:57:18 adam * Implemented TCL filter. Updated recctrl system. * * Revision 1.3 1998/10/16 08:14:36 adam @@ -77,7 +80,8 @@ void recTypes_add_handler (RecTypes rts, RecType rt) { struct recTypeEntry *rte; - rte = nmem_malloc (data1_nmem_get (rts->dh), sizeof(*rte)); + rte = (struct recTypeEntry *) + nmem_malloc (data1_nmem_get (rts->dh), sizeof(*rte)); rte->recType = rt; rte->init_flag = 0; diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index e4c910a..680dde2 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recgrs.c,v $ - * Revision 1.28 1999-05-21 12:00:17 adam + * Revision 1.29 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.28 1999/05/21 12:00:17 adam * Better diagnostics for extraction process. * * Revision 1.27 1999/05/20 12:57:18 adam @@ -238,7 +241,7 @@ static int read_grs_type (struct grs_handlers *h, static void grs_add_handler (struct grs_handlers *h, RecTypeGrs t) { - struct grs_handler *gh = malloc (sizeof(*gh)); + struct grs_handler *gh = (struct grs_handler *) malloc (sizeof(*gh)); gh->next = h->handlers; h->handlers = gh; gh->initFlag = 0; @@ -248,7 +251,7 @@ static void grs_add_handler (struct grs_handlers *h, RecTypeGrs t) static void *grs_init(RecType recType) { - struct grs_handlers *h = malloc (sizeof(*h)); + struct grs_handlers *h = (struct grs_handlers *) malloc (sizeof(*h)); h->handlers = 0; grs_add_handler (h, recTypeGrs_sgml); @@ -262,7 +265,7 @@ static void *grs_init(RecType recType) static void grs_destroy(void *clientData) { - struct grs_handlers *h = clientData; + struct grs_handlers *h = (struct grs_handlers *) clientData; struct grs_handler *gh = h->handlers, *gh_next; while (gh) { @@ -407,7 +410,7 @@ static int grs_extract(void *clientData, struct recExtractCtrl *p) struct grs_read_info gri; oident oe; int oidtmp[OID_SIZE]; - struct grs_handlers *h = clientData; + struct grs_handlers *h = (struct grs_handlers *) clientData; mem = nmem_create (); gri.readf = p->readf; @@ -523,7 +526,7 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) NMEM mem; struct grs_read_info gri; char *tagname; - struct grs_handlers *h = clientData; + struct grs_handlers *h = (struct grs_handlers *) clientData; mem = nmem_create(); gri.readf = p->readf; @@ -614,7 +617,7 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) "schemaIdentifier", mem))) { dnew->u.data.what = DATA1I_oid; - dnew->u.data.data = nmem_malloc(mem, p - tmp); + dnew->u.data.data = (char *) nmem_malloc(mem, p - tmp); memcpy(dnew->u.data.data, tmp, p - tmp); dnew->u.data.len = p - tmp; } @@ -668,21 +671,21 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) p->odr, &dummy))) p->diagnostic = 238; /* not available in requested syntax */ else - p->rec_len = -1; + p->rec_len = (size_t) (-1); break; case VAL_EXPLAIN: if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected, p->odr))) p->diagnostic = 238; else - p->rec_len = -1; + p->rec_len = (size_t) (-1); break; case VAL_SUMMARY: if (!(p->rec_buf = data1_nodetosummary(p->dh, node, selected, p->odr))) p->diagnostic = 238; else - p->rec_len = -1; + p->rec_len = (size_t) (-1); break; case VAL_SUTRS: if (!(p->rec_buf = data1_nodetobuf(p->dh, node, selected, diff --git a/recctrl/recgrs.h b/recctrl/recgrs.h index d9a76c4..e45691a 100644 --- a/recctrl/recgrs.h +++ b/recctrl/recgrs.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recgrs.h,v $ - * Revision 1.3 1999-02-02 14:51:29 adam + * Revision 1.4 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.3 1999/02/02 14:51:29 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.2 1997/04/30 08:56:08 quinn @@ -27,5 +30,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + extern RecType recTypeGrs; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/recctrl/rectext.c b/recctrl/rectext.c index 24d1c63..bcc9d26 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rectext.c,v $ - * Revision 1.11 1999-05-21 12:00:17 adam + * Revision 1.12 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.11 1999/05/21 12:00:17 adam * Better diagnostics for extraction process. * * Revision 1.10 1999/05/20 12:57:18 adam @@ -91,10 +94,10 @@ struct buf_info { struct buf_info *buf_open (struct recExtractCtrl *p) { - struct buf_info *fi = xmalloc (sizeof(*fi)); + struct buf_info *fi = (struct buf_info *) xmalloc (sizeof(*fi)); fi->p = p; - fi->buf = xmalloc (4096); + fi->buf = (char *) xmalloc (4096); fi->offset = 1; fi->max = 1; return fi; @@ -171,7 +174,7 @@ static int text_retrieve (void *clientData, struct recRetrieveCtrl *p) char *nb; text_size = 2*text_size + 8192; - nb = xmalloc (text_size); + nb = (char *) xmalloc (text_size); if (text_buf) { memcpy (nb, text_buf, text_ptr); diff --git a/recctrl/rectext.h b/recctrl/rectext.h index 401fb68..2ba91c3 100644 --- a/recctrl/rectext.h +++ b/recctrl/rectext.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rectext.h,v $ - * Revision 1.3 1999-02-02 14:51:30 adam + * Revision 1.4 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.3 1999/02/02 14:51:30 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.2 1997/04/30 08:56:08 quinn @@ -23,5 +26,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + extern RecType recTypeText; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/recctrl/regxread.c b/recctrl/regxread.c index b7204dd..cc74152 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: regxread.c,v $ - * Revision 1.25 1999-05-25 12:33:32 adam + * Revision 1.26 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.25 1999/05/25 12:33:32 adam * Fixed bug in Tcl filter. * * Revision 1.24 1999/05/21 11:08:46 adam @@ -295,7 +298,7 @@ static char *f_win_get (struct lexSpec *spec, off_t start_pos, off_t end_pos, spec->f_win_start = start_pos; if (!spec->f_win_buf) - spec->f_win_buf = xmalloc (spec->f_win_size); + spec->f_win_buf = (char *) xmalloc (spec->f_win_size); *size = (*spec->f_win_rf)(spec->f_win_fh, spec->f_win_buf, spec->f_win_size); spec->f_win_end = spec->f_win_start + *size; @@ -351,8 +354,8 @@ static void regxCodeMk (struct regxCode **pp, const char *buf, int len) { struct regxCode *p; - p = xmalloc (sizeof(*p)); - p->str = xmalloc (len+1); + p = (struct regxCode *) xmalloc (sizeof(*p)); + p->str = (char *) xmalloc (len+1); memcpy (p->str, buf, len); p->str[len] = '\0'; *pp = p; @@ -392,7 +395,7 @@ static void actionListDel (struct lexRuleAction **rap) static struct lexContext *lexContextCreate (const char *name) { - struct lexContext *p = xmalloc (sizeof(*p)); + struct lexContext *p = (struct lexContext *) xmalloc (sizeof(*p)); p->name = xstrdup (name); p->ruleNo = 1; @@ -429,8 +432,8 @@ static struct lexSpec *lexSpecCreate (const char *name, data1_handle dh) struct lexSpec *p; int i; - p = xmalloc (sizeof(*p)); - p->name = xmalloc (strlen(name)+1); + p = (struct lexSpec *) xmalloc (sizeof(*p)); + p->name = (char *) xmalloc (strlen(name)+1); strcpy (p->name, name); #if HAVE_TCL_H @@ -439,19 +442,21 @@ static struct lexSpec *lexSpecCreate (const char *name, data1_handle dh) p->dh = dh; p->context = NULL; p->context_stack_size = 100; - p->context_stack = xmalloc (sizeof(*p->context_stack) * - p->context_stack_size); + p->context_stack = (struct lexContext **) + xmalloc (sizeof(*p->context_stack) * p->context_stack_size); p->f_win_buf = NULL; p->maxLevel = 128; - p->concatBuf = xmalloc (sizeof(*p->concatBuf) * p->maxLevel); + p->concatBuf = (struct lexConcatBuf **) + xmalloc (sizeof(*p->concatBuf) * p->maxLevel); for (i = 0; i < p->maxLevel; i++) { - p->concatBuf[i] = xmalloc (sizeof(**p->concatBuf)); + p->concatBuf[i] = (struct lexConcatBuf *) + xmalloc (sizeof(**p->concatBuf)); p->concatBuf[i]->len = p->concatBuf[i]->max = 0; p->concatBuf[i]->buf = 0; } - p->d1_stack = xmalloc (sizeof(*p->d1_stack) * p->maxLevel); + p->d1_stack = (data1_node **) xmalloc (sizeof(*p->d1_stack) * p->maxLevel); p->d1_level = 0; return p; } @@ -531,7 +536,7 @@ static int readParseToken (const char **cpp, int *len) cmd[i] = *cp + 'a' - 'A'; else break; - if (i < sizeof(cmd)-2) + if (i < (int) sizeof(cmd)-2) i++; cp++; } @@ -579,13 +584,13 @@ static int actionListMk (struct lexSpec *spec, const char *s, bodyMark = 1; continue; case REGX_CODE: - *ap = xmalloc (sizeof(**ap)); + *ap = (struct lexRuleAction *) xmalloc (sizeof(**ap)); (*ap)->which = tok; regxCodeMk (&(*ap)->u.code, s, len); s += len+1; break; case REGX_PATTERN: - *ap = xmalloc (sizeof(**ap)); + *ap = (struct lexRuleAction *) xmalloc (sizeof(**ap)); (*ap)->which = tok; (*ap)->u.pattern.body = bodyMark; bodyMark = 0; @@ -609,7 +614,7 @@ static int actionListMk (struct lexSpec *spec, const char *s, logf (LOG_WARN, "cannot use INIT here"); continue; case REGX_END: - *ap = xmalloc (sizeof(**ap)); + *ap = (struct lexRuleAction *) xmalloc (sizeof(**ap)); (*ap)->which = tok; break; } @@ -677,7 +682,7 @@ int readOneSpec (struct lexSpec *spec, const char *s) return -1; } s++; - rp = xmalloc (sizeof(*rp)); + rp = (struct lexRule *) xmalloc (sizeof(*rp)); rp->info.no = spec->context->ruleNo++; rp->next = spec->context->rules; spec->context->rules = rp; @@ -694,7 +699,7 @@ int readFileSpec (struct lexSpec *spec) int c, i, errors = 0; FILE *spec_inf = 0; - lineBuf = xmalloc (1+lineSize); + lineBuf = (char *) xmalloc (1+lineSize); #if HAVE_TCL_H if (spec->tcl_interp) { @@ -769,7 +774,8 @@ int readFileSpec (struct lexSpec *spec) for (lc = spec->context; lc; lc = lc->next) { struct lexRule *rp; - lc->fastRule = xmalloc (sizeof(*lc->fastRule) * lc->ruleNo); + lc->fastRule = (struct lexRuleInfo **) + xmalloc (sizeof(*lc->fastRule) * lc->ruleNo); for (i = 0; i < lc->ruleNo; i++) lc->fastRule[i] = NULL; for (rp = lc->rules; rp; rp = rp->next) @@ -845,7 +851,7 @@ static void execData (struct lexSpec *spec, char *old_buf, *new_buf; spec->concatBuf[spec->d1_level]->max = org_len + elen + 256; - new_buf = xmalloc (spec->concatBuf[spec->d1_level]->max); + new_buf = (char *) xmalloc (spec->concatBuf[spec->d1_level]->max); if ((old_buf = spec->concatBuf[spec->d1_level]->buf)) { memcpy (new_buf, old_buf, org_len); @@ -875,7 +881,7 @@ static void tagDataRelease (struct lexSpec *spec) assert (!res->u.data.data); assert (res->u.data.len > 0); if (res->u.data.len > DATA1_LOCALDATA) - res->u.data.data = nmem_malloc (spec->m, res->u.data.len); + res->u.data.data = (char *) nmem_malloc (spec->m, res->u.data.len); else res->u.data.data = res->lbuf; memcpy (res->u.data.data, spec->concatBuf[spec->d1_level]->buf, @@ -1011,7 +1017,7 @@ static void tagBegin (struct lexSpec *spec, res->u.tag.get_bytes = -1; if (len >= DATA1_LOCALDATA) - res->u.tag.tag = nmem_malloc (spec->m, len+1); + res->u.tag.tag = (char *) nmem_malloc (spec->m, len+1); else res->u.tag.tag = res->lbuf; @@ -1213,7 +1219,7 @@ static char *regxStrz (const char *src, int len, char *str) static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { - struct lexSpec *spec = clientData; + struct lexSpec *spec = (struct lexSpec *) clientData; if (argc < 2) return TCL_ERROR; if (!strcmp(argv[1], "record") && argc == 3) @@ -1273,7 +1279,7 @@ static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp, static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { - struct lexSpec *spec = clientData; + struct lexSpec *spec = (struct lexSpec *) clientData; if (argc < 2) return TCL_ERROR; @@ -1330,7 +1336,7 @@ static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, int argi = 1; int textFlag = 0; const char *element = 0; - struct lexSpec *spec = clientData; + struct lexSpec *spec = (struct lexSpec *) clientData; while (argi < argc) { @@ -1364,7 +1370,7 @@ static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { - struct lexSpec *spec = clientData; + struct lexSpec *spec = (struct lexSpec *) clientData; int argi = 1; int offset = 0; int no; @@ -1955,7 +1961,7 @@ static data1_node *lexRoot (struct lexSpec *spec, off_t offset, void grs_destroy(void *clientData) { - struct lexSpecs *specs = clientData; + struct lexSpecs *specs = (struct lexSpecs *) clientData; if (specs->spec) { lexSpecDestroy(&specs->spec); @@ -1965,7 +1971,7 @@ void grs_destroy(void *clientData) void *grs_init(void) { - struct lexSpecs *specs = xmalloc (sizeof(*specs)); + struct lexSpecs *specs = (struct lexSpecs *) xmalloc (sizeof(*specs)); specs->spec = 0; return specs; } @@ -1973,7 +1979,7 @@ void *grs_init(void) data1_node *grs_read_regx (struct grs_read_info *p) { int res; - struct lexSpecs *specs = p->clientData; + struct lexSpecs *specs = (struct lexSpecs *) p->clientData; struct lexSpec **curLexSpec = &specs->spec; #if REGX_DEBUG @@ -2019,7 +2025,7 @@ RecTypeGrs recTypeGrs_regx = ®x_type; data1_node *grs_read_tcl (struct grs_read_info *p) { int res; - struct lexSpecs *specs = p->clientData; + struct lexSpecs *specs = (struct lexSpecs *) p->clientData; struct lexSpec **curLexSpec = &specs->spec; #if REGX_DEBUG diff --git a/rset/rsbool.c b/rset/rsbool.c index 4156a4c..bdc39e6 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsbool.c,v $ - * Revision 1.15 1999-02-02 14:51:32 adam + * Revision 1.16 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.15 1999/02/02 14:51:32 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.14 1998/03/05 08:36:27 adam @@ -148,10 +151,10 @@ struct rset_bool_rfd { static void *r_create (RSET ct, const struct rset_control *sel, void *parms) { - rset_bool_parms *bool_parms = parms; + rset_bool_parms *bool_parms = (rset_bool_parms *) parms; struct rset_bool_info *info; - info = xmalloc (sizeof(*info)); + info = (struct rset_bool_info *) xmalloc (sizeof(*info)); info->key_size = bool_parms->key_size; info->rset_l = bool_parms->rset_l; info->rset_r = bool_parms->rset_r; @@ -163,7 +166,8 @@ static void *r_create (RSET ct, const struct rset_control *sel, void *parms) info->term_index_s = info->rset_l->no_rset_terms; ct->no_rset_terms = info->rset_l->no_rset_terms + info->rset_r->no_rset_terms; - ct->rset_terms = xmalloc (sizeof (*ct->rset_terms) * ct->no_rset_terms); + ct->rset_terms = (RSET_TERM *) + xmalloc (sizeof (*ct->rset_terms) * ct->no_rset_terms); memcpy (ct->rset_terms, info->rset_l->rset_terms, info->rset_l->no_rset_terms * sizeof(*ct->rset_terms)); @@ -175,7 +179,7 @@ static void *r_create (RSET ct, const struct rset_control *sel, void *parms) static RSFD r_open (RSET ct, int flag) { - struct rset_bool_info *info = ct->buf; + struct rset_bool_info *info = (struct rset_bool_info *) ct->buf; struct rset_bool_rfd *rfd; if (flag & RSETF_WRITE) @@ -183,7 +187,7 @@ static RSFD r_open (RSET ct, int flag) logf (LOG_FATAL, "bool set type is read-only"); return NULL; } - rfd = xmalloc (sizeof(*rfd)); + rfd = (struct rset_bool_rfd *) xmalloc (sizeof(*rfd)); rfd->next = info->rfd_list; info->rfd_list = rfd; rfd->info = info; @@ -221,7 +225,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_bool_info *info = ct->buf; + struct rset_bool_info *info = (struct rset_bool_info *) ct->buf; assert (info->rfd_list == NULL); xfree (ct->rset_terms); @@ -233,7 +237,7 @@ static void r_delete (RSET ct) static void r_rewind (RSFD rfd) { struct rset_bool_info *info = ((struct rset_bool_rfd*)rfd)->info; - struct rset_bool_rfd *p = rfd; + struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd; logf (LOG_DEBUG, "rsbool_rewind"); rset_rewind (info->rset_l, p->rfd_l); @@ -249,7 +253,7 @@ static int r_count (RSET ct) static int r_read_and (RSFD rfd, void *buf, int *term_index) { - struct rset_bool_rfd *p = rfd; + struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd; struct rset_bool_info *info = p->info; while (p->more_l && p->more_r) @@ -296,7 +300,7 @@ static int r_read_and (RSFD rfd, void *buf, int *term_index) static int r_read_or (RSFD rfd, void *buf, int *term_index) { - struct rset_bool_rfd *p = rfd; + struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd; struct rset_bool_info *info = p->info; while (p->more_l || p->more_r) @@ -341,7 +345,7 @@ static int r_read_or (RSFD rfd, void *buf, int *term_index) static int r_read_not (RSFD rfd, void *buf, int *term_index) { - struct rset_bool_rfd *p = rfd; + struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd; struct rset_bool_info *info = p->info; while (p->more_l || p->more_r) diff --git a/rset/rset.c b/rset/rset.c index 5a3c4d2..d6bab13 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rset.c,v $ - * Revision 1.13 1999-02-02 14:51:33 adam + * Revision 1.14 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.13 1999/02/02 14:51:33 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.12 1998/04/26 10:56:57 adam @@ -64,7 +67,7 @@ RSET rset_create(const struct rset_control *sel, void *parms) int i; logf (LOG_DEBUG, "rs_create(%s)", sel->desc); - rnew = xmalloc(sizeof(*rnew)); + rnew = (RSET) xmalloc(sizeof(*rnew)); rnew->control = sel; rnew->flags = 0; rnew->count = 1; @@ -101,14 +104,14 @@ RSET_TERM *rset_terms(RSET rs, int *no) RSET_TERM rset_term_create (const char *name, int length, const char *flags) { - RSET_TERM t = xmalloc (sizeof(*t)); + RSET_TERM t = (RSET_TERM) xmalloc (sizeof(*t)); if (!name) t->name = NULL; else if (length == -1) t->name = xstrdup (name); else { - t->name = xmalloc (length+1); + t->name = (char*) xmalloc (length+1); memcpy (t->name, name, length); t->name[length] = '\0'; } @@ -129,7 +132,7 @@ void rset_term_destroy (RSET_TERM t) RSET_TERM rset_term_dup (RSET_TERM t) { - RSET_TERM nt = xmalloc (sizeof(*nt)); + RSET_TERM nt = (RSET_TERM) xmalloc (sizeof(*nt)); if (t->name) nt->name = xstrdup (t->name); else diff --git a/rset/rsisam.c b/rset/rsisam.c index baa2fc1..e816376 100644 --- a/rset/rsisam.c +++ b/rset/rsisam.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsisam.c,v $ - * Revision 1.19 1999-02-02 14:51:34 adam + * Revision 1.20 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.19 1999/02/02 14:51:34 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.18 1998/03/05 08:36:28 adam @@ -113,24 +116,24 @@ struct rset_isam_info { static void *r_create(RSET ct, const struct rset_control *sel, void *parms) { - rset_isam_parms *pt = parms; + rset_isam_parms *pt = (rset_isam_parms *) parms; struct rset_isam_info *info; ct->flags |= RSET_FLAG_VOLATILE; - info = xmalloc (sizeof(struct rset_isam_info)); + info = (struct rset_isam_info *) xmalloc (sizeof(struct rset_isam_info)); info->is = pt->is; info->pos = pt->pos; info->ispt_list = NULL; ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); ct->rset_terms[0] = pt->rset_term; return info; } RSFD r_open (RSET ct, int flag) { - struct rset_isam_info *info = ct->buf; + struct rset_isam_info *info = (struct rset_isam_info *) ct->buf; struct rset_ispt_info *ptinfo; logf (LOG_DEBUG, "risam_open"); @@ -139,7 +142,7 @@ RSFD r_open (RSET ct, int flag) logf (LOG_FATAL, "ISAM set type is read-only"); return NULL; } - ptinfo = xmalloc (sizeof(*ptinfo)); + ptinfo = (struct rset_ispt_info *) xmalloc (sizeof(*ptinfo)); ptinfo->next = info->ispt_list; info->ispt_list = ptinfo; ptinfo->pt = is_position (info->is, info->pos); @@ -169,7 +172,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_isam_info *info = ct->buf; + struct rset_isam_info *info = (struct rset_isam_info *) ct->buf; logf (LOG_DEBUG, "rsisam_delete"); assert (info->ispt_list == NULL); diff --git a/rset/rsisamc.c b/rset/rsisamc.c index 42b6c52..cd8d9dd 100644 --- a/rset/rsisamc.c +++ b/rset/rsisamc.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsisamc.c,v $ - * Revision 1.6 1999-02-02 14:51:35 adam + * Revision 1.7 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.6 1999/02/02 14:51:35 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.5 1998/03/05 08:36:28 adam @@ -69,23 +72,23 @@ struct rset_isamc_info { static void *r_create(RSET ct, const struct rset_control *sel, void *parms) { - rset_isamc_parms *pt = parms; + rset_isamc_parms *pt = (rset_isamc_parms *) parms; struct rset_isamc_info *info; ct->flags |= RSET_FLAG_VOLATILE; - info = xmalloc (sizeof(*info)); + info = (struct rset_isamc_info *) xmalloc (sizeof(*info)); info->is = pt->is; info->pos = pt->pos; info->ispt_list = NULL; ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); ct->rset_terms[0] = pt->rset_term; return info; } RSFD r_open (RSET ct, int flag) { - struct rset_isamc_info *info = ct->buf; + struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf; struct rset_pp_info *ptinfo; logf (LOG_DEBUG, "risamc_open"); @@ -94,7 +97,7 @@ RSFD r_open (RSET ct, int flag) logf (LOG_FATAL, "ISAMC set type is read-only"); return NULL; } - ptinfo = xmalloc (sizeof(*ptinfo)); + ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo)); ptinfo->next = info->ispt_list; info->ispt_list = ptinfo; ptinfo->pt = isc_pp_open (info->is, info->pos); @@ -123,7 +126,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_isamc_info *info = ct->buf; + struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf; logf (LOG_DEBUG, "rsisamc_delete"); assert (info->ispt_list == NULL); diff --git a/rset/rsisams.c b/rset/rsisams.c index 1a3ec60..471babf 100644 --- a/rset/rsisams.c +++ b/rset/rsisams.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsisams.c,v $ - * Revision 1.1 1999-05-12 15:24:25 adam + * Revision 1.2 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.1 1999/05/12 15:24:25 adam * First version of ISAMS. * */ @@ -52,23 +55,23 @@ struct rset_isams_info { static void *r_create(RSET ct, const struct rset_control *sel, void *parms) { - rset_isams_parms *pt = parms; + rset_isams_parms *pt = (struct rset_isams_parms *) parms; struct rset_isams_info *info; ct->flags |= RSET_FLAG_VOLATILE; - info = xmalloc (sizeof(*info)); + info = (struct rset_isams_info *) xmalloc (sizeof(*info)); info->is = pt->is; info->pos = pt->pos; info->ispt_list = NULL; ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); ct->rset_terms[0] = pt->rset_term; return info; } RSFD r_open (RSET ct, int flag) { - struct rset_isams_info *info = ct->buf; + struct rset_isams_info *info = (struct rset_isams_info *) ct->buf; struct rset_pp_info *ptinfo; logf (LOG_DEBUG, "risams_open"); @@ -77,7 +80,7 @@ RSFD r_open (RSET ct, int flag) logf (LOG_FATAL, "ISAMS set type is read-only"); return NULL; } - ptinfo = xmalloc (sizeof(*ptinfo)); + ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo)); ptinfo->next = info->ispt_list; info->ispt_list = ptinfo; ptinfo->pt = isams_pp_open (info->is, info->pos); @@ -106,7 +109,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_isams_info *info = ct->buf; + struct rset_isams_info *info = (struct rset_isams_info *) ct->buf; logf (LOG_DEBUG, "rsisams_delete"); assert (info->ispt_list == NULL); diff --git a/rset/rsm_or.c b/rset/rsm_or.c index 2683029..a0f37a5 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.7 1998-09-22 10:03:46 adam + * Revision 1.8 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.7 1998/09/22 10:03:46 adam * Changed result sets to be persistent in the sense that they can * be re-searched if needed. * Fixed memory leak in rsm_or. @@ -151,19 +154,19 @@ static struct trunc_info *heap_init (int size, int key_size, int (*cmp)(const void *p1, const void *p2)) { - struct trunc_info *ti = xmalloc (sizeof(*ti)); + struct trunc_info *ti = (struct trunc_info *) xmalloc (sizeof(*ti)); int i; ++size; ti->heapnum = 0; ti->keysize = key_size; ti->cmp = cmp; - ti->indx = xmalloc (size * sizeof(*ti->indx)); - ti->heap = xmalloc (size * sizeof(*ti->heap)); - ti->ptr = xmalloc (size * sizeof(*ti->ptr)); - ti->swapbuf = xmalloc (ti->keysize); - ti->tmpbuf = xmalloc (ti->keysize); - ti->buf = xmalloc (size * ti->keysize); + ti->indx = (int *) xmalloc (size * sizeof(*ti->indx)); + ti->heap = (char **) xmalloc (size * sizeof(*ti->heap)); + ti->ptr = (int *) xmalloc (size * sizeof(*ti->ptr)); + ti->swapbuf = (char *) xmalloc (ti->keysize); + ti->tmpbuf = (char *) xmalloc (ti->keysize); + ti->buf = (char *) xmalloc (size * ti->keysize); for (i = size; --i >= 0; ) { ti->ptr[i] = i; @@ -184,11 +187,11 @@ static void heap_close (struct trunc_info *ti) static void *r_create (RSET ct, const struct rset_control *sel, void *parms) { - rset_m_or_parms *r_parms = parms; + rset_m_or_parms *r_parms = (rset_m_or_parms *) parms; struct rset_mor_info *info; ct->flags |= RSET_FLAG_VOLATILE; - info = xmalloc (sizeof(*info)); + info = (struct rset_mor_info *) xmalloc (sizeof(*info)); info->key_size = r_parms->key_size; assert (info->key_size > 1); info->cmp = r_parms->cmp; @@ -197,14 +200,14 @@ static void *r_create (RSET ct, const struct rset_control *sel, void *parms) info->isc = r_parms->isc; info->no_isam_positions = r_parms->no_isam_positions; - info->isam_positions = xmalloc (sizeof(*info->isam_positions) * - info->no_isam_positions); + info->isam_positions = (ISAM_P *) + xmalloc (sizeof(*info->isam_positions) * info->no_isam_positions); memcpy (info->isam_positions, r_parms->isam_positions, sizeof(*info->isam_positions) * info->no_isam_positions); info->rfd_list = NULL; ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); ct->rset_terms[0] = r_parms->rset_term; return info; } @@ -212,7 +215,7 @@ static void *r_create (RSET ct, const struct rset_control *sel, void *parms) static RSFD r_open (RSET ct, int flag) { struct rset_mor_rfd *rfd; - struct rset_mor_info *info = ct->buf; + struct rset_mor_info *info = (struct rset_mor_info *) ct->buf; int i; if (flag & RSETF_WRITE) @@ -220,13 +223,14 @@ static RSFD r_open (RSET ct, int flag) logf (LOG_FATAL, "m_or set type is read-only"); return NULL; } - rfd = xmalloc (sizeof(*rfd)); + rfd = (struct rset_mor_rfd *) xmalloc (sizeof(*rfd)); rfd->flag = flag; rfd->next = info->rfd_list; rfd->info = info; info->rfd_list = rfd; - rfd->ispt = xmalloc (sizeof(*rfd->ispt) * info->no_isam_positions); + rfd->ispt = (ISAMC_PP *) + xmalloc (sizeof(*rfd->ispt) * info->no_isam_positions); rfd->ti = heap_init (info->no_isam_positions, info->key_size, info->cmp); @@ -275,7 +279,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_mor_info *info = ct->buf; + struct rset_mor_info *info = (struct rset_mor_info *) ct->buf; int i; assert (info->rfd_list == NULL); diff --git a/rset/rsnull.c b/rset/rsnull.c index a6d4959..23d6d49 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsnull.c,v $ - * Revision 1.11 1999-02-02 14:51:36 adam + * Revision 1.12 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.11 1999/02/02 14:51:36 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.10 1998/03/05 08:36:28 adam @@ -79,10 +82,10 @@ const struct rset_control *rset_kind_null = &control; static void *r_create(RSET ct, const struct rset_control *sel, void *parms) { - rset_null_parms *null_parms = parms; + rset_null_parms *null_parms = (rset_null_parms *) parms; ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); if (parms) ct->rset_terms[0] = null_parms->rset_term; else diff --git a/rset/rstemp.c b/rset/rstemp.c index b487875..fe30044 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rstemp.c,v $ - * Revision 1.25 1999-02-02 14:51:37 adam + * Revision 1.26 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.25 1999/02/02 14:51:37 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.24 1998/03/05 08:36:28 adam @@ -152,15 +155,15 @@ struct rset_temp_rfd { static void *r_create(RSET ct, const struct rset_control *sel, void *parms) { - rset_temp_parms *temp_parms = parms; + rset_temp_parms *temp_parms = (rset_temp_parms *) parms; struct rset_temp_info *info; - info = xmalloc (sizeof(struct rset_temp_info)); + info = (struct rset_temp_info *) xmalloc (sizeof(struct rset_temp_info)); info->fd = -1; info->fname = NULL; info->key_size = temp_parms->key_size; info->buf_size = 4096; - info->buf_mem = xmalloc (info->buf_size); + info->buf_mem = (char *) xmalloc (info->buf_size); info->pos_cur = 0; info->pos_end = 0; info->pos_buf = 0; @@ -170,18 +173,18 @@ static void *r_create(RSET ct, const struct rset_control *sel, void *parms) info->temp_path = NULL; else { - info->temp_path = xmalloc (strlen(temp_parms->temp_path)+1); + info->temp_path = (char *) xmalloc (strlen(temp_parms->temp_path)+1); strcpy (info->temp_path, temp_parms->temp_path); } ct->no_rset_terms = 1; - ct->rset_terms = xmalloc (sizeof(*ct->rset_terms)); + ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); ct->rset_terms[0] = temp_parms->rset_term; return info; } static RSFD r_open (RSET ct, int flag) { - struct rset_temp_info *info = ct->buf; + struct rset_temp_info *info = (struct rset_temp_info *) ct->buf; struct rset_temp_rfd *rfd; assert (info->fd == -1); @@ -197,7 +200,7 @@ static RSFD r_open (RSET ct, int flag) exit (1); } } - rfd = xmalloc (sizeof(*rfd)); + rfd = (struct rset_temp_rfd *) xmalloc (sizeof(*rfd)); rfd->info = info; r_rewind (rfd); return rfd; @@ -214,7 +217,7 @@ static void r_flush (RSFD rfd, int mk) { char *s = (char*) tempnam (info->temp_path, "zrs"); - info->fname = xmalloc (strlen(s)+1); + info->fname = (char *) xmalloc (strlen(s)+1); strcpy (info->fname, s); logf (LOG_DEBUG, "creating tempfile %s", info->fname); @@ -227,7 +230,8 @@ static void r_flush (RSFD rfd, int mk) } if (info->fname && info->fd != -1 && info->dirty) { - size_t r, count; + size_t count; + int r; if (lseek (info->fd, info->pos_buf, SEEK_SET) == -1) { @@ -237,7 +241,7 @@ static void r_flush (RSFD rfd, int mk) count = info->buf_size; if (count > info->pos_end - info->pos_buf) count = info->pos_end - info->pos_buf; - if ((r = write (info->fd, info->buf_mem, count)) < count) + if ((r = write (info->fd, info->buf_mem, count)) < (int) count) { if (r == -1) logf (LOG_FATAL|LOG_ERRNO, "read %s", info->fname); @@ -265,7 +269,7 @@ static void r_close (RSFD rfd) static void r_delete (RSET ct) { - struct rset_temp_info *info = ct->buf; + struct rset_temp_info *info = (struct rset_temp_info*) ct->buf; if (info->fname) unlink (info->fname); @@ -294,7 +298,8 @@ static void r_reread (RSFD rfd) if (info->fname) { - size_t r, count; + size_t count; + int r; info->pos_border = info->pos_cur + info->buf_size; if (info->pos_border > info->pos_end) @@ -307,7 +312,7 @@ static void r_reread (RSFD rfd) logf (LOG_FATAL|LOG_ERRNO, "lseek %s", info->fname); exit (1); } - if ((r = read (info->fd, info->buf_mem, count)) < count) + if ((r = read (info->fd, info->buf_mem, count)) < (int) count) { if (r == -1) logf (LOG_FATAL|LOG_ERRNO, "read %s", info->fname); @@ -334,7 +339,7 @@ static void r_rewind (RSFD rfd) static int r_count (RSET ct) { - struct rset_temp_info *info = ct->buf; + struct rset_temp_info *info = (struct rset_temp_info *) ct->buf; return info->pos_end / info->key_size; } diff --git a/util/charmap.c b/util/charmap.c index 08bbdb2..5b5b81e 100644 --- a/util/charmap.c +++ b/util/charmap.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: charmap.c,v $ - * Revision 1.14 1998-10-13 20:09:18 adam + * Revision 1.15 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.14 1998/10/13 20:09:18 adam * Changed call to readconf_line. * * Revision 1.13 1997/10/27 14:33:06 adam @@ -112,7 +115,7 @@ static chr_t_entry *set_map_string(chr_t_entry *root, NMEM nmem, { if (!root) { - root = nmem_malloc(nmem, sizeof(*root)); + root = (chr_t_entry *) nmem_malloc(nmem, sizeof(*root)); root->children = 0; root->target = 0; } @@ -130,7 +133,8 @@ static chr_t_entry *set_map_string(chr_t_entry *root, NMEM nmem, { int i; - root->children = nmem_malloc(nmem, sizeof(chr_t_entry*) * 256); + root->children = (chr_t_entry **) + nmem_malloc(nmem, sizeof(chr_t_entry*) * 256); for (i = 0; i < 256; i++) root->children[i] = 0; } @@ -241,7 +245,7 @@ static unsigned char prim(char **s) */ static void fun_addentry(const char *s, void *data, int num) { - chrmaptab tab = data; + chrmaptab tab = (chrmaptab) data; char tmp[2]; tmp[0] = num; tmp[1] = '\0'; @@ -256,7 +260,7 @@ static void fun_addentry(const char *s, void *data, int num) */ static void fun_addspace(const char *s, void *data, int num) { - chrmaptab tab = data; + chrmaptab tab = (chrmaptab) data; tab->input = set_map_string(tab->input, tab->nmem, s, strlen(s), (char*) CHR_SPACE); } @@ -266,7 +270,7 @@ static void fun_addspace(const char *s, void *data, int num) */ static void fun_mkstring(const char *s, void *data, int num) { - chrwork *arg = data; + chrwork *arg = (chrwork *) data; const char **res, *p = s; res = chr_map_input(arg->map, &s, strlen(s)); @@ -281,14 +285,15 @@ static void fun_mkstring(const char *s, void *data, int num) */ static void fun_addmap(const char *s, void *data, int num) { - chrwork *arg = data; + chrwork *arg = (chrwork *) data; assert(arg->map->input); set_map_string(arg->map->input, arg->map->nmem, s, strlen(s), arg->string); } -static int scan_string(char *s, void (*fun)(const char *c, void *data, int num), - void *data, int *num) +static int scan_string(char *s, + void (*fun)(const char *c, void *data, int num), + void *data, int *num) { unsigned char c, str[1024], begin, end, *p; @@ -357,21 +362,24 @@ chrmaptab chrmaptab_create(const char *tabpath, const char *name, int map_only) logf(LOG_WARN|LOG_ERRNO, "%s", name); return 0; } - res = xmalloc(sizeof(*res)); + res = (chrmaptab) xmalloc(sizeof(*res)); res->nmem = nmem_create (); - res->tmp_buf = nmem_malloc (res->nmem, sizeof(*res->tmp_buf) * 100); - res->input = nmem_malloc(res->nmem, sizeof(*res->input)); + res->tmp_buf = (char **) + nmem_malloc (res->nmem, sizeof(*res->tmp_buf) * 100); + res->input = (chr_t_entry *) nmem_malloc(res->nmem, sizeof(*res->input)); res->input->target = (unsigned char*) CHR_UNKNOWN; res->input->equiv = 0; - res->input->children = nmem_malloc(res->nmem, sizeof(res->input) * 256); + res->input->children = (chr_t_entry **) + nmem_malloc(res->nmem, sizeof(res->input) * 256); for (i = 0; i < 256; i++) { - res->input->children[i] = nmem_malloc(res->nmem, sizeof(*res->input)); + res->input->children[i] = (chr_t_entry *) + nmem_malloc(res->nmem, sizeof(*res->input)); res->input->children[i]->children = 0; if (map_only) { - res->input->children[i]->target = nmem_malloc (res->nmem, - 2 * sizeof(char)); + res->input->children[i]->target = (unsigned char *) + nmem_malloc (res->nmem, 2 * sizeof(char)); res->input->children[i]->target[0] = i; res->input->children[i]->target[1] = 0; } diff --git a/util/passwddb.c b/util/passwddb.c index cbe1485..7e76d7c 100644 --- a/util/passwddb.c +++ b/util/passwddb.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: passwddb.c,v $ - * Revision 1.4 1999-02-02 14:51:39 adam + * Revision 1.5 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.4 1999/02/02 14:51:39 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.3 1998/06/25 19:16:32 adam @@ -46,7 +49,7 @@ struct passwd_db { Passwd_db passwd_db_open (void) { - struct passwd_db *p = xmalloc (sizeof(*p)); + struct passwd_db *p = (struct passwd_db *) xmalloc (sizeof(*p)); p->entries = 0; return p; } @@ -86,7 +89,7 @@ int passwd_db_file (Passwd_db db, const char *fname) get_entry (&cp, name, 128); get_entry (&cp, des, 128); - pe = xmalloc (sizeof(*pe)); + pe = (struct passwd_entry *) xmalloc (sizeof(*pe)); pe->name = xstrdup (name); pe->des = xstrdup (des); pe->next = db->entries; diff --git a/util/res.c b/util/res.c index d4522db..b21e706 100644 --- a/util/res.c +++ b/util/res.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: res.c,v $ - * Revision 1.24 1999-02-02 14:51:42 adam + * Revision 1.25 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.24 1999/02/02 14:51:42 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.23 1998/10/28 15:18:55 adam @@ -96,10 +99,11 @@ static struct res_entry *add_entry (Res r) struct res_entry *resp; if (!r->first) - resp = r->last = r->first = xmalloc (sizeof(*resp)); + resp = r->last = r->first = + (struct res_entry *) xmalloc (sizeof(*resp)); else { - resp = xmalloc (sizeof(*resp)); + resp = (struct res_entry *) xmalloc (sizeof(*resp)); r->last->next = resp; r->last = resp; } @@ -119,7 +123,7 @@ static void reread (Res r) assert (r); r->init = 1; - val_buf = xmalloc (val_max); + val_buf = (char*) xmalloc (val_max); fr = fopen (r->name, "r"); if (!fr) @@ -141,7 +145,7 @@ static void reread (Res r) fr_buf[no] = '\0'; resp = add_entry (r); - resp->name = xmalloc (no+1); + resp->name = (char*) xmalloc (no+1); resp->value = NULL; strcpy (resp->name, fr_buf); } @@ -163,7 +167,7 @@ static void reread (Res r) continue; fr_buf[no++] = '\0'; resp = add_entry (r); - resp->name = xmalloc (no); + resp->name = (char*) xmalloc (no); strcpy (resp->name, fr_buf); while (strchr (" \t", fr_buf[no])) @@ -178,7 +182,7 @@ static void reread (Res r) val_buf[val_size-1] == '\t')) val_size--; val_buf[val_size++] = '\0'; - resp->value = xmalloc (val_size); + resp->value = (char*) xmalloc (val_size); strcpy (resp->value, val_buf); logf (LOG_DEBUG, "(name=%s,value=%s)", resp->name, resp->value); @@ -189,7 +193,7 @@ static void reread (Res r) line = fgets (fr_buf, sizeof(fr_buf)-1, fr); if (!line) { - resp->value = xmalloc (val_size); + resp->value = (char*) xmalloc (val_size); strcpy (resp->value, val_buf); break; } @@ -202,7 +206,7 @@ static void reread (Res r) { char *nb; - nb = xmalloc (val_max+=1024); + nb = (char*) xmalloc (val_max+=1024); memcpy (nb, val_buf, val_size); xfree (val_buf); val_buf = nb; @@ -227,7 +231,7 @@ Res res_open (const char *name) logf (LOG_LOG|LOG_ERRNO, "Cannot access resource file `%s'", name); return NULL; } - r = xmalloc (sizeof(*r)); + r = (Res) xmalloc (sizeof(*r)); r->init = 0; r->first = r->last = NULL; r->name = xstrdup (name); diff --git a/util/zebramap.c b/util/zebramap.c index 18869b9..3d75a41 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebramap.c,v $ - * Revision 1.14 1999-02-19 10:37:40 adam + * Revision 1.15 1999-05-26 07:49:14 adam + * C++ compilation. + * + * Revision 1.14 1999/02/19 10:37:40 adam * Minor fix. * * Revision 1.13 1999/02/18 15:01:04 adam @@ -126,7 +129,7 @@ static void zebra_map_read (ZebraMaps zms, const char *name) zm = &zms->map_list; else zm = &(*zm)->next; - *zm = nmem_malloc (zms->nmem, sizeof(**zm)); + *zm = (struct zebra_map *) nmem_malloc (zms->nmem, sizeof(**zm)); (*zm)->reg_id = argv[1][0]; (*zm)->maptab_name = NULL; (*zm)->maptab = NULL; @@ -140,7 +143,7 @@ static void zebra_map_read (ZebraMaps zms, const char *name) zm = &zms->map_list; else zm = &(*zm)->next; - *zm = nmem_malloc (zms->nmem, sizeof(**zm)); + *zm = (struct zebra_map *) nmem_malloc (zms->nmem, sizeof(**zm)); (*zm)->reg_id = argv[1][0]; (*zm)->maptab_name = NULL; (*zm)->type = ZEBRA_MAP_TYPE_SORT; @@ -177,14 +180,14 @@ static void zebra_map_read (ZebraMaps zms, const char *name) static void zms_map_handle (void *p, const char *name, const char *value) { - ZebraMaps zms = p; + ZebraMaps zms = (ZebraMaps) p; zebra_map_read (zms, value); } ZebraMaps zebra_maps_open (Res res) { - ZebraMaps zms = xmalloc (sizeof(*zms)); + ZebraMaps zms = (ZebraMaps) xmalloc (sizeof(*zms)); int i; zms->nmem = nmem_create (); @@ -197,7 +200,7 @@ ZebraMaps zebra_maps_open (Res res) zms->temp_map_ptr[0] = zms->temp_map_str; zms->temp_map_ptr[1] = NULL; - zms->lookup_array = + zms->lookup_array = (struct zebra_map**) nmem_malloc (zms->nmem, sizeof(*zms->lookup_array)*256); for (i = 0; i<256; i++) zms->lookup_array[i] = 0; @@ -216,7 +219,7 @@ chrmaptab zebra_charmap_get (ZebraMaps zms, unsigned reg_id) struct zebra_map *zm = zebra_map_get (zms, reg_id); if (!zm) { - zm = nmem_malloc (zms->nmem, sizeof(*zm)); + zm = (struct zebra_map *) nmem_malloc (zms->nmem, sizeof(*zm)); logf (LOG_WARN, "Unknown register type: %c", reg_id); zm->reg_id = reg_id;