bool str_to_int(const char *s, int base, int *i) { long long ll; bool ok = str_to_llong(s, base, &ll); *i = ll; return ok; }
bool str_to_long(const char *s, int base, long *li) { long long ll; bool ok = str_to_llong(s, base, &ll); *li = ll; return ok; }
static void cmd_dict_inc(int argc, char *argv[]) { struct dict *dict; struct dict_transaction_context *trans; long long diff; int ret; dict = cmd_dict_init(&argc, &argv, 2, 0, cmd_dict_inc); if (str_to_llong(argv[1], &diff) < 0) i_fatal("Invalid diff: %s", argv[1]); trans = dict_transaction_begin(dict); dict_atomic_inc(trans, argv[0], diff); ret = dict_transaction_commit(&trans); if (ret < 0) { i_error("dict_transaction_commit() failed"); doveadm_exit_code = EX_TEMPFAIL; } else if (ret == 0) { i_error("%s doesn't exist", argv[0]); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } dict_deinit(&dict); }
bool str_to_ullong(const char *s, int base, unsigned long long *ull) { return str_to_llong(s, base, (long long *) ull); }