From 210f86abdf36eb11b273e3691e126f199068db7f Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 31 Jul 2018 19:38:09 +0000 Subject: [PATCH] Relocate some public functions above the internal functions comment. ok claudio@ --- usr.bin/ldap/ber.c | 126 +++++++++++++++++++++--------------------- usr.sbin/ldapd/ber.c | 126 +++++++++++++++++++++--------------------- usr.sbin/snmpd/ber.c | 126 +++++++++++++++++++++--------------------- usr.sbin/ypldap/ber.c | 126 +++++++++++++++++++++--------------------- 4 files changed, 252 insertions(+), 252 deletions(-) diff --git a/usr.bin/ldap/ber.c b/usr.bin/ldap/ber.c index 981595fc4ce..f2543f23bbe 100644 --- a/usr.bin/ldap/ber.c +++ b/usr.bin/ldap/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.16 2018/07/31 11:37:18 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.17 2018/07/31 19:38:09 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struct ber_oid *o) 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 * ber_add_oid(struct ber_element *prev, struct ber_oid *o) { @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) } +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 * @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, struct ber_element *root) 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 * @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root) 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 */ @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct ber_element *elm) 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 ber_getc(struct ber *b, u_char *c) { @@ -1266,29 +1292,3 @@ ber_read(struct ber *ber, void *buf, size_t 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); -} diff --git a/usr.sbin/ldapd/ber.c b/usr.sbin/ldapd/ber.c index e30f882aadd..08280dbeed7 100644 --- a/usr.sbin/ldapd/ber.c +++ b/usr.sbin/ldapd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.26 2018/07/31 11:37:18 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.27 2018/07/31 19:38:09 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struct ber_oid *o) 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 * ber_add_oid(struct ber_element *prev, struct ber_oid *o) { @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) } +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 * @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, struct ber_element *root) 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 * @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root) 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 */ @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct ber_element *elm) 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 ber_getc(struct ber *b, u_char *c) { @@ -1266,29 +1292,3 @@ ber_read(struct ber *ber, void *buf, size_t 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); -} diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c index e9f7b45df1c..0f9b51d4a60 100644 --- a/usr.sbin/snmpd/ber.c +++ b/usr.sbin/snmpd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.45 2018/07/31 11:37:18 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.46 2018/07/31 19:38:09 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struct ber_oid *o) 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 * ber_add_oid(struct ber_element *prev, struct ber_oid *o) { @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) } +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 * @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, struct ber_element *root) 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 * @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root) 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 */ @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct ber_element *elm) 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 ber_getc(struct ber *b, u_char *c) { @@ -1266,29 +1292,3 @@ ber_read(struct ber *ber, void *buf, size_t 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); -} diff --git a/usr.sbin/ypldap/ber.c b/usr.sbin/ypldap/ber.c index 0da4bb3aba1..5829298a650 100644 --- a/usr.sbin/ypldap/ber.c +++ b/usr.sbin/ypldap/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.28 2018/07/31 11:37:18 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.29 2018/07/31 19:38:09 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struct ber_oid *o) 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 * ber_add_oid(struct ber_element *prev, struct ber_oid *o) { @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) } +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 * @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, struct ber_element *root) 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 * @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root) 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 */ @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct ber_element *elm) 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 ber_getc(struct ber *b, u_char *c) { @@ -1266,29 +1292,3 @@ ber_read(struct ber *ber, void *buf, size_t 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); -} -- 2.20.1