1999-03-21 21:32:45 +00:00
|
|
|
|
1999-04-15 17:40:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-03-21 21:32:45 +00:00
|
|
|
#ifdef __REACTOS__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-04-15 17:40:56 +00:00
|
|
|
|
1999-03-21 21:32:45 +00:00
|
|
|
|
|
|
|
void* malloc(size_t _size)
|
|
|
|
{
|
|
|
|
return(HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
_size));
|
|
|
|
}
|
|
|
|
|
1999-04-15 17:40:56 +00:00
|
|
|
|
1999-03-21 21:32:45 +00:00
|
|
|
void free(void* _ptr)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void* realloc(void* _ptr, size_t _size)
|
|
|
|
{
|
|
|
|
return(HeapReAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
_ptr,
|
|
|
|
_size));
|
|
|
|
}
|
|
|
|
|
1999-04-15 17:40:56 +00:00
|
|
|
|
|
|
|
char *_strdup(const char *_s)
|
1999-03-21 21:32:45 +00:00
|
|
|
{
|
|
|
|
char *rv;
|
|
|
|
if (_s == 0)
|
|
|
|
return 0;
|
|
|
|
rv = (char *)malloc(strlen(_s) + 1);
|
|
|
|
if (rv == 0)
|
|
|
|
return 0;
|
|
|
|
strcpy(rv, _s);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-15 17:40:56 +00:00
|
|
|
void _makepath( char *path, const char *drive, const char *dir, const char *fname, const char *ext )
|
1999-03-21 21:32:45 +00:00
|
|
|
{
|
|
|
|
int dir_len;
|
|
|
|
if ( drive != NULL ) {
|
|
|
|
strcat(path,drive);
|
|
|
|
strcat(path,":");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dir != NULL ) {
|
|
|
|
strcat(path,dir);
|
|
|
|
if ( *dir != '\\' )
|
|
|
|
strcat(path,"\\");
|
|
|
|
dir_len = strlen(dir);
|
|
|
|
if ( *(dir + dir_len - 1) != '\\' )
|
|
|
|
strcat(path,"\\");
|
|
|
|
}
|
|
|
|
if ( fname != NULL ) {
|
|
|
|
strcat(path,fname);
|
|
|
|
if ( ext != NULL ) {
|
|
|
|
if ( *ext != '.')
|
|
|
|
strcat(path,".");
|
|
|
|
strcat(path,ext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 17:25:39 +00:00
|
|
|
|
|
|
|
char *strtok(char *s, const char *delim)
|
|
|
|
{
|
|
|
|
const char *spanp;
|
|
|
|
int c, sc;
|
|
|
|
char *tok;
|
|
|
|
static char *last;
|
|
|
|
|
|
|
|
if (s == NULL && (s = last) == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
|
|
|
*/
|
|
|
|
cont:
|
|
|
|
c = *s++;
|
|
|
|
for (spanp = delim; (sc = *spanp++) != 0;) {
|
|
|
|
if (c == sc)
|
|
|
|
goto cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == 0) { /* no non-delimiter characters */
|
|
|
|
last = NULL;
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
tok = s - 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
|
|
|
* Note that delim must have one NUL; we stop if we see that, too.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
c = *s++;
|
|
|
|
spanp = delim;
|
|
|
|
do {
|
|
|
|
if ((sc = *spanp++) == c) {
|
|
|
|
if (c == 0)
|
|
|
|
s = NULL;
|
|
|
|
else
|
|
|
|
s[-1] = 0;
|
|
|
|
last = s;
|
|
|
|
return (tok);
|
|
|
|
}
|
|
|
|
} while (sc != 0);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
1999-04-15 17:40:56 +00:00
|
|
|
#endif
|