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
/
ber_int.c
diff --git
a/src/ber_int.c
b/src/ber_int.c
index
d181671
..
40dbb0c
100644
(file)
--- a/
src/ber_int.c
+++ b/
src/ber_int.c
@@
-1,9
+1,9
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_int.c
* \brief Implements BER INTEGER encoding and decoding.
*
* \file ber_int.c
* \brief Implements BER INTEGER encoding and decoding.
*
@@
-28,7
+28,7
@@
#include "odr-priv.h"
static int ber_encinteger(ODR o, Odr_int val);
#include "odr-priv.h"
static int ber_encinteger(ODR o, Odr_int val);
-static int ber_decinteger(const unsigned char *buf, Odr_int *val, int max);
+static int ber_decinteger(const char *buf, Odr_int *val, int max);
int ber_integer(ODR o, Odr_int *val)
{
int ber_integer(ODR o, Odr_int *val)
{
@@
-37,12
+37,12
@@
int ber_integer(ODR o, Odr_int *val)
switch (o->direction)
{
case ODR_DECODE:
switch (o->direction)
{
case ODR_DECODE:
- if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0)
+ if ((res = ber_decinteger(o->op->bp, val, odr_max(o))) <= 0)
{
odr_seterror(o, OPROTO, 50);
return 0;
}
{
odr_seterror(o, OPROTO, 50);
return 0;
}
- o->bp += res;
+ o->op->bp += res;
return 1;
case ODR_ENCODE:
if ((res = ber_encinteger(o, *val)) < 0)
return 1;
case ODR_ENCODE:
if ((res = ber_encinteger(o, *val)) < 0)
@@
-66,7
+66,7
@@
int ber_encinteger(ODR o, Odr_int val)
size_t i;
for (i = sizeof(uval); i > 0; )
{
size_t i;
for (i = sizeof(uval); i > 0; )
{
- tmp[--i] = uval;
+ tmp[--i] = (unsigned char ) uval; /* only want lower 8 bits */
uval >>= 8;
}
for (i = 0; i < sizeof(uval)-1; i++)
uval >>= 8;
}
for (i = 0; i < sizeof(uval)-1; i++)
@@
-77,7
+77,7
@@
int ber_encinteger(ODR o, Odr_int val)
len = sizeof(uval) - i;
if (ber_enclen(o, len, 1, 1) != 1)
return -1;
len = sizeof(uval) - i;
if (ber_enclen(o, len, 1, 1) != 1)
return -1;
- if (odr_write(o, (unsigned char*) tmp + i, len) < 0)
+ if (odr_write(o, (const char *) tmp + i, len) < 0)
return -1;
return 0;
}
return -1;
return 0;
}
@@
-85,30
+85,29
@@
int ber_encinteger(ODR o, Odr_int val)
/*
* Returns: Number of bytes read or 0 if no match, -1 if error.
*/
/*
* Returns: Number of bytes read or 0 if no match, -1 if error.
*/
-int ber_decinteger(const unsigned char *buf, Odr_int *val, int max)
+int ber_decinteger(const char *buf, Odr_int *val, int max)
{
unsigned long long uval = 0;
{
unsigned long long uval = 0;
- int len;
- size_t i;
+ int i, len;
int res;
int res;
- const unsigned char *b = buf;
+ const unsigned char *b = (const unsigned char *) buf;
- if ((res = ber_declen(b, &len, max)) < 0)
+ if ((res = ber_declen((const char *) b, &len, max)) < 0)
return -1;
if (len+res > max || len < 0) /* out of bounds or indefinite encoding */
return -1;
if (len+res > max || len < 0) /* out of bounds or indefinite encoding */
- return -1;
+ return -1;
if (len > (int) sizeof(uval)) /* let's be reasonable, here */
return -1;
b += res;
if (*b & 0x80)
if (len > (int) sizeof(uval)) /* let's be reasonable, here */
return -1;
b += res;
if (*b & 0x80)
- for (i = 0; i < sizeof(uval) - len; i++)
+ for (i = 0; i < (int) sizeof(uval) - len; i++)
uval = (uval << 8) + 0xFF;
for (i = 0; i < len; i++)
uval = (uval << 8) + b[i];
*val = uval;
b += len;
uval = (uval << 8) + 0xFF;
for (i = 0; i < len; i++)
uval = (uval << 8) + b[i];
*val = uval;
b += len;
- return b - buf;
+ return (const char *) b - buf;
}
/*
* Local variables:
}
/*
* Local variables: