00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _DBASE_H
00025 #define _DBASE_H
00026 #include <sqlite3.h>
00027
00035 #define SERVICES_TABLE "Services"
00036
00039 #define SERVICE_MULTIPLEXUID "mplexuid"
00040
00043 #define SERVICE_ID "id"
00044
00047 #define SERVICE_SOURCE "source"
00048
00051 #define SERVICE_CA "ca"
00052
00055 #define SERVICE_NAME "name"
00056
00059 #define SERVICE_TYPE "type"
00060
00063 #define SERVICE_PMTPID "pmtpid"
00064
00067 #define SERVICE_PMTVERSION "pmtversion"
00068
00071 #define SERVICE_PCRPID "pcrpid"
00072
00075 #define SERVICE_PROVIDER "provider"
00076
00079 #define SERVICE_DEFAUTHORITY "defauthority"
00080
00084 #define MULTIPLEXES_TABLE "Multiplexes"
00085
00088 #define MULTIPLEX_UID "uid"
00089
00092 #define MULTIPLEX_FREQ "freq"
00093
00096 #define MULTIPLEX_TSID "tsid"
00097
00100 #define MULTIPLEX_NETID "netid"
00101
00104 #define MULTIPLEX_TYPE "type"
00105
00108 #define MULTIPLEX_PATVERSION "patversion"
00109
00113 #define OFDMPARAMS_TABLE "OFDMParameters"
00114
00117 #define OFDMPARAM_MULTIPLEXUID "mplexuid"
00118
00121 #define OFDMPARAM_FREQ "freq"
00122
00125 #define OFDMPARAM_INVERSION "inversion"
00126
00129 #define OFDMPARAM_BW "bw"
00130
00133 #define OFDMPARAM_FEC_HP "fec_hp"
00134
00137 #define OFDMPARAM_FEC_LP "fec_lp"
00138
00141 #define OFDMPARAM_QAM "qam"
00142
00145 #define OFDMPARAM_TRANSMISSIONM "transmissionm"
00146
00149 #define OFDMPARAM_GUARDLIST "guardlist"
00150
00153 #define OFDMPARAM_HIERARCHINFO "hierarchinfo"
00154
00158 #define QPSKPARAMS_TABLE "QPSKParameters"
00159
00162 #define QPSKPARAM_MULTIPLEXUID "mplexuid"
00163
00166 #define QPSKPARAM_FREQ "freq"
00167
00170 #define QPSKPARAM_INVERSION "inversion"
00171
00174 #define QPSKPARAM_SYMBOL_RATE "symbol_rate"
00175
00178 #define QPSKPARAM_FEC_INNER "fec_inner"
00179
00182 #define QPSKPARAM_POLARISATION "polarisation"
00183
00186 #define QPSKPARAM_SATNUMBER "satnumber"
00187
00191 #define QAMPARAMS_TABLE "QAMParameters"
00192
00195 #define QAMPARAM_MULTIPLEXUID "mplexuid"
00196
00199 #define QAMPARAM_FREQ "freq"
00200
00203 #define QAMPARAM_INVERSION "inversion"
00204
00207 #define QAMPARAM_SYMBOL_RATE "symbol_rate"
00208
00211 #define QAMPARAM_FEC_INNER "fec_inner"
00212
00215 #define QAMPARAM_MODULATION "modulation"
00216
00220 #define VSBPARAMS_TABLE "VSBParameters"
00221
00224 #define VSBPARAM_MULTIPLEXUID "mplexuid"
00225
00228 #define VSBPARAM_FREQ "freq"
00229
00232 #define VSBPARAM_MODULATION "modulation"
00233
00237 #define PIDS_TABLE "PIDs"
00238
00241 #define PID_MULTIPLEXUID "mplexuid"
00242
00245 #define PID_SERVICEID "serviceid"
00246
00249 #define PID_PID "pid"
00250
00253 #define PID_TYPE "type"
00254
00257 #define PID_SUBTYPE "subtype"
00258
00261 #define PID_PMTVERSION "pmtversion"
00262
00265 #define PID_DESCRIPTORS "descriptors"
00266
00270 #define METADATA_TABLE "Metadata"
00271
00274 #define METADATA_NAME "name"
00275
00278 #define METADATA_VALUE "value"
00279
00283 #define EPGEVENTS_TABLE "EPGEvents"
00284
00287 #define EPGEVENT_NETID "netid"
00288
00291 #define EPGEVENT_TSID "tsid"
00292
00295 #define EPGEVENT_SERVICEID "serviceid"
00296
00299 #define EPGEVENT_EVENTID "eventid"
00300
00303 #define EPGEVENT_STARTTIME "starttime"
00304
00307 #define EPGEVENT_ENDTIME "endtime"
00308
00311 #define EPGEVENT_CA "ca"
00312
00316 #define EPGRATINGS_TABLE "EPGRatings"
00317
00320 #define EPGRATING_ID "id"
00321
00324 #define EPGRATING_EVENTUID "eventuid"
00325
00328 #define EPGRATING_STANDARD "standard"
00329
00332 #define EPGRATING_RATING "rating"
00333
00337 #define EPGDETAILS_TABLE "EPGDetails"
00338
00341 #define EPGDETAIL_ID "id"
00342
00345 #define EPGDETAIL_EVENTUID "eventuid"
00346
00349 #define EPGDETAIL_LANGUAGE "lang"
00350
00353 #define EPGDETAIL_NAME "name"
00354
00357 #define EPGDETAIL_VALUE "value"
00358
00362 #define METADATA_NAME_LNB_LOW_FREQ "lnb.lowfreq"
00363
00366 #define METADATA_NAME_LNB_HIGH_FREQ "lnb.highfreq"
00367
00370 #define METADATA_NAME_LNB_SWITCH_FREQ "lnb.switchfreq"
00371
00375 #define METADATA_NAME_SCAN_ALL "scan.all"
00376
00387 #define STATEMENT_INIT int rc; sqlite3_stmt *stmt=NULL
00388
00389 #ifndef DBASE_CONNECTION_GET
00390
00393 #define DBASE_CONNECTION_GET DBaseConnectionGet
00394 #endif
00395
00400 #define STATEMENT_PREPARE(_statement) rc = sqlite3_prepare( DBASE_CONNECTION_GET(), _statement, -1, &stmt, NULL)
00401
00407 #define STATEMENT_PREPAREVA(_statement, _args...) \
00408 do{\
00409 char *sqlstring;\
00410 sqlstring = sqlite3_mprintf(_statement, _args);\
00411 if (sqlstring)\
00412 {\
00413 STATEMENT_PREPARE(sqlstring);\
00414 sqlite3_free(sqlstring);\
00415 }\
00416 else\
00417 {\
00418 rc = SQLITE_NOMEM;\
00419 }\
00420 }while(0)
00421
00425 #define STATEMENT_STEP() rc = sqlite3_step(stmt)
00426
00431 #define STATEMENT_COLUMN_INT(_index) sqlite3_column_int(stmt, _index)
00432
00436 #define STATEMENT_COLUMN_DOUBLE(_index) sqlite3_column_double(stmt, _index)
00437
00444 #define STATEMENT_COLUMN_TEXT(_index) (char*)sqlite3_column_text( stmt, _index)
00445
00449 #define STATEMENT_FINALIZE() rc = sqlite3_finalize(stmt)
00450
00455 #define PRINTLOG_SQLITE3ERROR() \
00456 do{\
00457 LogModule(LOG_DEBUG, "dbase", "%s(%d): Failed with error code 0x%x=%s\n",\
00458 __FUNCTION__,__LINE__, rc, sqlite3_errmsg(DBASE_CONNECTION_GET()));\
00459 }while(0)
00460
00468 #define RETURN_ON_ERROR(_result) \
00469 do{\
00470 if ((rc != SQLITE_OK) && (rc != SQLITE_ROW) && (rc != SQLITE_DONE))\
00471 {\
00472 PRINTLOG_SQLITE3ERROR();\
00473 if (stmt)\
00474 {\
00475 STATEMENT_FINALIZE();\
00476 }\
00477 return _result;\
00478 }\
00479 }while(0)
00480
00484 #define RETURN_RC_ON_ERROR RETURN_ON_ERROR(rc)
00485
00495 int DBaseInit(int adapter);
00496
00501 void DBaseDeInit();
00502
00507 sqlite3* DBaseConnectionGet(void);
00508
00514 int DBaseTransactionBegin(void);
00515
00520 int DBaseTransactionCommit(void);
00521
00529 int DBaseMetadataGet(char *name, char **value);
00530
00537 int DBaseMetadataSet(char *name, char *value);
00538
00545 int DBaseMetadataGetInt(char *name, int *value);
00552 int DBaseMetadataSetInt(char *name, int value);
00553
00560 int DBaseMetadataGetDouble(char *name, double *value);
00561
00568 int DBaseMetadataSetDouble(char *name, double value);
00569
00575 int DBaseMetadataDelete(char *name);
00576
00578 #endif