mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-11-26 02:09:49 +08:00
Clean up for 0.6 release and some bug fixes
This commit is contained in:
@@ -97,6 +97,8 @@ gmdb_debug_select_cb(GtkTreeSelection *select, GladeXML *xml)
|
||||
GtkWidget *textview;
|
||||
gchar *fieldname;
|
||||
|
||||
fprintf(stderr, "select_cb fired\n");
|
||||
|
||||
textview = glade_xml_get_widget (xml, "debug_textview");
|
||||
gmdb_debug_text_off(textview);
|
||||
|
||||
@@ -291,6 +293,8 @@ gmdb_debug_display_cb(GtkWidget *w, gpointer data)
|
||||
gchar *s;
|
||||
GladeXML *xml;
|
||||
|
||||
fprintf(stderr, "display fired\n");
|
||||
|
||||
if (!mdb) return;
|
||||
|
||||
win = gtk_widget_get_toplevel(w);
|
||||
@@ -974,6 +978,7 @@ gmdb_debug_close_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GladeXML *xml;
|
||||
|
||||
fprintf(stderr, "close fired\n");
|
||||
xml = g_object_get_data(G_OBJECT(w), "debugwin_xml");
|
||||
debug_list = g_list_remove(debug_list, xml);
|
||||
gtk_widget_destroy(w);
|
||||
@@ -984,6 +989,7 @@ gmdb_debug_close_all()
|
||||
GladeXML *xml;
|
||||
GtkWidget *win;
|
||||
|
||||
fprintf(stderr, "close_all fired\n");
|
||||
while ((xml = g_list_nth_data(debug_list, 0))) {
|
||||
win = glade_xml_get_widget (xml, "debug_window");
|
||||
debug_list = g_list_remove(debug_list, xml);
|
||||
@@ -1006,6 +1012,7 @@ gmdb_debug_new_cb(GtkWidget *w, gpointer data)
|
||||
/* load the interface */
|
||||
debugwin_xml = glade_xml_new(GMDB_GLADEDIR "gmdb-debug.glade", NULL, NULL);
|
||||
/* connect the signals in the interface */
|
||||
fprintf(stderr, "autoconnect signals\n");
|
||||
glade_xml_signal_autoconnect(debugwin_xml);
|
||||
|
||||
debug_list = g_list_append(debug_list, debugwin_xml);
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
<property name="default_height">200</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="enable_layout_config">True</property>
|
||||
|
||||
<child internal-child="dock">
|
||||
@@ -175,25 +180,52 @@
|
||||
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
|
||||
<property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
|
||||
<property name="tooltips">True</property>
|
||||
<property name="show_arrow">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="button4">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Open a new window</property>
|
||||
<property name="stock-id">gtk-new</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
<signal name="clicked" handler="gmdb_debug_new_cb" last_modification_time="Fri, 03 Jan 2003 13:12:52 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorToolItem" id="separatortoolitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="back_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Back</property>
|
||||
<property name="stock-id">gtk-go-back</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
<signal name="clicked" handler="gmdb_debug_back_cb" object="debug_window"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="new_group">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
@@ -201,29 +233,63 @@
|
||||
<widget class="GtkToolButton" id="forward_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Forward</property>
|
||||
<property name="stock-id">gtk-go-forward</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
<signal name="clicked" handler="gmdb_debug_forward_cb" object="debug_window"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="jump_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Jump to</property>
|
||||
<property name="stock-id">gtk-jump-to</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
<signal name="clicked" handler="gmdb_debug_jump_cb" object="debug_window"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorToolItem" id="separatortoolitem2">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="close_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Close window</property>
|
||||
<property name="stock-id">gtk-close</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="visible_horizontal">True</property>
|
||||
<property name="visible_vertical">True</property>
|
||||
<property name="is_important">False</property>
|
||||
<signal name="clicked" handler="gmdb_debug_close_cb" object="debug_window"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="new_group">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
@@ -326,7 +392,8 @@
|
||||
<property name="label" translatable="yes">_Display</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<signal name="clicked" handler="gmdb_debug_display_cb" object="debug_entry"/>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="gtk_main_quit" object="debug_entry" last_modification_time="Tue, 23 Aug 2005 12:40:43 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
@@ -389,6 +456,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_NONE</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
|
||||
@@ -183,7 +183,7 @@ void mdb_iconv_init(MdbHandle *mdb)
|
||||
const char *iconv_code;
|
||||
|
||||
/* check environment variable */
|
||||
if (!(iconv_code=getenv("MDB_ICONV"))) {
|
||||
if (!(iconv_code=getenv("MDBICONV"))) {
|
||||
iconv_code="UTF-8";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver mdb-prop mdb-import prtable prcat prdata prkkd prdump prole updrow prindex
|
||||
bin_PROGRAMS = mdb-export mdb-array mdb-schema mdb-tables mdb-parsecsv mdb-header mdb-sql mdb-ver mdb-prop
|
||||
noinst_PROGRAMS = mdb-import prtable prcat prdata prkkd prdump prole updrow prindex
|
||||
LIBS = $(GLIB_LIBS) @LIBS@ @LEXLIB@
|
||||
DEFS = @DEFS@ -DLOCALEDIR=\"$(localedir)\"
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS)
|
||||
|
||||
@@ -29,19 +29,27 @@
|
||||
#define is_text_type(x) (x==MDB_TEXT || x==MDB_MEMO || x==MDB_SDATETIME)
|
||||
|
||||
static char *sanitize_name(char *str, int sanitize);
|
||||
static char *escapes(char *s);
|
||||
|
||||
void
|
||||
print_col(gchar *col_val, int quote_text, int col_type)
|
||||
print_col(gchar *col_val, int quote_text, int col_type, char *quote_char, char *escape_char)
|
||||
{
|
||||
gchar *s;
|
||||
|
||||
if (quote_text && is_text_type(col_type)) {
|
||||
fprintf(stdout,"\"");
|
||||
fprintf(stdout,quote_char);
|
||||
for (s=col_val;*s;s++) {
|
||||
if (*s=='"') fprintf(stdout,"\"\"");
|
||||
if (strlen(quote_char)==1 && *s==quote_char[0]) {
|
||||
/* double the char if no escape char passed */
|
||||
if (!escape_char) {
|
||||
fprintf(stdout,"%s%s",quote_char,quote_char);
|
||||
} else {
|
||||
fprintf(stdout,"%s%s",escape_char,quote_char);
|
||||
}
|
||||
}
|
||||
else fprintf(stdout,"%c",*s);
|
||||
}
|
||||
fprintf(stdout,"\"");
|
||||
fprintf(stdout,quote_char);
|
||||
} else {
|
||||
fprintf(stdout,"%s",col_val);
|
||||
}
|
||||
@@ -57,13 +65,15 @@ main(int argc, char **argv)
|
||||
int *bound_lens;
|
||||
char *delimiter = NULL;
|
||||
char *row_delimiter = NULL;
|
||||
char *quote_char = NULL;
|
||||
char *escape_char = NULL;
|
||||
char header_row = 1;
|
||||
char quote_text = 1;
|
||||
char insert_statements = 0;
|
||||
char sanitize = 0;
|
||||
int opt;
|
||||
|
||||
while ((opt=getopt(argc, argv, "HQd:D:R:IS"))!=-1) {
|
||||
while ((opt=getopt(argc, argv, "HQq:X:d:D:R:IS"))!=-1) {
|
||||
switch (opt) {
|
||||
case 'H':
|
||||
header_row = 0;
|
||||
@@ -71,11 +81,14 @@ main(int argc, char **argv)
|
||||
case 'Q':
|
||||
quote_text = 0;
|
||||
break;
|
||||
case 'q':
|
||||
quote_char = (char *) g_strdup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
delimiter = (char *) g_strdup(optarg);
|
||||
delimiter = escapes(optarg);
|
||||
break;
|
||||
case 'R':
|
||||
row_delimiter = (char *) g_strdup(optarg);
|
||||
row_delimiter = escapes(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
insert_statements = 1;
|
||||
@@ -87,10 +100,16 @@ main(int argc, char **argv)
|
||||
case 'D':
|
||||
mdb_set_date_fmt(optarg);
|
||||
break;
|
||||
case 'X':
|
||||
escape_char = (char *) g_strdup(optarg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!quote_char) {
|
||||
quote_char = (char *) g_strdup("\"");
|
||||
}
|
||||
if (!delimiter) {
|
||||
delimiter = (char *) g_strdup(",");
|
||||
}
|
||||
@@ -112,8 +131,12 @@ main(int argc, char **argv)
|
||||
fprintf(stderr," -I INSERT statements (instead of CSV)\n");
|
||||
fprintf(stderr," -D <format> set the date format (see strftime(3) for details)\n");
|
||||
fprintf(stderr," -S Sanitize names (replace spaces etc. with underscore)\n");
|
||||
fprintf(stderr," -Q <char> Use <char> to wrap text-like fields. Default is \".\n");
|
||||
fprintf(stderr," -X <char> Use <char> to escape quoted characters within a field. Default is doubling.\n");
|
||||
g_free (delimiter);
|
||||
g_free (row_delimiter);
|
||||
g_free (quote_char);
|
||||
if (escape_char) g_free (escape_char);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -122,17 +145,22 @@ main(int argc, char **argv)
|
||||
if (!(mdb = mdb_open(argv[optind], MDB_NOFLAGS))) {
|
||||
g_free (delimiter);
|
||||
g_free (row_delimiter);
|
||||
g_free (quote_char);
|
||||
if (escape_char) g_free (escape_char);
|
||||
mdb_exit();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
table = mdb_read_table_by_name(mdb, argv[argc-1], MDB_TABLE);
|
||||
if (!table) {
|
||||
fprintf(stderr, "Error: Table %s does not exist in this database.\n", argv[argc-1]);
|
||||
g_free (delimiter);
|
||||
g_free (row_delimiter);
|
||||
g_free (quote_char);
|
||||
if (escape_char) g_free (escape_char);
|
||||
mdb_close(mdb);
|
||||
mdb_exit();
|
||||
exit(0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
mdb_read_columns(table);
|
||||
@@ -149,7 +177,8 @@ main(int argc, char **argv)
|
||||
fprintf(stdout,"%s",col->name);
|
||||
for (j=1;j<table->num_cols;j++) {
|
||||
col=g_ptr_array_index(table->columns,j);
|
||||
fprintf(stdout,"%s%s",delimiter,col->name);
|
||||
fprintf(stdout,delimiter);
|
||||
fprintf(stdout,"%s",col->name);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
@@ -174,16 +203,16 @@ main(int argc, char **argv)
|
||||
mdb_ole_read(mdb, col, bound_values[j], MDB_BIND_SIZE);
|
||||
}
|
||||
if (j>0) {
|
||||
fprintf(stdout,"%s",delimiter);
|
||||
fprintf(stdout,delimiter);
|
||||
}
|
||||
if (insert_statements && !bound_lens[j]) {
|
||||
print_col("NULL",0,col->col_type);
|
||||
print_col("NULL",0,col->col_type, quote_char, escape_char);
|
||||
} else {
|
||||
print_col(bound_values[j], quote_text, col->col_type);
|
||||
print_col(bound_values[j], quote_text, col->col_type, quote_char, escape_char);
|
||||
}
|
||||
}
|
||||
if (insert_statements) fprintf(stdout,")");
|
||||
fprintf(stdout,"%s", row_delimiter);
|
||||
fprintf(stdout, row_delimiter);
|
||||
}
|
||||
for (j=0;j<table->num_cols;j++) {
|
||||
g_free(bound_values[j]);
|
||||
@@ -194,6 +223,8 @@ main(int argc, char **argv)
|
||||
|
||||
g_free (delimiter);
|
||||
g_free (row_delimiter);
|
||||
g_free (quote_char);
|
||||
if (escape_char) g_free (escape_char);
|
||||
mdb_close(mdb);
|
||||
mdb_exit();
|
||||
|
||||
@@ -219,3 +250,27 @@ static char *sanitize_name(char *str, int sanitize)
|
||||
return namebuf;
|
||||
}
|
||||
|
||||
static char *escapes(char *s)
|
||||
{
|
||||
char *d = (char *) g_strdup(s);
|
||||
char *t = d;
|
||||
unsigned char encode = 0;
|
||||
|
||||
for (;*s; s++) {
|
||||
if (encode) {
|
||||
switch (*s) {
|
||||
case 'n': *t++='\n'; break;
|
||||
case 't': *t++='\t'; break;
|
||||
case 'r': *t++='\r'; break;
|
||||
default: *t++='\\'; *t++=*s; break;
|
||||
}
|
||||
encode=0;
|
||||
} else if (*s=='\\') {
|
||||
encode=1;
|
||||
} else {
|
||||
*t++=*s;
|
||||
}
|
||||
}
|
||||
*t='\0';
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ extern void clear_history ();
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
void dump_results(MdbSQL *sql, char *delimiter);
|
||||
void dump_results_pp(MdbSQL *sql);
|
||||
void dump_results(FILE *out, MdbSQL *sql, char *delimiter);
|
||||
void dump_results_pp(FILE *out, MdbSQL *sql);
|
||||
int yyparse(void);
|
||||
|
||||
#if SQL
|
||||
@@ -200,7 +200,7 @@ read_file(char *s, int line, unsigned int *bufsz, char *mybuf)
|
||||
return lines;
|
||||
}
|
||||
void
|
||||
run_query(MdbSQL *sql, char *mybuf, char *delimiter)
|
||||
run_query(FILE *out, MdbSQL *sql, char *mybuf, char *delimiter)
|
||||
{
|
||||
MdbTableDef *table;
|
||||
|
||||
@@ -219,48 +219,48 @@ run_query(MdbSQL *sql, char *mybuf, char *delimiter)
|
||||
}
|
||||
mdb_sql_bind_all(sql);
|
||||
if (pretty_print)
|
||||
dump_results_pp(sql);
|
||||
dump_results_pp(out, sql);
|
||||
else
|
||||
dump_results(sql, delimiter);
|
||||
dump_results(out, sql, delimiter);
|
||||
}
|
||||
}
|
||||
|
||||
void print_value(char *v, int sz, int first)
|
||||
void print_value(FILE *out, char *v, int sz, int first)
|
||||
{
|
||||
int i;
|
||||
int vlen;
|
||||
|
||||
if (first) {
|
||||
fprintf(stdout,"|");
|
||||
fprintf(out,"|");
|
||||
}
|
||||
vlen = strlen(v);
|
||||
for (i=0;i<sz;i++) {
|
||||
fprintf(stdout,"%c",i >= vlen ? ' ' : v[i]);
|
||||
fprintf(out,"%c",i >= vlen ? ' ' : v[i]);
|
||||
}
|
||||
fprintf(stdout,"|");
|
||||
fprintf(out,"|");
|
||||
}
|
||||
static void print_break(int sz, int first)
|
||||
static void print_break(FILE *out, int sz, int first)
|
||||
{
|
||||
int i;
|
||||
if (first) {
|
||||
fprintf(stdout,"+");
|
||||
fprintf(out,"+");
|
||||
}
|
||||
for (i=0;i<sz;i++) {
|
||||
fprintf(stdout,"-");
|
||||
fprintf(out,"-");
|
||||
}
|
||||
fprintf(stdout,"+");
|
||||
fprintf(out,"+");
|
||||
}
|
||||
void print_rows_retrieved(unsigned long row_count)
|
||||
void print_rows_retrieved(FILE *out, unsigned long row_count)
|
||||
{
|
||||
if (!row_count)
|
||||
fprintf(stdout, "No Rows retrieved\n");
|
||||
fprintf(out, "No Rows retrieved\n");
|
||||
else if (row_count==1)
|
||||
fprintf(stdout, "1 Row retrieved\n");
|
||||
fprintf(out, "1 Row retrieved\n");
|
||||
else
|
||||
fprintf(stdout, "%lu Rows retrieved\n", row_count);
|
||||
fprintf(out, "%lu Rows retrieved\n", row_count);
|
||||
}
|
||||
void
|
||||
dump_results(MdbSQL *sql, char *delimiter)
|
||||
dump_results(FILE *out, MdbSQL *sql, char *delimiter)
|
||||
{
|
||||
unsigned int j;
|
||||
MdbSQLColumn *sqlcol;
|
||||
@@ -269,33 +269,33 @@ dump_results(MdbSQL *sql, char *delimiter)
|
||||
if (headers) {
|
||||
for (j=0;j<sql->num_columns-1;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
fprintf(stdout, "%s%s", sqlcol->name,
|
||||
fprintf(out, "%s%s", sqlcol->name,
|
||||
delimiter ? delimiter : "\t");
|
||||
}
|
||||
sqlcol = g_ptr_array_index(sql->columns,sql->num_columns-1);
|
||||
fprintf(stdout, "%s", sqlcol->name);
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out, "%s", sqlcol->name);
|
||||
fprintf(out,"\n");
|
||||
}
|
||||
while(mdb_fetch_row(sql->cur_table)) {
|
||||
row_count++;
|
||||
for (j=0;j<sql->num_columns-1;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
fprintf(stdout, "%s%s", sql->bound_values[j],
|
||||
fprintf(out, "%s%s", sql->bound_values[j],
|
||||
delimiter ? delimiter : "\t");
|
||||
}
|
||||
sqlcol = g_ptr_array_index(sql->columns,sql->num_columns-1);
|
||||
fprintf(stdout, "%s", sql->bound_values[sql->num_columns-1]);
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out, "%s", sql->bound_values[sql->num_columns-1]);
|
||||
fprintf(out,"\n");
|
||||
}
|
||||
if (footers) {
|
||||
print_rows_retrieved(row_count);
|
||||
print_rows_retrieved(out, row_count);
|
||||
}
|
||||
|
||||
mdb_sql_reset(sql);
|
||||
}
|
||||
|
||||
void
|
||||
dump_results_pp(MdbSQL *sql)
|
||||
dump_results_pp(FILE *out, MdbSQL *sql)
|
||||
{
|
||||
unsigned int j;
|
||||
MdbSQLColumn *sqlcol;
|
||||
@@ -307,40 +307,40 @@ dump_results_pp(MdbSQL *sql)
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
if (strlen(sqlcol->name)>sqlcol->disp_size)
|
||||
sqlcol->disp_size = strlen(sqlcol->name);
|
||||
print_break(sqlcol->disp_size, !j);
|
||||
print_break(out, sqlcol->disp_size, !j);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out,"\n");
|
||||
for (j=0;j<sql->num_columns;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
print_value(sqlcol->name,sqlcol->disp_size,!j);
|
||||
print_value(out, sqlcol->name,sqlcol->disp_size,!j);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out,"\n");
|
||||
}
|
||||
|
||||
for (j=0;j<sql->num_columns;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
print_break(sqlcol->disp_size, !j);
|
||||
print_break(out, sqlcol->disp_size, !j);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out,"\n");
|
||||
|
||||
/* print each row */
|
||||
while(mdb_fetch_row(sql->cur_table)) {
|
||||
row_count++;
|
||||
for (j=0;j<sql->num_columns;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
print_value(sql->bound_values[j],sqlcol->disp_size,!j);
|
||||
print_value(out, sql->bound_values[j],sqlcol->disp_size,!j);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out,"\n");
|
||||
}
|
||||
|
||||
/* footer */
|
||||
for (j=0;j<sql->num_columns;j++) {
|
||||
sqlcol = g_ptr_array_index(sql->columns,j);
|
||||
print_break(sqlcol->disp_size, !j);
|
||||
print_break(out, sqlcol->disp_size, !j);
|
||||
}
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(out,"\n");
|
||||
if (footers) {
|
||||
print_rows_retrieved(row_count);
|
||||
print_rows_retrieved(out, row_count);
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
@@ -430,7 +430,7 @@ char *delimiter = NULL;
|
||||
if ((!s) || (!fgets(s, 256, in))) {
|
||||
/* if we have something in the buffer, run it */
|
||||
if (strlen(mybuf))
|
||||
run_query(sql, mybuf, delimiter);
|
||||
run_query(out, sql, mybuf, delimiter);
|
||||
break;
|
||||
}
|
||||
if (s[strlen(s)-1]=='\n')
|
||||
@@ -450,7 +450,7 @@ char *delimiter = NULL;
|
||||
line = 0;
|
||||
} else if (!strcmp(s,"go")) {
|
||||
line = 0;
|
||||
run_query(sql, mybuf, delimiter);
|
||||
run_query(out, sql, mybuf, delimiter);
|
||||
mybuf[0]='\0';
|
||||
} else if (!strcmp(s,"reset")) {
|
||||
line = 0;
|
||||
|
||||
Reference in New Issue
Block a user