NeXus  4.4.3
 All Data Structures Files Functions Variables Typedefs Macros Pages
stptok.c
Go to the documentation of this file.
1 /*
2 ** stptok() -- public domain by Ray Gardner, modified by Bob Stout
3 **
4 ** You pass this function a string to parse, a buffer to receive the
5 ** "token" that gets scanned, the length of the buffer, and a string of
6 ** "break" characters that stop the scan. It will copy the string into
7 ** the buffer up to any of the break characters, or until the buffer is
8 ** full, and will always leave the buffer null-terminated. It will
9 ** return a pointer to the first non-breaking character after the one
10 ** that stopped the scan.
11 */
12 
13 #include <string.h>
14 #include <stdlib.h>
15 #include "nx_stptok.h"
16 
17 char *stptok(const char *s, char *tok, size_t toklen, char *brk)
18 {
19  char *lim, *b;
20 
21  if (!*s)
22  return NULL;
23 
24  lim = tok + toklen - 1;
25  while ( *s && tok < lim )
26  {
27  for ( b = brk; *b; b++ )
28  {
29  if ( *s == *b )
30  {
31  *tok = 0;
32  return (char *)(s+1);
33  }
34  }
35  *tok++ = *s++;
36  }
37  *tok = 0;
38  return (char *)s;
39 }
40 /*---------------------------------------------------------------------------*/
41 /*
42  static char *SkipSpace(char *pText)
43  {
44  char *pRes;
45 
46  pRes = pText;
47  while(*pRes)
48  {
49  if( (*pRes != ' ') && (*pRes != '\t') && (*pRes != '\r') )
50  {
51  return pRes;
52  }
53  pRes++;
54  }
55  return NULL;
56  }
57 */
58 
59 
60 
61 
62 
63 
64 
65 
66 
char * stptok(const char *s, char *tok, size_t toklen, char *brk)
Definition: stptok.c:17