00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <net-snmp/net-snmp-config.h>
00033
00034 #if !HAVE_STRTOK_R
00035
00036 #ifndef WIN32
00037 #include <sys/cdefs.h>
00038 #endif
00039
00040 #include <string.h>
00041
00042
00043
00044
00045 char *
00046 strtok_r(char *s, const char *delim, char **lasts)
00047 {
00048 const char *spanp;
00049 int c, sc;
00050 char *tok;
00051
00052
00053
00054
00055
00056 if (s == NULL && (s = *lasts) == NULL)
00057 return (NULL);
00058
00059
00060
00061
00062 cont:
00063 c = *s++;
00064 for (spanp = delim; (sc = *spanp++) != 0;) {
00065 if (c == sc)
00066 goto cont;
00067 }
00068
00069 if (c == 0) {
00070 *lasts = NULL;
00071 return (NULL);
00072 }
00073 tok = s - 1;
00074
00075
00076
00077
00078
00079 for (;;) {
00080 c = *s++;
00081 spanp = delim;
00082 do {
00083 if ((sc = *spanp++) == c) {
00084 if (c == 0)
00085 s = NULL;
00086 else
00087 s[-1] = 0;
00088 *lasts = s;
00089 return (tok);
00090 }
00091 } while (sc != 0);
00092 }
00093
00094 }
00095 #endif