#12 All TCADB tests passed! Going to work on EJDB...
authoradam <anton@adamansky.com>
Sat, 20 Apr 2013 15:48:05 +0000 (22:48 +0700)
committeradam <anton@adamansky.com>
Sat, 20 Apr 2013 15:48:05 +0000 (22:48 +0700)
tcejdb/Makefile.in
tcejdb/configure.ac
tcejdb/ejdb.c
tcejdb/tcadb.c
tcejdb/tcadb.h
tcejdb/tcatest.c
tcejdb/tchdb.c
tcejdb/win32/platform.c

index c215968..8997bb0 100644 (file)
@@ -510,8 +510,8 @@ check-adb :
        $(RUNENV) $(RUNCMD) ./tcatest read 'casket.tcf#mode=r'
        $(RUNENV) $(RUNCMD) ./tcatest remove 'casket.tcf#mode=w'
        $(RUNENV) $(RUNCMD) ./tcatest write '*#bnum=5000#cap=100' 50000
-       $(RUNENV) $(RUNCMD) ./tcatest misc '*' 5000
-       $(RUNENV) $(RUNCMD) ./tcatest wicked '*' 5000
+       $(RUNENV) $(RUNCMD) ./tcatest misc '#' 5000
+       $(RUNENV) $(RUNCMD) ./tcatest wicked '#' 5000
        $(RUNENV) $(RUNCMD) ./tcatest write '%casket-mul.tch#mode=wct#bnum=500' 50000
        $(RUNENV) $(RUNCMD) ./tcatest read '%casket-mul.tch#mode=r'
        $(RUNENV) $(RUNCMD) ./tcatest remove '%casket-mul.tch#mode=w'
index 6b78ad1..ceddf10 100644 (file)
@@ -69,7 +69,7 @@ AC_ARG_ENABLE(debug,
 if test "$enable_debug" = "yes"
 then
   MYCFLAGS="-std=gnu99 -Wall -pedantic -fsigned-char -g -O0 -Wfatal-errors -Werror"
-  MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG -DEJDB_STATIC"
+  MYCPPFLAGS="$MYCPPFLAGS -D_DEBUG -UNDEBUG -DEJDB_STATIC"
   MYCMDLDFLAGS="$MYCMDLDFLAGS -static"
   enables="$enables (debug)"
 fi
@@ -80,7 +80,7 @@ AC_ARG_ENABLE(devel,
 if test "$enable_devel" = "yes"
 then
   MYCFLAGS="-std=gnu99 -Wall -pedantic -fsigned-char -g -O2 -pipe"
-  MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG"
+  MYCPPFLAGS="$MYCPPFLAGS -D_DEBUG -UNDEBUG"
   enables="$enables (devel)"
 fi
 
index 799c32d..7fd63bf 100644 (file)
@@ -178,9 +178,6 @@ static const bool no = false;
     jb->metadb = tctdbnew();
     tctdbsetmutex(jb->metadb);
     tctdbsetcache(jb->metadb, 1024, 0, 0);
-#ifdef _DEBUG
-    tchdbsetdbgfd(jb->metadb->hdb, fileno(stderr));
-#endif
     if (!_ejdbsetmutex(jb)) {
         tctdbdel(jb->metadb);
         TCFREE(jb);
index f426cf3..29d758a 100644 (file)
@@ -3608,7 +3608,7 @@ static bool tcadbmulopen(ADBMUL *mul, const char *name){
     if(otmode){
       for(int i = 0; i < cnum; i++){
         const char *cpath = TCLISTVALPTR(cpaths, i);
-        if(unlink(cpath) != 0) err = true;
+        if(!tcunlinkfile(cpath) != 0) err = true;
       }
       tclistclear(cpaths);
       cnum = 0;
index 63656e0..73eb7aa 100644 (file)
@@ -24,6 +24,7 @@
 #define __TCADB_CLINKAGEBEGIN
 #define __TCADB_CLINKAGEEND
 #endif
+
 __TCADB_CLINKAGEBEGIN
 
 
@@ -40,30 +41,30 @@ __TCADB_CLINKAGEBEGIN
  *************************************************************************************************/
 
 
-typedef struct {                         /* type of structure for an abstract database */
-  int omode;                             /* open mode */
-  TCMDB *mdb;                            /* on-memory hash database object */
-  TCNDB *ndb;                            /* on-memory tree database object */
-  TCHDB *hdb;                            /* hash database object */
-  TCBDB *bdb;                            /* B+ tree database object */
-  TCFDB *fdb;                            /* fixed-length databae object */
-  TCTDB *tdb;                            /* table database object */
-  int64_t capnum;                        /* capacity number of records */
-  int64_t capsiz;                        /* capacity size of using memory */
-  uint32_t capcnt;                       /* count for capacity check */
-  BDBCUR *cur;                           /* cursor of B+ tree */
-  void *skel;                            /* skeleton database */
+typedef struct { /* type of structure for an abstract database */
+    int omode; /* open mode */
+    TCMDB *mdb; /* on-memory hash database object */
+    TCNDB *ndb; /* on-memory tree database object */
+    TCHDB *hdb; /* hash database object */
+    TCBDB *bdb; /* B+ tree database object */
+    TCFDB *fdb; /* fixed-length databae object */
+    TCTDB *tdb; /* table database object */
+    int64_t capnum; /* capacity number of records */
+    int64_t capsiz; /* capacity size of using memory */
+    uint32_t capcnt; /* count for capacity check */
+    BDBCUR *cur; /* cursor of B+ tree */
+    void *skel; /* skeleton database */
 } TCADB;
 
-enum {                                   /* enumeration for open modes */
-  ADBOVOID,                              /* not opened */
-  ADBOMDB,                               /* on-memory hash database */
-  ADBONDB,                               /* on-memory tree database */
-  ADBOHDB,                               /* hash database */
-  ADBOBDB,                               /* B+ tree database */
-  ADBOFDB,                               /* fixed-length database */
-  ADBOTDB,                               /* table database */
-  ADBOSKEL                               /* skeleton database */
+enum { /* enumeration for open modes */
+    ADBOVOID, /* not opened */
+    ADBOMDB, /* on-memory hash database */
+    ADBONDB, /* on-memory tree database */
+    ADBOHDB, /* hash database */
+    ADBOBDB, /* B+ tree database */
+    ADBOFDB, /* fixed-length database */
+    ADBOTDB, /* table database */
+    ADBOSKEL /* skeleton database */
 };
 
 
@@ -414,42 +415,40 @@ EJDB_EXPORT uint64_t tcadbsize(TCADB *adb);
    should be deleted with the function `tclistdel' when it is no longer in use. */
 EJDB_EXPORT TCLIST *tcadbmisc(TCADB *adb, const char *name, const TCLIST *args);
 
-
-
 /*************************************************************************************************
  * features for experts
  *************************************************************************************************/
 
 
-typedef struct {                         /* type of structure for a extra database skeleton */
-  void *opq;                             /* opaque pointer */
-  void (*del)(void *);                   /* destructor */
-  bool (*open)(void *, const char *);
-  bool (*close)(void *);
-  bool (*put)(void *, const void *, int, const void *, int);
-  bool (*putkeep)(void *, const void *, int, const void *, int);
-  bool (*putcat)(void *, const void *, int, const void *, int);
-  bool (*out)(void *, const void *, int);
-  void *(*get)(void *, const void *, int, int *);
-  int (*vsiz)(void *, const void *, int);
-  bool (*iterinit)(void *);
-  void *(*iternext)(void *, int *);
-  TCLIST *(*fwmkeys)(void *, const void *, int, int);
-  int (*addint)(void *, const void *, int, int);
-  double (*adddouble)(void *, const void *, int, double);
-  bool (*sync)(void *);
-  bool (*optimize)(void *, const char *);
-  bool (*vanish)(void *);
-  bool (*copy)(void *, const char *);
-  bool (*tranbegin)(void *);
-  bool (*trancommit)(void *);
-  bool (*tranabort)(void *);
-  const char *(*path)(void *);
-  uint64_t (*rnum)(void *);
-  uint64_t (*size)(void *);
-  TCLIST *(*misc)(void *, const char *, const TCLIST *);
-  bool (*putproc)(void *, const void *, int, const void *, int, TCPDPROC, void *);
-  bool (*foreach)(void *, TCITER, void *);
+typedef struct { /* type of structure for a extra database skeleton */
+    void *opq; /* opaque pointer */
+    void (*del)(void *); /* destructor */
+    bool (*open)(void *, const char *);
+    bool (*close)(void *);
+    bool (*put)(void *, const void *, int, const void *, int);
+    bool (*putkeep)(void *, const void *, int, const void *, int);
+    bool (*putcat)(void *, const void *, int, const void *, int);
+    bool (*out)(void *, const void *, int);
+    void *(*get)(void *, const void *, int, int *);
+    int (*vsiz)(void *, const void *, int);
+    bool (*iterinit)(void *);
+    void *(*iternext)(void *, int *);
+    TCLIST * (*fwmkeys)(void *, const void *, int, int);
+    int (*addint)(void *, const void *, int, int);
+    double (*adddouble)(void *, const void *, int, double);
+    bool (*sync)(void *);
+    bool (*optimize)(void *, const char *);
+    bool (*vanish)(void *);
+    bool (*copy)(void *, const char *);
+    bool (*tranbegin)(void *);
+    bool (*trancommit)(void *);
+    bool (*tranabort)(void *);
+    const char *(*path)(void *);
+    uint64_t(*rnum)(void *);
+    uint64_t(*size)(void *);
+    TCLIST * (*misc)(void *, const char *, const TCLIST *);
+    bool (*putproc)(void *, const void *, int, const void *, int, TCPDPROC, void *);
+    bool (*foreach)(void *, TCITER, void *);
 } ADBSKEL;
 
 /* type of the pointer to a mapping function.
@@ -461,7 +460,7 @@ typedef struct {                         /* type of structure for a extra databa
    `op' specifies the pointer to the optional opaque object.
    The return value is true to continue iteration or false to stop iteration. */
 typedef bool (*ADBMAPPROC)(void *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
-                           void *op);
+        void *op);
 
 
 /* Set an extra database sleleton to an abstract database object.
@@ -505,7 +504,7 @@ EJDB_EXPORT void *tcadbreveal(TCADB *adb);
    If successful, the return value is true, else, it is false.
    This function does not work for the table database. */
 EJDB_EXPORT bool tcadbputproc(TCADB *adb, const void *kbuf, int ksiz, const void *vbuf, int vsiz,
-                  TCPDPROC proc, void *op);
+        TCPDPROC proc, void *op);
 
 
 /* Process each record atomically of an abstract database object.
index 1cc4d9c..adfd364 100644 (file)
@@ -340,6 +340,9 @@ static int runmisc(int argc, char **argv){
     }
   }
   if(!name || !rstr) usage();
+  if (*name == '#') {
+      *name = '*';
+  }
   int rnum = tcatoix(rstr);
   if(rnum < 1) usage();
   int rv = procmisc(name, rnum);
@@ -363,6 +366,9 @@ static int runwicked(int argc, char **argv){
     }
   }
   if(!name || !rstr) usage();
+  if (*name == '#') {
+      *name = '*';
+  }
   int rnum = tcatoix(rstr);
   if(rnum < 1) usage();
   int rv = procwicked(name, rnum);
index db7024a..be486d5 100644 (file)
@@ -346,7 +346,7 @@ bool tchdbsetcache(TCHDB *hdb, int32_t rcnum) {
 
 /* Set the size of the extra mapped memory of a hash database object. */
 bool tchdbsetxmsiz(TCHDB *hdb, int64_t xmsiz) {
-#ifdef _WIN32
+#if defined (_WIN32) && defined(_DEBUG)
     fprintf(stderr, "\ntchdbsetxmsiz does not takes effect on windows platform\n");
     return true;
 #else
index 2fb219e..ff63ef6 100644 (file)
@@ -125,7 +125,7 @@ int glob(const char *pattern, int flags,
     pglob->gl_offs = 10;
     if ((pglob->gl_pathv = calloc(10, sizeof (char *))) == NULL)
         return GLOB_NOSPACE;
-    char *separator = strrchr(pattern, '/');
+    char *separator = strrchr(pattern, MYPATHCHR);
 
     if (separator != NULL) {
         directory = tccalloc(1, separator - pattern + 2);
@@ -149,7 +149,7 @@ int glob(const char *pattern, int flags,
         pglob->gl_pathv[pglob->gl_pathc++] = entry;
         if (pglob->gl_pathc == pglob->gl_offs) {
             /* increase array size */
-            void *tmp = realloc(pglob->gl_pathv, sizeof (char *)*(pglob->gl_offs + 10));
+            void *tmp = realloc(pglob->gl_pathv, sizeof (char *) * (pglob->gl_offs + 10));
             if (tmp == NULL) {
                 globfree(pglob);
                 if (directory != NULL)
@@ -167,6 +167,7 @@ int glob(const char *pattern, int flags,
 }
 
 #ifdef EJDB_DLL
+
 BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
     BOOL result = PTW32_TRUE;
     switch (fdwReason) {