чување 7f14344e67799376cb64b3e70d270eb5923e3a56
родитељ eb90a58c1cb0d2b5c66d3a546c63aa93d69fe32c
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Wed, 1 May 2024 22:03:11 +0200
Add -V
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | defs.h | | | 7 | ++++--- |
| M | slweb.c | | | 35 | ++++++++++++++++++++++++++--------- |
измењених датотека: 2, додавања: 30(+), брисања: 12(-)
diff --git a/defs.h b/defs.h
@@ -20,10 +20,10 @@
#include <unistd.h>
#ifndef strlcpy
-size_t strlcpy(char *dst, const char *src, size_t dsize);
+size_t strlcpy(char* dst, const char* src, size_t dsize);
#endif
#ifndef strlcat
-size_t strlcat(char *dst, const char *src, size_t dsize);
+size_t strlcat(char* dst, const char* src, size_t dsize);
#endif
#include "version.h"
@@ -69,7 +69,8 @@ typedef enum {
CMD_BASEDIR,
CMD_HELP,
CMD_LINK_PREFIX,
- CMD_VERSION
+ CMD_VERSION,
+ CMD_FULL_VERSION
} Command;
typedef struct {
diff --git a/slweb.c b/slweb.c
@@ -41,6 +41,13 @@ static long tsv_iter = 0;
static ULLONG state = ST_NONE;
static int incdir_only_summary = 0;
+#define COPYRIGHT \
+ (" This program is licensed under the terms of GNU GPL v3" \
+ " or (at your option)\n" \
+ " any later version. Copyright (C) 2020-2024 Strahinya Radich.\n" \
+ " See the file LICENSE for exact copyright and license " \
+ "details.")
+
#define CHECKEXITNOMEM(ptr) \
do \
{ \
@@ -92,22 +99,25 @@ static int incdir_only_summary = 0;
int slweb_cleanup(void);
int usage(void);
-int version(void);
+int version(const int full);
int
-version(void)
+version(const int full)
{
printf("%s %s, committed on %s\n", PROGRAMNAME, VERSION, DATE);
+ if (full)
+ puts(COPYRIGHT);
return 0;
}
int
usage(void)
{
- printf("Usage: %s [-b|--body-only] [-d|--basedir <dir>]"
- " [-p|--global-link-prefix <URL>] [-h|--help]"
- " [-v|--version] [filename]\n",
- PROGRAMNAME);
+ printf("Usage:\t%s -h | --help | -V | --full-version | -v | --version\n"
+ "\t%s [-b] [-d directory] [-p URL] [filename]\n"
+ "\t%s [--body-only] [--basedir directory]"
+ " [--global-link-prefix URL] [filename]\n",
+ PROGRAMNAME, PROGRAMNAME, PROGRAMNAME);
return 0;
}
@@ -5593,7 +5603,9 @@ main(const int argc, const char** argv)
if (c == '-')
{
- if (!strcmp(arg, "version"))
+ if (!strcmp(arg, "full-version"))
+ cmd = CMD_FULL_VERSION;
+ else if (!strcmp(arg, "version"))
cmd = CMD_VERSION;
else if (!strcmp(arg, "body-only"))
{
@@ -5644,6 +5656,9 @@ main(const int argc, const char** argv)
case 'p':
cmd = CMD_LINK_PREFIX;
break;
+ case 'V':
+ cmd = CMD_FULL_VERSION;
+ break;
case 'v':
cmd = CMD_VERSION;
break;
@@ -5683,8 +5698,10 @@ main(const int argc, const char** argv)
if (cmd == CMD_BASEDIR)
return error(1, (u8*)"-d: Argument required");
- if (cmd == CMD_VERSION)
- return version();
+ if (cmd == CMD_FULL_VERSION)
+ return version(1);
+ else if (cmd == CMD_VERSION)
+ return version(0);
FILE* input = NULL;
FILE* output = stdout;