aboutsummaryrefslogtreecommitdiffstats
path: root/src/location-geofile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/location-geofile.c')
-rw-r--r--src/location-geofile.c114
1 files changed, 0 insertions, 114 deletions
diff --git a/src/location-geofile.c b/src/location-geofile.c
deleted file mode 100644
index 62d6b26..0000000
--- a/src/location-geofile.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * redshift-ng - Automatically adjust display colour temperature according the Sun
- *
- * Copyright (c) 2009-2018 Jon Lund Steffensen <jonlst@gmail.com>
- * Copyright (c) 2014-2016, 2025 Mattias Andrée <m@maandree.se>
- *
- * redshift-ng is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * redshift-ng is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with redshift-ng. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "common.h"
-
-
-struct location_state {
- /**
- * The loaded location
- */
- struct location location;
-
- /**
- * File to read location from, `NULL` for default
- */
- char *file;
-};
-
-
-static int
-geofile_create(struct location_state **state_out)
-{
- *state_out = emalloc(sizeof(**state_out));
- (*state_out)->file = NULL;
- return 0;
-}
-
-
-GCC_ONLY(__attribute__((__pure__)))
-static int
-geofile_start(struct location_state *state)
-{
- struct libgeome_data data = {.requested_data = LIBGEOME_DATUM_LATITUDE | LIBGEOME_DATUM_LONGITUDE};
- struct libgeome_context ctx;
- int r;
- libgeome_basic_context(&ctx, argv0);
- r = libgeome_get_from_file(&ctx, &data, state->file);
- free(state->file);
- state->file = NULL;
- if (r || data.requested_data != (LIBGEOME_DATUM_LATITUDE | LIBGEOME_DATUM_LONGITUDE))
- return -1;
- state->location.latitude = data.latitude;
- state->location.longitude = data.longitude;
- return 0;
-}
-
-
-static void
-geofile_free(struct location_state *state)
-{
- free(state->file);
- free(state);
-}
-
-
-static void
-geofile_print_help(void)
-{
- printf(_("Specify location via file.\n"));
- printf("\n");
-
- printf(" file=%s %s\n", _("FILE "), _("File to read location from (empty for default)"));
- printf("\n");
-}
-
-
-static int
-geofile_set_option(struct location_state *state, const char *key, const char *value)
-{
- if (!strcasecmp(key, "file")) {
- free(state->file);
- state->file = *value ? estrdup(value) : NULL;
- return 0;
- } else {
- weprintf(_("Unknown provider parameter: `%s'."), key);
- return -1;
- }
-}
-
-
-static int
-geofile_get_fd(struct location_state *state)
-{
- (void) state;
- return -1;
-}
-
-
-static int
-geofile_fetch(struct location_state *state, struct location *location_out, int *available_out)
-{
- *location_out = state->location;
- *available_out = 1;
- return 0;
-}
-
-
-const struct location_provider geofile_location_provider = LOCATION_PROVIDER_INIT("geofile", geofile);