diff options
author | murray <murray@FreeBSD.org> | 2000-11-08 11:57:03 +0000 |
---|---|---|
committer | murray <murray@FreeBSD.org> | 2000-11-08 11:57:03 +0000 |
commit | 6cea38cf1a4a0b20f777f7cc06c6a06f16afda10 (patch) | |
tree | 371b15b9a944b88058132c50c9878fd115b01437 /lib/libutil/property.c | |
parent | bbaa0eac15144a50028913f7f32940543d8114d1 (diff) | |
download | FreeBSD-src-6cea38cf1a4a0b20f777f7cc06c6a06f16afda10.zip FreeBSD-src-6cea38cf1a4a0b20f777f7cc06c6a06f16afda10.tar.gz |
Added PROPERTY_MAX_VALUE and PROPERTY_MAX_NAME defines to libutil.h so
that applications know how large of a buffer they must allocate before
calling property_find(). Also added a $FreeBSD$ tag while I'm here.
Approved by: jkh
Diffstat (limited to 'lib/libutil/property.c')
-rw-r--r-- | lib/libutil/property.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libutil/property.c b/lib/libutil/property.c index 23714a0..ba8eef9 100644 --- a/lib/libutil/property.c +++ b/lib/libutil/property.c @@ -28,6 +28,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD$ + * */ #include <ctype.h> @@ -39,9 +41,6 @@ #include <sys/types.h> #include <libutil.h> -#define MAX_NAME 64 -#define MAX_VALUE 512 - static properties property_alloc(char *name, char *value) { @@ -58,8 +57,8 @@ properties properties_read(int fd) { properties head, ptr; - char hold_n[MAX_NAME + 1]; - char hold_v[MAX_VALUE + 1]; + char hold_n[PROPERTY_MAX_NAME + 1]; + char hold_v[PROPERTY_MAX_VALUE + 1]; char buf[BUFSIZ * 4]; int bp, n, v, max; enum { LOOK, COMMENT, NAME, VALUE, MVALUE, COMMIT, FILL, STOP } state; @@ -97,7 +96,7 @@ properties_read(int fd) continue; } else if (isalnum(ch) || ch == '_') { - if (n >= MAX_NAME) { + if (n >= PROPERTY_MAX_NAME) { n = 0; state = COMMENT; } @@ -146,7 +145,7 @@ properties_read(int fd) state = COMMIT; } else { - if (v >= MAX_VALUE) { + if (v >= PROPERTY_MAX_VALUE) { state = COMMENT; v = n = 0; break; @@ -158,7 +157,7 @@ properties_read(int fd) case MVALUE: /* multiline value */ - if (v >= MAX_VALUE) { + if (v >= PROPERTY_MAX_VALUE) { warn("properties_read: value exceeds max length"); state = COMMENT; n = v = 0; |