From a93feb77d01cb05e665107b1f935edebb3d09388 Mon Sep 17 00:00:00 2001 From: ngn Date: Sat, 10 Aug 2024 23:56:33 +0300 Subject: [PATCH] new: add pool path option --- locale/tr/LC_MESSAGES/pooler.po | 26 +++++++++++++------------- src/config.c | 5 +++++ src/config.h | 1 + src/main.c | 10 ++++++++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/locale/tr/LC_MESSAGES/pooler.po b/locale/tr/LC_MESSAGES/pooler.po index 3f9644b..41ff7cb 100644 --- a/locale/tr/LC_MESSAGES/pooler.po +++ b/locale/tr/LC_MESSAGES/pooler.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-08 15:46+0300\n" +"POT-Creation-Date: 2024-08-10 23:56+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,27 +17,27 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/config.c:125 +#: src/config.c:130 #, c-format msgid "Unknown configuration option: %s" msgstr "" -#: src/config.c:127 +#: src/config.c:132 #, c-format msgid "Unknown configuration option: %s/%s" msgstr "" -#: src/config.c:135 +#: src/config.c:140 #, fuzzy, c-format msgid "Failed to access the configuration file: %s" msgstr "Kayıt dosyasını açmak başarısız oldu: %s" -#: src/config.c:140 +#: src/config.c:145 #, fuzzy msgid "Failed to parse the configuration" msgstr "Kayıt dosyasını açmak başarısız oldu: %s" -#: src/config.c:147 +#: src/config.c:152 #, fuzzy, c-format msgid "Hostname not specified for the pool: %s" msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s" @@ -118,37 +118,37 @@ msgstr "%s: havuz bilgisi başarıyla yüklendi" msgid "%s: hostname not specified for pool, skipping" msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s" -#: src/main.c:157 +#: src/main.c:163 #, fuzzy, c-format msgid "%s: failed access the pool directory (%s)" msgstr "Havuz dizinine erişilemiyor: %s" -#: src/main.c:162 +#: src/main.c:168 #, fuzzy, c-format msgid "%s: failed to add pool to the list (%s)" msgstr "Havuzu listeye eklemek başarısız oldu: %s" -#: src/main.c:170 +#: src/main.c:176 #, c-format msgid "Failed to sync the pools: %s" msgstr "Havuzları sekronize etmek başarısız oldu: %s" -#: src/main.c:175 +#: src/main.c:181 #, fuzzy msgid "None of the pools is available for serving" msgstr "Havuzların hiçbiri sunmak için müsait değil" -#: src/main.c:179 +#: src/main.c:185 #, c-format msgid "Serving %lu pool on %s" msgstr "%lu tane havuz %s adresinde sunuluyor" -#: src/main.c:179 +#: src/main.c:185 #, c-format msgid "Serving %lu pools on %s" msgstr "%lu tane havuz %s adresinde sunuluyor" -#: src/main.c:182 +#: src/main.c:188 #, c-format msgid "Failed to start the server: %s" msgstr "Sunucuyu başlatmak başarısız oldu: %s" diff --git a/src/config.c b/src/config.c index e672719..3e25c91 100644 --- a/src/config.c +++ b/src/config.c @@ -110,6 +110,11 @@ int config_load_handler(void *data, const char *_section, const char *_key, cons config.pools->host = strdup(value); } + else if (eq(key, "path")) { + free(config.pools->path); + config.pools->path = strdup(value); + } + else if (eq(key, "dir")) { free(config.pools->dir); config.pools->dir = strdup(value); diff --git a/src/config.h b/src/config.h index 89c71f3..4d396a7 100644 --- a/src/config.h +++ b/src/config.h @@ -23,6 +23,7 @@ typedef struct pool_config { struct pool_config *next; char *name; char *host; + char *path; char *dir; } pool_config_t; diff --git a/src/main.c b/src/main.c index 9cf634a..77bf64b 100644 --- a/src/main.c +++ b/src/main.c @@ -150,8 +150,14 @@ int main(int argc, char *argv[]) { goto end_ctx; } - char url[strlen(pool->host) + 20]; - sprintf(url, "mptp://%s", pool->host); + char url[strlen(pool->host) + 20 + (pool->path == NULL ? 0 : strlen(pool->path))]; + + if (NULL == pool->path) + sprintf(url, "mptp://%s/", pool->host); + else if (pool->path[0] == '/') + sprintf(url, "mptp://%s%s", pool->host, pool->path); + else + sprintf(url, "mptp://%s/%s", pool->host, pool->path); if (!file_canread(pool->dir)) { error(_("%s: failed access the pool directory (%s)"), pool->name, pool->dir);