#ifndef _LIB_DBSQL_ #define _LIB_DBSQL_ #include "SDDAS_types.h" #include "Time_t.h" #ifndef ALL_OKAY #define ALL_OKAY 1 #endif /* Remove definition of NO_DATA on Windows */ #ifdef NO_DATA #undef NO_DATA #endif #define DB_START_plus 1000 #define NO_DATA DB_START_plus+200 #define DB_START_neg -1000 #define CONFIG_FILE_ERROR DB_START_neg-2 #define DBF_ERROR DB_START_neg-10 #define DB_STOP_neg DB_START_neg-20 typedef const char **DB_ROW; typedef void *DB_RESULT; /* this #define defines the maximum length of a project, mission, experiment, instrument, and virtual */ #define MAX_IDFS_NAME 25 #define MAX_IDFS_VIRT_NAME 34 typedef enum {_H_AND_D_, _HEADER_, _DATA_, _VIDF_} RequestedDataType; #ifdef __cplusplus extern "C" { #endif /* * Old compatibility routines */ SDDAS_SHORT get_data_key (SDDAS_CHAR *pstr, SDDAS_CHAR *mstr, SDDAS_CHAR *estr, SDDAS_CHAR *istr, SDDAS_CHAR *vstr, SDDAS_ULONG *data_key); int get_first_vidf_times (SDDAS_ULONG data_key, SDDAS_SHORT *btime_yr, SDDAS_SHORT *btime_day, SDDAS_ULONG *btime_msec); int dbGetFile (SDDAS_ULONG, Time_t *, Time_t, RequestedDataType, char *, char *, char *); char *db_msgs (int); /* PUBLIC routines */ /* set the name of the database */ void dbSetDatabaseName (const char *name); /* get the database name */ const char* dbGetDatabaseName (); /* create the database */ SDDAS_BOOL dbCreate (const char *filename); /* check if the database is local or remote */ SDDAS_BOOL dbIsLocal (); /* initialize the DB sub-system */ void dbInitialize (); SDDAS_BOOL dbInitializeMsg (); SDDAS_BOOL dbInitializeRemoteMsg (const char *host, const char *user, const char *passwd, const char *db, const unsigned int port); /* close the DB sub-system */ void dbClose (); /* return a data key from a hierarchy */ SDDAS_ULONG dbGetDataKey (char *, char *, char *, char *, char *); /* return a header/data file name from a given time */ int dbIDFSGetRealTimeFile (SDDAS_ULONG, RequestedDataType, char *, char *, char *); int dbIDFSGetFile (SDDAS_ULONG, SDDAS_SHORT, SDDAS_SHORT, SDDAS_LONG, SDDAS_SHORT, SDDAS_SHORT, SDDAS_LONG, RequestedDataType, char *, char *, char *); int dbIDFSGetFileAndTimes (SDDAS_ULONG, SDDAS_SHORT *, SDDAS_SHORT *, SDDAS_LONG *, SDDAS_SHORT, SDDAS_SHORT, SDDAS_LONG, RequestedDataType, char *, char *, char *); /* Pack the database */ SDDAS_BOOL dbPack (); /* return the strings given a data key - returns either sFalse on error or sTrue if all is well */ SDDAS_BOOL dbKeyToStrings (SDDAS_ULONG, char *, char *, char *, char *, char *); SDDAS_BOOL dbKeyToStrings_r (SDDAS_ULONG, char *, char *, char *, char *, char *); /* return a list of strings defining the hierarchy */ char **dbHierarchy (int numargs, ...); void dbFreeHierarchyList (char **); /* return a nicely formatted hierarchy string */ char *dbHierarchyString (SDDAS_ULONG); /* return the virtual name */ char *dbVirtualName (SDDAS_ULONG); int dbVirtualName_r (SDDAS_ULONG, char *, int); /* return an error message given an error code */ char *dbErrorMsg (); /* use these when you have a data key and not the full hierarchy */ char *dbCfgItem (SDDAS_ULONG, const char *, int); char *dbCfgPath (SDDAS_ULONG, const char *); /* use this to query the data base */ int dbQueryExec (const char *); void *dbQuery (const char *); void *dbQueryStore (const char *); /* if the above is supposed to return NULL, use this function to see if the query was valid! */ unsigned int dbBadQuery (); /* free the resulting query */ void dbFreeResult (void *); /* fetch a row of a query */ void *dbFetchRow (void *); /* return the number of rows */ int dbNumberRows (void *); /* return the number of fields */ int dbNumberFields (void *); /* return the field name of field i */ char *dbFieldName (void *, int i); /* return sTrue if database is connected */ SDDAS_BOOL dbConnected (); #ifdef __cplusplus } #endif #endif