version 1.16, 2018/07/31 11:37:18 |
version 1.17, 2018/07/31 19:38:09 |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
int |
|
ber_oid_cmp(struct ber_oid *a, struct ber_oid *b) |
|
{ |
|
size_t i; |
|
for (i = 0; i < BER_MAX_OID_LEN; i++) { |
|
if (a->bo_id[i] != 0) { |
|
if (a->bo_id[i] == b->bo_id[i]) |
|
continue; |
|
else if (a->bo_id[i] < b->bo_id[i]) { |
|
/* b is a successor of a */ |
|
return (1); |
|
} else { |
|
/* b is a predecessor of a */ |
|
return (-1); |
|
} |
|
} else if (b->bo_id[i] != 0) { |
|
/* b is larger, but a child of a */ |
|
return (2); |
|
} else |
|
break; |
|
} |
|
|
|
/* b and a are identical */ |
|
return (0); |
|
} |
|
|
struct ber_element * |
struct ber_element * |
ber_add_oid(struct ber_element *prev, struct ber_oid *o) |
ber_add_oid(struct ber_element *prev, struct ber_oid *o) |
{ |
{ |
|
|
|
|
} |
} |
|
|
|
ssize_t |
|
ber_get_writebuf(struct ber *b, void **buf) |
|
{ |
|
if (b->br_wbuf == NULL) |
|
return -1; |
|
*buf = b->br_wbuf; |
|
return (b->br_wend - b->br_wbuf); |
|
} |
|
|
/* |
/* |
* write ber elements to the write buffer |
* write ber elements to the write buffer |
* |
* |
|
|
return (len); |
return (len); |
} |
} |
|
|
|
void |
|
ber_set_readbuf(struct ber *b, void *buf, size_t len) |
|
{ |
|
b->br_rbuf = b->br_rptr = buf; |
|
b->br_rend = (u_int8_t *)buf + len; |
|
} |
|
|
/* |
/* |
* read ber elements from the read buffer |
* read ber elements from the read buffer |
* |
* |
|
|
return (root->be_len + size); |
return (root->be_len + size); |
} |
} |
|
|
|
void |
|
ber_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *)) |
|
{ |
|
b->br_application = cb; |
|
} |
|
|
|
void |
|
ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t), |
|
void *arg) |
|
{ |
|
elm->be_cb = cb; |
|
elm->be_cbarg = arg; |
|
} |
|
|
|
void |
|
ber_free(struct ber *b) |
|
{ |
|
free(b->br_wbuf); |
|
} |
|
|
/* |
/* |
* internal functions |
* internal functions |
*/ |
*/ |
|
|
return totlen; |
return totlen; |
} |
} |
|
|
void |
|
ber_set_readbuf(struct ber *b, void *buf, size_t len) |
|
{ |
|
b->br_rbuf = b->br_rptr = buf; |
|
b->br_rend = (u_int8_t *)buf + len; |
|
} |
|
|
|
ssize_t |
|
ber_get_writebuf(struct ber *b, void **buf) |
|
{ |
|
if (b->br_wbuf == NULL) |
|
return -1; |
|
*buf = b->br_wbuf; |
|
return (b->br_wend - b->br_wbuf); |
|
} |
|
|
|
void |
|
ber_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *)) |
|
{ |
|
b->br_application = cb; |
|
} |
|
|
|
void |
|
ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t), |
|
void *arg) |
|
{ |
|
elm->be_cb = cb; |
|
elm->be_cbarg = arg; |
|
} |
|
|
|
void |
|
ber_free(struct ber *b) |
|
{ |
|
free(b->br_wbuf); |
|
} |
|
|
|
static ssize_t |
static ssize_t |
ber_getc(struct ber *b, u_char *c) |
ber_getc(struct ber *b, u_char *c) |
{ |
{ |
|
|
ber->br_offs += len; |
ber->br_offs += len; |
|
|
return len; |
return len; |
} |
|
|
|
int |
|
ber_oid_cmp(struct ber_oid *a, struct ber_oid *b) |
|
{ |
|
size_t i; |
|
for (i = 0; i < BER_MAX_OID_LEN; i++) { |
|
if (a->bo_id[i] != 0) { |
|
if (a->bo_id[i] == b->bo_id[i]) |
|
continue; |
|
else if (a->bo_id[i] < b->bo_id[i]) { |
|
/* b is a successor of a */ |
|
return (1); |
|
} else { |
|
/* b is a predecessor of a */ |
|
return (-1); |
|
} |
|
} else if (b->bo_id[i] != 0) { |
|
/* b is larger, but a child of a */ |
|
return (2); |
|
} else |
|
break; |
|
} |
|
|
|
/* b and a are identical */ |
|
return (0); |
|
} |
} |