Changeset 260 for trunk/src/sh_string.c


Ignore:
Timestamp:
Dec 7, 2009, 10:00:29 PM (15 years ago)
Author:
katerina
Message:

Support event correlation (ticket #178).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_string.c

    r237 r260  
    238238{
    239239  return split_array_ws_int (line, nfields, lengths, SH_SPLIT_LIST);
     240}
     241
     242/* return a split() of a list contained in 'PREFIX\s*( list ).*'
     243 */
     244char ** split_array_braced (char *line, const char * prefix,
     245                            unsigned int * nfields, size_t * lengths)
     246{
     247  char * s = line;
     248  char * p;
     249
     250  while ( *s && isspace((int)*s) ) ++s;
     251  if (prefix && 0 != strncmp(s, prefix, strlen(prefix)))
     252    return NULL;
     253  s = &s[strlen(prefix)];
     254  while ( *s && isspace((int)*s) ) ++s;
     255  if (!s || (*s != '('))
     256    return NULL;
     257  ++s;
     258  p = strchr(s, ')');
     259  if (!p || (*p == *s))
     260    return NULL;
     261  *p = '\0';
     262  return split_array_list (s, nfields, lengths);
    240263}
    241264
Note: See TracChangeset for help on using the changeset viewer.