Skip to content

Commit adf3bb9

Browse files
committed
Update help message defaults based on config.h
This change moves default value macros from config.c to config.h and updates the help message in main.c to use these macros. This reduces maintenance load by ensuring that the help message always reflects the actual default values used in the code. Resolves #150
1 parent 749eed3 commit adf3bb9

4 files changed

Lines changed: 38 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ and this project adheres to
2121
([3a53c40](https://github.com/fangfufu/httpdirfs/commit/3a53c40))
2222
(https://github.com/fangfufu/httpdirfs/issues/177).
2323

24+
### Changed
25+
26+
- Update help's default value based on `config.h`
27+
(https://github.com/fangfufu/httpdirfs/issues/150).
28+
2429
## [1.2.8] - 2026-05-10
2530

2631
### Added

src/config.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@
33
#include "log.h"
44
#include <stddef.h>
55

6-
/**
7-
* \brief The default HTTP 429 (too many requests) wait time
8-
*/
9-
#define DEFAULT_HTTP_WAIT_SEC 5
10-
/**
11-
* \brief Data file block size
12-
* \details We set it to 1024*1024*8 = 8MiB
13-
*/
14-
#define DEFAULT_DATA_BLKSZ (8 * 1024 * 1024)
15-
16-
/**
17-
* \brief Maximum segment block count
18-
* \details This is set to 128*1024 blocks, which uses 128KB. By default,
19-
* this allows the user to store (128*1024)*(8*1024*1024) = 1TB of data
20-
*/
21-
#define DEFAULT_MAX_SEGBC (128 * 1024)
226

237
ConfigStruct CONFIG;
248

src/config.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@
2828
*/
2929
#define DEFAULT_REFRESH_TIMEOUT 3600
3030

31+
/**
32+
* \brief The default HTTP 429 (too many requests) wait time
33+
*/
34+
#define DEFAULT_HTTP_WAIT_SEC 5
35+
36+
/**
37+
* \brief Data file block size in MB
38+
*/
39+
#define DEFAULT_DATA_BLKSZ_MB 8
40+
41+
/**
42+
* \brief Data file block size
43+
* \details We set it to 1024*1024*8 = 8MiB
44+
*/
45+
#define DEFAULT_DATA_BLKSZ (DEFAULT_DATA_BLKSZ_MB * 1024 * 1024)
46+
47+
/**
48+
* \brief Maximum segment block count
49+
* \details This is set to 128*1024 blocks, which uses 128KB. By default,
50+
* this allows the user to store (128*1024)*(8*1024*1024) = 1TB of data
51+
*/
52+
#define DEFAULT_MAX_SEGBC (128 * 1024)
53+
54+
#define STR(x) #x
55+
#define XSTR(x) STR(x)
56+
3157
/**
3258
* \brief Operation modes
3359
*/

src/main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,23 +440,24 @@ HTTPDirFS options:\n\
440440
specified with `--cache-location`, if the option is\n\
441441
seen first. Then exit in either case.\n\
442442
--cacert Certificate authority for the server\n\
443-
--dl-seg-size Set cache download segment size, in MB (default: 8)\n\
443+
--dl-seg-size Set cache download segment size, in MB (default: " XSTR(
444+
DEFAULT_DATA_BLKSZ_MB) ")\n\
444445
Note: this setting is ignored if previously\n\
445446
cached data is found for the requested file.\n\
446447
--http-header Set one or more HTTP headers\n\
447448
--max-seg-count Set maximum number of download segments a file\n\
448-
can have. (default: 128*1024)\n\
449+
can have. (default: " XSTR(DEFAULT_MAX_SEGBC) ")\n\
449450
With the default setting, the maximum memory usage\n\
450451
per file is 128KB. This allows caching files up\n\
451452
to 1TB in size using the default segment size.\n\
452453
--max-conns Set maximum number of network connections that\n\
453-
libcurl is allowed to make. (default: 10)\n\
454+
libcurl is allowed to make. (default: " XSTR(DEFAULT_NETWORK_MAX_CONNS) ")\n\
454455
--refresh-timeout The directories are refreshed after the specified\n\
455-
time, in seconds (default: 3600)\n\
456+
time, in seconds (default: " XSTR(DEFAULT_REFRESH_TIMEOUT) ")\n\
456457
--retry-wait Set delay in seconds before retrying an HTTP request\n\
457-
after encountering an error. (default: 5)\n\
458+
after encountering an error. (default: " XSTR(DEFAULT_HTTP_WAIT_SEC) ")\n\
458459
--invalid-refresh Try refreshing invalid links when reading a directory.\n\
459-
--user-agent Set user agent string (default: \"HTTPDirFS\")\n\
460+
--user-agent Set user agent string (default: \"" DEFAULT_USER_AGENT "\")\n\
460461
--no-range-check Disable the built-in check for the server's support\n\
461462
for HTTP range requests\n\
462463
--zero-len-is-dir If a file has a zero length, treat it as a directory\n\

0 commit comments

Comments
 (0)