📄 util.h
字号:
/* * File: util.h * * Interface of a utility library performing common tasks. * * See Also * util.c -- An implementation exposing a util.h interface. * * Copyright (C) 2002 RidgeRun, Inc. * Author: RidgeRun, Inc <skranz@ridgerun.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``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 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Please report all bugs/problems to the author or <support@dsplinux.net> * * key: RRGPLCR (do not remove) * */#ifndef UTIL_H#define UTIL_Hextern int util_putchar(int c); // --putchar-- // Sends character c to consoleextern void util_printf(const char *fmt, ...); // --util_printf-- // For description see `man printf`.extern int util_getchar(void); // --util_getchar-- // For description see `man getchar`.extern void util_gets(char *s, int size); // --util_fgets-- // Internally uses io_getchar_con to acquire a string // or until size number of chars have already been acquired. // For description see `man gets`.extern void util_strip_CRLF(char *s); // --util_strip_CRLF-- // strip any CR ('\r') and/or LF ('\n') chars that might // be sitting at the end of the supplied string. // examples: // in: "foo\n" out: "foo" // in: "foo\r" out: "foo" // in: "foo\r\n" out: "foo"extern char *util_strchr(const char *s, int c); // --strchr-- // returns a pointer to the first occurrence of the character c in the // string s.extern int util_strcmp(const char *s1, const char *s2); // --util_strcmp-- // For description see `man strcmp`.extern int util_strncmp(const char *s1, const char *s2, int len); // --util_strncmp-- // For description see `man strncmp`.extern int util_strlen(const char *s); // --util_strlen-- // For description see `man strcmp`.extern char *util_strcpy(char *dest, const char *src); // --util_strcpy-- // For description see `man strcpy`.extern char *util_strncpy(char *dest, const char *src, int count); // --util_strncpy-- // For description see `man strncpy`.extern unsigned char util_ascii_to_bin(unsigned char c); // --util_ascii_to_bin-- // Converts ascii codes for '0'-'9' into the // binary numeric values 1-9 respectively.extern unsigned char util_decstrtobyte(char *str); // --util_decstrtobyte-- // Incoming string is assumed to be a decimal numeric string // whos converted value will fit within a single byte. // example "1", "255", "125", "34", etc.extern unsigned int util_decstrtoint(char *str); // --util_decstrtoint-- // Incoming string is assumed to be a decimal numeric string // whos converted value will fit within a single int. // example "1", "255", "125", "34", "65535", etc.extern unsigned char util_hexstrtobyte(char *str); // --util_hexstrtobyte-- // Incoming string is assumed to be a hex numeric string // (without the 0x prefix) whos converted value will fit within // a single byte. example "1", "ff", "7d", "22", etc.extern int util_hexstrtoint(char *str, int *ret); // --util_hexstrtoint-- // Incoming string is assumed to be a hex numeric string // (without the 0x prefix) whos converted value will fit within // a integer. example "1", "ff", "7d", "22", etc. Returns 0 // on success, -1 if a bad digit is encountered.extern unsigned long util_IPstr_to_num(char *IP); // --util_IPstr_to_num-- // Input string is expected to be in x.x.x.x format // where x can be up to three numeric characters. // example. "128.34.130.9"extern void util_fill_MAC(unsigned char *mac_array, char *MAC_str); // --util_fill_MAC-- // Input string is expected to be in standard MAC format; // x:x:x:x:x:x, where x can be up to two numeric hex characters. // example. "ff:0:e0:10:c:22". This call will convert the incoming // string into a series of numeric values which are loaded into // the callers supplied array; mac_array[0] through mac_array[5].#ifdef BSPCONF_BTLDR_CS8900_DEBUGextern void util_dump_memory(unsigned int addr, int len);#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -