Skip to content

Instantly share code, notes, and snippets.

@adolgarev
Created December 24, 2013 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adolgarev/8112518 to your computer and use it in GitHub Desktop.
Save adolgarev/8112518 to your computer and use it in GitHub Desktop.
/* MySQL specific routines */
#ifndef EXTERN_MYSQL_H
#define EXTERN_MYSQL_H
#include <mysql/mysql.h>
extern char *DBHOST;
extern char *DBUSER;
extern char *DBPASSWD;
extern char *DBDB;
extern int DBPORT;
extern char *DBUNIXSOCKET;
typedef MYSQL_TIME mb_time_t;
/* prepared requests numbers */
typedef enum {
mb_db_schedule_stmt,
...
} mb_db_stmt_e;
int mb_db_init();
int mb_db_del();
/* execute prepared request, what is a request number from mb_db_stmt_e enum
count points to variable where rows number will be stored,
returns pointer to array of rows, you need to free() allocated memory,
returns NULL in case of empty set or error, sets count to -1 if error occured */
void *mb_db_exec(int what, size_t *count);
#define MB_DB_CONFIG_VALUE_LEN 256
#define MB_DB_SETTINGS_VALUE_LEN 4096
/* below are the structs to hold results from db */
typedef struct {
int schedule_id;
char name[128];
int schedule_type;
char enabled;
short int starthour;
short int startminute;
short int endhour;
short int endminute;
short int everyhours;
short int day;
char sunday;
char monday;
char tuesday;
char wednesday;
char thursday;
char friday;
char saturday;
int status;
short int retentionmethod;
short int retentionlength;
char username[64];
char machine_username[128];
char machine_address[128];
int machine_os_type;
} mb_db_schedule_t;
...
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment