mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-07-16 12:19:31 +08:00
print_col new FILE* outfile parameter
TODO: Merge that code with the one in gmdb2
This commit is contained in:
parent
915eeb61d4
commit
7e8ae9b121
@ -36,7 +36,7 @@ static char *escapes(char *s);
|
|||||||
|
|
||||||
//#define DONT_ESCAPE_ESCAPE
|
//#define DONT_ESCAPE_ESCAPE
|
||||||
static void
|
static void
|
||||||
print_col(gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char, int bin_mode)
|
print_col(FILE *outfile, gchar *col_val, int quote_text, int col_type, int bin_len, char *quote_char, char *escape_char, int bin_mode)
|
||||||
{
|
{
|
||||||
size_t quote_len = strlen(quote_char); /* multibyte */
|
size_t quote_len = strlen(quote_char); /* multibyte */
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ print_col(gchar *col_val, int quote_text, int col_type, int bin_len, char *quote
|
|||||||
escape_char = quote_char;
|
escape_char = quote_char;
|
||||||
|
|
||||||
if (quote_text && is_quote_type(col_type)) {
|
if (quote_text && is_quote_type(col_type)) {
|
||||||
fputs(quote_char,stdout);
|
fputs(quote_char, outfile);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (is_binary_type(col_type)) {
|
if (is_binary_type(col_type)) {
|
||||||
if (bin_mode == BIN_MODE_STRIP)
|
if (bin_mode == BIN_MODE_STRIP)
|
||||||
@ -59,21 +59,21 @@ print_col(gchar *col_val, int quote_text, int col_type, int bin_len, char *quote
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (quote_len && !strncmp(col_val, quote_char, quote_len)) {
|
if (quote_len && !strncmp(col_val, quote_char, quote_len)) {
|
||||||
fprintf(stdout, "%s%s", escape_char, quote_char);
|
fprintf(outfile, "%s%s", escape_char, quote_char);
|
||||||
col_val += quote_len;
|
col_val += quote_len;
|
||||||
#ifndef DONT_ESCAPE_ESCAPE
|
#ifndef DONT_ESCAPE_ESCAPE
|
||||||
} else if (orig_escape_len && !strncmp(col_val, escape_char, orig_escape_len)) {
|
} else if (orig_escape_len && !strncmp(col_val, escape_char, orig_escape_len)) {
|
||||||
fprintf(stdout, "%s%s", escape_char, escape_char);
|
fprintf(outfile, "%s%s", escape_char, escape_char);
|
||||||
col_val += orig_escape_len;
|
col_val += orig_escape_len;
|
||||||
#endif
|
#endif
|
||||||
} else if (is_binary_type(col_type) && *col_val <= 0 && bin_mode == BIN_MODE_OCTAL)
|
} else if (is_binary_type(col_type) && *col_val <= 0 && bin_mode == BIN_MODE_OCTAL)
|
||||||
fprintf(stdout, "\\%03o", *(unsigned char*)col_val++);
|
fprintf(outfile, "\\%03o", *(unsigned char*)col_val++);
|
||||||
else
|
else
|
||||||
putc(*col_val++, stdout);
|
putc(*col_val++, outfile);
|
||||||
}
|
}
|
||||||
fputs(quote_char, stdout);
|
fputs(quote_char, outfile);
|
||||||
} else
|
} else
|
||||||
fputs(col_val, stdout);
|
fputs(col_val, outfile);
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@ -253,7 +253,7 @@ main(int argc, char **argv)
|
|||||||
value = bound_values[j];
|
value = bound_values[j];
|
||||||
length = bound_lens[j];
|
length = bound_lens[j];
|
||||||
}
|
}
|
||||||
print_col(value, quote_text, col->col_type, length, quote_char, escape_char, bin_mode);
|
print_col(stdout, value, quote_text, col->col_type, length, quote_char, escape_char, bin_mode);
|
||||||
if (col->col_type == MDB_OLE)
|
if (col->col_type == MDB_OLE)
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user