static int prompt_timezone(void) { _cleanup_strv_free_ char **zones = NULL; int r; if (arg_timezone) return 0; if (!arg_prompt_timezone) return 0; r = get_timezones(&zones); if (r < 0) return log_error_errno(r, "Cannot query timezone list: %m"); print_welcome(); printf("\nAvailable Time Zones:\n\n"); r = show_menu(zones, 3, 22, 30); if (r < 0) return r; putchar('\n'); r = prompt_loop("Please enter timezone name or number", zones, timezone_is_valid, &arg_timezone); if (r < 0) return r; return 0; }
static void test_get_timezones(void) { _cleanup_strv_free_ char **zones = NULL; int r; char **zone; r = get_timezones(&zones); assert_se(r == 0); STRV_FOREACH(zone, zones) { assert_se(timezone_is_valid(*zone)); }
static int list_timezones(int argc, char **argv, void *userdata) { _cleanup_strv_free_ char **zones = NULL; int r; r = get_timezones(&zones); if (r < 0) return log_error_errno(r, "Failed to read list of time zones: %m"); (void) pager_open(arg_no_pager, false); strv_print(zones); return 0; }
static void test_get_timezones(void) { _cleanup_strv_free_ char **zones = NULL; int r; char **zone; log_info("/* %s */", __func__); r = get_timezones(&zones); assert_se(r == 0); STRV_FOREACH(zone, zones) assert_se(timezone_is_valid(*zone, LOG_ERR)); }
static int list_timezones(sd_bus *bus, char **args, unsigned n) { _cleanup_strv_free_ char **zones = NULL; int r; assert(args); assert(n == 1); r = get_timezones(&zones); if (r < 0) return log_error_errno(r, "Failed to read list of time zones: %m"); pager_open(arg_no_pager, false); strv_print(zones); return 0; }
static int list_timezones(sd_bus *bus, char **args, unsigned n) { _cleanup_strv_free_ char **zones = NULL; int r; assert(args); assert(n == 1); r = get_timezones(&zones); if (r < 0) { log_error("Failed to read list of time zones: %s", strerror(-r)); return r; } pager_open_if_enabled(); strv_print(zones); return 0; }