📄 convert.h
字号:
/*************************************************************************** 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. **************************************************************************//*************************************************************************** FILENAME VERSION** CONVERT.H Nucleus Common Library 1.1** DESCRIPTION** ASCII to XXX Conversion Routines** DATA STRUCTURES** none** DEPENDENCIES** ncl.h* limits.h* stdarg.h**************************************************************************/#ifndef CONVERT_H#define CONVERT_H#define NU_NCL_SOURCE_FILE#include "ncl\inc\ncl.h"#include "ncl\inc\limits.h"#include "ncl\inc\abbr.h"/************************************************************************ Macros to negate an unsigned long, and convert to a signed long* and to negate an unsigned int, and convert to a signed int.* It is needed to prevent possible overflows for large negatives.* These macros should work on any form of integer representation.************************************************************************/#define SNEGATE(uvalue) ((uvalue <= LONG_MAX) \ ? (-(long) uvalue ) \ : (-(long)(uvalue-LONG_MAX) - LONG_MAX))#define SINEGATE(uvalue) ((uvalue <= INT_MAX) \ ? (-(int) uvalue) \ : (-(int)(uvalue-INT_MAX) - INT_MAX))/************************************************************************ Macros for converting single digits into integer values.* These macros use the '_hexes' array which must equal HEX_STRING.** char* HEX_BASE(int base)* This macro returns a pointer to a string containing the valid* "digits" for numbers in base 'base'. Any alphabetic digit will* be in upper case. The string is null-terminated.** int HEX_EVAL(char* digit)* This macro returns the integer value of the character pointed to* by 'digit'. It is assumed that 'digit' points to a valid character* in the string returned by HEX_BASE.************************************************************************/#define HEX_BASE(base) (&(_hexes[36]) - (base))#define HEX_EVAL(digit) (&(_hexes[35]) - (digit))#define HEX_STRING "ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210"extern const char _hexes[];/************************************************************************ Routine to convert a string into a simple unsigned long integer. ************************************************************************/extern int NCL__str2ul PROTOE((ulong*, const char*, char**, int, int));#define S2L_ERROR 0 /* no legitimate number found */#define S2L_VALID 1 /* number found which fits into a ulong */#define S2L_OVFLW 2 /* number found, but overflows ulong *//************************************************************************ Generic String To XXX Conversion Routines. ************************************************************************/extern ulong NCL__strtoul PROTOE((const char*, char**, int, int, ulong));extern long NCL__strtol PROTOE((const char*, char**, int, int));#undef NU_NCL_SOURCE_FILE#endif /* CONVERT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -