Mercurial > noffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 25:ab6cf19be6d3 | 26:526a4c34ee2e |
|---|---|
| 1 /* | 1 /* |
| 2 util.c | 2 util.c |
| 3 | 3 |
| 4 $Id: util.c 3 2000-01-04 11:35:42Z enz $ | 4 $Id: util.c 32 2000-04-29 14:45:56Z enz $ |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "util.h" | 7 #include "util.h" |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <ctype.h> | 9 #include <ctype.h> |
| 98 return p + 1; | 98 return p + 1; |
| 99 --p; | 99 --p; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 const char * | |
| 104 Utl_getHeaderLn( Str result, const char *p ) | |
| 105 { | |
| 106 const char * res = Utl_getLn( result, p ); | |
| 107 | |
| 108 /* Look for followon line if this isn't a blank line. */ | |
| 109 if ( res != NULL && !isspace( result[ 0 ] ) ) | |
| 110 while ( res != NULL && res[ 0 ] != '\n' && isspace( res[ 0 ] ) ) | |
| 111 { | |
| 112 Str nextLine; | |
| 113 const char *here; | |
| 114 char *next; | |
| 115 | |
| 116 here = res; | |
| 117 res = Utl_getLn( nextLine, res ); | |
| 118 next = Utl_stripWhiteSpace( nextLine ); | |
| 119 | |
| 120 if ( next[ 0 ] != '\0' ) | |
| 121 { | |
| 122 Utl_catStr( result, " " ); | |
| 123 Utl_catStr( result, next ); | |
| 124 } | |
| 125 else | |
| 126 { | |
| 127 res = here; | |
| 128 break; | |
| 129 } | |
| 130 } | |
| 131 | |
| 132 return res; | |
| 133 } | |
| 134 | |
| 103 void | 135 void |
| 104 Utl_toLower( Str line ) | 136 Utl_toLower( Str line ) |
| 105 { | 137 { |
| 106 char *p; | 138 char *p; |
| 107 | 139 |
| 137 } | 169 } |
| 138 | 170 |
| 139 void | 171 void |
| 140 Utl_cpyStrN( Str dst, const char *src, size_t n ) | 172 Utl_cpyStrN( Str dst, const char *src, size_t n ) |
| 141 { | 173 { |
| 174 if ( n > MAXCHAR ) | |
| 175 n = MAXCHAR; | |
| 142 dst[ 0 ] = '\0'; | 176 dst[ 0 ] = '\0'; |
| 177 strncat( dst, src, n ); | |
| 178 } | |
| 179 | |
| 180 void | |
| 181 Utl_catStr( Str dst, const char *src ) | |
| 182 { | |
| 183 strncat( dst, src, MAXCHAR - strlen( dst ) ); | |
| 184 } | |
| 185 | |
| 186 void | |
| 187 Utl_catStrN( Str dst, const char *src, size_t n ) | |
| 188 { | |
| 189 if ( n > MAXCHAR - strlen( dst ) ) | |
| 190 n = MAXCHAR - strlen( dst ); | |
| 143 strncat( dst, src, n ); | 191 strncat( dst, src, n ); |
| 144 } | 192 } |
| 145 | 193 |
| 146 void | 194 void |
| 147 Utl_stamp( Str file ) | 195 Utl_stamp( Str file ) |
