logo       

rev 388 - in trunk: modules/DBM modules/Prosist pr: msg#00144

Subject: rev 388 - in trunk: modules/DBM modules/Prosist pr
Author: mark
Date: 2004-04-18 02:19:00 -0400 (Sun, 18 Apr 2004)
New Revision: 388

Modified:
   trunk/modules/DBM/DBM.c
   trunk/modules/Prosist/Prosist.c
   trunk/modules/Prosist/Prosist.vcproj
   trunk/pr/dbm.pr
Log:
more work on prosist, changed TRUNC const to TRUNCATE 
in DBM

Modified: trunk/modules/DBM/DBM.c
===================================================================
--- trunk/modules/DBM/DBM.c     2004-04-18 05:37:25 UTC (rev 387)
+++ trunk/modules/DBM/DBM.c     2004-04-18 06:19:00 UTC (rev 388)
@@ -79,10 +79,10 @@
 MODULE_DECLARE(DB);
 MODULE_DECLARE(DBM_Exc);
 
-MODULE_CONSTANT_DECLARE(DBM, READONLY ); 
-MODULE_CONSTANT_DECLARE(DBM, READWRITE); 
-MODULE_CONSTANT_DECLARE(DBM, RWCREATE ); 
-MODULE_CONSTANT_DECLARE(DBM, RWTRUNC  ); 
+MODULE_CONSTANT_DECLARE(DBM, READONLY   ); 
+MODULE_CONSTANT_DECLARE(DBM, READWRITE  ); 
+MODULE_CONSTANT_DECLARE(DBM, RWCREATE   ); 
+MODULE_CONSTANT_DECLARE(DBM, RWTRUNCATE ); 
 
 MODULE_START(DBM)
 {
@@ -104,10 +104,10 @@
        MODULE_ADD_TO_OBJ(DBM_Exc, DBM_OBJ, "DBMError");
        DBM_OBJ->unclonable = TRUE;
 
-       MODULE_CONSTANT_INT(DBM, READONLY,  APR_DBM_READONLY ); // read-only 
access
-       MODULE_CONSTANT_INT(DBM, READWRITE, APR_DBM_READWRITE); // read-write 
access
-       MODULE_CONSTANT_INT(DBM, RWCREATE,  APR_DBM_RWCREATE ); // r/w, create 
if needed
-       MODULE_CONSTANT_INT(DBM, RWTRUNC,   APR_DBM_RWTRUNC  ); // r/w, 
truncate if already there
+       MODULE_CONSTANT_INT(DBM, READONLY,   APR_DBM_READONLY  ); // read-only 
access
+       MODULE_CONSTANT_INT(DBM, READWRITE,  APR_DBM_READWRITE ); // read-write 
access
+       MODULE_CONSTANT_INT(DBM, RWCREATE,   APR_DBM_RWCREATE  ); // r/w, 
create if needed
+       MODULE_CONSTANT_INT(DBM, RWTRUNCATE, APR_DBM_RWTRUNC   ); // r/w, 
truncate if already there
 }
 
 DEF( DB, getNames, FPARM2( name,  NULL, 
@@ -306,4 +306,6 @@
        MODULE_ADD_SYM(DB, close);
        MODULE_ADD_SYM(DB, closed_QUES);
        MODULE_ADD_SYM(DB, __objList__);
+
+       check_exceptions(ist);
 }
Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c     2004-04-18 05:37:25 UTC (rev 387)
+++ trunk/modules/Prosist/Prosist.c     2004-04-18 06:19:00 UTC (rev 388)
@@ -53,60 +53,23 @@
 
 // Prosist.c - peristant Prothon db
 
-#include <stdio.h>
-#include <string.h>
 #include <prothon/prothon_dll.h>
 
-#define INITIAL_NUMBER_OF_OBJECTS  32
+#include <apr_dbm.h>
 
-typedef struct obj_map_s* obj_map_p;
+typedef apr_dbm_t* apr_dbm_p;
 
-typedef struct obj_map_s {
-       int                     free;
-       obj_p           obj;
-       size_t          ofs;
-       size_t          len;
-       obj_map_p       prev;
-       obj_map_p       next;
-} obj_map_t;
 
-typedef struct {
-       apr_file_t*                     stream;
-       apr_pool_t*                     pool;
-       apr_thread_mutex_t*     mutex;
-       size_t                          file_size;                              
-       size_t                          free_size;                              
-       obj_map_p                       free_list;
-       obj_map_p                       map_list;
-} dbdata_t;
-
-typedef dbdata_t* dbdata_p;
-
-
-
-void store_object(isp ist, dbdata_p dbdatap, obj_p root_obj) {
-
-}
-
-void trans_abort(isp ist, dbdata_p dbdatap) {
-
-}
-
-void trans_commit(isp ist, dbdata_p dbdatap) {
-
-}
-
-obj_p load_object(isp ist, dbdata_p dbdatap, i64_t id) {
-       obj_p obj = NULL;
-
-       return obj;
-}
-
-
 MODULE_DECLARE(Prosist);
 MODULE_DECLARE(DB);
-MODULE_DECLARE(ProsistException);
+MODULE_DECLARE(ProsistExc);
 
+MODULE_CONSTANT_DECLARE(Prosist, READONLY ); 
+MODULE_CONSTANT_DECLARE(Prosist, READWRITE); 
+MODULE_CONSTANT_DECLARE(Prosist, RWCREATE ); 
+MODULE_CONSTANT_DECLARE(Prosist, RWTRUNCATE  ); 
+
+
 MODULE_START(Prosist)
 {
        Prosist_OBJ = NEW_OBJ(NULL);
@@ -117,64 +80,69 @@
        MODULE_SET_DOC(DB, "Prosist.DB database object prototype");
        MODULE_ADD_TO_OBJ(DB, Prosist_OBJ, "DB");
 
-       ProsistException_OBJ = NEW_OBJ(OBJ(EXCEPTION));
-       MODULE_SET_DOC(ProsistException, "Re module error");
-       MODULE_ADD_TO_OBJ(ProsistException, Prosist_OBJ, "ProsistException");
+       ProsistExc_OBJ = NEW_OBJ(OBJ(EXCEPTION));
+       MODULE_SET_DOC(ProsistExc, "Prosist module error");
+       MODULE_ADD_TO_OBJ(ProsistExc, Prosist_OBJ, "ProsistException");
 
        DB_OBJ->unclonable = TRUE;
        set_obj_rdacc(DB_OBJ, ACC_USER1);
+       
+       MODULE_CONSTANT_INT(Prosist, READONLY,   APR_DBM_READONLY ); // 
read-only access
+       MODULE_CONSTANT_INT(Prosist, READWRITE,  APR_DBM_READWRITE); // 
read-write access
+       MODULE_CONSTANT_INT(Prosist, RWCREATE,   APR_DBM_RWCREATE ); // r/w, 
create if needed
+       MODULE_CONSTANT_INT(Prosist, RWTRUNCATE, APR_DBM_RWTRUNC  ); // r/w, 
truncate if already there
 }
 
-DEF( DB, __init__, list6(ist, sym(ist, "filename"),  NULL, 
-                                         sym(ist, "root"),      OBJ(NONE),
-                                                         sym(ist, 
"overwrite"), OBJ(PR_FALSE) ) ) {
-       char* filename;
-    obj_p root_obj;
-       int overwrite = FALSE;
-       apr_int32_t flags;
-       apr_status_t aprerr;
-       dbdata_p dbdatap;
+DEF( DB, __init__, FPARM4( name,  NULL, 
+                           root,  OBJ(NONE), 
+                           mode,  Prosist_RWCREATE, 
+                           uperm, NEW_INT(APR_UREAD|APR_UWRITE) ) ) {
 
-       CHECK_TYPE_EXC(parms[1], OBJ(STRING_PROTO), "string");
-       filename = pr_strptr(parms[1]);
+       apr_status_t aprerr;
+       apr_pool_t* cntxt;
+       apr_dbm_p db;
+       char *name;
+    obj_p root_obj;
+    int mode, uperm;
+       
+       STRING_PARAM(1, name);
        root_obj = parms[3];
-       if (parms[5] == OBJ(PR_TRUE)) overwrite = TRUE;
+       INT_32_PARAM(3, mode);
+       INT_32_PARAM(4, uperm);
 
-       self->data_type = DATA_TYPE_DATAPTR;
-       dbdatap = self->data.ptr = pr_malloc(sizeof(dbdata_t));
+       aprerr = apr_pool_create(&cntxt, get_pr_head_pool());
+       IF_APR_ERR("out of memory opening Prosist database") return NULL;
 
-       //dbdatap->obj_map = new_dict_obj(ist, INITIAL_NUMBER_OF_OBJECTS);
+       aprerr = apr_dbm_open_ex(&db, "SDBM", name, mode, uperm, cntxt);  
+       IF_APR_ERR("opening Prosist database") return NULL;
 
-       aprerr = apr_pool_create(&(dbdatap->pool), get_pr_head_pool());
-       IF_APR_ERR("Out of memory creating Prosist DB") return NULL;
-       flags = APR_READ | APR_WRITE | APR_BINARY;
-       if (root_obj != OBJ(NONE)) {
-               flags |= APR_CREATE;
-               if (!overwrite) flags |= APR_EXCL;
+       if (root_obj == OBJ(NONE)) {
+               if (mode == APR_DBM_RWTRUNC) {
+                       raise_exception(ist, ProsistExc_OBJ, "root == None 
incompatible with RWTRUNC mode");
+                       return NULL;
+               }
+               //root_obj = load_object(ist, dbdatap, 0);
+       } else {
+               if (mode != APR_DBM_RWCREATE && mode != APR_DBM_RWTRUNC) {
+                       raise_exception(ist, ProsistExc_OBJ, "root obj given 
but mode doesn't allow creation");
+                       return NULL;
+               }
+               //store_object(ist, dbdatap, root_obj);
        }
-       aprerr = apr_file_open(&(dbdatap->stream), filename, flags, 
APR_OS_DEFAULT, dbdatap->pool);
-       if (aprerr != APR_SUCCESS) {
-               char err_buf[80];
-               raise_exception(ist, OBJ(IOEXCEPTION), "Unable to open file %s: 
%s",
-                               filename, apr_strerror(aprerr, err_buf, 
sizeof(err_buf)));
-               apr_pool_destroy(dbdatap->pool);
-               return NULL;
-       }
-       if (root_obj == OBJ(NONE))
-               root_obj = load_object(ist, dbdatap, 0);
-       else
-               store_object(ist, dbdatap, root_obj);
 
        read_unlock(ist, self);
        set_obj_rdacc(self, ACC_USER1);
        set_obj_doc(self, "Prosist DataBase");
        set_attr(ist, self, sym(ist, "filename"), parms[1]);
-       set_attr(ist, self, sym(ist, "root"), root_obj);
+       set_attr(ist, self, sym(ist, "root"),     root_obj);
        read_lock(ist, self);
 
+       self->data_type = DATA_TYPE_DATAPTR;
+       self->data.ptr  = db;
+
        return OBJ(NONE);
 }
-
+/*
 DEF(DB, abort, NULL) {
        dbdata_p dbdatap = self->data.ptr;
        if (dbdatap)
@@ -205,15 +173,11 @@
        if (self->data.ptr) return OBJ(PR_FALSE);
        else                return OBJ(PR_TRUE);
 }
-
+*/
 MAIN_MODULE_INIT(Prosist)
 {
        MODULE_SUB_INIT(Prosist);
        MODULE_ADD_SYM(DB, __init__);
-       MODULE_ADD_SYM(DB, abort);
-       MODULE_ADD_SYM(DB, commit);
-       MODULE_ADD_SYM(DB, close);
-       MODULE_ADD_SYM(DB, closed_QUES);
 
        check_exceptions(ist);
 }

Modified: trunk/modules/Prosist/Prosist.vcproj
===================================================================
--- trunk/modules/Prosist/Prosist.vcproj        2004-04-18 05:37:25 UTC (rev 
387)
+++ trunk/modules/Prosist/Prosist.vcproj        2004-04-18 06:19:00 UTC (rev 
388)
@@ -19,7 +19,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               
AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+                               
AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
                                
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
                                MinimalRebuild="TRUE"
                                BasicRuntimeChecks="3"
@@ -33,11 +33,11 @@
                                Name="VCCustomBuildTool"/>
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="apr.lib wsock32.lib"
+                               AdditionalDependencies="apr.lib aprutil.lib 
wsock32.lib"
                                OutputFile="$(OutDir)/Prosist.dll"
                                LinkIncremental="2"
-                               
AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
-                               IgnoreDefaultLibraryNames="LIBCMTD.lib"
+                               
AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+                               IgnoreDefaultLibraryNames="LIBCMTD.LIB"
                                GenerateDebugInformation="TRUE"
                                ProgramDatabaseFile="$(OutDir)/Prosist.pdb"
                                SubSystem="2"
Modified: trunk/pr/dbm.pr
===================================================================
--- trunk/pr/dbm.pr     2004-04-18 05:37:25 UTC (rev 387)
+++ trunk/pr/dbm.pr     2004-04-18 06:19:00 UTC (rev 388)
@@ -4,7 +4,7 @@
 
 from DBM import DB
 
-db = DB("test.dbm", mode=DBM.RWTRUNC)
+db = DB("test.dbm", mode=DBM.RWTRUNCATE)
 
 if db.exists?('a'):
        print 'err1'




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe