ReactOS 0.4.16-dev-125-g798ea90
Strntok.c File Reference
#include <string.h>
#include "Strn.h"
Include dependency graph for Strntok.c:

Go to the source code of this file.

Functions

charStrtok (char *buf, const char *delims)
 
int Strntok (char *dstTokenStart, size_t tokenSize, char *buf, const char *delims)
 

Function Documentation

◆ Strntok()

int Strntok ( char dstTokenStart,
size_t  tokenSize,
char buf,
const char delims 
)

Definition at line 80 of file Strntok.c.

81{
82 static char *p = NULL;
83 char *end;
84 char *lim;
85 char *dst;
86 int len;
87
88 dst = dstTokenStart;
89 lim = dst + tokenSize - 1; /* Leave room for nul byte. */
90
91 if (buf != NULL) {
92 p = buf;
93 } else {
94 if (p == NULL) {
95 *dst = '\0';
96 return (-1); /* No more tokens. */
97 }
98 }
99
100 for (end = p; ; end++) {
101 if (*end == '\0') {
102 p = NULL; /* This is the last token. */
103 break;
104 }
105 if (strchr(delims, (int) *end) != NULL) {
106 ++end;
107 p = end;
108 break;
109 }
110 if (dst < lim) /* Don't overrun token size. */
111 *dst++ = *end;
112 }
113 *dst = '\0';
114 len = (int) (dst - dstTokenStart); /* Return length of token. */
115
116#if (STRN_ZERO_PAD == 1)
117 /* Pad with zeros. */
118 for (++dst; dst <= lim; )
119 *dst++ = 0;
120#endif /* STRN_ZERO_PAD */
121
122 return (len);
123} /* Strntok */
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint GLuint end
Definition: gl.h:1545
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722

◆ Strtok()

char * Strtok ( char buf,
const char delims 
)

Definition at line 35 of file Strntok.c.

36{
37 static char *p = NULL;
38 char *start, *end;
39
40 if (buf != NULL) {
41 p = buf;
42 } else {
43 if (p == NULL)
44 return (NULL); /* No more tokens. */
45 }
46 for (start = p, end = p; ; end++) {
47 if (*end == '\0') {
48 p = NULL; /* This is the last token. */
49 break;
50 }
51 if (strchr(delims, (int) *end) != NULL) {
52 *end++ = '\0';
53 p = end;
54 break;
55 }
56 }
57 return (start);
58} /* Strtok */
GLuint start
Definition: gl.h:1545