mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@@ -28,10 +29,39 @@ int main(int argc, char **argv) {
|
||||
char *locale = NULL;
|
||||
char *table_name = NULL;
|
||||
GError *error = NULL;
|
||||
int print_mdbver = 0;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s <file> <table>\n", argv[0]);
|
||||
return 1;
|
||||
GOptionContext *opt_context;
|
||||
GOptionEntry entries[] = {
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{NULL}
|
||||
};
|
||||
opt_context = g_option_context_new("<file> <table> - print the number of records in an Access database");
|
||||
g_option_context_add_main_entries(opt_context, entries, NULL /*i18n*/);
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
if (!g_option_context_parse (opt_context, &argc, &argv, &error))
|
||||
{
|
||||
fprintf(stderr, "option parsing failed: %s\n", error->message);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
return 1;
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
if (argc != 3) {
|
||||
fputs("Wrong number of arguments.\n\n", stderr);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
return 1;
|
||||
}
|
||||
table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, &error);
|
||||
setlocale(LC_CTYPE, locale);
|
||||
if (!table_name) {
|
||||
fprintf(stderr, "Error converting table argument: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// open db and try to read table:
|
||||
@@ -42,13 +72,6 @@ int main(int argc, char **argv) {
|
||||
if (!mdb_read_catalog(mdb, MDB_TABLE)) {
|
||||
return 1;
|
||||
}
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, &error);
|
||||
setlocale(LC_CTYPE, locale);
|
||||
if (!table_name) {
|
||||
fprintf(stderr, "Error converting table argument: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < mdb->num_catalog; i++) {
|
||||
entry = g_ptr_array_index(mdb->catalog, i);
|
||||
if (entry->object_type == MDB_TABLE && !g_ascii_strcasecmp(entry->object_name, table_name)) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
#define EXPORT_BIND_SIZE 200000
|
||||
|
||||
@@ -56,6 +57,7 @@ main(int argc, char **argv)
|
||||
int ret;
|
||||
char *locale = NULL;
|
||||
char *table_name = NULL;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{"no-header", 'H', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &header_row, "Suppress header row.", NULL},
|
||||
@@ -73,6 +75,7 @@ main(int argc, char **argv)
|
||||
{"null", '0', 0, G_OPTION_ARG_STRING, &null_text, "Use <char> to represent a NULL value", "char"},
|
||||
{"bin", 'b', 0, G_OPTION_ARG_STRING, &str_bin_mode, "Binary export mode", "strip|raw|octal|hex"},
|
||||
{"boolean-words", 'B', 0, G_OPTION_ARG_NONE, &boolean_words, "Use TRUE/FALSE in Boolean fields (default is 0/1)", NULL},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{NULL},
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -88,7 +91,13 @@ main(int argc, char **argv)
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
if (argc != 3) {
|
||||
fputs("Wrong number of arguments.\n\n", stderr);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
#define MAX_ROW_SIZE 4096
|
||||
|
||||
@@ -158,10 +159,12 @@ main(int argc, char **argv)
|
||||
FILE *in;
|
||||
char *delimiter;
|
||||
int header_rows = 0;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{ "header", 'H', 0, G_OPTION_ARG_INT, &header_rows, "skip <rows> header rows", "row"},
|
||||
{ "delimiter", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Specify a column delimiter", "char"},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{ NULL },
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -176,6 +179,13 @@ main(int argc, char **argv)
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
|
||||
if (!delimiter)
|
||||
delimiter = g_strdup(",");
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
@@ -115,11 +116,13 @@ main(int argc, char **argv)
|
||||
int ret;
|
||||
char *table_name = NULL;
|
||||
char *locale = NULL;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{"date-format", 'D', 0, G_OPTION_ARG_STRING, &shortdate_fmt, "Set the date format (see strftime(3) for details)", "format"},
|
||||
{"datetime-format", 'T', 0, G_OPTION_ARG_STRING, &date_fmt, "Set the date/time format (see strftime(3) for details)", "format"},
|
||||
{"no-unprintable", 'U', 0, G_OPTION_ARG_NONE, &drop_nonascii, "Change unprintable characters to spaces (otherwise escaped as \\u00XX)", NULL},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -135,6 +138,13 @@ main(int argc, char **argv)
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
if (argc != 3) {
|
||||
fputs("Wrong number of arguments.\n\n", stderr);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
void dump_kkd(MdbHandle *mdb, void *kkd, size_t len);
|
||||
|
||||
@@ -32,10 +33,43 @@ main(int argc, char **argv)
|
||||
void *buf;
|
||||
int col_num;
|
||||
int found = 0;
|
||||
int print_mdbver = 0;
|
||||
GError *error = NULL;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr,"Usage: %s <file> <object name> [<prop col>]\n",
|
||||
argv[0]);
|
||||
GOptionContext *opt_context;
|
||||
GOptionEntry entries[] = {
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{NULL}
|
||||
};
|
||||
opt_context = g_option_context_new("<file> <object name> [<prop col>] - display properties of an object in an Access database");
|
||||
g_option_context_add_main_entries(opt_context, entries, NULL /*i18n*/);
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
if (!g_option_context_parse (opt_context, &argc, &argv, &error))
|
||||
{
|
||||
fprintf(stderr, "option parsing failed: %s\n", error->message);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
return 1;
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
if (argc != 3 && argc != 4) {
|
||||
fputs("Wrong number of arguments.\n\n", stderr);
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, NULL);
|
||||
if (argc < 4)
|
||||
propColName = g_strdup("LvProp");
|
||||
else
|
||||
propColName = g_locale_to_utf8(argv[3], -1, NULL, NULL, NULL);
|
||||
setlocale(LC_CTYPE, locale);
|
||||
if (!table_name || !propColName) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -44,17 +78,6 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
locale = setlocale(LC_CTYPE, "");
|
||||
table_name = g_locale_to_utf8(argv[2], -1, NULL, NULL, NULL);
|
||||
if (argc < 4)
|
||||
propColName = g_strdup("LvProp");
|
||||
else
|
||||
propColName = g_locale_to_utf8(argv[3], -1, NULL, NULL, NULL);
|
||||
setlocale(LC_CTYPE, locale);
|
||||
if (!table_name || !propColName) {
|
||||
mdb_close(mdb);
|
||||
return 1;
|
||||
}
|
||||
table = mdb_read_table_by_name(mdb, "MSysObjects", MDB_ANY);
|
||||
if (!table) {
|
||||
g_free(table_name);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
**************************************************************/
|
||||
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
#define QUERY_BIND_SIZE 200000
|
||||
|
||||
@@ -68,6 +69,7 @@ int main (int argc, char **argv) {
|
||||
char *sql_sorting = malloc(bind_size);
|
||||
int flagint;
|
||||
char *locale = NULL;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GError *error = NULL;
|
||||
GOptionContext *opt_context;
|
||||
@@ -76,6 +78,7 @@ int main (int argc, char **argv) {
|
||||
{"list", 'L', 0, G_OPTION_ARG_NONE, &list_only, "List queries in the database (default if no query name is passed)", NULL},
|
||||
{"newline", '1', 0, G_OPTION_ARG_NONE, &line_break, "Use newline as the delimiter (used in conjunction with listing)", NULL},
|
||||
{"delimiter", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Specify delimiter to use", "delim"},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{NULL}
|
||||
};
|
||||
opt_context = g_option_context_new("<file> <query name> - list or export queries from an Access database");
|
||||
@@ -87,6 +90,13 @@ int main (int argc, char **argv) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
/* let's turn list_only on if only a database filename was passed */
|
||||
if(argc == 2) {
|
||||
list_only=1;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
/* this utility dumps the schema for an existing database */
|
||||
#include "mdbtools.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@@ -34,6 +35,7 @@ main (int argc, char **argv)
|
||||
int opt_indexes = MDB_SHEXP_DEFAULT & MDB_SHEXP_INDEXES;
|
||||
int opt_relations = MDB_SHEXP_DEFAULT & MDB_SHEXP_RELATIONS;
|
||||
int success = 0;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{ "table", 'T', 0, G_OPTION_ARG_STRING, &tabname, "Only create schema for named table", "table"},
|
||||
@@ -52,6 +54,7 @@ main (int argc, char **argv)
|
||||
{ "no-indexes", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_indexes, "Don't include indexes", NULL},
|
||||
{ "relations", 0, 0, G_OPTION_ARG_NONE, &opt_relations, "Include foreign key constraints", NULL},
|
||||
{ "no-relations", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &opt_relations, "Don't include foreign key constraints", NULL},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{ NULL },
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -67,6 +70,13 @@ main (int argc, char **argv)
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
|
||||
setlocale(LC_CTYPE, old_locale);
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ extern void clear_history ();
|
||||
|
||||
#include <string.h>
|
||||
#include "mdbsql.h"
|
||||
#include "mdbver.h"
|
||||
|
||||
void dump_results(FILE *out, MdbSQL *sql, char *delimiter);
|
||||
void dump_results_pp(FILE *out, MdbSQL *sql);
|
||||
@@ -334,6 +335,7 @@ main(int argc, char **argv)
|
||||
char *delimiter = NULL;
|
||||
int in_from_colon_r = 0;
|
||||
char *locale = NULL;
|
||||
int print_mdbver = 0;
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{ "delim", 'd', 0, G_OPTION_ARG_STRING, &delimiter, "Use this delimiter.", "char"},
|
||||
@@ -342,6 +344,7 @@ main(int argc, char **argv)
|
||||
{ "no-footer", 'F', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &footers, "Don't print footer", NULL},
|
||||
{ "input", 'i', 0, G_OPTION_ARG_FILENAME, &filename_in, "Read SQL from specified file", "file"},
|
||||
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &filename_out, "Write result to specified file", "file"},
|
||||
{"version", 0, 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{ NULL },
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -357,6 +360,13 @@ main(int argc, char **argv)
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
exit (1);
|
||||
}
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
exit(argc > 1);
|
||||
}
|
||||
setlocale(LC_CTYPE, locale);
|
||||
|
||||
if (argc > 2) {
|
||||
|
||||
@@ -26,12 +26,8 @@ main(int argc, char **argv)
|
||||
MdbHandle *mdb;
|
||||
int print_mdbver = 0;
|
||||
|
||||
/* setlocale (LC_ALL, ""); */
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{ "mdbtools", 'M', 0, G_OPTION_ARG_NONE, &print_mdbver, "Show MDBtools version", NULL},
|
||||
{ "version", 'M', 0, G_OPTION_ARG_NONE, &print_mdbver, "Show mdbtools version and exit", NULL},
|
||||
{ NULL },
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -48,9 +44,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (print_mdbver) {
|
||||
if (argc > 1) {
|
||||
fputs(g_option_context_get_help(opt_context, TRUE, NULL), stderr);
|
||||
}
|
||||
fprintf(stdout,"%s\n", MDB_FULL_VERSION);
|
||||
if (argc == 1)
|
||||
exit(0);
|
||||
exit(argc > 1);
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
|
||||
Reference in New Issue
Block a user