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

📄 strtoul.c

📁 Nucleus Common Library for Integrator using ARM Developer Suite
💻 C
字号:
/*************************************************************************
*
*               Copyright Mentor Graphics Corporation 2002
*                         All Rights Reserved.
*
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
* SUBJECT TO LICENSE TERMS.
*
*************************************************************************/

/*************************************************************************
* FILE NAME                                     VERSION
*
*       strtoul.c                               Nucleus Common Library 1.1
*
* DESCRIPTION
*
*       This file contains the implementation of NCL_stroul.
*
* DATA STRUCTURES
*
*       None.
*
* FUNCTIONS
*
*       NCL_stroul
*
* DEPENDENCIES
*
*       ncl.h
*       convert.h
*       ctype.h
*       nucleus.h
*
************************************************************************/

#define NU_NCL_SOURCE_FILE

#include "ncl\inc\ncl.h"
#include "ncl\inc\convert.h"
#include "ncl\inc\ctype.h"
#include "plus\nucleus.h"                                /* MMU Support */

/*************************************************************************
*
*   FUNCTION
*
*       NCL_strtoul
*
*   DESCRIPTION
*
*       This routine scans a string for an unsigned long integer.  The
*       integer may be preceeded by optional whitespace characters, and
*       by a single '+' or '-' sign.  The integer is in the base specified
*       (from base 2 to 36).  If "base" is 0, then the integer is octal if
*       preceeded by '0', hexadecimal if '0x', or decimal by default.
*       A hexadecimal number may optionally be preceeded by "0x".
*       If "endptr" is non-zero, it is set to point to the first invalid
*       character found after the integer, or to nptr if a valid integer
*       can't be scanned from the string.
*
*   INPUTS
*
*       nptr                The start of the string to be processed
*       base                The number system to use (binary, hex, etc...)
*
*   OUTPUTS
*
*       endptr              The first valid character after the integer
*                             (passed by reference)
*       ulong               The unsigned long represented by the string
*
*************************************************************************/

ulong NCL_strtoul (const char *nptr, char **endptr, int  base)
{
    register const uchar *ptr = (const uchar *)nptr;
    ulong   value;

    while (NCL_isspace (*ptr))
        ++ptr;                                  /* skip over whitespace */

    value = NCL__strtoul ((const char*)ptr, endptr, base, -1, ULONG_MAX);

    if (endptr != (char**) 0)                 /* indicate any errors */
    {
      if (*endptr == (char*)ptr)
          *endptr = (char *)nptr;
    }

    return (value);
}

⌨️ 快捷键说明

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