Mercurial > noffle
diff util.c @ 26:526a4c34ee2e noffle
[svn] Applied patch from Jim Hague: support for local groups / new command
line options --create and --cancel.
author | enz |
---|---|
date | Sat, 29 Apr 2000 15:45:56 +0100 |
parents | 04124a4423d4 |
children | 8e972daaeab9 |
line wrap: on
line diff
--- a/util.c Sat Apr 29 14:37:59 2000 +0100 +++ b/util.c Sat Apr 29 15:45:56 2000 +0100 @@ -1,7 +1,7 @@ /* util.c - $Id: util.c 3 2000-01-04 11:35:42Z enz $ + $Id: util.c 32 2000-04-29 14:45:56Z enz $ */ #include "util.h" @@ -100,6 +100,38 @@ } } +const char * +Utl_getHeaderLn( Str result, const char *p ) +{ + const char * res = Utl_getLn( result, p ); + + /* Look for followon line if this isn't a blank line. */ + if ( res != NULL && !isspace( result[ 0 ] ) ) + while ( res != NULL && res[ 0 ] != '\n' && isspace( res[ 0 ] ) ) + { + Str nextLine; + const char *here; + char *next; + + here = res; + res = Utl_getLn( nextLine, res ); + next = Utl_stripWhiteSpace( nextLine ); + + if ( next[ 0 ] != '\0' ) + { + Utl_catStr( result, " " ); + Utl_catStr( result, next ); + } + else + { + res = here; + break; + } + } + + return res; +} + void Utl_toLower( Str line ) { @@ -139,11 +171,27 @@ void Utl_cpyStrN( Str dst, const char *src, size_t n ) { + if ( n > MAXCHAR ) + n = MAXCHAR; dst[ 0 ] = '\0'; strncat( dst, src, n ); } void +Utl_catStr( Str dst, const char *src ) +{ + strncat( dst, src, MAXCHAR - strlen( dst ) ); +} + +void +Utl_catStrN( Str dst, const char *src, size_t n ) +{ + if ( n > MAXCHAR - strlen( dst ) ) + n = MAXCHAR - strlen( dst ); + strncat( dst, src, n ); +} + +void Utl_stamp( Str file ) { FILE *f;