File: splitmem.c

package info (click to toggle)
ngetty 1.0-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 304 kB
  • ctags: 207
  • sloc: ansic: 1,503; makefile: 236; sh: 109; asm: 100
file content (17 lines) | stat: -rw-r--r-- 321 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
unsigned int splitmem(char **v,char *xbuf, char c) /*EXTRACT_INCL*/{
  char **w, *s;
  unsigned int n=1;
  for (s=xbuf; *s; s++) if (*s==c) n++;
  if (v) {
    w=v;
    *w++=xbuf;
    for (s=xbuf; ;) {
      while (*s && *s!=c) s++;
      if (*s==0) break;
      *s=0;
      *w++ = ++s;
    }
    *w=0;
  }
  return n;
}