home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <string.h>
-
- #include "defines.h"
- #include "proto.h"
-
- static int pads(char *cpBuf, int wBuf, char *cpPad)
- {
- char *cp = cpBuf;
- while( cp < cpBuf+wBuf && isanyof(*cp, cpPad) )
- ++cp;
- return cp - cpBuf;
- }
-
- static int notpads(char *cpBuf, int wBuf, char *cpPad)
- {
- char *cp = cpBuf;
- while( cp < cpBuf+wBuf && !isanyof(*cp, cpPad) )
- ++cp;
- return cp - cpBuf;
- }
-
- static char *cpaToken[256];
- static char caTokens[1024];
-
- int tokenize(char ***cpppToken, char *cpBuf, int wBuf, char *cpPad)
- {
- char *cpi = cpBuf;
- char *cpo = caTokens;
- int pcnt = 0;
- int n;
-
- cpaToken[pcnt] = NULL;
- for ( ; cpi < cpBuf+wBuf-1; ) {
- if ((n = pads(cpi, (cpBuf+wBuf)-cpi, cpPad)) == 0) {
- n = notpads(cpi, (cpBuf+wBuf)-cpi, cpPad);
- cpaToken[pcnt++] = cpo;
- cpaToken[pcnt] = NULL;
- memcpy(cpo, cpi, n);
- cpo += n;
- *cpo++ = NUL;
- }
- cpi += n;
- }
- *cpppToken = cpaToken;
- return pcnt;
- }
-
-