Atrinik Client 2.5
client/porting.c
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00031 #include <global.h>
00032 
00033 #ifndef __CPROTO__
00034 
00035 #   ifndef HAVE_STRTOK_R
00036 
00039 char *strtok_r(char *s, const char *delim, char **save_ptr)
00040 {
00041     char *token;
00042 
00043     if (s == NULL)
00044     {
00045         s = *save_ptr;
00046     }
00047 
00048     /* Scan leading delimiters.  */
00049     s += strspn(s, delim);
00050 
00051     if (*s == '\0')
00052     {
00053         *save_ptr = s;
00054         return NULL;
00055     }
00056 
00057     /* Find the end of the token.  */
00058     token = s;
00059     s = strpbrk(token, delim);
00060 
00061     if (s == NULL)
00062     {
00063         /* This token finishes the string.  */
00064         *save_ptr = strchr(token, '\0');
00065     }
00066     else
00067     {
00068         /* Terminate the token and make *SAVE_PTR point past it.  */
00069         *s = '\0';
00070         *save_ptr = s + 1;
00071     }
00072 
00073     return token;
00074 }
00075 
00076 #   endif
00077 
00078 #endif