本文整理汇总了C++中IS_VALID_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_VALID_STRING函数的具体用法?C++ IS_VALID_STRING怎么用?C++ IS_VALID_STRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IS_VALID_STRING函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lagopus_snmp_get_agentx_sock
lagopus_result_t
lagopus_snmp_get_agentx_sock(char **agentx_sock) {
if (agentx_sock != NULL && *agentx_sock == NULL) {
if (IS_VALID_STRING(conf.agentx_sock) == true) {
char *str = NULL;
s_rlock_snmp_conf(&conf);
{
str = strdup(conf.agentx_sock);
}
s_unlock_snmp_conf(&conf);
if (IS_VALID_STRING(str) == true) {
*agentx_sock = str;
return LAGOPUS_RESULT_OK;
} else {
free((void *)str);
return LAGOPUS_RESULT_NO_MEMORY;
}
} else {
return LAGOPUS_RESULT_NOT_DEFINED;
}
}
return LAGOPUS_RESULT_INVALID_ARGS;
}
开发者ID:JackieXie168,项目名称:lagopus,代码行数:25,代码来源:snmp_cmd.c
示例2: mccp_str_trim_right
mccp_result_t
mccp_str_trim_right(const char *org, const char *trimchars,
char **retptr) {
mccp_result_t n = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(org) == true &&
IS_VALID_STRING(trimchars) == true &&
retptr != NULL) {
char *buf = strdup(org);
char *ed = buf + strlen(buf) - 1;
*retptr = NULL;
while (ed >= buf) {
if (strchr(trimchars, (int)*ed) != NULL) {
*ed = '\0';
ed--;
} else {
break;
}
}
*retptr = buf;
n = (mccp_result_t)strlen(buf);
} else {
n = MCCP_RESULT_INVALID_ARGS;
}
return n;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:30,代码来源:strutils.c
示例3: s_log_init
static inline bool
s_log_init(mccp_log_destination_t dst,
const char *arg,
bool multi_process,
bool emit_date,
uint64_t debug_level,
uint64_t trace_flags) {
bool ret = false;
if (s_is_fork_initialized == false) {
(void)pthread_atfork(NULL, NULL, s_child_at_fork);
s_is_fork_initialized = true;
}
if (dst == MCCP_LOG_EMIT_TO_FILE ||
dst == MCCP_LOG_EMIT_TO_UNKNOWN) {
int ofd = -INT_MAX;
s_log_final();
if (IS_VALID_STRING(arg) == true &&
dst == MCCP_LOG_EMIT_TO_FILE &&
s_is_file(arg) == true) {
ofd = open(arg, O_RDWR | O_CREAT | O_APPEND, 0600);
if (ofd >= 0) {
s_log_fd = fdopen(ofd, "a+");
if (s_log_fd != NULL) {
ret = true;
}
}
} else {
s_log_fd = NULL; /* use stderr. */
ret = true;
}
} else if (dst == MCCP_LOG_EMIT_TO_SYSLOG) {
if (IS_VALID_STRING(arg) == true) {
s_log_final();
openlog(arg, 0, LOG_USER);
ret = true;
}
}
if (ret == true) {
s_log_dst = dst;
free((void *)s_log_arg);
s_log_arg = (IS_VALID_STRING(arg) == true) ? strdup(arg) : NULL;
s_do_multi_process = multi_process;
s_do_date = emit_date;
s_dbg_level = debug_level;
s_trace_flags = trace_flags;
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:57,代码来源:logger.c
示例4: s_parse_bigint_by_base
static inline bool
s_parse_bigint_by_base(const char *str, MP_INT *valptr, unsigned int base) {
bool ret = false;
bool is_neg = false;
skip_spaces(str);
if (IS_VALID_STRING(str) == true) {
switch ((int)str[0]) {
case '-': {
is_neg = true;
str++;
break;
}
case '+': {
str++;
break;
}
}
}
skip_spaces(str);
if (IS_VALID_STRING(str) == true) {
char *buf = strdup(str);
if (buf != NULL) {
size_t len;
if ((len = strlen(buf)) > 0) {
const MP_INT *mul = NULL;
char *endp = &(buf[len]);
trim_spaces(buf, endp);
mul = s_get_prefix_multiplier(buf);
if (mul != NULL) {
MP_INT tmp;
if (mpz_init_set_str(&tmp, buf, (int)base) == 0) {
mpz_mul(valptr, &tmp, mul);
if (is_neg == true) {
mpz_neg(valptr, valptr);
}
ret = true;
}
mpz_clear(&tmp);
}
}
free((void *)buf);
}
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:49,代码来源:strutils.c
示例5: mccp_str_tokenize
mccp_result_t
mccp_str_tokenize(char *buf, char **tokens,
size_t max, const char *delm) {
mccp_result_t n = 0;
size_t no_delm = 0;
if (IS_VALID_STRING(buf) == true &&
IS_VALID_STRING(delm) == true) {
while (*buf != '\0' && (size_t)n < max) {
while (strchr(delm, (int)*buf) != NULL && *buf != '\0') {
/*
* Increent the pointer while *buf is a delimiter.
*/
buf++;
}
if (*buf == '\0') {
break;
}
tokens[n] = buf;
no_delm = 0;
while (strchr(delm, (int)*buf) == NULL && *buf != '\0') {
no_delm++;
buf++;
}
if (*buf == '\0') {
if (no_delm > 0) {
n++;
}
break;
}
*buf = '\0';
n++;
if (*(buf + 1) == '\0') {
break;
} else {
buf++;
}
}
} else {
n = MCCP_RESULT_INVALID_ARGS;
}
return n;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:48,代码来源:strutils.c
示例6: tmp_dir_opt_parse
static lagopus_result_t
tmp_dir_opt_parse(const char *const *argv[],
void *c, void *out_configs,
lagopus_dstring_t *result) {
lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
char *path = NULL;
(void) out_configs;
(void) c;
if (argv != NULL && out_configs != NULL && result != NULL) {
if (*(*argv + 1) != NULL) {
(*argv)++;
if (IS_VALID_STRING(*(*argv)) == true) {
ret = flow_cmd_dump_tmp_dir_set(*(*argv));
if (ret != LAGOPUS_RESULT_OK) {
ret = datastore_json_result_string_setf(result, ret,
"Bad opt value = %s.",
*(*argv));
}
} else {
ret = datastore_json_result_string_setf(result, ret,
"Bad opt value = %s.",
*(*argv));
}
} else {
if ((ret = flow_cmd_dump_tmp_dir_get(&path)) ==
LAGOPUS_RESULT_OK) {
if ((ret = lagopus_dstring_appendf(result, "{")) !=
LAGOPUS_RESULT_OK) {
lagopus_perror(ret);
goto done;
}
if ((ret = datastore_json_string_append(
result, ATTR_NAME_GET(opt_strs, OPT_TMP_DIR),
path, false)) !=
LAGOPUS_RESULT_OK) {
lagopus_perror(ret);
goto done;
}
if ((ret = lagopus_dstring_appendf(result, "}")) !=
LAGOPUS_RESULT_OK) {
lagopus_perror(ret);
goto done;
}
} else {
ret = datastore_json_result_string_setf(result, ret,
"Can't get tmp dir.");
}
}
} else {
ret = datastore_json_result_set(result,
LAGOPUS_RESULT_INVALID_ARGS,
NULL);
}
done:
free(path);
return ret;
}
开发者ID:tidatida,项目名称:lagopus,代码行数:60,代码来源:flow_cmd.c
示例7: s_once_proc
static void
s_once_proc(void) {
char *dbg_lvl_str = getenv("LAGOPUS_LOG_DEBUGLEVEL");
char *logfile = getenv("LAGOPUS_LOG_FILE");
uint16_t d = 0;
lagopus_log_destination_t log_dst = LAGOPUS_LOG_EMIT_TO_UNKNOWN;
if (IS_VALID_STRING(dbg_lvl_str) == true) {
uint16_t tmp = 0;
if (lagopus_str_parse_uint16(dbg_lvl_str, &tmp) == LAGOPUS_RESULT_OK) {
d = tmp;
}
}
if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
log_dst = LAGOPUS_LOG_EMIT_TO_FILE;
}
if (lagopus_log_initialize(log_dst, logfile, false, true, d) !=
LAGOPUS_RESULT_OK) {
lagopus_exit_error(1, "logger initialization error.\n");
}
if (d > 0) {
lagopus_msg_debug(d, "Logger debug level is set to: %d.\n", d);
}
}
开发者ID:D-TOKIOKA,项目名称:lagopus,代码行数:26,代码来源:logger.c
示例8: mccp_str_parse_double
mccp_result_t
mccp_str_parse_double(const char *buf, double *val) {
mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(buf) == true &&
val != NULL) {
size_t len = strlen(buf);
if (len > 0) {
char *eptr = NULL;
double tmp = strtod(buf, &eptr);
if (eptr == (buf + len)) {
ret = MCCP_RESULT_OK;
*val = tmp;
} else {
ret = MCCP_RESULT_NAN;
}
} else {
ret = MCCP_RESULT_INVALID_ARGS;
}
} else {
ret = MCCP_RESULT_INVALID_ARGS;
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:27,代码来源:strutils.c
示例9: mccp_str_parse_uint16
mccp_result_t
mccp_str_parse_uint16(const char *buf, uint16_t *val) {
mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(buf) == true &&
val != NULL) {
MP_INT v;
mpz_init(&v);
if ((ret = s_parse_bigint_in_range(buf, &v,
&s_0, &s_USHRT_MAX)) ==
MCCP_RESULT_OK) {
#ifdef MCCP_ARCH_64_BITS
uint64_t v64 = (uint64_t)mpz_get_ui(&v);
*val = (uint16_t)v64;
#else
uint64_t v64 = s_bignum_2_uint64_t(&v);
*val = (uint16_t)v64;
#endif /* MCCP_ARCH_64_BITS */
}
mpz_clear(&v);
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:28,代码来源:strutils.c
示例10: s_once_proc
static void
s_once_proc(void) {
char *dbg_lvl_str = getenv("LAGOPUS_LOG_DEBUGLEVEL");
char *logfile = getenv("LAGOPUS_LOG_FILE");
uint16_t d = 0;
lagopus_log_destination_t log_dst = LAGOPUS_LOG_EMIT_TO_UNKNOWN;
if (IS_VALID_STRING(dbg_lvl_str) == true) {
uint16_t tmp = 0;
if (lagopus_str_parse_uint16(dbg_lvl_str, &tmp) == LAGOPUS_RESULT_OK) {
d = tmp;
}
}
if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
log_dst = LAGOPUS_LOG_EMIT_TO_FILE;
}
if (lagopus_log_initialize(log_dst, logfile, false, true, d) !=
LAGOPUS_RESULT_OK) {
lagopus_exit_error(1, "logger initialization error.\n");
}
if (d > 0) {
lagopus_msg_debug(d, "Logger debug level is set to: %d.\n", d);
}
#ifdef HAVE_PROCFS_SELF_EXE
if (readlink("/proc/self/exe", s_exefile, PATH_MAX) != -1) {
(void)lagopus_set_command_name(s_exefile);
lagopus_msg_debug(10, "set the command name '%s'.\n",
lagopus_get_command_name());
}
#endif /* HAVE_PROCFS_SELF_EXE */
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:34,代码来源:logger.c
示例11: mccp_str_parse_bool
mccp_result_t
mccp_str_parse_bool(const char *buf, bool *val) {
mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(buf) == true &&
val != NULL) {
if (strcasecmp(buf, "true") == 0 ||
strcasecmp(buf, "yes") == 0 ||
strcasecmp(buf, "on") == 0 ||
strcmp(buf, "1") == 0) {
*val = true;
ret = MCCP_RESULT_OK;
} else if (strcasecmp(buf, "false") == 0 ||
strcasecmp(buf, "no") == 0 ||
strcasecmp(buf, "off") == 0 ||
strcmp(buf, "0") == 0) {
*val = false;
ret = MCCP_RESULT_OK;
} else {
ret = MCCP_RESULT_INVALID_ARGS;
}
} else {
ret = MCCP_RESULT_INVALID_ARGS;
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:27,代码来源:strutils.c
示例12: s_opt_parse_port
static inline lagopus_result_t
s_opt_parse_port(datastore_interp_state_t state,
const char *const argv[], lagopus_dstring_t *result) {
lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
uint16_t tmp = 0;
if (IS_VALID_STRING(*argv) == true) {
if ((ret = lagopus_str_parse_uint16(*argv, &tmp)) ==
LAGOPUS_RESULT_OK) {
if (state != DATASTORE_INTERP_STATE_DRYRUN) {
s_port = tmp;
}
ret = LAGOPUS_RESULT_OK;
} else {
ret = datastore_json_result_string_setf(result,
LAGOPUS_RESULT_INVALID_ARGS,
"\"can't parse '%s' as a "
"uint16_t integer.\"",
*argv);
}
} else {
ret = datastore_json_result_string_setf(result,
LAGOPUS_RESULT_INVALID_ARGS,
"Bad opt value = %s",
*argv);
}
return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:28,代码来源:datastore_cmd.c
示例13: s_opt_parse_tls
static inline lagopus_result_t
s_opt_parse_tls(datastore_interp_state_t state,
const char *const argv[], lagopus_dstring_t *result) {
lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
bool tls = false;
if (IS_VALID_STRING(*argv) == true) {
if (state == DATASTORE_INTERP_STATE_DRYRUN) {
ret = LAGOPUS_RESULT_OK;
} else {
ret = lagopus_str_parse_bool(*argv, &tls);
if (ret == LAGOPUS_RESULT_OK) {
s_set_tls(tls);
} else {
ret = datastore_json_result_string_setf(result,
LAGOPUS_RESULT_INVALID_ARGS,
"Bad opt value = %s",
*argv);
}
}
} else {
ret = datastore_json_result_string_setf(result,
LAGOPUS_RESULT_INVALID_ARGS,
"Bad opt value = %s",
*argv);
}
return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:28,代码来源:datastore_cmd.c
示例14: s_find_module
static inline gallus_result_t
s_find_module(const char *name, a_module **retmptr) {
gallus_result_t ret = GALLUS_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(name) == true) {
ret = GALLUS_RESULT_NOT_FOUND;
if (retmptr != NULL) {
*retmptr = NULL;
}
if (s_n_modules > 0) {
a_module *mptr;
size_t i;
for (i = 0; i < s_n_modules; i++) {
mptr = &(s_modules[i]);
if (strcmp(mptr->m_name, name) == 0) {
if (retmptr != NULL) {
*retmptr = mptr;
return (gallus_result_t)i;
}
}
}
}
} else {
ret = GALLUS_RESULT_INVALID_ARGS;
}
return ret;
}
开发者ID:uTnOJkji5quPSNE5,项目名称:gallus,代码行数:31,代码来源:module.c
示例15: s_once_proc
static void
s_once_proc(void) {
char *dbg_lvl_str = getenv("MCCP_LOG_DEBUGLEVEL");
char *logfile = getenv("MCCP_LOG_FILE");
uint64_t d = 0;
mccp_log_destination_t log_dst = MCCP_LOG_EMIT_TO_UNKNOWN;
if (IS_VALID_STRING(dbg_lvl_str) == true) {
uint64_t tmp = 0;
if (mccp_str_parse_uint64(dbg_lvl_str, &tmp) == MCCP_RESULT_OK) {
d = tmp;
}
}
if ((logfile = s_validate_path(logfile, s_is_valid_path)) != NULL) {
log_dst = MCCP_LOG_EMIT_TO_FILE;
}
if (mccp_log_initialize(log_dst, logfile, false, true, d, 0LL) !=
MCCP_RESULT_OK) {
mccp_exit_error(1, "logger initialization error.\n");
}
if (d > 0) {
mccp_msg_debug(d, "Logger debug level is set to: " PF64(u) ".\n", d);
}
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:26,代码来源:logger.c
示例16: mccp_str_parse_int64
mccp_result_t
mccp_str_parse_int64(const char *buf, int64_t *val) {
mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(buf) == true &&
val != NULL) {
MP_INT v;
mpz_init(&v);
if ((ret = s_parse_bigint_in_range(buf, &v,
&s_LLONG_MIN, &s_LLONG_MAX)) ==
MCCP_RESULT_OK) {
#ifdef MCCP_ARCH_64_BITS
*val = (int64_t)mpz_get_si(&v);
#else
*val = (int64_t)s_bignum_2_uint64_t(&v);
#endif /* MCCP_ARCH_64_BITS */
}
mpz_clear(&v);
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:26,代码来源:strutils.c
示例17: s_parse_snmp
static lagopus_result_t
s_parse_snmp(datastore_interp_t *iptr,
datastore_interp_state_t state,
size_t argc, const char *const argv[],
lagopus_hashmap_t *hptr,
datastore_update_proc_t u_proc,
datastore_enable_proc_t e_proc,
datastore_serialize_proc_t s_proc,
datastore_destroy_proc_t d_proc,
lagopus_dstring_t *result) {
lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
size_t i;
(void)iptr;
(void)state;
(void)argc;
(void)hptr;
(void)u_proc;
(void)e_proc;
(void)s_proc;
(void)d_proc;
for (i = 0; i < argc; i++) {
lagopus_msg_debug(1, "argv[" PFSZS(4, u) "]:\t'%s'\n", i, argv[i]);
}
argv++;
if (IS_VALID_STRING(*argv) == false) {
ret = s_parse_snmp_show(result);
} else {
ret = s_parse_snmp_internal(argv, result);
}
return ret;
}
开发者ID:JackieXie168,项目名称:lagopus,代码行数:35,代码来源:snmp_cmd.c
示例18: mccp_str_parse_int16_by_base
mccp_result_t
mccp_str_parse_int16_by_base(const char *buf, int16_t *val,
unsigned int base) {
mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
if (IS_VALID_STRING(buf) == true &&
val != NULL &&
base > 1) {
MP_INT v;
mpz_init(&v);
if ((ret = s_parse_bigint_by_base_in_range(buf, &v, base,
&s_SHRT_MIN, &s_SHRT_MAX)) ==
MCCP_RESULT_OK) {
#ifdef MCCP_ARCH_64_BITS
int64_t v64 = (int64_t)mpz_get_si(&v);
*val = (int16_t)v64;
#else
int64_t v64 = (int64_t)s_bignum_2_uint64_t(&v);
*val = (int16_t)v64;
#endif /* MCCP_ARCH_64_BITS */
}
mpz_clear(&v);
}
return ret;
}
开发者ID:GPtpvWKrrZWERTEg,项目名称:mccp,代码行数:30,代码来源:strutils.c
示例19: parse_args
static void
parse_args(int argc, const char *const argv[]) {
(void)argc;
while (*argv != NULL) {
if (strcmp("--help", *argv) == 0 ||
strcmp("-?", *argv) == 0) {
usage(stderr);
exit(0);
} else if (strcmp("-to", *argv) == 0) {
if (IS_VALID_STRING(*(argv + 1)) == true) {
int64_t tmp;
argv++;
if (lagopus_str_parse_int64(*argv, &tmp) == LAGOPUS_RESULT_OK) {
if (tmp >= 0) {
s_to = ONE_SEC * tmp;
}
} else {
fprintf(stderr, "can't parse \"%s\" as a number.\n", *argv);
exit(1);
}
} else {
fprintf(stderr, "A timeout # is not specified.\n");
exit(1);
}
}
argv++;
}
}
开发者ID:hibitomo,项目名称:lagopus,代码行数:29,代码来源:dummy-main.c
示例20: s_log_reinit
static inline bool
s_log_reinit(void) {
const char *arg =
(IS_VALID_STRING(s_log_arg) == true) ? s_log_arg : NULL;
bool ret = s_log_init(s_log_dst, arg,
s_do_multi_process, s_do_date, s_dbg_level);
return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:9,代码来源:logger.c
注:本文中的IS_VALID_STRING函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论