commit 51bd2b6121ff710559a752937750c6395a08c853
parent f033d2c9f22d0efb1c8800cbf5d863416456b5ed
Author: Florian Dold <florian@dold.me>
Date: Mon, 17 Nov 2025 14:39:52 +0100
allow loading SPA from absolute dir
Diffstat:
2 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/src/include/taler/taler_mhd_lib.h b/src/include/taler/taler_mhd_lib.h
@@ -1113,7 +1113,9 @@ TALER_MHD_reply_cors_preflight (struct MHD_Connection *connection);
/**
- * Load SPA files from @a dir
+ * Load SPA files from @a dir, relative to the project's
+ * data directory.
+ *
*
* @param pd project data to use to determine the parent directory
* @param dir directory suffix to append to our data directory with the location of the files of the SPA
@@ -1123,6 +1125,17 @@ struct TALER_MHD_Spa *
TALER_MHD_spa_load (const struct GNUNET_OS_ProjectData *pd,
const char *dir);
+/**
+ * Load SPA files from absolute path to directory @a dn.
+ *
+ *
+ * @param dn directory with the location of the files of the SPA,
+ * should be an absolute path.
+ * @return handle to serve static files from @a dir
+ */
+struct TALER_MHD_Spa *
+TALER_MHD_spa_load_dir (const char *dn);
+
/**
* Release resources used by SPA handler.
diff --git a/src/mhd/mhd_spa.c b/src/mhd/mhd_spa.c
@@ -296,28 +296,10 @@ build_webui (void *cls,
struct TALER_MHD_Spa *
-TALER_MHD_spa_load (const struct GNUNET_OS_ProjectData *pd,
- const char *dir)
+TALER_MHD_spa_load_dir (const char *dn)
{
struct TALER_MHD_Spa *spa;
- char *dn;
- {
- char *path;
-
- path = GNUNET_OS_installation_get_path (pd,
- GNUNET_OS_IPK_DATADIR);
- if (NULL == path)
- {
- GNUNET_break (0);
- return NULL;
- }
- GNUNET_asprintf (&dn,
- "%s%s",
- path,
- dir);
- GNUNET_free (path);
- }
spa = GNUNET_new (struct TALER_MHD_Spa);
if (-1 ==
GNUNET_DISK_directory_scan (dn,
@@ -327,15 +309,36 @@ TALER_MHD_spa_load (const struct GNUNET_OS_ProjectData *pd,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to load WebUI from `%s'\n",
dn);
- GNUNET_free (dn);
TALER_MHD_spa_free (spa);
return NULL;
}
- GNUNET_free (dn);
return spa;
}
+struct TALER_MHD_Spa *
+TALER_MHD_spa_load (const struct GNUNET_OS_ProjectData *pd,
+ const char *dir)
+{
+ char *dn;
+ char *path;
+
+ path = GNUNET_OS_installation_get_path (pd,
+ GNUNET_OS_IPK_DATADIR);
+ if (NULL == path)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ GNUNET_asprintf (&dn,
+ "%s%s",
+ path,
+ dir);
+ GNUNET_free (path);
+ return TALER_MHD_spa_load_dir (dn);
+}
+
+
void
TALER_MHD_spa_free (struct TALER_MHD_Spa *spa)
{