aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-03-27 20:00:54 +0100
committerMattias Andrée <m@maandree.se>2025-03-27 20:00:54 +0100
commit8731767251de4633b0f8d9e17f6f0e15b5d3ea18 (patch)
tree35d152f922972f11bcd0aec0f2c864e990fec48d
parentAdd patterns for commands (breaks backwards compatbility because libgeome_get_from_netservice was inlined) + add libgeome_get_portability (diff)
downloadlibgeome-8731767251de4633b0f8d9e17f6f0e15b5d3ea18.tar.gz
libgeome-8731767251de4633b0f8d9e17f6f0e15b5d3ea18.tar.bz2
libgeome-8731767251de4633b0f8d9e17f6f0e15b5d3ea18.tar.xz
Add libgeome_default_geolocation_file
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Makefile1
-rw-r--r--TODO1
-rw-r--r--libgeome.h10
-rw-r--r--libgeome_default_geolocation_file.c5
-rw-r--r--libgeome_get_from_file.c2
5 files changed, 16 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f86cb27..a300c5b 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ LIB_NAME = geome
OBJ =\
libgeome_netservices.o\
+ libgeome_default_geolocation_file.o\
libgeome_basic_context.o\
libgeome_get_portability.o\
libgeome_get_from_time.o\
diff --git a/TODO b/TODO
index 1ad9a60..ced7b6c 100644
--- a/TODO
+++ b/TODO
@@ -15,4 +15,3 @@ Add support for more automatic location determination
Add geome utility
Add support for detecting WiFi and cell towers, using a location service to get a location
Add support for detecting changes in nearby WiFi and cell towers
-Make default file for libgeome_get_from_file visible to application
diff --git a/libgeome.h b/libgeome.h
index da9b216..a4257a5 100644
--- a/libgeome.h
+++ b/libgeome.h
@@ -246,6 +246,14 @@ extern const struct libgeome_netservice libgeome_netservices[];
*/
extern const size_t libgeome_netservices_count;
+/**
+ * The default file for `libgeome_get_from_file`
+ *
+ * By default this is `/etc/geolocation`, but it can be
+ * changed at compile-time
+ */
+extern const char *const libgeome_default_geolocation_file;
+
/**
* Create a basic initialisation for `struct libgeome_context`
@@ -320,7 +328,7 @@ int libgeome_get_from_timezone(struct libgeome_context *ctx, struct libgeome_dat
* This function will get both the latitude and
* the longitude but nothing more
*
- * The default file is /etc/geolocation unless changed at compile time
+ * The default file stored in `libgeome_default_geolocation_file`
*
* @param ctx Library context
* @param out Output parameter, `out->requested_data` must be set
diff --git a/libgeome_default_geolocation_file.c b/libgeome_default_geolocation_file.c
new file mode 100644
index 0000000..a0d7017
--- /dev/null
+++ b/libgeome_default_geolocation_file.c
@@ -0,0 +1,5 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+const char *const libgeome_default_geolocation_file = GEOFILE;
diff --git a/libgeome_get_from_file.c b/libgeome_get_from_file.c
index bbed448..59ad662 100644
--- a/libgeome_get_from_file.c
+++ b/libgeome_get_from_file.c
@@ -39,7 +39,7 @@ libgeome_get_from_file(struct libgeome_context *ctx, struct libgeome_data *out,
int r;
if (!path)
- path = GEOFILE;
+ path = libgeome_default_geolocation_file;
f = fopen(path, "r");
if (!f) {