12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
*/ |
*/ |
|
|
|
16 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
17 |
#include <config.h> |
#include <config.h> |
18 |
#endif |
#endif |
25 |
|
|
26 |
#include "wptTypes.h" |
#include "wptTypes.h" |
27 |
|
|
28 |
|
|
29 |
/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */ |
/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */ |
30 |
char* |
char* |
31 |
strsep (char **stringp, const char *delim) |
strsep (char **stringp, const char *delim) |
75 |
size_t n; |
size_t n; |
76 |
size_t buflen = strlen (buf); |
size_t buflen = strlen (buf); |
77 |
|
|
78 |
for( t=buf, n=buflen, s=sub ; n ; t++, n-- ) { |
for (t=buf, n=buflen, s=sub ; n ; t++, n--) { |
79 |
if( toupper(*t) == toupper(*s) ) { |
if (toupper (*t) == toupper (*s)) { |
80 |
for( buf=t++, buflen = n--, s++; |
for( buf=t++, buflen = n--, s++; |
81 |
n && toupper(*t) == toupper(*s); t++, s++, n-- ) |
n && toupper(*t) == toupper(*s); t++, s++, n-- ) |
82 |
; |
; |
83 |
if( !*s ) |
if (!*s) |
84 |
return buf; |
return buf; |
85 |
t = buf; n = buflen; s = sub ; |
t = buf; n = buflen; s = sub ; |
86 |
} |
} |
99 |
|
|
100 |
/* If we are not in path mode (@is_path = 1) we also consider |
/* If we are not in path mode (@is_path = 1) we also consider |
101 |
path separators as illegal chars. */ |
path separators as illegal chars. */ |
102 |
if (!is_path) { |
if (!is_path && (strchr (fname, ':') || strchr (fname, '\\'))) |
103 |
if (strchr (fname, ':') || strchr (fname, '\\')) |
return -1; |
|
return -1; |
|
|
} |
|
104 |
|
|
105 |
for (i=0; i < strlen (fname); i++) { |
for (i=0; i < strlen (fname); i++) { |
106 |
if (strchr (not_allowed, fname[i])) |
if (strchr (not_allowed, fname[i])) |