From: Howard Chu Date: Mon, 24 Jan 2005 03:40:29 +0000 (+0000) Subject: Added ldif_countlines() X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~271 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=67583f45eb2fafd9a5455a3c69aedf7ec7cbb26a;p=openldap Added ldif_countlines() --- 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 ) {