int parse_sem_id(char *entry) { char *parm; int iter, indx1 = 0, indx2; while(entry[indx1] == ' ') indx1++; while(entry[indx1] && entry[indx1] != ' ') indx1++; while(entry[indx1] == ' ') indx1++; if ('\0' == entry[indx1]) { assert(FALSE); return -1; } indx2 = indx1; parm = &entry[indx1]; while(entry[indx2] && entry[indx2] != ' ') indx2++; entry[indx2] = '\0'; if (cli_is_dcm(parm)) return (int)STRTOUL(parm, NULL, 10); else if (cli_is_hex(parm + 2)) return (int)STRTOUL(parm, NULL, 16); else { assert(FALSE); return -1; } }
/* ----------------------------------------------------- * Check if the value is numeric if it is supposed to be * * Return: * TRUE - It is numeric or val_type is not * numeric anyway * FALSE - Is not numeric * ----------------------------------------------------- */ boolean_t cli_numeric_check(CLI_ENTRY *pparm, char *val_str) { boolean_t retval = TRUE; if (VAL_NUM == pparm->val_type) { if (pparm->hex_num) { if (!cli_is_hex(val_str)) { SNPRINTF(cli_err_str, MAX_CLI_ERR_STR, "Unrecognized value: %s, HEX number expected", val_str); retval = FALSE; } } else if (!cli_is_dcm(val_str)) { SNPRINTF(cli_err_str, MAX_CLI_ERR_STR, "Unrecognized value: %s, Decimal number expected", val_str); retval = FALSE; } } return (retval); }