various doxygen fixes
[asterisk-bristuff.git] / strcompat.c
bloba5502c25ebaae7f49396046ca9089a0a1a771ce0
1 /*
2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2006, Digium, Inc.
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
17 /*! \file
19 * \brief Compatibility functions for strsep and strtoq missing on Solaris
22 #include <sys/types.h>
23 #include <stdio.h>
25 #include "asterisk.h"
27 #include "asterisk/compat.h"
29 #ifndef HAVE_STRSEP
30 char *strsep(char **str, const char *delims)
32 char *token;
34 if (!*str) {
35 /* No more tokens */
36 return NULL;
39 token = *str;
40 while (**str != '\0') {
41 if (strchr(delims, **str)) {
42 **str = '\0';
43 (*str)++;
44 return token;
46 (*str)++;
49 /* There is no other token */
50 *str = NULL;
52 return token;
54 #endif
56 #ifndef HAVE_SETENV
57 int setenv(const char *name, const char *value, int overwrite)
59 unsigned char *buf;
60 int buflen;
62 buflen = strlen(name) + strlen(value) + 2;
63 if (!(buf = alloca(buflen)))
64 return -1;
66 if (!overwrite && getenv(name))
67 return 0;
69 snprintf(buf, buflen, "%s=%s", name, value);
71 return putenv(buf);
73 #endif
75 #ifndef HAVE_UNSETENV
76 int unsetenv(const char *name)
78 return setenv(name, "", 0);
80 #endif