int cmd_str(FILE * f, int argc, char ** argv) { int ret = 0; int i; if (argc == 1) return const_strbuf_dump(f); for (i = 1; i < argc; ++i) { if ((ret = const_str_add(argv[i], strlen(argv[i]))) < 0) break; } return ret; }
int db_pw_enc(struct microjs_json_parser * jsn, int typ, struct microjs_val * val, struct pw_entry * pw) { int desc = 0; uint16_t min; uint16_t max; int ret; if (typ == MICROJS_JSON_STRING) { DCC_LOG(LOG_MSG, "string!"); if ((ret = const_str_add(val->str.dat, val->str.len)) < 0) return ret; desc = ret; typ = microjs_json_get_val(jsn, val); } if (typ != MICROJS_JSON_INTEGER) { DCC_LOG(LOG_ERROR, "expecting integer!"); return -1; } min = val->u32; max = min; DCC_LOG1(LOG_MSG, "min=%d", min); if ((typ = microjs_json_get_val(jsn, val)) == MICROJS_JSON_INTEGER) { max = val->u32; DCC_LOG1(LOG_MSG, "max=%d", max); typ = microjs_json_get_val(jsn, val); } if (typ != MICROJS_JSON_END_ARRAY) { DCC_LOG(LOG_ERROR, "expecting array closing!"); return -1; } pw->min = min; pw->max = max; pw->desc = desc; return 0; }