⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itow.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
#include <string.h>
#include <windows.h>

/*
 * @implemented
 * from wine cvs 2006-05-21
 */
wchar_t *
_i64tow(__int64 value, wchar_t *string, int radix)
{
    ULONGLONG val;
    int negative;
    WCHAR buffer[65];
    PWCHAR pos;
    WCHAR digit;

    if (value < 0 && radix == 10) {
	negative = 1;
        val = -value;
    } else {
	negative = 0;
        val = value;
    } /* if */

    pos = &buffer[64];
    *pos = '\0';

    do {
	digit = val % radix;
	val = val / radix;
	if (digit < 10) {
	    *--pos = '0' + digit;
	} else {
	    *--pos = 'a' + digit - 10;
	} /* if */
    } while (val != 0L);

    if (negative) {
	*--pos = '-';
    } /* if */

    if (string != NULL) {
	memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
    } /* if */
    return string;
}


/*
 * @implemented
 */
wchar_t *
_ui64tow(unsigned __int64 value, wchar_t *string, int radix)
{
    WCHAR buffer[65];
    PWCHAR pos;
    WCHAR digit;

    pos = &buffer[64];
    *pos = '\0';

    do {
	digit = value % radix;
	value = value / radix;
	if (digit < 10) {
	    *--pos = '0' + digit;
	} else {
	    *--pos = 'a' + digit - 10;
	} /* if */
    } while (value != 0L);

    if (string != NULL) {
	memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
    } /* if */
    return string;
}


/*
 * @implemented
 * from wine cvs 2006-05-21
 */
wchar_t *
_itow(int value, wchar_t *string, int radix)
{
  return _ltow(value, string, radix);
}


/*
 * @implemented
 * from wine cvs 2006-05-21
 */
wchar_t *
_ltow(long value, wchar_t *string, int radix)
{
    unsigned long val;
    int negative;
    WCHAR buffer[33];
    PWCHAR pos;
    WCHAR digit;

    if (value < 0 && radix == 10) {
	negative = 1;
        val = -value;
    } else {
	negative = 0;
        val = value;
    } /* if */

    pos = &buffer[32];
    *pos = '\0';

    do {
	digit = val % radix;
	val = val / radix;
	if (digit < 10) {
	    *--pos = '0' + digit;
	} else {
	    *--pos = 'a' + digit - 10;
	} /* if */
    } while (val != 0L);

    if (negative) {
	*--pos = '-';
    } /* if */

    if (string != NULL) {
	memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
    } /* if */
    return string;
}


/*
 * @implemented
 * from wine cvs 2006-05-21
 */
wchar_t *
_ultow(unsigned long value, wchar_t *string, int radix)
{
    WCHAR buffer[33];
    PWCHAR pos;
    WCHAR digit;

    pos = &buffer[32];
    *pos = '\0';

    do {
	digit = value % radix;
	value = value / radix;
	if (digit < 10) {
	    *--pos = '0' + digit;
	} else {
	    *--pos = 'a' + digit - 10;
	} /* if */
    } while (value != 0L);

    if (string != NULL) {
	memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
    } /* if */
    return string;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -