aboutsummaryrefslogtreecommitdiffstats
path: root/src/location-manual.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-03-16 22:36:46 +0100
committerMattias Andrée <m@maandree.se>2025-03-16 22:36:46 +0100
commitf84a3ba77c61a351e1d7efb67bd40db23a435281 (patch)
tree83948f9074f2c761913cbb648f8b36bcdae43367 /src/location-manual.c
parentMajor refactoring and some fixes (diff)
downloadredshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.gz
redshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.bz2
redshift-ng-f84a3ba77c61a351e1d7efb67bd40db23a435281.tar.xz
Refactor
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/location-manual.c')
-rw-r--r--src/location-manual.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/location-manual.c b/src/location-manual.c
index 8df1874..a394f29 100644
--- a/src/location-manual.c
+++ b/src/location-manual.c
@@ -25,17 +25,17 @@ struct location_state {
static int
-location_manual_init(struct location_state **state)
+manual_create(struct location_state **state_out)
{
- *state = emalloc(sizeof(**state));
- (*state)->loc.latitude = NAN;
- (*state)->loc.longitude = NAN;
+ *state_out = emalloc(sizeof(**state_out));
+ (*state_out)->loc.latitude = NAN;
+ (*state_out)->loc.longitude = NAN;
return 0;
}
GCC_ONLY(__attribute__((__pure__)))
static int
-location_manual_start(struct location_state *state)
+manual_start(struct location_state *state)
{
if (isnan(state->loc.latitude) || isnan(state->loc.longitude))
eprintf(_("Latitude and longitude must be set."));
@@ -43,13 +43,13 @@ location_manual_start(struct location_state *state)
}
static void
-location_manual_free(struct location_state *state)
+manual_free(struct location_state *state)
{
free(state);
}
static void
-location_manual_print_help(FILE *f)
+manual_print_help(FILE *f)
{
fputs(_("Specify location manually.\n"), f);
fputs("\n", f);
@@ -65,7 +65,7 @@ location_manual_print_help(FILE *f)
}
static int
-location_manual_set_option(struct location_state *state, const char *key, const char *value)
+manual_set_option(struct location_state *state, const char *key, const char *value)
{
/* Parse float value */
char *end;
@@ -91,28 +91,19 @@ location_manual_set_option(struct location_state *state, const char *key, const
}
static int
-location_manual_get_fd(struct location_state *state)
+manual_get_fd(struct location_state *state)
{
(void) state;
return -1;
}
static int
-location_manual_handle(struct location_state *state, struct location *location, int *available)
+manual_fetch(struct location_state *state, struct location *location_out, int *available_out)
{
- *location = state->loc;
- *available = 1;
+ *location_out = state->loc;
+ *available_out = 1;
return 0;
}
-const struct location_provider manual_location_provider = {
- "manual",
- &location_manual_init,
- &location_manual_start,
- &location_manual_free,
- &location_manual_print_help,
- &location_manual_set_option,
- &location_manual_get_fd,
- &location_manual_handle
-};
+const struct location_provider manual_location_provider = LOCATION_PROVIDER_INIT("manual", manual);