- Timestamp:
- Sep 16, 2002, 2:51:33 PM (22 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- af2ca19
- Parents:
- 425c013
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
util.c
r5145235 r42abb10 148 148 } 149 149 150 /* skips n tokens and returns where that would be.151 * TODO: handle quotes more sanely. */152 150 char *skiptokens(char *buff, int n) { 151 /* skips n tokens and returns where that would be. 152 * TODO: handle quotes more sanely. */ 153 153 154 int inquotes=0; 154 155 while (*buff && n>0) { … … 288 289 289 290 char *stristr(char *a, char *b) { 291 /* exactly like strstr but it's case insensitive */ 290 292 char *x, *y, *ret; 291 293 … … 306 308 } 307 309 308 /* Caller must free response.309 Takes in strings which are space-separated lists of tokens310 and returns a single string containing no token more than once.311 If prohibit is non-null, no token may start with a character312 in prohibit.313 */314 310 char *owl_util_uniq(char *A, char *B, char *prohibit) { 311 /* Caller must free response. 312 Takes in strings which are space-separated lists of tokens 313 and returns a single string containing no token more than once. 314 If prohibit is non-null, no token may start with a character 315 in prohibit. 316 */ 317 315 318 char *cat, **tok; 316 319 int toklen, i, j, first=1; … … 338 341 } 339 342 340 341 342 /* returns if a string is only whitespace */343 343 int only_whitespace(char *s) { 344 /* returns if a string is only whitespace */ 345 344 346 int i; 345 347 for (i=0; s[i]; i++) { … … 349 351 } 350 352 353 /* hooks for doing memory allocation et. al. in owl */ 354 351 355 void *owl_malloc(size_t size) { 352 356 return(malloc(size)); … … 365 369 } 366 370 367 /* allocates memory and returns the string or null.368 * caller must free the string.369 * from Linux sprintf man page.370 */371 371 char *owl_sprintf(const char *fmt, ...) { 372 /* allocates memory and returns the string or null. 373 * caller must free the string. 374 * from Linux sprintf man page. 375 */ 376 372 377 int n, size = 100; 373 378 char *p; 374 379 va_list ap; 375 if ((p = owl_malloc (size)) == NULL) 376 return NULL; 380 if ((p = owl_malloc (size)) == NULL) return (NULL); 377 381 while (1) { 378 382 /* Try to print in the allocated space. */ … … 427 431 } 428 432 429 /* Caller must free returned string.430 * Returns a string with any occurances of 'from' replaced with 'to'.431 * Does not currently handle backslash quoting, but may in the future.432 */433 433 char *owl_util_substitute(char *in, char *from, char *to) { 434 /* Caller must free returned string. 435 * Returns a string with any occurances of 'from' replaced with 'to'. 436 * Does not currently handle backslash quoting, but may in the future. 437 */ 438 434 439 char *out; 435 440 int outlen, tolen, fromlen, inpos=0, outpos=0;
Note: See TracChangeset
for help on using the changeset viewer.