Merge branch 'master' into no-glib

This commit is contained in:
Evan Miller
2020-08-04 23:53:50 -04:00
12 changed files with 91 additions and 12 deletions

View File

@@ -372,7 +372,7 @@ static ssize_t _mdb_read_pg(MdbHandle *mdb, void *pg_buf, unsigned long pg)
fstat(mdb->f->fd, &status);
if (status.st_size < offset) {
fprintf(stderr,"offset %jd is beyond EOF\n",(intmax_t)offset);
fprintf(stderr,"offset %" PRIu64 " is beyond EOF\n",(uint64_t)offset);
return 0;
}
if (mdb->stats && mdb->stats->collect)

View File

@@ -88,11 +88,8 @@ mdb_unicode2ascii(MdbHandle *mdb, char *src, size_t slen, char *dest, size_t dle
dlen -= len_out;
#else
if (IS_JET3(mdb)) {
size_t copy_len = len_in;
if (copy_len > dlen)
copy_len = dlen;
strncpy(out_ptr, in_ptr, copy_len);
dlen = copy_len;
dlen = MIN(len_in, len_out);
strncpy(out_ptr, in_ptr, dlen);
} else {
/* rough UCS-2LE to ISO-8859-1 conversion */
unsigned int i;

View File

@@ -131,6 +131,23 @@ mdb_read_props(MdbHandle *mdb, GPtrArray *names, gchar *kkd, int len)
if (dtype == MDB_BOOL) {
g_hash_table_insert(props->hash, g_strdup(name),
g_strdup(kkd[pos + 8] ? "yes" : "no"));
} else if (dtype == MDB_BINARY && dsize == 16 && strcmp(name, "GUID") == 0) {
gchar *guid = g_malloc0(39);
snprintf(guid, 39, "{%02X%02X%02X%02X" "-" "%02X%02X" "-" "%02X%02X"
"-" "%02X%02X" "%02X%02X%02X%02X%02X%02X}",
(unsigned char)kkd[pos+11], (unsigned char)kkd[pos+10],
(unsigned char)kkd[pos+9], (unsigned char)kkd[pos+8], // little-endian
(unsigned char)kkd[pos+13], (unsigned char)kkd[pos+12], // little-endian
(unsigned char)kkd[pos+15], (unsigned char)kkd[pos+14], // little-endian
(unsigned char)kkd[pos+16], (unsigned char)kkd[pos+17], // big-endian
(unsigned char)kkd[pos+18], (unsigned char)kkd[pos+19],
(unsigned char)kkd[pos+20], (unsigned char)kkd[pos+21],
(unsigned char)kkd[pos+22], (unsigned char)kkd[pos+23]); // big-endian
g_hash_table_insert(props->hash, g_strdup(name), guid);
} else {
g_hash_table_insert(props->hash, g_strdup(name),
mdb_col_to_string(mdb, kkd, pos + 8, dtype, dsize));

View File

@@ -81,7 +81,7 @@ mdb_write_pg(MdbHandle *mdb, unsigned long pg)
fstat(mdb->f->fd, &status);
/* is page beyond current size + 1 ? */
if (status.st_size < offset + mdb->fmt->pg_size) {
fprintf(stderr,"offset %jd is beyond EOF\n",(intmax_t)offset);
fprintf(stderr,"offset %" PRIu64 " is beyond EOF\n",(uint64_t)offset);
return 0;
}
lseek(mdb->f->fd, offset, SEEK_SET);

View File

@@ -32,9 +32,10 @@
#ifdef HAVE_STRPTIME
#include <time.h>
#include <stdio.h>
#include <locale.h>
#endif
#include <locale.h>
char *g_input_ptr;
/* Prevent warnings from -Wmissing-prototypes. */
@@ -52,6 +53,8 @@ int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
static MdbSargNode * mdb_sql_alloc_node(void);
void
mdb_sql_error(MdbSQL* sql, char *fmt, ...)
{
@@ -204,7 +207,7 @@ MdbHandle *mdb_sql_open(MdbSQL *sql, char *db_name)
return sql->mdb;
}
MdbSargNode *
static MdbSargNode *
mdb_sql_alloc_node()
{
return (MdbSargNode *) g_malloc0(sizeof(MdbSargNode));

View File

@@ -122,6 +122,7 @@ FILE *cfile;
fprintf (cfile, "\tdump_string (x.");
break;
default:
fprintf(stderr, "ERROR: unsupported type: 0x%02x\n", col->col_type);
unsupported = 1;
break;
}
@@ -147,8 +148,6 @@ FILE *cfile;
mdb_close (mdb);
if (unsupported)
fputs("ERROR: unsupported type.\n", stderr);
exit(unsupported);
}