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
Update NEWS
[yaz-moved-to-github.git]
/
src
/
odr.c
diff --git
a/src/odr.c
b/src/odr.c
index
beb2986
..
142249f
100644
(file)
--- a/
src/odr.c
+++ b/
src/odr.c
@@
-1,9
+1,6
@@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
* See the file LICENSE for details.
- *
- * $Id: odr.c,v 1.16 2007-03-19 21:08:13 adam Exp $
- *
*/
/**
*/
/**
@@
-25,12
+22,12
@@
#include <yaz/snprintf.h>
#include "odr-priv.h"
#include <yaz/snprintf.h>
#include "odr-priv.h"
-static int log_level=0;
-static int log_level_initialized=0;
+static int log_level = 0;
+static int log_level_initialized = 0;
Odr_null *ODR_NULLVAL = (Odr_null *) "NULL"; /* the presence of a null value */
Odr_null *ODR_NULLVAL = (Odr_null *) "NULL"; /* the presence of a null value */
-Odr_null *odr_nullval (void)
+Odr_null *odr_nullval(void)
{
return ODR_NULLVAL;
}
{
return ODR_NULLVAL;
}
@@
-67,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)
{
@@
-147,10
+144,10
@@
void odr_FILE_write(ODR o, void *handle, int type,
fputs("\n", (FILE*) handle);
}
#endif
fputs("\n", (FILE*) handle);
}
#endif
- for (i = 0; i<len; i++)
+ for (i = 0; i < len; i++)
{
unsigned c = ((const unsigned char *) buf)[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;
@@
-178,8
+175,9
@@
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_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))
@@
-196,7
+194,7
@@
int odr_set_charset(ODR o, const char *to, const char *from)
o->op->iconv_handle = 0;
if (to && from)
{
o->op->iconv_handle = 0;
if (to && from)
{
- o->op->iconv_handle = yaz_iconv_open (to, from);
+ o->op->iconv_handle = yaz_iconv_open(to, from);
if (o->op->iconv_handle == 0)
return -1;
}
if (o->op->iconv_handle == 0)
return -1;
}
@@
-209,13
+207,13
@@
ODR odr_createmem(int direction)
ODR o;
if (!log_level_initialized)
{
ODR o;
if (!log_level_initialized)
{
- log_level=yaz_log_module_level("odr");
- log_level_initialized=1;
+ log_level = yaz_log_module_level("odr");
+ log_level_initialized = 1;
}
}
- if (!(o = (ODR)xmalloc(sizeof(*o))))
+ if (!(o = (ODR) xmalloc(sizeof(*o))))
return 0;
return 0;
- o->op = (struct Odr_private *) xmalloc (sizeof(*o->op));
+ o->op = (struct Odr_private *) xmalloc(sizeof(*o->op));
o->direction = direction;
o->buf = 0;
o->size = o->pos = o->top = 0;
o->direction = direction;
o->buf = 0;
o->size = o->pos = o->top = 0;
@@
-226,7
+224,7
@@
ODR odr_createmem(int direction)
o->op->iconv_handle = 0;
odr_setprint(o, stderr);
odr_reset(o);
o->op->iconv_handle = 0;
odr_setprint(o, stderr);
odr_reset(o);
- yaz_log (log_level, "odr_createmem dir=%d o=%p", direction, o);
+ yaz_log(log_level, "odr_createmem dir=%d o=%p", direction, o);
return o;
}
return o;
}
@@
-234,8
+232,8
@@
void odr_reset(ODR o)
{
if (!log_level_initialized)
{
{
if (!log_level_initialized)
{
- log_level=yaz_log_module_level("odr");
- log_level_initialized=1;
+ log_level = yaz_log_module_level("odr");
+ log_level_initialized = 1;
}
odr_seterror(o, ONONE, 0);
}
odr_seterror(o, ONONE, 0);
@@
-254,9
+252,9
@@
void odr_reset(ODR o)
o->op->lenlen = 1;
if (o->op->iconv_handle != 0)
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
o->op->lenlen = 1;
if (o->op->iconv_handle != 0)
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
- yaz_log (log_level, "odr_reset o=%p", o);
+ 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);
@@
-265,17
+263,16
@@
void odr_destroy(ODR o)
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)
- yaz_iconv_close (o->op->iconv_handle);
+ yaz_iconv_close(o->op->iconv_handle);
xfree(o->op);
xfree(o);
xfree(o->op);
xfree(o);
- yaz_log (log_level, "odr_destroy o=%p", o);
+ yaz_log(log_level, "odr_destroy o=%p", o);
}
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
{
odr_seterror(o, ONONE, 0);
o->bp = (unsigned char *) buf;
}
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->can_grow = can_grow;
o->top = o->pos = 0;
o->buf = (unsigned char *) buf;
o->op->can_grow = can_grow;
o->top = o->pos = 0;
@@
-303,6
+300,7
@@
void odr_printf(ODR o, const char *fmt, ...)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab