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

📄 str.c

📁 VIA VT6524 8口网管交换机源码
💻 C
字号:
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This software is copyrighted by and is the sole property of
 * VIA Networking Technologies, Inc. This software may only be used
 * in accordance with the corresponding license agreement. Any unauthorized
 * use, duplication, transmission, distribution, or disclosure of this
 * software is expressly forbidden.
 *
 * This software is provided by VIA Networking Technologies, Inc. "as is"
 * and any express or implied warranties, including, but not limited to, the
 * implied warranties of merchantability and fitness for a particular purpose
 * are disclaimed. In no event shall VIA Networking Technologies, Inc.
 * be liable for any direct, indirect, incidental, special, exemplary, or
 * consequential damages.
 *
 *
 * File:    str.c
 *
 * Purpose: String operations (used to replace "string.h")
 *
 * Author:  Jenda Jao
 *
 * Date:    Jan 08, 2002
 *
 * Functions:
 *
 * Revision History:
 *
 */


#ifdef __MODULE_WEB_SMART
#include <ctype.h>
#endif

#if !defined(__STR_H__)
#include "str.h"
#endif




/*---------------------  Static Definitions  ------------------------*/

/*---------------------  Static Types  ------------------------------*/

/*---------------------  Static Macros  -----------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/

/*---------------------  Export Variables  --------------------------*/




char STRcStrcmp (char *s1, char *s2) DIRECT_FUNTYPE_REENT
{
    char cRes;
    BYTE pt = 0;

    while (1)
    {
        if ((s1[pt] | s2[pt]) == 0)
            return 0;

        cRes = s1[pt] - s2[pt];
        if (cRes != 0)
            return cRes;
        pt++;
    }
}


void STRvStrcpy (char *s1, char *s2) DIRECT_FUNTYPE_REENT
{
    BYTE pt;

    for (pt=0; s2[pt]; pt++)
        s1[pt] = s2[pt];

    s1[pt] = '\0';
}


UINT8 STRbyStrlen (char *str) DIRECT_FUNTYPE_REENT
{
    BYTE pt;

    for (pt=0; str[pt]; pt++);

    return pt;
}


void STRvMemcpy (void *s1, void *s2, UINT16 n) DIRECT_FUNTYPE_REENT
{
    UINT16 pt;

    for (pt=0; pt<n; pt++)
        *((PBYTE)s1+pt) = *((PBYTE)s2+pt);
}


void STRvMemset (void *s, char val, UINT16 n) DIRECT_FUNTYPE_REENT
{
    UINT16 pt;

    for (pt=0; pt<n; pt++)
        *((PBYTE)s+pt) = val;
}


#ifdef __MODULE_WEB_SMART

UINT32 STRdwStr2Dec (char *str) DIRECT_FUNTYPE_REENT
{
    UINT32  dwValue=0;
    BYTE    byLen;

    // convert string to num value
    for (byLen=0; isdigit(str[byLen]); byLen++)
        dwValue = dwValue*10 + toint(str[byLen]);

    return dwValue;
}


char STRcMemcmp(void *s1, void *s2, BYTE n) DIRECT_FUNTYPE_REENT
{
    BYTE pt;
    for (pt = 0; pt < n; pt++)
    {
        if (*((PBYTE)s1+pt) != *((PBYTE)s2+pt))
            return (*((PBYTE)s1+pt) - *((PBYTE)s2+pt));
    }
    return 0;
}

#endif

⌨️ 快捷键说明

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