Changeset 42abb10 for util.c


Ignore:
Timestamp:
Sep 16, 2002, 2:51:33 PM (18 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
af2ca19
Parents:
425c013
Message:
There is now a 'zlist' command that acts like 'znol -l'
'l' is bound to 'zlist'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r5145235 r42abb10  
    148148}
    149149
    150 /* skips n tokens and returns where that would be.
    151  * TODO: handle quotes more sanely. */
    152150char *skiptokens(char *buff, int n) {
     151  /* skips n tokens and returns where that would be.
     152   * TODO: handle quotes more sanely. */
     153 
    153154  int inquotes=0;
    154155  while (*buff && n>0) {
     
    288289
    289290char *stristr(char *a, char *b) {
     291  /* exactly like strstr but it's case insensitive */
    290292  char *x, *y, *ret;
    291293
     
    306308}
    307309
    308 /* Caller must free response.
    309    Takes in strings which are space-separated lists of tokens
    310    and returns a single string containing no token more than once.
    311    If prohibit is non-null, no token may start with a character
    312    in prohibit.
    313 */
    314310char *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 
    315318  char *cat, **tok;
    316319  int toklen, i, j, first=1;
     
    338341}
    339342
    340 
    341 
    342 /* returns if a string is only whitespace */
    343343int only_whitespace(char *s) {
     344  /* returns if a string is only whitespace */
     345
    344346  int i;
    345347  for (i=0; s[i]; i++) {
     
    349351}
    350352
     353/* hooks for doing memory allocation et. al. in owl */
     354
    351355void *owl_malloc(size_t size) {
    352356  return(malloc(size));
     
    365369}
    366370
    367 /* allocates memory and returns the string or null.
    368  * caller must free the string.
    369  * from Linux sprintf man page.
    370  */
    371371char *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 
    372377  int n, size = 100;
    373378  char *p;
    374379  va_list ap;
    375   if ((p = owl_malloc (size)) == NULL)
    376     return NULL;
     380  if ((p = owl_malloc (size)) == NULL) return (NULL);
    377381  while (1) {
    378382    /* Try to print in the allocated space. */
     
    427431}
    428432
    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  */
    433433char *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 
    434439  char *out;
    435440  int   outlen, tolen, fromlen, inpos=0, outpos=0;
Note: See TracChangeset for help on using the changeset viewer.