From 67583f45eb2fafd9a5455a3c69aedf7ec7cbb26a Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 24 Jan 2005 03:40:29 +0000 Subject: [PATCH] Added ldif_countlines() --- include/ldif.h | 3 +++ libraries/liblutil/ldif.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/ldif.h b/include/ldif.h index 88c062217e..fec4b65ae9 100644 --- a/include/ldif.h +++ b/include/ldif.h @@ -75,6 +75,9 @@ ldif_fetch_url LDAP_P(( LDAP_LDIF_F( char * ) ldif_getline LDAP_P(( char **next )); +LDAP_LDIF_F( int ) +ldif_countlines LDAP_P(( LDAP_CONST char *line )); + LDAP_LDIF_F( int ) ldif_read_record LDAP_P(( FILE *fp, diff --git a/libraries/liblutil/ldif.c b/libraries/liblutil/ldif.c index 79f1140611..e0412b2ae9 100644 --- a/libraries/liblutil/ldif.c +++ b/libraries/liblutil/ldif.c @@ -308,6 +308,21 @@ ldif_parse_line2( * which it updates and must be supplied on subsequent calls. */ +int +ldif_countlines( LDAP_CONST char *buf ) +{ + char *nl; + int ret = 0; + + if ( !buf ) return ret; + + for ( nl = strchr(buf, '\n'); nl; nl = strchr(nl, '\n') ) { + nl++; + if ( *nl != ' ' ) ret++; + } + return ret; +} + char * ldif_getline( char **next ) { -- 2.39.5