aboutsummaryrefslogtreecommitdiffstats
path: root/src/location-manual.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/location-manual.c')
-rw-r--r--src/location-manual.c57
1 files changed, 20 insertions, 37 deletions
diff --git a/src/location-manual.c b/src/location-manual.c
index 7ab9162..0048128 100644
--- a/src/location-manual.c
+++ b/src/location-manual.c
@@ -15,40 +15,23 @@
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2010-2017 Jon Lund Steffensen <jonlst@gmail.com>
+ Copyright (c) 2025 Mattias Andrée <m@maandree.se>
*/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-#include <errno.h>
-
#include "common.h"
-#ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(s) gettext(s)
-#else
-# define _(s) s
-#endif
-
-typedef struct {
- location_t loc;
-} location_manual_state_t;
+struct location_state {
+ struct location loc;
+};
static int
-location_manual_init(location_manual_state_t **state)
+location_manual_init(struct location_state **state)
{
- *state = malloc(sizeof(location_manual_state_t));
+ *state = malloc(sizeof(struct location_state));
if (*state == NULL) return -1;
- location_manual_state_t *s = *state;
+ struct location_state *s = *state;
s->loc.lat = NAN;
s->loc.lon = NAN;
@@ -56,7 +39,7 @@ location_manual_init(location_manual_state_t **state)
}
static int
-location_manual_start(location_manual_state_t *state)
+location_manual_start(struct location_state *state)
{
/* Latitude and longitude must be set */
if (isnan(state->loc.lat) || isnan(state->loc.lon)) {
@@ -68,7 +51,7 @@ location_manual_start(location_manual_state_t *state)
}
static void
-location_manual_free(location_manual_state_t *state)
+location_manual_free(struct location_state *state)
{
free(state);
}
@@ -90,7 +73,7 @@ location_manual_print_help(FILE *f)
}
static int
-location_manual_set_option(location_manual_state_t *state, const char *key,
+location_manual_set_option(struct location_state *state, const char *key,
const char *value)
{
/* Parse float value */
@@ -115,14 +98,14 @@ location_manual_set_option(location_manual_state_t *state, const char *key,
}
static int
-location_manual_get_fd(location_manual_state_t *state)
+location_manual_get_fd(struct location_state *state)
{
return -1;
}
static int
location_manual_handle(
- location_manual_state_t *state, location_t *location, int *available)
+ struct location_state *state, struct location *location, int *available)
{
*location = state->loc;
*available = 1;
@@ -131,13 +114,13 @@ location_manual_handle(
}
-const location_provider_t manual_location_provider = {
+const struct location_provider manual_location_provider = {
"manual",
- (location_provider_init_func *)location_manual_init,
- (location_provider_start_func *)location_manual_start,
- (location_provider_free_func *)location_manual_free,
- (location_provider_print_help_func *)location_manual_print_help,
- (location_provider_set_option_func *)location_manual_set_option,
- (location_provider_get_fd_func *)location_manual_get_fd,
- (location_provider_handle_func *)location_manual_handle
+ &location_manual_init,
+ &location_manual_start,
+ &location_manual_free,
+ &location_manual_print_help,
+ &location_manual_set_option,
+ &location_manual_get_fd,
+ &location_manual_handle
};