19 #include <CUnit/CUnit.h> 41 LOG_FATAL(
"Unable to connect to database");
44 MagicCookie = magic_open(MAGIC_PRESERVE_ATIME|MAGIC_MIME);
69 char SQL[MAXCMD] = {0};
70 PGresult *result = NULL;
71 char mimetype_name[] =
"application/octet-stream";
73 memset(SQL,
'\0', MAXCMD);
74 snprintf(SQL, MAXCMD,
"DELETE FROM mimetype where mimetype_name = '%s';", mimetype_name);
75 result = PQexec(
pgConn, SQL);
82 memset(SQL,
'\0', MAXCMD);
83 snprintf(SQL, MAXCMD,
"INSERT INTO mimetype (mimetype_name) VALUES ('%s');", mimetype_name);
84 result = PQexec(
pgConn, SQL);
95 memset(SQL,
'\0', MAXCMD);
96 snprintf(SQL, MAXCMD,
"SELECT mimetype_name from mimetype where mimetype_name = ('%s');", mimetype_name);
97 result = PQexec(
pgConn, SQL);
103 int count = PQntuples(result);
108 memset(SQL,
'\0', MAXCMD);
109 snprintf(SQL, MAXCMD,
"DELETE FROM mimetype where mimetype_name = '%s';", mimetype_name);
110 result = PQexec(
pgConn, SQL);
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
PGresult * DBMime
contents of mimetype table
int DBLoadMimeInit()
initialize DB
char * DBConfFile
DB conf file location.
PGconn * pgConn
Database connection.
void DBLoadMime()
Populate the DBMime table.
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
char SQL[256]
SQL query to execute.
CU_TestInfo testcases_DBLoadMime[]
testcases for function DBLoadGold
int MaxDBMime
how many rows in DBMime
void testDBLoadMime()
for function DBLoadMime()
magic_t MagicCookie
for Magic
int DBLoadMimeClean()
clean the env
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.