name.c

来自「Windows CE 6.0 BSP for VOIPAC Board (PXA」· C语言 代码 · 共 59 行

C
59
字号
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  File:  name.c
//
#include <windows.h>
#include <oal.h>

//------------------------------------------------------------------------------
//
//  Function:  OALKitlCreateName
//
//  This function create device name from prefix and mac address (usually last
//  two bytes of MAC address used for download).
//
VOID OALKitlCreateName(CHAR *pPrefix, UINT16 mac[3], CHAR *pBuffer)
{
    UINT32 count;
    UINT16 base, code;

    OALMSG(OAL_KITL&&OAL_FUNC, (
        L"+OALKitlCreateName('%hs', 0x%04x, 0x%08x)\r\n", pPrefix, mac, pBuffer
    ));
    
    count = 0;
    code = (mac[2] >> 8) | ((mac[2] & 0x00ff) << 8);
    while (count < OAL_KITL_ID_SIZE - 6 && pPrefix[count] != '\0') {
        pBuffer[count] = pPrefix[count];
        count++;
    }        
    base = 10000;
    while (base > code && base != 0) base /= 10;
    if (base == 0) { 
        pBuffer[count++] = '0';
    } else {
        while (base > 0) {
            pBuffer[count++] = code/base + '0';
            code %= base;
            base /= 10;
        }
    }        
    pBuffer[count] = '\0';

    OALMSG(OAL_KITL&&OAL_FUNC, (
        L"-OALKitlCreateName(pBuffer = '%hs')\r\n", pBuffer
    ));
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

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