コード例 #1
0
ファイル: strerror.c プロジェクト: chunhualiu/OpenNT
char * __cdecl strerror (
	int errnum
	)
{
#ifdef	_MT

	_ptiddata ptd = _getptd();

	char *errmsg;
	static char errmsg_backup[_SYS_MSGMAX+2];

#else

	static char errmsg[_ERRMSGLEN_];  /* Longest errmsg + \0 */

#endif

#ifdef	_MT

	if ( (ptd->_errmsg == NULL) && ((ptd->_errmsg =
            _malloc_crt(_ERRMSGLEN_))
	    == NULL) )
		errmsg = errmsg_backup; /* error: use backup */
	else
		errmsg = ptd->_errmsg;

#endif

	strcpy(errmsg, _sys_err_msg(errnum));
	return(errmsg);
}
コード例 #2
0
ファイル: _STRERR.C プロジェクト: ngphloc/agmagic
char * __cdecl _strerror (
        REG1 const char *message
        )
{
#ifdef _MT

        _ptiddata ptd = _getptd();
        char *bldmsg;

#else  /* _MT */

        static char bldmsg[_ERRMSGLEN_];

#endif  /* _MT */


#ifdef _MT

        /* Use per thread buffer area (malloc space, if necessary) */
        /* [NOTE: This buffer is shared between _strerror and streror.] */

        if ( (ptd->_errmsg == NULL) && ((ptd->_errmsg =
            _malloc_crt(_ERRMSGLEN_)) == NULL) )
                    return(NULL);
        bldmsg = ptd->_errmsg;

#endif  /* _MT */

        /* Build the error message */

        bldmsg[0] = '\0';

        if (message && *message) {
                strcat( bldmsg, message );
                strcat( bldmsg, ": " );
        }

        strcat( bldmsg, _sys_err_msg( errno ) );

        return( strcat( bldmsg, "\n" ) );
}
コード例 #3
0
void __cdecl _wperror (
        REG1 const wchar_t *wmessage
        )
{
        REG2 int fh = 2;
        int size;
        char *amessage;

        /* convert WCS string into ASCII string */

        size = wcslen(wmessage) + 1;

        if (NULL == (amessage = (char *)_malloc_crt(size * sizeof(char))))
            return;

        if (0 == (wcstombs(amessage, wmessage, size)))
        {
            _free_crt (amessage);
            return;
        }

        _lock_fh(fh);           /* acquire file handle lock */

        if (amessage && *amessage)
        {
                _write_lk(fh,(char *)amessage,strlen(amessage));
                _write_lk(fh,": ",2);
        }

        _free_crt(amessage);

        amessage = _sys_err_msg( errno );
        _write_lk(fh,(char *)amessage,strlen(amessage));
        _write_lk(fh,"\n",1);

        _unlock_fh(fh);         /* release file handle lock */
}