mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
__attribute__ change into macro
Makes it easier to port to another compiler. Thanks Jimmy Taker
This commit is contained in:
commit
0196d34d7b
@ -37,6 +37,10 @@
|
|||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MDB_DEBUG 0
|
#define MDB_DEBUG 0
|
||||||
|
|
||||||
#define MDB_PGSIZE 4096
|
#define MDB_PGSIZE 4096
|
||||||
@ -48,7 +52,10 @@
|
|||||||
#define MDB_MEMO_OVERHEAD 12
|
#define MDB_MEMO_OVERHEAD 12
|
||||||
#define MDB_BIND_SIZE 16384
|
#define MDB_BIND_SIZE 16384
|
||||||
|
|
||||||
#define MDB_DEPRECATED __attribute__((deprecated))
|
// Theses 2 atrbutes are not supported by all compilers:
|
||||||
|
// M$VC see http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc
|
||||||
|
#define MDB_DEPRECATED(type, funcname) type __attribute__((deprecated)) funcname
|
||||||
|
#define MDB_CONSTRUCTOR(funcname) void __attribute__((constructor)) funcname()
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MDB_PAGE_DB = 0,
|
MDB_PAGE_DB = 0,
|
||||||
@ -425,8 +432,8 @@ typedef struct {
|
|||||||
} MdbSarg;
|
} MdbSarg;
|
||||||
|
|
||||||
/* mem.c */
|
/* mem.c */
|
||||||
extern void MDB_DEPRECATED mdb_init();
|
extern MDB_DEPRECATED(void, mdb_init());
|
||||||
extern void MDB_DEPRECATED mdb_exit();
|
extern MDB_DEPRECATED(void, mdb_exit());
|
||||||
|
|
||||||
/* file.c */
|
/* file.c */
|
||||||
extern ssize_t mdb_read_pg(MdbHandle *mdb, unsigned long pg);
|
extern ssize_t mdb_read_pg(MdbHandle *mdb, unsigned long pg);
|
||||||
@ -496,14 +503,14 @@ extern int mdb_read_row(MdbTableDef *table, unsigned int row);
|
|||||||
extern void mdb_buffer_dump(const void *buf, int start, size_t len);
|
extern void mdb_buffer_dump(const void *buf, int start, size_t len);
|
||||||
|
|
||||||
/* backend.c */
|
/* backend.c */
|
||||||
extern char* MDB_DEPRECATED mdb_get_coltype_string(MdbBackend *backend, int col_type);
|
extern MDB_DEPRECATED(char*, mdb_get_coltype_string(MdbBackend *backend, int col_type));
|
||||||
extern int MDB_DEPRECATED mdb_coltype_takes_length(MdbBackend *backend, int col_type);
|
extern MDB_DEPRECATED(int, mdb_coltype_takes_length(MdbBackend *backend, int col_type));
|
||||||
extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
|
extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
|
||||||
extern const char* mdb_get_colbacktype_string(const MdbColumn *col);
|
extern const char* mdb_get_colbacktype_string(const MdbColumn *col);
|
||||||
extern int mdb_colbacktype_takes_length(const MdbColumn *col);
|
extern int mdb_colbacktype_takes_length(const MdbColumn *col);
|
||||||
extern void MDB_DEPRECATED mdb_init_backends();
|
extern MDB_DEPRECATED(void, mdb_init_backends());
|
||||||
extern void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendType *backend_type, MdbBackendType *type_shortdate, MdbBackendType *type_autonum, const char *short_now, const char *long_now, const char *charset_statement, const char *drop_statement, const char *constaint_not_empty_statement, const char *column_comment_statement, const char *table_comment_statement, gchar* (*quote_schema_name)(const gchar*, const gchar*));
|
extern void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendType *backend_type, MdbBackendType *type_shortdate, MdbBackendType *type_autonum, const char *short_now, const char *long_now, const char *charset_statement, const char *drop_statement, const char *constaint_not_empty_statement, const char *column_comment_statement, const char *table_comment_statement, gchar* (*quote_schema_name)(const gchar*, const gchar*));
|
||||||
extern void MDB_DEPRECATED mdb_remove_backends();
|
extern MDB_DEPRECATED(void, mdb_remove_backends());
|
||||||
extern int mdb_set_default_backend(MdbHandle *mdb, const char *backend_name);
|
extern int mdb_set_default_backend(MdbHandle *mdb, const char *backend_name);
|
||||||
extern void mdb_print_schema(MdbHandle *mdb, FILE *outfile, char *tabname, char *dbnamespace, guint32 export_options);
|
extern void mdb_print_schema(MdbHandle *mdb, FILE *outfile, char *tabname, char *dbnamespace, guint32 export_options);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
static int is_init;
|
static int is_init;
|
||||||
GHashTable *mdb_backends;
|
GHashTable *mdb_backends;
|
||||||
|
void _mdb_remove_backends();
|
||||||
|
|
||||||
/* Access data types */
|
/* Access data types */
|
||||||
static MdbBackendType mdb_access_types[] = {
|
static MdbBackendType mdb_access_types[] = {
|
||||||
@ -259,8 +260,8 @@ quote_with_squotes(const gchar* value)
|
|||||||
return quote_generic(value, '\'', '\'');
|
return quote_generic(value, '\'', '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
char * MDB_DEPRECATED
|
MDB_DEPRECATED(char*,
|
||||||
mdb_get_coltype_string(MdbBackend *backend, int col_type)
|
mdb_get_coltype_string(MdbBackend *backend, int col_type))
|
||||||
{
|
{
|
||||||
static int warn_deprecated = 0;
|
static int warn_deprecated = 0;
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
@ -277,8 +278,8 @@ mdb_get_coltype_string(MdbBackend *backend, int col_type)
|
|||||||
return backend->types_table[col_type].name;
|
return backend->types_table[col_type].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MDB_DEPRECATED
|
MDB_DEPRECATED(int,
|
||||||
mdb_coltype_takes_length(MdbBackend *backend, int col_type)
|
mdb_coltype_takes_length(MdbBackend *backend, int col_type))
|
||||||
{
|
{
|
||||||
static int warn_deprecated = 0;
|
static int warn_deprecated = 0;
|
||||||
if (!warn_deprecated) {
|
if (!warn_deprecated) {
|
||||||
@ -325,7 +326,9 @@ mdb_colbacktype_takes_length(const MdbColumn *col)
|
|||||||
return type->needs_length;
|
return type->needs_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDB_DEPRECATED mdb_init_backends() {
|
MDB_DEPRECATED(void,
|
||||||
|
mdb_init_backends())
|
||||||
|
{
|
||||||
fprintf(stderr, "mdb_init_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
fprintf(stderr, "mdb_init_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +338,7 @@ void MDB_DEPRECATED mdb_init_backends() {
|
|||||||
* Initializes the mdb_backends hash and loads the builtin backends.
|
* Initializes the mdb_backends hash and loads the builtin backends.
|
||||||
* Use mdb_remove_backends() to destroy this hash when done.
|
* Use mdb_remove_backends() to destroy this hash when done.
|
||||||
*/
|
*/
|
||||||
void __attribute__ ((constructor)) _mdb_init_backends()
|
MDB_CONSTRUCTOR(_mdb_init_backends)
|
||||||
{
|
{
|
||||||
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
|
|
||||||
@ -399,7 +402,10 @@ void __attribute__ ((constructor)) _mdb_init_backends()
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
quote_schema_name_rquotes_merge);
|
quote_schema_name_rquotes_merge);
|
||||||
|
|
||||||
|
atexit(_mdb_remove_backends);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendType *backend_type, MdbBackendType *type_shortdate, MdbBackendType *type_autonum, const char *short_now, const char *long_now, const char *charset_statement, const char *drop_statement, const char *constaint_not_empty_statement, const char *column_comment_statement, const char *table_comment_statement, gchar* (*quote_schema_name)(const gchar*, const gchar*))
|
void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendType *backend_type, MdbBackendType *type_shortdate, MdbBackendType *type_autonum, const char *short_now, const char *long_now, const char *charset_statement, const char *drop_statement, const char *constaint_not_empty_statement, const char *column_comment_statement, const char *table_comment_statement, gchar* (*quote_schema_name)(const gchar*, const gchar*))
|
||||||
{
|
{
|
||||||
MdbBackend *backend = (MdbBackend *) g_malloc0(sizeof(MdbBackend));
|
MdbBackend *backend = (MdbBackend *) g_malloc0(sizeof(MdbBackend));
|
||||||
@ -418,7 +424,9 @@ void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendTy
|
|||||||
g_hash_table_insert(mdb_backends, backend_name, backend);
|
g_hash_table_insert(mdb_backends, backend_name, backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDB_DEPRECATED mdb_remove_backends() {
|
MDB_DEPRECATED(void,
|
||||||
|
mdb_remove_backends())
|
||||||
|
{
|
||||||
fprintf(stderr, "mdb_remove_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
fprintf(stderr, "mdb_remove_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +435,8 @@ void MDB_DEPRECATED mdb_remove_backends() {
|
|||||||
*
|
*
|
||||||
* Removes all entries from and destroys the mdb_backends hash.
|
* Removes all entries from and destroys the mdb_backends hash.
|
||||||
*/
|
*/
|
||||||
void __attribute__ ((destructor)) _mdb_remove_backends()
|
void
|
||||||
|
_mdb_remove_backends()
|
||||||
{
|
{
|
||||||
g_hash_table_foreach_remove(mdb_backends, mdb_drop_backend, NULL);
|
g_hash_table_foreach_remove(mdb_backends, mdb_drop_backend, NULL);
|
||||||
g_hash_table_destroy(mdb_backends);
|
g_hash_table_destroy(mdb_backends);
|
||||||
|
@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
#include "mdbtools.h"
|
#include "mdbtools.h"
|
||||||
|
|
||||||
void MDB_DEPRECATED mdb_init()
|
MDB_DEPRECATED(void,
|
||||||
|
mdb_init())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "mdb_init() is DEPRECATED and does nothing. Stop calling it.\n");
|
fprintf(stderr, "mdb_init() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDB_DEPRECATED mdb_exit()
|
MDB_DEPRECATED(void,
|
||||||
|
mdb_exit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "mdb_exit() is DEPRECATED and does nothing. Stop calling it.\n");
|
fprintf(stderr, "mdb_exit() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,10 @@ TypeInfo type_info[] = {
|
|||||||
#define MAX_TYPE_INFO 11
|
#define MAX_TYPE_INFO 11
|
||||||
|
|
||||||
#ifdef ENABLE_ODBC_W
|
#ifdef ENABLE_ODBC_W
|
||||||
void __attribute__ ((constructor)) my_init(){
|
void my_fini();
|
||||||
|
|
||||||
|
MDB_CONSTRUCTOR(my_init)
|
||||||
|
{
|
||||||
TRACE("my_init");
|
TRACE("my_init");
|
||||||
int endian = 1;
|
int endian = 1;
|
||||||
const char* wcharset;
|
const char* wcharset;
|
||||||
@ -133,9 +136,12 @@ void __attribute__ ((constructor)) my_init(){
|
|||||||
*/
|
*/
|
||||||
iconv_out = iconv_open(wcharset, "UTF-8");
|
iconv_out = iconv_open(wcharset, "UTF-8");
|
||||||
iconv_in = iconv_open("UTF-8", wcharset);
|
iconv_in = iconv_open("UTF-8", wcharset);
|
||||||
|
|
||||||
|
atexit(my_fini);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__ ((destructor)) my_fini(){
|
void my_fini()
|
||||||
|
{
|
||||||
TRACE("my_fini");
|
TRACE("my_fini");
|
||||||
if(iconv_out != (iconv_t)-1)iconv_close(iconv_out);
|
if(iconv_out != (iconv_t)-1)iconv_close(iconv_out);
|
||||||
if(iconv_in != (iconv_t)-1)iconv_close(iconv_in);
|
if(iconv_in != (iconv_t)-1)iconv_close(iconv_in);
|
||||||
|
Loading…
Reference in New Issue
Block a user