https://github.com/j123b567/scpi-parser
Dependents: scpi_sx127x scpi_sx127x_firstTest MLX90418_I2C_master
src/utils_private.h@1:b497f235115a, 2015-08-07 (annotated)
- Committer:
- dudmuck
- Date:
- Fri Aug 07 21:54:11 2015 +0000
- Revision:
- 1:b497f235115a
update from github commit 6e5e3e0e3fc450eaf53feee059824ad85c4f270d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudmuck | 1:b497f235115a | 1 | /*- |
dudmuck | 1:b497f235115a | 2 | * Copyright (c) 2012-2013 Jan Breuer, |
dudmuck | 1:b497f235115a | 3 | * |
dudmuck | 1:b497f235115a | 4 | * All Rights Reserved |
dudmuck | 1:b497f235115a | 5 | * |
dudmuck | 1:b497f235115a | 6 | * Redistribution and use in source and binary forms, with or without |
dudmuck | 1:b497f235115a | 7 | * modification, are permitted provided that the following conditions are |
dudmuck | 1:b497f235115a | 8 | * met: |
dudmuck | 1:b497f235115a | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
dudmuck | 1:b497f235115a | 10 | * this list of conditions and the following disclaimer. |
dudmuck | 1:b497f235115a | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
dudmuck | 1:b497f235115a | 12 | * notice, this list of conditions and the following disclaimer in the |
dudmuck | 1:b497f235115a | 13 | * documentation and/or other materials provided with the distribution. |
dudmuck | 1:b497f235115a | 14 | * |
dudmuck | 1:b497f235115a | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
dudmuck | 1:b497f235115a | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
dudmuck | 1:b497f235115a | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
dudmuck | 1:b497f235115a | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
dudmuck | 1:b497f235115a | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
dudmuck | 1:b497f235115a | 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
dudmuck | 1:b497f235115a | 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
dudmuck | 1:b497f235115a | 22 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
dudmuck | 1:b497f235115a | 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
dudmuck | 1:b497f235115a | 24 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
dudmuck | 1:b497f235115a | 25 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dudmuck | 1:b497f235115a | 26 | */ |
dudmuck | 1:b497f235115a | 27 | |
dudmuck | 1:b497f235115a | 28 | /** |
dudmuck | 1:b497f235115a | 29 | * @file scpi_utils.h |
dudmuck | 1:b497f235115a | 30 | * @date Thu Nov 15 10:58:45 UTC 2012 |
dudmuck | 1:b497f235115a | 31 | * |
dudmuck | 1:b497f235115a | 32 | * @brief Conversion routines and string manipulation routines |
dudmuck | 1:b497f235115a | 33 | * |
dudmuck | 1:b497f235115a | 34 | * |
dudmuck | 1:b497f235115a | 35 | */ |
dudmuck | 1:b497f235115a | 36 | |
dudmuck | 1:b497f235115a | 37 | #ifndef SCPI_UTILS_PRIVATE_H |
dudmuck | 1:b497f235115a | 38 | #define SCPI_UTILS_PRIVATE_H |
dudmuck | 1:b497f235115a | 39 | |
dudmuck | 1:b497f235115a | 40 | #include <stdint.h> |
dudmuck | 1:b497f235115a | 41 | #include "scpi/config.h" |
dudmuck | 1:b497f235115a | 42 | #include "scpi/types.h" |
dudmuck | 1:b497f235115a | 43 | |
dudmuck | 1:b497f235115a | 44 | #ifdef __cplusplus |
dudmuck | 1:b497f235115a | 45 | extern "C" { |
dudmuck | 1:b497f235115a | 46 | #endif |
dudmuck | 1:b497f235115a | 47 | |
dudmuck | 1:b497f235115a | 48 | #if defined(__GNUC__) && (__GNUC__ >= 4) |
dudmuck | 1:b497f235115a | 49 | #define LOCAL __attribute__((visibility ("hidden"))) |
dudmuck | 1:b497f235115a | 50 | #else |
dudmuck | 1:b497f235115a | 51 | #define LOCAL |
dudmuck | 1:b497f235115a | 52 | #endif |
dudmuck | 1:b497f235115a | 53 | |
dudmuck | 1:b497f235115a | 54 | char * strnpbrk(const char *str, size_t size, const char *set) LOCAL; |
dudmuck | 1:b497f235115a | 55 | scpi_bool_t compareStr(const char * str1, size_t len1, const char * str2, size_t len2) LOCAL; |
dudmuck | 1:b497f235115a | 56 | scpi_bool_t compareStrAndNum(const char * str1, size_t len1, const char * str2, size_t len2, int32_t * num) LOCAL; |
dudmuck | 1:b497f235115a | 57 | size_t strToLong(const char * str, int32_t * val, int8_t base) LOCAL; |
dudmuck | 1:b497f235115a | 58 | size_t strToDouble(const char * str, double * val) LOCAL; |
dudmuck | 1:b497f235115a | 59 | scpi_bool_t locateText(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL; |
dudmuck | 1:b497f235115a | 60 | scpi_bool_t locateStr(const char * str1, size_t len1, const char ** str2, size_t * len2) LOCAL; |
dudmuck | 1:b497f235115a | 61 | size_t skipWhitespace(const char * cmd, size_t len) LOCAL; |
dudmuck | 1:b497f235115a | 62 | scpi_bool_t matchPattern(const char * pattern, size_t pattern_len, const char * str, size_t str_len, int32_t * num) LOCAL; |
dudmuck | 1:b497f235115a | 63 | scpi_bool_t matchCommand(const char * pattern, const char * cmd, size_t len, int32_t *numbers, size_t numbers_len) LOCAL; |
dudmuck | 1:b497f235115a | 64 | scpi_bool_t composeCompoundCommand(const scpi_token_t * prev, scpi_token_t * current) LOCAL; |
dudmuck | 1:b497f235115a | 65 | |
dudmuck | 1:b497f235115a | 66 | #if !HAVE_STRNLEN |
dudmuck | 1:b497f235115a | 67 | size_t BSD_strnlen(const char *s, size_t maxlen) LOCAL; |
dudmuck | 1:b497f235115a | 68 | #endif |
dudmuck | 1:b497f235115a | 69 | |
dudmuck | 1:b497f235115a | 70 | #if !HAVE_STRNCASECMP && !HAVE_STRNICMP |
dudmuck | 1:b497f235115a | 71 | int OUR_strncasecmp(const char *s1, const char *s2, size_t n) LOCAL; |
dudmuck | 1:b497f235115a | 72 | #endif |
dudmuck | 1:b497f235115a | 73 | |
dudmuck | 1:b497f235115a | 74 | #ifndef min |
dudmuck | 1:b497f235115a | 75 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
dudmuck | 1:b497f235115a | 76 | #endif |
dudmuck | 1:b497f235115a | 77 | |
dudmuck | 1:b497f235115a | 78 | #ifndef max |
dudmuck | 1:b497f235115a | 79 | #define max(a, b) (((a) > (b)) ? (a) : (b)) |
dudmuck | 1:b497f235115a | 80 | #endif |
dudmuck | 1:b497f235115a | 81 | |
dudmuck | 1:b497f235115a | 82 | #if 0 |
dudmuck | 1:b497f235115a | 83 | #define max(a,b) \ |
dudmuck | 1:b497f235115a | 84 | ({ __typeof__ (a) _a = (a); \ |
dudmuck | 1:b497f235115a | 85 | __typeof__ (b) _b = (b); \ |
dudmuck | 1:b497f235115a | 86 | _a > _b ? _a : _b; }) |
dudmuck | 1:b497f235115a | 87 | |
dudmuck | 1:b497f235115a | 88 | #define min(a,b) \ |
dudmuck | 1:b497f235115a | 89 | ({ __typeof__ (a) _a = (a); \ |
dudmuck | 1:b497f235115a | 90 | __typeof__ (b) _b = (b); \ |
dudmuck | 1:b497f235115a | 91 | _a < _b ? _a : _b; }) |
dudmuck | 1:b497f235115a | 92 | |
dudmuck | 1:b497f235115a | 93 | #endif |
dudmuck | 1:b497f235115a | 94 | |
dudmuck | 1:b497f235115a | 95 | #ifdef __cplusplus |
dudmuck | 1:b497f235115a | 96 | } |
dudmuck | 1:b497f235115a | 97 | #endif |
dudmuck | 1:b497f235115a | 98 | |
dudmuck | 1:b497f235115a | 99 | #endif /* SCPI_UTILS_PRIVATE_H */ |