From 405ddade01900b838c9d0d995ab1ec6647d35c28 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周二, 28 1月 2014 16:49:04 +0800 Subject: [PATCH] Merge pull request #12 from karlp/docupdates --- libscpi/src/utils.h | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libscpi/src/utils.h b/libscpi/src/utils.h index 7429246..f3b6859 100644 --- a/libscpi/src/utils.h +++ b/libscpi/src/utils.h @@ -38,26 +38,45 @@ #define SCPI_UTILS_H #include <stdint.h> +#include "scpi/config.h" #include "scpi/types.h" #ifdef __cplusplus extern "C" { #endif +#if defined(__GNUC__) && (__GNUC__ >= 4) #define LOCAL __attribute__((visibility ("hidden"))) +#else + #define LOCAL +#endif - char * strnpbrk(const char *str, size_t size, const char *set) LOCAL; - bool_t compareStr(const char * str1, size_t len1, const char * str2, size_t len2) LOCAL; + const char * strnpbrk(const char *str, size_t size, const char *set) LOCAL; + scpi_bool_t compareStr(const char * str1, size_t len1, const char * str2, size_t len2) LOCAL; size_t longToStr(int32_t val, char * str, size_t len) LOCAL; size_t doubleToStr(double val, char * str, size_t len) LOCAL; size_t strToLong(const char * str, int32_t * val) LOCAL; size_t strToDouble(const char * str, double * val) LOCAL; - bool_t locateText(const char * str1, size_t len1, char ** str2, size_t * len2) LOCAL; - bool_t locateStr(const char * str1, size_t len1, char ** str2, size_t * len2) LOCAL; + scpi_bool_t locateText(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL; + scpi_bool_t locateStr(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL; size_t skipWhitespace(const char * cmd, size_t len) LOCAL; - bool_t matchPattern(const char * pattern, size_t pattern_len, const char * str, size_t str_len) LOCAL; + size_t skipColon(const char * cmd, size_t len) LOCAL; + scpi_bool_t matchPattern(const char * pattern, size_t pattern_len, const char * str, size_t str_len) LOCAL; + scpi_bool_t matchCommand(const char * pattern, const char * cmd, size_t len) LOCAL; + scpi_bool_t composeCompoundCommand(char * ptr_prev, size_t len_prev, char ** pptr, size_t * plen); +#if !HAVE_STRNLEN + size_t BSD_strnlen(const char *s, size_t maxlen); +#endif +#if !HAVE_STRNCASECMP && !HAVE_STRNICMP + int OUR_strncasecmp(const char *s1, const char *s2, size_t n); +#endif + +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) + +#if 0 #define max(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ @@ -68,6 +87,8 @@ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; }) +#endif + #ifdef __cplusplus } #endif -- Gitblit v1.9.1