Jan Breuer
2013-10-22 fea06605af79832c6abe7a8e6a24c142987994d6
libscpi/src/utils.c
@@ -1,5 +1,7 @@
/*-
 * Copyright (c) 2012-2013 Jan Breuer,
 * Copyright (c) 2013 Jan Breuer
 *                    Richard.hmm
 * Copyright (c) 2012 Jan Breuer
 *
 * All Rights Reserved
 * 
@@ -375,33 +377,12 @@
}
/** 
 * is colon or not.  add by hmm 2013.4.1
 * is colon or not
 * @param cmd - command
 * @return
 */
static bool_t iscolon(const char * cmd) {
    char* pColon = ":";
    if(0 == SCPI_strncasecmp(cmd, pColon, 1))
    {
        return TRUE;
    }
    return FALSE;
}
/**
 * Count colon from the beggining  add by hmm 2013.4.1
 * @param cmd - command
 * @param len - max search length
 * @return number of colon
 */
size_t skipColon(const char * cmd, size_t len) {
    size_t i;
    for (i = 0; i < len; i++) {
        if (!iscolon(&cmd[i])) {
            return i;
        }
    }
    return len;
static bool_t iscolon(char ch) {
    return (':' == ch) ? TRUE : FALSE;
}
/**
@@ -488,6 +469,12 @@
    size_t cmd_len = SCPI_strnlen(cmd, len);
    const char * cmd_end = cmd + cmd_len;
    
    /* TODO: now it is possible to send command ":*IDN?" which is incorrect */
    if (iscolon(cmd_ptr[0])) {
        cmd_len --;
        cmd_ptr ++;
    }
    while (1) {
        int pattern_sep_pos = patternSeparatorPos(pattern_ptr, pattern_end - pattern_ptr);
        int cmd_sep_pos = cmdSeparatorPos(cmd_ptr, cmd_end - cmd_ptr);
@@ -552,3 +539,21 @@
}
#endif
#if !HAVE_STRNCASECMP && !HAVE_STRNICMP
int OUR_strncasecmp(const char *s1, const char *s2, size_t n) {
    unsigned char c1, c2;
    for(; n != 0; n--) {
        c1 = tolower((unsigned char)*s1++);
        c2 = tolower((unsigned char)*s2++);
        if (c1 != c2) {
            return c1 - c2;
        }
        if (c1 = '\0') {
            return 0;
        }
    }
    return 0;
}
#endif