コード例 #1
0
ファイル: browse.c プロジェクト: doniexun/OrangeC
sqlite3 *BrowseDBOpen(PROJECTITEM *pj)
{
    char name[MAX_PATH], *p;
    sqlite3 *rv = NULL;
    strcpy(name, pj->realName);
    p = strrchr(name, '.');
    if (!p)
        p = name + strlen(name);
    strcpy(p, ".obr");
    if (sqlite3_open_v2(name, &rv,SQLITE_OPEN_READWRITE, NULL) == SQLITE_OK)
    {
        char *zErrMsg = NULL;
        version_ok = FALSE;
        if (sqlite3_exec(rv, "SELECT value FROM brPropertyBag WHERE property = \"brVersion\"", 
                              verscallback, 0, &zErrMsg) != SQLITE_OK || !version_ok)
        {
            sqlite3_free(zErrMsg);
            DBClose(rv);
            rv = NULL;
        }
        else
        {
            sqlite3_busy_timeout(rv, 800);
        }
    }
    else
    {
        DBClose(rv);
        rv = NULL;
    }
    
    return rv;
}
コード例 #2
0
ファイル: extenddb.c プロジェクト: sscreation/eXTendDB
void
XTDBFreeHandle(XTDBHandle* handle) {
    //PrintProfile(handle);
    if (handle->indexes) {
        XTDBForAllIDX(handle,NULL,DBClose,DBFree,NULL);
        tcmapdel(handle->indexes);
    }
    /*   HashTableIterator iter;
       hash_table_iterate(handle->indexes,&iter);
       while (hash_table_iter_has_more(&iter)) {
          DataBaseBE* be = hash_table_iter_next(&iter);
          printf("Closing db %p \n",be);
          DBClose(be);
          DBFree(be);
       }*/
    if (handle->mainDB) {
        DBClose(handle->mainDB);
        DBFree(handle->mainDB);
    }
    if (handle->descDB) {
        DBClose(handle->descDB);
        DBFree(handle->descDB);
    }
    //hash_table_free(handle->indexes);
    StrFree(&handle->dbName);
    StrFree(&handle->dataDir);
    StrFree(&handle->descName);
    StrFree(&handle->mainDbFileName);
    memset(handle,0,sizeof(*handle));
    free(handle);
}
コード例 #3
0
ファイル: SILO_CycObj.cpp プロジェクト: jdhare/hym_silo
//============================================================================//
void SILO_CycObj::Write_SILO(char *silo_path) {
    // Write out the SILO database filename:
    char full_name[1001];
    sprintf(full_name,"%s%s_%0.3d.silo",silo_path,silo_name,this->cycle);

    // Bail out if this SILO database should not be written:
    if(!write_flag) {
        cout << "      Ignored: " << full_name << "\n";
        return;
    }
    
    // Open the .silo database file:
    DBfile *dbfile = DBCreate(full_name,DB_CLOBBER,DB_LOCAL,"data",DB_PDB);   
    // Write the mesh to the .silo database:
    WriteMesh_SILO(dbfile,mesh_name,this->silodims,this->mesh_coords,
                   this->cycle,this->time);    
    // Write the data to the .silo database:
    for(int m=0; m<nvars; m++) {
        if(this->mask_flags[m]) {
            this->data_objs[m]->WriteData_SILO(dbfile,this->cycle,mesh_name,
                                               this->mesh_coords);
        }
    }
    // Close the completed .silo database:
    DBClose(dbfile);
    cout << "      Output:  " << full_name << "\n";    
}
コード例 #4
0
ファイル: ucdsamp3.c プロジェクト: drhansj/polymec-dev
/***********************************************************************
 *  Program
 *
 *      ucdsamp3
 *
 *  Purpose
 *
 *      Sample program illustrating use of SILO for writing 3D
 *      unstructured cell data.
 *
 *  Modifications
 *
 * 	Robb Matzke, 1999-04-09
 *	Added argument parsing to control the driver which is used.
 ***********************************************************************/
int
main(int argc, char *argv[])
{
    DBfile        *dbfile;
    int		  i, driver=DB_PDB;
    char	  *filename="ucdsamp3.pdb";
    int            show_all_errors = FALSE;

    /* Parse command-line */
    for (i=1; i<argc; i++) {
	if (!strncmp(argv[i], "DB_PDB", 6)) {
	    driver = StringToDriver(argv[i]);
	    filename = "ucdsamp3.pdb";
	} else if (!strncmp(argv[i], "DB_HDF5", 7)) {
            driver = StringToDriver(argv[i]);
	    filename = "ucdsamp3.h5";
        } else if (!strcmp(argv[i], "show-all-errors")) {
            show_all_errors = 1;
	} else if (argv[i][0] != '\0') {
	    fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
	}
    }

    DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_ALL, NULL);

    dbfile = DBCreate(filename, 0, DB_LOCAL, "ucd test file", driver);
    printf("Creating file: '%s'...\n", filename);
    build_ucd3(dbfile, "mesh1");
    DBClose(dbfile);

    CleanupDriverStuff();
    exit(0);
}
コード例 #5
0
static void CloseDatabase(AirspaceDBType *db) {

	LOGENTRY;

	if (db->external) {

		LOGTAG("Closing external");

		DBRecordFree(db->lat1Idx);
		DBRecordFree(db->lon1Idx);
		DBRecordFree(db->lat3Idx);
		DBRecordFree(db->lon3Idx);
		DBRecordFree(db->typeIdx);

		PFCloseFile(db->extDB);

	} else {

		LOGTAG("Closing internal");
		DBRecordFree(db->lat1Idx);
		DBRecordFree(db->lon1Idx);
		DBRecordFree(db->lat3Idx);
		DBRecordFree(db->lon3Idx);
		DBRecordFree(db->typeIdx);

		DBClose(db->intDB);

	}

	PFMemFree(db);

	LOGEXIT;

}
コード例 #6
0
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose: Test various read operations.	
 *
 * Return:	0
 *
 * Programmer:Mark C. Miller, Thu Jul 15 08:23:56 PDT 2010
 *-------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
    int            driver = DB_PDB, driverType = DB_PDB;
    int            i, err = 0;
    DBfile        *dbfile;
    int            show_all_errors = FALSE;
    char           filename[256];
    char          *obj_names[13];
    int            ordering[13];

    /* Parse command-line */
    for (i=1; i<argc; i++) {
        if (!strncmp(argv[i], "DB_PDB", 6)) {
            driver = StringToDriver(argv[i]);
            driverType = DB_PDB;
        } else if (!strncmp(argv[i], "DB_HDF5", 7)) {
            driver = StringToDriver(argv[i]);
            driverType = DB_HDF5;
        } else if (!strcmp(argv[i], "show-all-errors")) {
            show_all_errors = 1;
	} else if (argv[i][0] != '\0') {
	    fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
	}
    }
    
    DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_TOP, NULL);
    DBForceSingle(1);

    sprintf(filename, "multi_rect2d.%s", driverType==DB_PDB?"pdb":"h5");
    dbfile = DBOpen(filename, DB_UNKNOWN, DB_READ);
    DBSetDir(dbfile, "block7");

    obj_names[0] = "cycle";
    obj_names[1] = "d";
    obj_names[2] = "../_fileinfo";
    obj_names[3] = "otherfile:block7/u";
    obj_names[4] = "v";
    obj_names[5] = "u";
    obj_names[6] = "/.silo/#000005";
    obj_names[7] = "../block7/d";
    obj_names[8] = "../block9/d";
    obj_names[9] = "../block4/d";
    obj_names[10] = "../mesh1_hidden";
    obj_names[11] = "../mesh1";
    obj_names[12] = "../block11/u";

    DBSortObjectsByOffset(dbfile, 13, obj_names, ordering);
    printf("UNsorted objects...\n");
    for (i = 0; i < 13; i++)
        printf("\t\"%s\"\n", obj_names[i]);
    printf("Sorted objects...\n");
    for (i = 0; i < 13; i++)
        printf("\t\"%s\"\n", obj_names[ordering[i]]);

    DBClose(dbfile);

    return err;
}
コード例 #7
0
/*--------------------*/
int main(int argc, char **argv) {
    DBfile *db;
    int            i, driver = DB_PDB;
    char          *filename = "csg.pdb";
    int            show_all_errors = FALSE;
    char  *coordnames[3];
    float *coord[3];

    for (i=1; i<argc; i++) {
        if (!strncmp(argv[i], "DB_PDB",6)) {
            driver = StringToDriver(argv[i]);
            filename = "mat3d_3across.pdb";
        } else if (!strncmp(argv[i], "DB_HDF5", 7)) {
            driver = StringToDriver(argv[i]);
            filename = "mat3d_3across.h5";
        } else if (!strcmp(argv[i], "show-all-errors")) {
            show_all_errors = 1;
	} else if (argv[i][0] != '\0') {
            fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
        }
    }

  if (show_all_errors) DBShowErrors(DB_ALL_AND_DRVR, 0);

  coordnames[0]=strdup("x");
  coordnames[1]=strdup("y");
  coordnames[2]=strdup("z");

  coord[0] = x;
  coord[1] = y;
  coord[2] = z;

  dims[0]=nx;
  dims[1]=ny;
  dims[2]=nz;

  db=DBCreate(filename, DB_CLOBBER, DB_LOCAL,
              "Mixed zone 3d test", driver);

  DBPutQuadmesh(db, "mesh", coordnames, coord, dims, 3, 
                DB_FLOAT, DB_NONCOLLINEAR, NULL);

  dims[0]=zx;
  dims[1]=zy;
  dims[2]=zz;

  DBPutMaterial(db, "material", "mesh", nmat, matnos, matlist, dims, 3, 
		mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, NULL);

  DBClose(db);
 
  free(coordnames[0]);
  free(coordnames[1]);
  free(coordnames[2]);

  CleanupDriverStuff();
  return 0;
}
コード例 #8
0
ファイル: bounce.C プロジェクト: maxhutch/visit
    virtual void WriteMasterFile(const bool *domainsHaveData)
    {
        std::string filename(MasterFile());        
        DBfile *dbfile = DBCreate(filename.c_str(), DB_CLOBBER, DB_LOCAL,
                                  "3D point mesh", DB_HDF5);
        if(dbfile == NULL)
        {
            fprintf(stderr, "Could not create master Silo file!\n");
            return;
        }

        // Create an option list for saving cycle and time values.
        DBoptlist *optlist = DBMakeOptlist(2);
        DBAddOption(optlist, DBOPT_CYCLE, (void *)&cycle);
        DBAddOption(optlist, DBOPT_DTIME, (void *)&time);

        const char *snames[] = {"pointmesh", "vx", "vy", "vz", "restitution", "mass", "dom", "contact"};
        const int svartypes[] = {DB_POINTMESH, DB_POINTVAR, DB_POINTVAR, DB_POINTVAR, DB_POINTVAR,
                                               DB_POINTVAR, DB_POINTVAR, DB_POINTVAR};
        const bool isMesh[] = {true, false, false, false, false, false, false, false};
        for(size_t i = 0; i < (sizeof(snames)/sizeof(const char*)); ++i)
        {
            std::vector<std::string> names;
            for(int d = 0; d < nDomains; ++d)
            {
                std::string domName("EMPTY");
                if(domainsHaveData[d])
                    domName = (DomainFile(d) + ":") + snames[i];
                names.push_back(domName);
            }
            char **varnames = new char *[nDomains];
            int *vartypes = new int[nDomains];
            for(int d = 0; d < nDomains; ++d)
            {
                varnames[d] = (char*)names[d].c_str();
                vartypes[d] = svartypes[i];
            }

            if(isMesh[i])
                DBPutMultimesh(dbfile, snames[i], nDomains, varnames, vartypes, optlist);
            else
                DBPutMultivar(dbfile, snames[i], nDomains, varnames, vartypes, optlist);
        }

        const char *names[] = {"velocity", "speed", "ID"};
        const char *defs[] = {"{vx,vy,vz}", "magnitude(velocity)", "global_nodeid(pointmesh)"};
        int types[] = {DB_VARTYPE_VECTOR, DB_VARTYPE_SCALAR, DB_VARTYPE_SCALAR};
        DBPutDefvars(dbfile, "defvars", 3, (char**)names, types, (char**)defs, NULL);
        DBFreeOptlist(optlist);

        DBClose(dbfile);
    }
コード例 #9
0
ファイル: meshorigin.C プロジェクト: maxhutch/visit
int
main(int argc, char *argv[])
{
    int driver = DB_PDB;
    DBfile *dbfile = NULL;

    // Look through command line args.
    for(int j = 1; j < argc; ++j)
    {
        if (strcmp(argv[j], "-driver") == 0)
        {
            j++;

            if (strcmp(argv[j], "DB_HDF5") == 0)
                driver = DB_HDF5;
            else if (strcmp(argv[j], "DB_PDB") == 0)
                driver = DB_PDB;
            else
            {
               fprintf(stderr,"Uncrecognized driver name \"%s\"\n",
                   argv[j]);
            }
        }
    }

    /* Open the Silo file */
    dbfile = DBCreate("meshorigin.silo", DB_CLOBBER, DB_LOCAL,
        "Many mesh types with different cell/node offsets", driver);
    if(dbfile == NULL)
    {
        fprintf(stderr, "Could not create Silo file!\n");
        return -1;
    }

    /* Add other Silo calls here. */
    write_point3d(dbfile, "pointmesh0", 0);
    write_point3d(dbfile, "pointmesh1", 1);

    write_rect3d(dbfile, "rectmesh0", 0);
    write_rect3d(dbfile, "rectmesh1", 1);

    write_curv3d(dbfile, "curvemesh0", 0);
    write_curv3d(dbfile, "curvemesh1", 1);

    write_ucd3d(dbfile, "ucdmesh0", 0);
    write_ucd3d(dbfile, "ucdmesh1", 1);

    /* Close the Silo file. */
    DBClose(dbfile);
    return 0;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: JakeWhaley/DeltaEcho
int main( int argc, char* args[] )
{
	
	sqlite3 *db;
	char *zErrMsg = 0;

	
	DBMemOpen(&db);
	DBClose(db);
	//DBOpen(&db,"master.db");
	//DBClose(db);

	//int execsuccess = sqlite3_exec(db,"SELECT name FROM (SELECT * FROM sqlite_master UNION ALLSELECT * FROM sqlite_temp_master)WHERE type='table'ORDER BY name",NULL,NULL,NULL);
	SQLTable master("master.db","master");
	if((master.GetRecordCount()>3) && (master.GetFieldCount() == 2))
	{
		if(master.Get(0,0).getType()==2)
		{
			if(master.Get(0,1).getType()==1)
			{
				char * magic = master.Get(0,1).getCData();
				if(isEqual(magic,"682"))
				{
					char * engineVer = master.Get(1,1).getCData();
					char * configVer = master.Get(2,1).getCData();

					if(isEqual(engineVer, "00.00.01"))
					{
						if(isEqual(configVer, "00.00.01"))
						{



						}
					}
					delete [] engineVer;
					delete [] configVer;
				}
				delete [] magic;
			}
		}
	}

	char * str = master.GetAllChar();
	std::printf(str);
	/**/
	SDL_Delay(5000);
	//DBClose(db);
	delete [] str;
	return 0;
};
コード例 #11
0
logical CTX_DBBase :: ExecuteAction (DB_Event intevent )
{
  logical                 term = NO;
BEGINSEQ
  if ( !this )                                       LEAVESEQ
  
  switch ( intevent )
  {
    case DBO_Opened     : term = DBOpened();         break;
    case DBO_Initialize : term = DBInitialize();     break;
    case DBO_Created    : if ( !(term = DBCreated()) )
                            intern_states.data_state = DAT_Filled; 
			  break;
    case DBO_NotCreated : term = DBNotCreated();     break;
    case DBO_Read       : if ( !(term = DBRead()) )
                            intern_states.data_state = DAT_Filled; 
			  break;
    case DBO_Reset      : term = DBReset();          break;
    case DBO_Stored     : term = DBStored();         break;
    case DBO_Inserted   : if ( !(term = DBInserted()) )
                            intern_states.data_state = DAT_Filled; 
			  break;
    case DBO_NotInserted: term = DBNotInserted();    break;
    case DBO_Removed    : term = DBRemoved();        break;
    case DBO_NotRemoved : term = DBNotRemoved();     break;
    case DBO_Deleted    : term = DBDeleted();        break;
    case DBO_NotDeleted : term = DBNotDeleted();     break;
    case DBO_Refresh    : term = DBRefresh();        break;
    case DBO_NotOpened  : term = DBNotOpened();      break;
    case DBO_Close      : term = DBClose();          break;
    
    case DBP_Read       : term = DBBeforeRead();     break;
    case DBP_Create     : term = DBCreate();         break;
    case DBP_Modify     : term = DBModify();         break;
    case DBP_Store      : term = DBStore();          break;
    case DBP_Insert     : term = DBInsert();         break;
    case DBP_Open       : term = DBOpen();           break;
    case DBP_Remove     : term = DBRemove();         break;
    case DBP_Delete     : term = DBDelete();         break;
    case DBP_Select     : term = DBSelect();         break;
    
    case DB_undefined   :                            LEAVESEQ
    default             : ERROR
  }

RECOVER
  term = YES;
ENDSEQ
  return(term);
}
コード例 #12
0
/*-------------------------------------------------------------------------
 * Function:    main
 *
 * Purpose:     Generate multi block curvilinear test file with species info.
 *
 * Return:      Success:
 *
 *              Failure:
 *
 * Programmer:  Jeremy Meredith, Sept 29, 1998
 *
 * Modifications:
 * 	Robb Matzke, 1999-04-09
 *	Added argument parsing to control the driver which is used.
 *
 *------------------------------------------------------------------------*/
int
main(int argc, char *argv[]) {
    DBfile         *dbfile;
    int		   i, driver = DB_PDB;
    char	   *filename = "multispec.pdb";

    /* Parse command-line options */
    for (i=1; i<argc; i++) {
	if (!strcmp(argv[i], "DB_PDB")) {
	    driver = DB_PDB;
	    filename = "multispec.pdb";
	} else if (!strcmp(argv[i], "DB_HDF5")) {
	    driver = DB_HDF5;
	    filename = "multispec.h5";
	} else {
	    fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
	}
    }
    
    /*
     * Create the multi-block curvilinear 2d mesh.
     */
    fprintf(stdout, "creating %s\n", filename);
    if ((dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL,
                         "multi-block curvilinear 2d test file", driver))
        == NULL)
    {
        fprintf(stderr, "Could not create '%s'.\n", filename);
    } else if (build_dbfile(dbfile) == -1)
    {
        fprintf(stderr, "Error in creating '%s'.\n", filename);
        DBClose(dbfile);
    } else
        DBClose(dbfile);

    return(0);
}
コード例 #13
0
ファイル: dataextents.c プロジェクト: burlen/visit_vtk_7_src
void
write_master(double extents[4][2])
{
    DBfile *dbfile = NULL;

    /* Open the Silo file */
    dbfile = DBCreate("dataextents.root", DB_CLOBBER, DB_LOCAL,
    "Master file with data extents", DB_HDF5);    

    write_multimesh(dbfile);
    write_multivar(dbfile, extents);

    /* Close the Silo file. */
    DBClose(dbfile);
}
コード例 #14
0
ファイル: silo.cpp プロジェクト: STEllAR-GROUP/octopus
void single_variable_silo_writer::stop_write_locked(mutex_type::scoped_lock& l)
{
    OCTOPUS_ASSERT(l.owns_lock());

    merge_locked(l);

    if (file_)
    {
        DBClose(file_);
        file_ = 0; 
    }

    directory_names_.clear(); 
    merged_ = false;
}
コード例 #15
0
/*--------------------*/
int main(int argc, char **argv) {
    DBfile *db;
    int            i, driver = DB_PDB;
    char          *filename = "csg.pdb";
    char  *coordnames[3];
    float *coord[3];

    for (i=1; i<argc; i++) {
        if (!strcmp(argv[i], "DB_PDB")) {
            driver = DB_PDB;
            filename = "mat3d_3across.pdb";
        } else if (!strcmp(argv[i], "DB_HDF5")) {
            driver = DB_HDF5;
            filename = "mat3d_3across.h5";
        } else {
            fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
        }
    }

  coordnames[0]=strdup("x");
  coordnames[1]=strdup("y");
  coordnames[2]=strdup("z");

  coord[0] = x;
  coord[1] = y;
  coord[2] = z;

  dims[0]=nx;
  dims[1]=ny;
  dims[2]=nz;

  db=DBCreate(filename, DB_CLOBBER, DB_LOCAL,
              "Mixed zone 3d test", driver);

  DBPutQuadmesh(db, "mesh", coordnames, coord, dims, 3, 
                DB_FLOAT, DB_NONCOLLINEAR, NULL);

  dims[0]=zx;
  dims[1]=zy;
  dims[2]=zz;

  DBPutMaterial(db, "material", "mesh", nmat, matnos, matlist, dims, 3, 
		mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, NULL);

  DBClose(db);

  return 0;
}
コード例 #16
0
void
write_master(double extents[4][2])
{
    DBfile *dbfile = NULL;
    char **meshnames = NULL, **varnames = NULL;
    int dom, nmesh = 4, nvar = 4;
    int *meshtypes = NULL, *vartypes = NULL;

    /* Open the Silo file */
    dbfile = DBCreate("dataextents.root", DB_CLOBBER, DB_LOCAL,
    "Master file with data extents", DB_HDF5);    

    write_multimesh(dbfile);
    write_multivar(dbfile, extents);

    /* Close the Silo file. */
    DBClose(dbfile);
}
コード例 #17
0
ファイル: majorder.c プロジェクト: drhansj/polymec-dev
int
main(int argc, char *argv[])
{
    DBfile         *dbfile = NULL;
    int             i;
    int		    driver = DB_PDB;
    char 	    *filename = "majorder.silo";
    void           *coords[2];
    int             ndims = 2;
    int             dims[2] = {3,2}; 
    int             dims1[2] = {4,3}; 
    int             colmajor = DB_COLMAJOR;
    DBoptlist      *optlist;

    /* Parse command-line */
    for (i=1; i<argc; i++) {
	if (!strncmp(argv[i], "DB_", 3)) {
	    driver = StringToDriver(argv[i]);
	} else if (argv[i][0] != '\0') {
	    fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
	}
    }
    
    dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL, "test major order on quad meshes and vars", driver);

    coords[0] = row_maj_x_data;
    coords[1] = row_maj_y_data;
    DBPutQuadmesh(dbfile, "row_major_mesh", 0, coords, dims1, ndims, DB_FLOAT, DB_NONCOLLINEAR, 0);
    DBPutQuadvar1(dbfile, "row_major_var", "row_major_mesh", row_maj_v_data, dims, ndims, 0, 0, DB_INT, DB_ZONECENT, 0);

    optlist = DBMakeOptlist(1);
    DBAddOption(optlist, DBOPT_MAJORORDER, &colmajor);
    coords[0] = col_maj_x_data;
    coords[1] = col_maj_y_data;
    DBPutQuadmesh(dbfile, "col_major_mesh", 0, coords, dims1, ndims, DB_FLOAT, DB_NONCOLLINEAR, optlist);
    DBPutQuadvar1(dbfile, "col_major_var", "col_major_mesh", col_maj_v_data, dims, ndims, 0, 0, DB_INT, DB_ZONECENT, optlist);
    DBFreeOptlist(optlist);

    DBClose(dbfile);

    CleanupDriverStuff();

    return 0;
}
コード例 #18
0
ファイル: brswnd.c プロジェクト: bencz/OrangeC
static void CreateUsageList(void)
{
    HWND hwnd = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0);
    PROJECTITEM *pj;
    sqlite3 *db = BrowseOpenDBByHWND(hwnd, &pj);
    if (db)
    {
        char mangled[2048], *srcName = brsName;
        BROWSELIST *rv = NULL, **scan;
        FreeUsageList();
        
        GetQualifiedName(mangled, &srcName, FALSE, FALSE);
        
        if (!strrchr(mangled+1, '@'))
        {
            DEBUG_INFO *inf;
            int id;
            mangled[0] = '_';
            if (id = LookupSymbolBrowse(db, mangled))
            {
                BROWSELIST *next = calloc(sizeof(BROWSELIST), 1);
                next->next = rv ;
                rv = next;
                strcpy(next->name, mangled+1);
                next->id = id;
            }
            rv = LookupCPPNamesBrowse(db, mangled , rv);
            mangled[0] = '@';
        }
        rv = LookupCPPNamesBrowse(db, mangled, rv);
        LookupLineInfo(db, rv);
        LookupUsageInfo(db, rv);
        while (rv)
        {
            BROWSELIST *next = rv->next;
            free(rv);
            rv = next;
        }
        PostMessage(hwndBrowse, WM_USER, 0, 0);
        DBClose(db);
    }
}
コード例 #19
0
ファイル: point2d.c プロジェクト: ahota/visit_intel
int
main(int argc, char *argv[])
{
    DBfile *dbfile = NULL;
    /* Open the Silo file */
    dbfile = DBCreate("point2d.silo", DB_CLOBBER, DB_LOCAL,
        "2D point mesh", DB_HDF5);
    if(dbfile == NULL)
    {
        fprintf(stderr, "Could not create Silo file!\n");
        return -1;
    }

    /* Add other Silo calls here. */
    write_point2d(dbfile);

    /* Close the Silo file. */
    DBClose(dbfile);
    return 0;
}
コード例 #20
0
ファイル: basic.c プロジェクト: ahota/visit_intel
int
main(int argc, char *argv[])
{
    DBfile *dbfile = NULL;
    /* Open the Silo file */
    dbfile = DBCreate("basic.silo", DB_CLOBBER, DB_LOCAL,
      "Comment about the data", DB_HDF5);
    if(dbfile == NULL)
    {
        fprintf(stderr, "Could not create Silo file!\n");
        return -1;
    }

    /* Add other Silo calls here. */

    /* Close the Silo file. */
    DBClose(dbfile);

    return 0;
}
コード例 #21
0
ファイル: csg.C プロジェクト: maxhutch/visit
int
main(int argc, char *argv[])
{
    DBfile        *dbfile;
    int            i=1, driver = DB_PDB;

    DBShowErrors(DB_ALL, NULL);

    while (i < argc)
    {
        if (strcmp(argv[i], "-driver") == 0)
        {
            i++;

            if (strcmp(argv[i], "DB_HDF5") == 0)
            {
                driver = DB_HDF5;
            }
            else if (strcmp(argv[i], "DB_PDB") == 0)
            {
                driver = DB_PDB;
            }
            else
            {
               fprintf(stderr,"Uncrecognized driver name \"%s\"\n",
                   argv[i]);
               exit(-1);
            }
        }
        i++;
    }

    dbfile = DBCreate("csg.silo", 0, DB_LOCAL, "csg test file", driver);
    build_csg(dbfile, "csgmesh");
    build_greenman_csg(dbfile, "greenman_mesh");
    build_primitives_csg(dbfile);
    build_csg_time_series(driver);
    DBClose(dbfile);

    return 0;
}
コード例 #22
0
ファイル: vectorvar.c プロジェクト: ahota/visit_intel
int
main(int argc, char *argv[])
{
    DBfile *dbfile = NULL;
    /* Open the Silo file */
    dbfile = DBCreate("vectorvar.silo", DB_CLOBBER, DB_LOCAL,
        "Vector quadvars in 3D", DB_HDF5);
    if(dbfile == NULL)
    {
        fprintf(stderr, "Could not create Silo file!\n");
        return -1;
    }

    /* Add other Silo calls here. */
    write_curv3d(dbfile);
    write_zonecent_quadvar(dbfile);
    write_nodecent_quadvar(dbfile);

    /* Close the Silo file. */
    DBClose(dbfile);
    return 0;
}
コード例 #23
0
ファイル: optlist.c プロジェクト: burlen/visit_vtk_7_src
int
main(int argc, char *argv[])
{
    DBfile *dbfile = NULL;
    /* Open the Silo file */
    dbfile = DBCreate("optlist.silo", DB_CLOBBER, DB_LOCAL,
        "Option list example", DB_HDF5);
    if(dbfile == NULL)
    {
        fprintf(stderr, "Could not create Silo file!\n");
        return -1;
    }

    /* Add other Silo calls here. */
    write_rect2d(dbfile);
    write_zonecent_quadvar2d(dbfile);
    write_nodecent_quadvar2d(dbfile);

    /* Close the Silo file. */
    DBClose(dbfile);
    return 0;
}
コード例 #24
0
ファイル: extenddb.c プロジェクト: sscreation/eXTendDB
uint8_t
XTDBDropIndex(XTDBHandle* handle,char* fieldName) {
    //void * iter = DBIter(handle->descDB);
    uint8_t deleted=False;
    String descKey,idxDBName;
    BinaryStr key,value;
    DataBaseBE* idxDB;

    idxDB = XTDBGetIndex(handle,fieldName);
    if (!idxDB) {
        handle->error = XTDB_NO_ENTRY;
        return False;
    }
    StrInit(&descKey);
    if (StrAppendFmt(&descKey,"index.value.%s",fieldName)) {
        handle->error = XTDB_NO_MEM;
        return False;
    }
    StrToBStr(IDXFIELDNAME,&key);
    StrToBStr(fieldName,&value);
    DBDeleteKeyVal(handle->descDB,&key,&value);
    DBClose(idxDB);

    if (!XTDBRemoveIndex(handle,fieldName)) {
        return False;
    }

    DBFree(idxDB);
    StrToBStr(descKey.ptr,&key);
    DBDelete(handle->descDB,&key);
    if (GetIndexDBName(handle,fieldName,&idxDBName)) {
        handle->error = XTDB_NO_MEM;
        return False;
    }
    unlink(STR(&idxDBName));
    StrFree(&descKey);
    StrFree(&idxDBName);
    return True;
}
コード例 #25
0
void
write_domains(void)
{
    float x[] = {0., 1., 2.5, 5.};
    float y[] = {0., 2., 2.25, 2.55,  5.};
    int dims[] = {4, 5};
    int dom, i, ndims = 2;

    float tx[] = {0., -5., -5., 0.};
    float ty[] = {0., 0., -5., -5.};

    for(dom = 0; dom < 4; ++dom)
    {
        DBfile *dbfile = NULL;
        float xc[4], yc[5];
        float *coords[] = {xc, yc};
        char filename[100];

        for(i = 0; i < 4; ++i)
            xc[i] = x[i] + tx[dom];
        for(i = 0; i < 5; ++i)
            yc[i] = y[i] + ty[dom];

        /* Open the Silo file */
        sprintf(filename, "multimesh.%d", dom);
        dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL,
        "domain data", DB_HDF5);    

        /* Write a rectilinear mesh. */
        DBPutQuadmesh(dbfile, "quadmesh", NULL, coords, dims, ndims,
                      DB_FLOAT, DB_COLLINEAR, NULL);

        /* Close the Silo file. */
        DBClose(dbfile);
    }
}
コード例 #26
0
void
write_master(void)
{
    DBfile *dbfile = NULL;
    char **meshnames = NULL;
    int dom, nmesh = 4, *meshtypes = NULL;

    /* Create the list of mesh names. */
    meshnames = (char **)malloc(nmesh * sizeof(char *));
    for(dom = 0; dom < nmesh; ++dom)
    {
        char tmp[100];
        sprintf(tmp, "multimesh.%d:quadmesh", dom);
        meshnames[dom] = strdup(tmp);
    }
    /* Create the list of mesh types. */
    meshtypes = (int *)malloc(nmesh * sizeof(int));
    for(dom = 0; dom < nmesh; ++dom)
        meshtypes[dom] = DB_QUAD_RECT;

    /* Open the Silo file */
    dbfile = DBCreate("multimesh.root", DB_CLOBBER, DB_LOCAL,
    "Master file", DB_HDF5);    

    /* Write the multimesh. */
    DBPutMultimesh(dbfile, "quadmesh", nmesh, meshnames, meshtypes, NULL);

    /* Close the Silo file. */
    DBClose(dbfile);

    /* Free the memory*/
    for(dom = 0; dom < nmesh; ++dom)
        free(meshnames[dom]);
    free(meshnames);
    free(meshtypes);
}
コード例 #27
0
ファイル: mat_3x3x3_3across.C プロジェクト: zetwal/visit
/*--------------------*/
int main(int argc, char **argv) {
    DBfile *db;
    int            i, driver = DB_PDB;
    char          *filename = "mat_3x3x3_3across.silo";
    char  *coordnames[3];
    float *coord[3];

    i=1;
    while (i < argc)
    {
        if (strcmp(argv[i], "-driver") == 0)
        {
            i++;

            if (strcmp(argv[i], "DB_HDF5") == 0)
            {
                driver = DB_HDF5;
            }
            else if (strcmp(argv[i], "DB_PDB") == 0)
            {
                driver = DB_PDB;
            }
            else
            {
               fprintf(stderr,"Uncrecognized driver name \"%s\"\n",
                   argv[i]);
               exit(-1);
            }
        }
        i++;
    }

  coordnames[0]=strdup("x");
  coordnames[1]=strdup("y");
  coordnames[2]=strdup("z");

  coord[0] = x;
  coord[1] = y;
  coord[2] = z;

  dims[0]=nx;
  dims[1]=ny;
  dims[2]=nz;

  db=DBCreate(filename, DB_CLOBBER, DB_LOCAL,
              "Mixed zone 2d test", driver);

  DBPutQuadmesh(db, "mesh", coordnames, coord, dims, 3, 
                DB_FLOAT, DB_NONCOLLINEAR, NULL);

  dims[0]=zx;
  dims[1]=zy;
  dims[2]=zz;

  DBPutMaterial(db, "material", "mesh", nmat, matnos, matlist, dims, 3, 
                mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, NULL);



  char *expNames[3] = {"mat1", "mat2", "mat3"};
  char *expDefs[3] = {"matvf(<material>, 1)", "matvf(<material>, 2)", "matvf(<material>, 3)"};
  int   expTypes[3] = {DB_VARTYPE_SCALAR, DB_VARTYPE_SCALAR, DB_VARTYPE_SCALAR};
  DBoptlist *optlists[3] = {NULL, NULL, NULL};

  DBPutDefvars(db, "_visit_defvars", 3, expNames, expTypes, expDefs, optlists);

  DBClose(db);

  return 0;
}
コード例 #28
0
ファイル: silock.c プロジェクト: drhansj/polymec-dev
int
main(int argc, char *argv[])
{
   int i;
   DBfile *siloFile;

   /* set default values */
   disableProgress = False;
   disableVerbose  = False;

   /* initialization */
   fBufSize = 0;
   dBufSize = 0;
   fBuf = NULL;
   dBuf = NULL;

   /* here's where we issue an error message if we have no isnan() test */
#ifndef HAVE_ISNAN
   fprintf(stderr,"silock cannot operate on this platform.\n");
   fprintf(stderr,"No isnan() function was found during configure\n");
   exit(-1);
#endif

   /* process the command line */
   for (i = 1; i < argc; i++)
   {
      if (!strcmp(argv[i], "-progress"))
         disableProgress = True;
      else if (!strcmp(argv[i], "-q"))
         disableVerbose = True;
      else if (!strcmp(argv[i], "-help"))
      {
         fprintf(stderr,"Scan a silo file for NaN/Inf floating point data\n"); 
         fprintf(stderr,"Warning: As a precaution, you should use this tool\n");
         fprintf(stderr,"         only on the same class of platform the\n");
         fprintf(stderr,"         data was generated on.\n");
         fprintf(stderr,"usage: silock [-q] [-progress]"
            " silofile\n");
         fprintf(stderr,"available options...\n");
         fprintf(stderr,"   -progress: Disable progress display\n");
         fprintf(stderr,"   -q:        Quiet. Report only if bad values\n");
         fprintf(stderr,"              exist and exit on first occurence\n");
         exit(-1);
      }
      else /* assume its a file and try to open it */
      {
         struct stat stat_buf;

         strncpy(fileName, argv[i], sizeof(fileName)-1);
         if (stat(fileName, &stat_buf) != 0)
         {
            fprintf(stderr,"unrecognized option \"%s\". Use -help for usage\n",
               fileName);
            exit(-1);
         }
         totalBytes = stat_buf.st_size;
      }
   }

   /* initialize progress meter */
   updateProgress(0);

   DBShowErrors(DB_NONE, NULL);

   siloFile = DBOpen(fileName, DB_UNKNOWN, DB_READ);

   if (siloFile == NULL)
   {
      fprintf(stderr, "unable to open silo file \"%s\"\n", fileName);
      exit(-1);
   }

   DBShowErrors(DB_TOP, NULL);

   if (DBGetDriverType(siloFile) == DB_HDF5 && !DBGuessHasFriendlyHDF5Names(siloFile))
   {
       fprintf(stderr,"WARNING: This is an HDF5 file without \"Friendly\" HDF5 array names.\n");
       fprintf(stderr,"WARNING: Consequently, while %s will be able to find/detect nans/infs,\n",
           strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0]);
       fprintf(stderr,"WARNING: the names of the arrays in which it finds them will be cryptic.\n");
       fprintf(stderr,"WARNING: You will most likely have to use h5ls/h5dump to determine which\n");
       fprintf(stderr,"WARNING: Silo objects are involved.\n");
       DBSetDir(siloFile, "/.silo");
       scanSiloDir(siloFile, "/.silo");
   }
   else
   {
       scanSiloDir(siloFile, "/");
   }

   DBClose(siloFile);

   if (fBuf != NULL)
      free(fBuf);
   if (dBuf != NULL)
      free(dBuf);

   if (!disableProgress)
      printf("\n*** 100 %% completed ***\n");

   if (!disableVerbose)
      printf("\n");

   return 0;
}
コード例 #29
0
ファイル: lineout_test.C プロジェクト: maxhutch/visit
int
main(int argc, char **argv)
{
    DBfile *dbfile;
    int N = 21;
    int driver = DB_PDB;

    int i = 1;
    while (i < argc)
    {
        if (strcmp(argv[i], "-driver") == 0)
        {
            i++;

            if (strcmp(argv[i], "DB_HDF5") == 0)
            {
                driver = DB_HDF5;
            }
            else if (strcmp(argv[i], "DB_PDB") == 0)
            {
                driver = DB_PDB;
            }
            else
            {
               fprintf(stderr,"Uncrecognized driver name \"%s\"\n",
                   argv[i]);
               exit(-1);
            }
        }
        else if (strcmp(argv[i], "-n") == 0)
        {
            i++;
            N = atoi(argv[i]);
            if (N < 0 || N > 10000)
            {
               fprintf(stderr,"size, %d, too large\n", N);
               exit(-1);
            }
            if (N % 2 != 1)
            {
               fprintf(stderr,"size, %d, should be an odd number\n", N);
               exit(-1);
            }
        }

        i++;
    }


    float x[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
    float y[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
    float *coords[2] = {x, y};

    dbfile = DBCreate("lineout_test.silo", DB_CLOBBER, DB_LOCAL,
                      "2D grid with stair-step and linear fields", driver);

    char *coordnames[2];
    coordnames[0] = "xcoords";
    coordnames[1] = "ycoords";

    int zonelist[] = {0,1,7,6,   1,2,8,7,   2,3,9,8,   3,4,10,9,   4,5,11,10};
    int zshapetype = DB_ZONETYPE_QUAD;
    int zshapesize = 4;
    int zshapecnt = 5;

    DBPutZonelist2(dbfile, "zl2d", 5, 2, zonelist, sizeof(zonelist)/sizeof(zonelist[0]), 0,
                   0, 0, &zshapetype, &zshapesize,
                   &zshapecnt, 1, NULL);

    DBPutUcdmesh(dbfile, "mesh", 2, coordnames, coords, 12, 5,
                     "zl2d", NULL, DB_FLOAT, NULL);

    float zc_var[] = {0.5, 1.5, 2.5, 3.5, 4.5};
    DBPutUcdvar1(dbfile, "zonal_var", "mesh", zc_var, 5, NULL, 0, DB_FLOAT,
        DB_ZONECENT, NULL);

    float nc_var[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
    DBPutUcdvar1(dbfile, "nodal_var", "mesh", nc_var, 12, NULL, 0, DB_FLOAT,
        DB_NODECENT, NULL);

    float x1[] = {-1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5};
    float y1[] = {-1.5, -1.5, -1.5, -1.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 1.5};
    int zonelist2[] = {0,1,5,4,   1,2,6,5,   2,3,7,6,
                       4,5,9,8,   5,6,10,9,  6,7,11,10,
		       8,9,13,12, 9,10,14,13,10,11,15,14};

    zshapecnt = 9;
    DBPutZonelist2(dbfile, "zl2d2", 9, 2, zonelist2, sizeof(zonelist2)/sizeof(zonelist2[0]), 0,
                   0, 0, &zshapetype, &zshapesize,
                   &zshapecnt, 1, NULL);

    coords[0] = x1; coords[1] = y1;
    DBPutUcdmesh(dbfile, "mesh2", 2, coordnames, coords, 16, 9,
                     "zl2d2", NULL, DB_FLOAT, NULL);

    float zc_var2[] = {1.5, 0, -1.5, 0, 0, 0, -1.5, 0, 1.5};
    DBPutUcdvar1(dbfile, "zonal_var2", "mesh2", zc_var2, 9, NULL, 0, DB_FLOAT,
        DB_ZONECENT, NULL);

    // This is designed to yield a perfect quadratic along the diagonal
    // y=x and y=-x lineouts such that value of nc_var2 is equal to distance
    // from origin (0,0), squared. A resulting lineout *should* look like a
    // perfect quadratic curve.
    float a = (1.5*1.5 + 1.5*1.5);
    float b = (0.5*0.5 + 1.5*1.5);
    float c = (0.5*0.5 + 0.5*0.5);
    float nc_var2[] = {-a, -b, b, a, -b, -c, c, b, b, c, -c, -b, a, b, -b, -a};
    DBPutUcdvar1(dbfile, "nodal_var2", "mesh2", nc_var2, 16, NULL, 0, DB_FLOAT,
        DB_NODECENT, NULL);

    DBClose(dbfile);
}
コード例 #30
0
int
main(int argc, char *argv[])
{
    
    int            nerrors = 0;
    int            i, j, ndims=1; 
    int            driver=DB_HDF5;
    char          *filename="largefile.h5";
    DBfile        *dbfile;

    /* Parse command-line */
    for (i=1; i<argc; i++) {
        if (!strcmp(argv[i], "DB_PDB")) {
            fprintf(stderr, "This test only supported on HDF5 driver\n");
            exit(1);
        } else if (!strcmp(argv[i], "DB_HDF5")) {
            driver = DB_HDF5;
            filename = "largefile.h5";
        } else {
            fprintf(stderr, "%s: ignored argument '%s'\n", argv[0], argv[i]);
        }
    }

    DBShowErrors(DB_TOP, NULL);
    DBForceSingle(1);

    /*
     * Create a file that contains a simple variables.
     */
    printf("Creating file: '%s'\n", filename);
    dbfile = DBCreate(filename, 0, DB_LOCAL, "Simple Test", driver);

    for (j = 0; j < 2500; j++)
    {
        char tmpname[64];

        if (j % 100 == 0)
            printf("Iterations %04d to %04d of %04d\n", j, j+100-1, 2500);

        sprintf(tmpname, "simple_%04d", j);

        for (i = 0; i < dims[0]; i++)
            val[i] = (float) dims[0] * j + i;

        if (DBWrite(dbfile, tmpname, val, dims, ndims, DB_FLOAT) != 0)
        {
            DBClose(dbfile);
            exit(1);
        }
    }

   /*
    * Put some objects VisIt can process at the end of the file
    */
    build_curve(dbfile, driver);

    DBClose(dbfile);

    /*
     * Now try opening the file again and reading the simple
     * variable.
     */
    printf("Reopening '%s'\n", filename);
    dbfile = DBOpen(filename, driver, DB_READ);

    if (dbfile == 0)
    {
        printf("Unable to Reopen file for reading\n");
        exit(1);
    }

    /*
     * Randomly examine 50 arrays from the first and last 500
     */
    srand(0xBabeFace);
    for (j = 0; j < 100; j++)
    {
        char tmpname[64];

        int n = rand() % 500 + (j >= 50 ? 200 : 0);

        sprintf(tmpname, "simple_%04d", n);

        if (DBReadVar(dbfile, tmpname, rval) < 0)
        {
            nerrors++;
            if (nerrors < 10) printf("DBReadVar for \"%s\" failed\n", tmpname);
            if (nerrors == 10) printf("Further errors will be suppressed\n");
        }

        for (i = 0; i < dims[0]; i++)
        {
            val[i] = (float) dims[0] * n + i;
            if (val[i] != rval[i])
            {
                nerrors++;
                if (nerrors < 10) printf("Read error in \"%s\" at position %04d. Expected %f, got %f\n",
                                          tmpname, i, val[i], rval[i]);
                if (nerrors == 10) printf("Further errors will be suppressed\n");
                break;
            }
        }
    }

    DBClose(dbfile);

    exit(nerrors > 0);
}