projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 5.9.0
[yaz-moved-to-github.git]
/
src
/
odr.c
diff --git
a/src/odr.c
b/src/odr.c
index
3ad263d
..
9cbac0d
100644
(file)
--- a/
src/odr.c
+++ b/
src/odr.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
@@
-64,7
+64,7
@@
void odr_perror(ODR o, const char *message)
fprintf(stderr, "%s: %s (code %d:%d)", message, odr_errlist[err], err, x);
if (e && *e)
fprintf(stderr, " element %s", e);
fprintf(stderr, "%s: %s (code %d:%d)", message, odr_errlist[err], err, x);
if (e && *e)
fprintf(stderr, " element %s", e);
-
+
fprintf(stderr, "\n");
if (element_path)
{
fprintf(stderr, "\n");
if (element_path)
{
@@
-135,19
+135,10
@@
void odr_FILE_write(ODR o, void *handle, int type,
const char *buf, int len)
{
int i;
const char *buf, int len)
{
int i;
-#if 0
- if (type == ODR_OCTETSTRING)
- {
- const char **stack_names = odr_get_element_path(o);
- for (i = 0; stack_names[i]; i++)
- fprintf((FILE*) handle, "[%s]", stack_names[i]);
- fputs("\n", (FILE*) handle);
- }
-#endif
for (i = 0; i < len; i++)
{
unsigned c = ((const unsigned char *) buf)[i];
for (i = 0; i < len; i++)
{
unsigned c = ((const unsigned char *) buf)[i];
- if (i == 2000 && len > 3100)
+ if (i == 20000 && len > 31000)
{
fputs(" ..... ", (FILE*) handle);
i = len - 1000;
{
fputs(" ..... ", (FILE*) handle);
i = len - 1000;
@@
-175,9
+166,13
@@
void odr_setprint(ODR o, FILE *file)
odr_set_stream(o, file, odr_FILE_write, odr_FILE_close);
}
odr_set_stream(o, file, odr_FILE_write, odr_FILE_close);
}
+void odr_setprint_noclose(ODR o, FILE *file)
+{
+ odr_set_stream(o, file, odr_FILE_write, 0);
+}
void odr_set_stream(ODR o, void *handle,
void odr_set_stream(ODR o, void *handle,
- void (*stream_write)(ODR o,
+ void (*stream_write)(ODR o,
void *handle, int type,
const char *buf, int len),
void (*stream_close)(void *handle))
void *handle, int type,
const char *buf, int len),
void (*stream_close)(void *handle))
@@
-215,14
+210,14
@@
ODR odr_createmem(int direction)
return 0;
o->op = (struct Odr_private *) xmalloc(sizeof(*o->op));
o->direction = direction;
return 0;
o->op = (struct Odr_private *) xmalloc(sizeof(*o->op));
o->direction = direction;
- o->buf = 0;
- o->size = o->pos = o->top = 0;
+ o->op->buf = 0;
+ o->op->size = o->op->pos = o->op->top = 0;
o->op->can_grow = 1;
o->mem = nmem_create();
o->op->enable_bias = 1;
o->op->odr_ber_tag.lclass = -1;
o->op->iconv_handle = 0;
o->op->can_grow = 1;
o->mem = nmem_create();
o->op->enable_bias = 1;
o->op->odr_ber_tag.lclass = -1;
o->op->iconv_handle = 0;
- odr_setprint(o, stderr);
+ odr_setprint_noclose(o, stderr);
odr_reset(o);
yaz_log(log_level, "odr_createmem dir=%d o=%p", direction, o);
return o;
odr_reset(o);
yaz_log(log_level, "odr_createmem dir=%d o=%p", direction, o);
return o;
@@
-237,9
+232,9
@@
void odr_reset(ODR o)
}
odr_seterror(o, ONONE, 0);
}
odr_seterror(o, ONONE, 0);
- o->bp = o->buf;
+ o->op->bp = o->op->buf;
odr_seek(o, ODR_S_SET, 0);
odr_seek(o, ODR_S_SET, 0);
- o->top = 0;
+ o->op->top = 0;
o->op->t_class = -1;
o->op->t_tag = -1;
o->op->indent = 0;
o->op->t_class = -1;
o->op->t_tag = -1;
o->op->indent = 0;
@@
-254,12
+249,12
@@
void odr_reset(ODR o)
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
yaz_log(log_level, "odr_reset o=%p", o);
}
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
yaz_log(log_level, "odr_reset o=%p", o);
}
-
+
void odr_destroy(ODR o)
{
nmem_destroy(o->mem);
void odr_destroy(ODR o)
{
nmem_destroy(o->mem);
- if (o->buf && o->op->can_grow)
- xfree(o->buf);
+ if (o->op->buf && o->op->can_grow)
+ xfree(o->op->buf);
if (o->op->stream_close)
o->op->stream_close(o->op->print);
if (o->op->iconv_handle != 0)
if (o->op->stream_close)
o->op->stream_close(o->op->print);
if (o->op->iconv_handle != 0)
@@
-272,19
+267,24
@@
void odr_destroy(ODR o)
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
{
odr_seterror(o, ONONE, 0);
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
{
odr_seterror(o, ONONE, 0);
- o->bp = (unsigned char *) buf;
- o->buf = (unsigned char *) buf;
+ o->op->bp = buf;
+ o->op->buf = buf;
o->op->can_grow = can_grow;
o->op->can_grow = can_grow;
- o->top = o->pos = 0;
- o->size = len;
+ o->op->top = o->op->pos = 0;
+ o->op->size = len;
}
char *odr_getbuf(ODR o, int *len, int *size)
{
}
char *odr_getbuf(ODR o, int *len, int *size)
{
- *len = o->top;
+ *len = o->op->top;
if (size)
if (size)
- *size = o->size;
- return (char*) o->buf;
+ *size = o->op->size;
+ return o->op->buf;
+}
+
+int odr_offset(ODR o)
+{
+ return o->op->bp - o->op->buf;
}
void odr_printf(ODR o, const char *fmt, ...)
}
void odr_printf(ODR o, const char *fmt, ...)