mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Deprecate more mdb_{init|remove}_backends
These functions now use the __attribute__((constructor)) & destructor. Old names were keep for compatibility Also put __attribute__((deprecated)) in mdbtools.h for all deprecated functions.
This commit is contained in:
parent
1700860912
commit
5f09513c85
@ -416,8 +416,8 @@ typedef struct {
|
||||
} MdbSarg;
|
||||
|
||||
/* mem.c */
|
||||
extern void mdb_init(); // DEPRECATED
|
||||
extern void mdb_exit(); // DEPRECATED
|
||||
extern void __attribute__((deprecated)) mdb_init();
|
||||
extern void __attribute__((deprecated)) mdb_exit();
|
||||
|
||||
/* file.c */
|
||||
extern ssize_t mdb_read_pg(MdbHandle *mdb, unsigned long pg);
|
||||
@ -487,14 +487,14 @@ extern int mdb_read_row(MdbTableDef *table, unsigned int row);
|
||||
extern void mdb_buffer_dump(const void *buf, int start, size_t len);
|
||||
|
||||
/* backend.c */
|
||||
extern char* mdb_get_coltype_string(MdbBackend *backend, int col_type); /* obsolete */
|
||||
extern int mdb_coltype_takes_length(MdbBackend *backend, int col_type); /* obsolete */
|
||||
extern char* __attribute__((deprecated)) mdb_get_coltype_string(MdbBackend *backend, int col_type);
|
||||
extern int __attribute__((deprecated)) mdb_coltype_takes_length(MdbBackend *backend, int col_type);
|
||||
extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
|
||||
extern const char* mdb_get_colbacktype_string(const MdbColumn *col);
|
||||
extern int mdb_colbacktype_takes_length(const MdbColumn *col);
|
||||
extern void mdb_init_backends();
|
||||
extern void __attribute__((deprecated)) 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_remove_backends();
|
||||
extern void __attribute__((deprecated)) mdb_remove_backends();
|
||||
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);
|
||||
|
||||
|
@ -237,7 +237,7 @@ quote_with_squotes(const gchar* value)
|
||||
return quote_generic(value, '\'', '\'');
|
||||
}
|
||||
|
||||
/* deprecated */ char *
|
||||
char * __attribute__((deprecated))
|
||||
mdb_get_coltype_string(MdbBackend *backend, int col_type)
|
||||
{
|
||||
static int warn_deprecated = 0;
|
||||
@ -255,7 +255,7 @@ mdb_get_coltype_string(MdbBackend *backend, int col_type)
|
||||
return backend->types_table[col_type].name;
|
||||
}
|
||||
|
||||
/* deprecated */ int
|
||||
int __attribute__((deprecated))
|
||||
mdb_coltype_takes_length(MdbBackend *backend, int col_type)
|
||||
{
|
||||
static int warn_deprecated = 0;
|
||||
@ -303,13 +303,17 @@ mdb_colbacktype_takes_length(const MdbColumn *col)
|
||||
return type->needs_length;
|
||||
}
|
||||
|
||||
void __attribute__((deprecated)) mdb_init_backends() {
|
||||
fprintf(stderr, "mdb_init_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* mdb_init_backends
|
||||
* _mdb_init_backends
|
||||
*
|
||||
* Initializes the mdb_backends hash and loads the builtin backends.
|
||||
* Use mdb_remove_backends() to destroy this hash when done.
|
||||
*/
|
||||
void mdb_init_backends()
|
||||
void __attribute__ ((constructor)) _mdb_init_backends()
|
||||
{
|
||||
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
|
||||
@ -382,12 +386,16 @@ void mdb_register_backend(char *backend_name, guint32 capabilities, MdbBackendTy
|
||||
g_hash_table_insert(mdb_backends, backend_name, backend);
|
||||
}
|
||||
|
||||
void __attribute__((deprecated)) mdb_remove_backends() {
|
||||
fprintf(stderr, "mdb_remove_backends() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* mdb_remove_backends
|
||||
*
|
||||
* Removes all entries from and destroys the mdb_backends hash.
|
||||
*/
|
||||
void mdb_remove_backends()
|
||||
void __attribute__ ((destructor)) _mdb_remove_backends()
|
||||
{
|
||||
g_hash_table_foreach_remove(mdb_backends, mdb_drop_backend, NULL);
|
||||
g_hash_table_destroy(mdb_backends);
|
||||
|
@ -18,15 +18,6 @@
|
||||
|
||||
#include "mdbtools.h"
|
||||
|
||||
void __attribute__ ((constructor)) _mdb_init()
|
||||
{
|
||||
mdb_init_backends();
|
||||
}
|
||||
void __attribute__ ((destructor)) _mdb_exit()
|
||||
{
|
||||
mdb_remove_backends();
|
||||
}
|
||||
|
||||
void __attribute__((deprecated)) mdb_init()
|
||||
{
|
||||
fprintf(stderr, "mdb_init() is DEPRECATED and does nothing. Stop calling it.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user