1 /*
2 * Routines to access hardware
3 *
4 * Copyright (c) 2013 Realtek Semiconductor Corp.
5 *
6 * This module is a confidential and proprietary property of RealTek and
7 * possession or use of this module requires written permission of RealTek.
8 */
9
10 #ifndef _STRPROC_H_
11 #define _STRPROC_H_
12
13 #include <stddef.h> /* for size_t */
14 #include <stdarg.h>
15 #include "platform_autoconf.h"
16 #include "basic_types.h"
17
18 #ifndef isprint
19 #define in_range(c, lo, up) ((u8)c >= lo && (u8)c <= up)
20 #define isprint(c) in_range(c, 0x20, 0x7f)
21 #define isdigit(c) in_range(c, '0', '9')
22 #define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
23 //#define islower(c) in_range(c, 'a', 'z')
24 #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ',')
25
26 #define isupper(c) (((c)>='A')&&((c)<='Z'))
27 #define islower(c) (((c)>='a')&&((c)<='z'))
28 #define isalpha(c) (isupper(c) || islower(c))
29 #endif
30
31
32 extern _LONG_CALL_ int _vsscanf(const char *buf, const char *fmt, va_list args);
33
34
35 extern _LONG_CALL_ SIZE_T _strlen(const char *s);
36 extern _LONG_CALL_ int _strcmp(const char *cs, const char *ct);
37 extern _LONG_CALL_ char *_strncpy(char *dest, const char *src, size_t count);
38 extern _LONG_CALL_ char *_strcpy(char *dest, const char *src);
39 extern _LONG_CALL_ size_t _strlen(const char *s);
40 extern _LONG_CALL_ size_t _strnlen(const char *s, size_t count);
41 extern _LONG_CALL_ int _strncmp(const char *cs, const char *ct, size_t count);
42 extern _LONG_CALL_ int _sscanf(const char *buf, const char *fmt, ...);
43 extern _LONG_CALL_ char *_strsep(char **s, const char *ct);
44
45 extern _LONG_CALL_ char *_strpbrk(const char *cs, const char *ct);
46 extern _LONG_CALL_ char *_strchr(const char *s, int c);
47 extern _LONG_CALL_ int _stricmp(const char* str1, const char* str2);
48 extern _LONG_CALL_ u8* _strupr(IN u8 *string);
49 extern _LONG_CALL_ int _stratoi(IN const char * s);
50 extern _LONG_CALL_ char * _strstr(IN const char * str1, IN const char * str2);
51 extern _LONG_CALL_ char* _strtok(IN char *str, IN const char* delim);
52
53 extern _LONG_CALL_ long _strtol(const char *cp, char **endp, int base);
54 extern _LONG_CALL_ unsigned long _strtoul(const char *cp, char **endp, int base);
55 extern _LONG_CALL_ long long _strtoll(const char *cp, char **endp, unsigned int base);
56 extern _LONG_CALL_ unsigned long long _strtoull(const char *cp, char **endp, unsigned int base);
57
58 extern _LONG_CALL_ u8 _char2num(u8 ch);
59 extern _LONG_CALL_ u8 _2char2dec(u8 hch, u8 lch);
60 extern _LONG_CALL_ u8 _2char2hex(u8 hch, u8 lch);
61
62 #if 0
63 /*
64 * Fast implementation of tolower() for internal usage. Do not use in your
65 * code.
66 */
67 static inline char _tolower(const char c)
68 {
69 return c | 0x20;
70 }
71 #endif
72 /* Fast check for octal digit */
isodigit(const char c)73 static inline int isodigit(const char c)
74 {
75 return c >= '0' && c <= '7';
76 }
77
78 #endif
79