mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
- Implement _onexit.
- Port __dllonexit from Wine. - Fix vsscanf stream initialization. svn path=/trunk/; revision=12364
This commit is contained in:
parent
691f45eb54
commit
5848acdc90
4 changed files with 46 additions and 27 deletions
|
@ -18,22 +18,3 @@ void _initterm(void (*fStart[])(void), void (*fEnd[])(void))
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef int (* _onexit_t)(void);
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
_onexit_t __dllonexit(_onexit_t func, void (** fStart[])(void), void (** fEnd[])(void))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
_onexit_t _onexit(_onexit_t x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ vsprintf(char *str, const char *fmt, va_list ap)
|
|||
FILE f;
|
||||
int len;
|
||||
|
||||
f._flag = _IOWRT|_IOSTRG|_IOBINARY;;
|
||||
f._flag = _IOWRT|_IOSTRG|_IOBINARY;
|
||||
f._ptr = str;
|
||||
f._cnt = INT_MAX;
|
||||
f._file = -1;
|
||||
|
|
|
@ -39,7 +39,7 @@ int __vsscanf(const char *s,const char *format,va_list arg)
|
|||
|
||||
memset((void *) &f, 0, sizeof (f));
|
||||
|
||||
f._flag = _IOREAD;
|
||||
f._flag = _IOREAD|_IOSTRG|_IOBINARY;
|
||||
f._ptr = (char *)s;
|
||||
f._base = (char *)s;
|
||||
f._bufsiz = strlen(s);
|
||||
|
|
|
@ -2,20 +2,58 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/internal/atexit.h>
|
||||
|
||||
typedef int (* _onexit_t)(void);
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*
|
||||
* Ported from WINE
|
||||
* Copyright (C) 2000 Jon Griffiths
|
||||
*/
|
||||
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
|
||||
{
|
||||
_onexit_t *tmp;
|
||||
int len;
|
||||
|
||||
if (!start || !*start || !end || !*end)
|
||||
return NULL;
|
||||
|
||||
len = (*end - *start);
|
||||
if (++len <= 0)
|
||||
return NULL;
|
||||
|
||||
tmp = (_onexit_t *)realloc(*start, len * sizeof(tmp));
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
|
||||
*start = tmp;
|
||||
*end = tmp + len;
|
||||
tmp[len - 1] = func;
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
atexit(void (*a)(void))
|
||||
_onexit_t _onexit(_onexit_t a)
|
||||
{
|
||||
struct __atexit *ap;
|
||||
if (a == 0)
|
||||
return -1;
|
||||
return NULL;
|
||||
ap = (struct __atexit *)malloc(sizeof(struct __atexit));
|
||||
if (!ap)
|
||||
return -1;
|
||||
return NULL;
|
||||
ap->__next = __atexit_ptr;
|
||||
ap->__function = a;
|
||||
ap->__function = (void (*)(void))a;
|
||||
__atexit_ptr = ap;
|
||||
return 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int atexit(void (*a)(void))
|
||||
{
|
||||
return _onexit((_onexit_t)a) == (_onexit_t)a ? 0 : -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue