mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-02-26 05:33:03 +08:00
Support --disable-glib flag with ODBC driver
This commit is contained in:
10
.travis.yml
10
.travis.yml
@@ -13,11 +13,19 @@ jobs:
|
|||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode11.4
|
osx_image: xcode11.4
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libiodbc2-dev
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- libiodbc
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- autoreconf -i -f -Wno-portability
|
- autoreconf -i -f -Wno-portability
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./configure --disable-man --disable-silent-rules --disable-glib
|
- ./configure --disable-man --disable-silent-rules --disable-glib --with-iodbc=/usr
|
||||||
- make
|
- make
|
||||||
- ./src/util/mdb-array test/data/ASampleDatabase.accdb "Asset Items"
|
- ./src/util/mdb-array test/data/ASampleDatabase.accdb "Asset Items"
|
||||||
- ./src/util/mdb-array test/data/nwind.mdb "Customers"
|
- ./src/util/mdb-array test/data/nwind.mdb "Customers"
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ typedef void (*GFunc) (gpointer data, gpointer user_data);
|
|||||||
typedef void (*GHFunc)(gpointer key, gpointer value, gpointer data);
|
typedef void (*GHFunc)(gpointer key, gpointer value, gpointer data);
|
||||||
typedef gboolean (*GHRFunc)(gpointer key, gpointer value, gpointer data);
|
typedef gboolean (*GHRFunc)(gpointer key, gpointer value, gpointer data);
|
||||||
|
|
||||||
|
typedef struct GString {
|
||||||
|
gchar *str;
|
||||||
|
size_t len;
|
||||||
|
size_t allocated_len;
|
||||||
|
} GString;
|
||||||
|
|
||||||
typedef struct GPtrArray {
|
typedef struct GPtrArray {
|
||||||
void **pdata;
|
void **pdata;
|
||||||
int len;
|
int len;
|
||||||
@@ -121,10 +127,20 @@ char *g_strconcat(const char *first, ...);
|
|||||||
char *g_strdup(const char *src);
|
char *g_strdup(const char *src);
|
||||||
char *g_strdup_printf(const char *format, ...);
|
char *g_strdup_printf(const char *format, ...);
|
||||||
gchar *g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delimiter);
|
gchar *g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delimiter);
|
||||||
|
void g_printerr(const gchar *format, ...);
|
||||||
|
|
||||||
|
/* GString */
|
||||||
|
GString *g_string_new(const gchar *init);
|
||||||
|
GString *g_string_assign(GString *string, const gchar *rval);
|
||||||
|
GString * g_string_append (GString *string, const gchar *val);
|
||||||
|
gchar *g_string_free (GString *string, gboolean free_segment);
|
||||||
|
|
||||||
/* GHashTable */
|
/* GHashTable */
|
||||||
void *g_hash_table_lookup(GHashTable *tree, const void *key);
|
void *g_hash_table_lookup(GHashTable *tree, const void *key);
|
||||||
|
gboolean g_hash_table_lookup_extended(GHashTable *table, const void *lookup_key,
|
||||||
|
void **orig_key, void **value);
|
||||||
void g_hash_table_insert(GHashTable *tree, void *key, void *value);
|
void g_hash_table_insert(GHashTable *tree, void *key, void *value);
|
||||||
|
gboolean g_hash_table_remove(GHashTable *hash_table, const void *key);
|
||||||
GHashTable *g_hash_table_new(GHashFunc hashes, GEqualFunc equals);
|
GHashTable *g_hash_table_new(GHashFunc hashes, GEqualFunc equals);
|
||||||
void g_hash_table_foreach(GHashTable *tree, GHFunc function, void *data);
|
void g_hash_table_foreach(GHashTable *tree, GHFunc function, void *data);
|
||||||
void g_hash_table_foreach_remove(GHashTable *tree, GHRFunc function, void *data);
|
void g_hash_table_foreach_remove(GHashTable *tree, GHRFunc function, void *data);
|
||||||
@@ -135,6 +151,7 @@ void g_ptr_array_sort(GPtrArray *array, GCompareFunc func);
|
|||||||
void g_ptr_array_foreach(GPtrArray *array, GFunc function, gpointer user_data);
|
void g_ptr_array_foreach(GPtrArray *array, GFunc function, gpointer user_data);
|
||||||
GPtrArray *g_ptr_array_new(void);
|
GPtrArray *g_ptr_array_new(void);
|
||||||
void g_ptr_array_add(GPtrArray *array, void *entry);
|
void g_ptr_array_add(GPtrArray *array, void *entry);
|
||||||
|
gboolean g_ptr_array_remove (GPtrArray *array, gpointer data);
|
||||||
void g_ptr_array_free(GPtrArray *array, gboolean something);
|
void g_ptr_array_free(GPtrArray *array, gboolean something);
|
||||||
|
|
||||||
/* GList */
|
/* GList */
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ mdb_ole_read(MdbHandle *mdb, MdbColumn *col, void *ole_ptr, size_t chunk_size)
|
|||||||
* mdb_ole_read_full calls mdb_ole_read then loop over mdb_ole_read_next as much as necessary.
|
* mdb_ole_read_full calls mdb_ole_read then loop over mdb_ole_read_next as much as necessary.
|
||||||
* returns the result in a big buffer.
|
* returns the result in a big buffer.
|
||||||
* The call must free it.
|
* The call must free it.
|
||||||
* Note that this function is not indempotent: It may be called only once per column after each bind.
|
* Note that this function is not idempotent: It may be called only once per column after each bind.
|
||||||
*/
|
*/
|
||||||
void*
|
void*
|
||||||
mdb_ole_read_full(MdbHandle *mdb, MdbColumn *col, size_t *size)
|
mdb_ole_read_full(MdbHandle *mdb, MdbColumn *col, size_t *size)
|
||||||
|
|||||||
@@ -145,6 +145,51 @@ gchar *g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delimiter)
|
|||||||
return orig;
|
return orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void g_printerr(const gchar *format, ...) {
|
||||||
|
va_list argp;
|
||||||
|
va_start(argp, format);
|
||||||
|
vfprintf(stderr, format, argp);
|
||||||
|
va_end(argp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GString */
|
||||||
|
|
||||||
|
GString *g_string_new (const gchar *init) {
|
||||||
|
GString *str = calloc(1, sizeof(GString));
|
||||||
|
str->str = strdup(init ? init : "");
|
||||||
|
str->len = strlen(str->str);
|
||||||
|
str->allocated_len = str->len+1;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString *g_string_assign(GString *string, const gchar *rval) {
|
||||||
|
size_t len = strlen(rval);
|
||||||
|
string->str = realloc(string->str, len+1);
|
||||||
|
strncpy(string->str, rval, len+1);
|
||||||
|
string->len = len;
|
||||||
|
string->allocated_len = len+1;
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
GString * g_string_append (GString *string, const gchar *val) {
|
||||||
|
size_t len = strlen(val);
|
||||||
|
string->str = realloc(string->str, string->len + len + 1);
|
||||||
|
strncpy(&string->str[string->len], val, len+1);
|
||||||
|
string->len += len;
|
||||||
|
string->allocated_len = string->len + len + 1;
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *g_string_free (GString *string, gboolean free_segment) {
|
||||||
|
char *data = string->str;
|
||||||
|
free(string);
|
||||||
|
if (free_segment) {
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/* GHashTable */
|
/* GHashTable */
|
||||||
|
|
||||||
typedef struct MyNode {
|
typedef struct MyNode {
|
||||||
@@ -162,6 +207,20 @@ void *g_hash_table_lookup(GHashTable *table, const void *key) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean g_hash_table_lookup_extended (GHashTable *table, const void *lookup_key,
|
||||||
|
void **orig_key, void **value) {
|
||||||
|
int i;
|
||||||
|
for (i=0; i<table->array->len; i++) {
|
||||||
|
MyNode *node = g_ptr_array_index(table->array, i);
|
||||||
|
if (table->compare(lookup_key, node->key)) {
|
||||||
|
*orig_key = node->key;
|
||||||
|
*value = node->value;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void g_hash_table_insert(GHashTable *table, void *key, void *value) {
|
void g_hash_table_insert(GHashTable *table, void *key, void *value) {
|
||||||
MyNode *node = calloc(1, sizeof(MyNode));
|
MyNode *node = calloc(1, sizeof(MyNode));
|
||||||
node->value = value;
|
node->value = value;
|
||||||
@@ -169,6 +228,22 @@ void g_hash_table_insert(GHashTable *table, void *key, void *value) {
|
|||||||
g_ptr_array_add(table->array, node);
|
g_ptr_array_add(table->array, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean g_hash_table_remove(GHashTable *table, gconstpointer key) {
|
||||||
|
int found = 0;
|
||||||
|
for (int i=0; i<table->array->len; i++) {
|
||||||
|
MyNode *node = g_ptr_array_index(table->array, i);
|
||||||
|
if (found) {
|
||||||
|
table->array->pdata[i-1] = table->array->pdata[i];
|
||||||
|
} else if (!found && table->compare(key, node->key)) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
table->array->len--;
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
GHashTable *g_hash_table_new(GHashFunc hashes, GEqualFunc equals) {
|
GHashTable *g_hash_table_new(GHashFunc hashes, GEqualFunc equals) {
|
||||||
GHashTable *table = calloc(1, sizeof(GHashTable));
|
GHashTable *table = calloc(1, sizeof(GHashTable));
|
||||||
table->array = g_ptr_array_new();
|
table->array = g_ptr_array_new();
|
||||||
@@ -219,6 +294,21 @@ void g_ptr_array_add(GPtrArray *array, void *entry) {
|
|||||||
array->pdata[array->len++] = entry;
|
array->pdata[array->len++] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean g_ptr_array_remove(GPtrArray *array, gpointer data) {
|
||||||
|
int found = 0;
|
||||||
|
for (int i=0; i<array->len; i++) {
|
||||||
|
if (found) {
|
||||||
|
array->pdata[i-1] = array->pdata[i];
|
||||||
|
} else if (!found && array->pdata[i] == data) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
array->len--;
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
void g_ptr_array_free(GPtrArray *array, gboolean something) {
|
void g_ptr_array_free(GPtrArray *array, gboolean something) {
|
||||||
free(array->pdata);
|
free(array->pdata);
|
||||||
free(array);
|
free(array);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ extern int SQLGetPrivateProfileString( LPCSTR lpszSection,
|
|||||||
int cbRetBuffer,
|
int cbRetBuffer,
|
||||||
LPCSTR lpszFilename);
|
LPCSTR lpszFilename);
|
||||||
#else
|
#else
|
||||||
static GString* GetIniFileName ();
|
static GString* GetIniFileName (void);
|
||||||
static int FileExists (const gchar* name);
|
static int FileExists (const gchar* name);
|
||||||
static int FindSection (FILE* stream, const char* section);
|
static int FindSection (FILE* stream, const char* section);
|
||||||
static int GetNextItem (FILE* stream, char** name, char** value);
|
static int GetNextItem (FILE* stream, char** name, char** value);
|
||||||
|
|||||||
@@ -19,7 +19,11 @@
|
|||||||
#ifndef _connectparams_h_
|
#ifndef _connectparams_h_
|
||||||
#define _connectparams_h_
|
#define _connectparams_h_
|
||||||
|
|
||||||
|
#ifdef HAVE_GLIB
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#else
|
||||||
|
#include <mdbfakeglib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -28,7 +32,7 @@ typedef struct
|
|||||||
GHashTable* table;
|
GHashTable* table;
|
||||||
} ConnectParams;
|
} ConnectParams;
|
||||||
|
|
||||||
ConnectParams* NewConnectParams ();
|
ConnectParams* NewConnectParams (void);
|
||||||
void FreeConnectParams (ConnectParams* params);
|
void FreeConnectParams (ConnectParams* params);
|
||||||
|
|
||||||
gboolean LookupDSN (ConnectParams* params, const gchar* dsnName);
|
gboolean LookupDSN (ConnectParams* params, const gchar* dsnName);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "mdbodbc.h"
|
#include "mdbodbc.h"
|
||||||
|
|
||||||
//#define TRACE(x) fprintf(stderr,"Function %s\n", x);
|
//#define TRACE(x) fprintf(stderr,"Function %s\n", x);
|
||||||
@@ -101,7 +102,7 @@ TypeInfo type_info[] = {
|
|||||||
#define MAX_TYPE_INFO 11
|
#define MAX_TYPE_INFO 11
|
||||||
|
|
||||||
#ifdef ENABLE_ODBC_W
|
#ifdef ENABLE_ODBC_W
|
||||||
void my_fini();
|
void my_fini(void);
|
||||||
|
|
||||||
MDB_CONSTRUCTOR(my_init)
|
MDB_CONSTRUCTOR(my_init)
|
||||||
{
|
{
|
||||||
@@ -784,7 +785,7 @@ static SQLRETURN SQL_API _SQLDescribeCol(
|
|||||||
strcpy(sqlState, "HY090"); // Invalid string or buffer length
|
strcpy(sqlState, "HY090"); // Invalid string or buffer length
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
if (snprintf(szColName, cbColNameMax, "%s", sqlcol->name) + 1 > cbColNameMax) {
|
if (snprintf((char *)szColName, cbColNameMax, "%s", sqlcol->name) + 1 > cbColNameMax) {
|
||||||
strcpy(sqlState, "01004"); // String data, right truncated
|
strcpy(sqlState, "01004"); // String data, right truncated
|
||||||
ret = SQL_SUCCESS_WITH_INFO;
|
ret = SQL_SUCCESS_WITH_INFO;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user