Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

strtok_r.c

Go to the documentation of this file.
00001 /* $Id$ */
00002 /*
00003  * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
00004  * (Royal Institute of Technology, Stockholm, Sweden).
00005  * All rights reserved.
00006  * 
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  * 
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 
00018  * 3. Neither the name of the Institute nor the names of its contributors
00019  *    may be used to endorse or promote products derived from this software
00020  *    without specific prior written permission.
00021  * 
00022  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  */
00034 
00035 #ifdef HAVE_CONFIG_H
00036 #include <config.h>
00037 /* $KTH: strtok_r.c,v 1.5 1999/12/02 16:58:53 joda Exp $" */
00038 #endif
00039 
00040 #include <string.h>
00041 
00042 #ifndef HAVE_STRTOK_R
00043 
00044 char *
00045 strtok_r(char *s1, const char *s2, char **lasts)
00046 {
00047   char *ret;
00048 
00049   if (s1 == NULL)
00050     s1 = *lasts;
00051   while(*s1 && strchr(s2, *s1))
00052     ++s1;
00053   if(*s1 == '\0')
00054     return NULL;
00055   ret = s1;
00056   while(*s1 && !strchr(s2, *s1))
00057     ++s1;
00058   if(*s1)
00059     *s1++ = '\0';
00060   *lasts = s1;
00061   return ret;
00062 }
00063 
00064 #endif /* HAVE_STRTOK_R */

Generated on Sun May 14 14:51:19 2006 by  doxygen 1.4.2