Revision: 34852
          http://brlcad.svn.sourceforge.net/brlcad/?rev=34852&view=rev
Author:   bob1961
Date:     2009-06-23 15:19:32 +0000 (Tue, 23 Jun 2009)

Log Message:
-----------
Modify ged_open() to create a dbip if a NULL one is passed in.

Modified Paths:
--------------
    brlcad/trunk/src/libged/ged.c

Modified: brlcad/trunk/src/libged/ged.c
===================================================================
--- brlcad/trunk/src/libged/ged.c       2009-06-23 14:59:35 UTC (rev 34851)
+++ brlcad/trunk/src/libged/ged.c       2009-06-23 15:19:32 UTC (rev 34852)
@@ -250,13 +250,42 @@
     } else {
        struct db_i     *dbip;
 
-       if (ged_decode_dbip(filename, &dbip) != GED_OK) {
+       if (sscanf(filename, "%ul", (unsigned long *)&dbip) != 1) {
            /* Restore RT's material head */
            rt_new_material_head(save_materp);
 
            return GED_NULL;
        }
 
+       if (dbip == DBI_NULL) {
+           register int i;
+
+           BU_GETSTRUCT(dbip, db_i);
+           dbip->dbi_eof = -1L;
+           dbip->dbi_fp = NULL;
+           dbip->dbi_mf = NULL;
+           dbip->dbi_read_only = 0;
+
+           /* Initialize fields */
+           for (i=0; i<RT_DBNHASH; i++) {
+               dbip->dbi_Head[i] = DIR_NULL;
+           }
+
+           dbip->dbi_local2base = 1.0;         /* mm */
+           dbip->dbi_base2local = 1.0;
+           dbip->dbi_title = bu_strdup("Untitled BRL-CAD Database");
+           dbip->dbi_uses = 1;
+           dbip->dbi_filename = NULL;
+           dbip->dbi_filepath = NULL;
+           dbip->dbi_version = 5;
+
+           bu_ptbl_init(&dbip->dbi_clients, 128, "dbi_clients[]");
+           dbip->dbi_magic = DBI_MAGIC;                /* Now it's valid */
+       }
+
+       /* Could core dump */
+       RT_CK_DBI(dbip);
+
        if (strcmp(dbtype, "disk" ) == 0)
            wdbp = wdb_dbopen(dbip, RT_WDB_TYPE_DB_DISK);
        else if (strcmp(dbtype, "disk_append") == 0)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to