feat: --version
This commit is contained in:
parent
80e34d8158
commit
ebb8a91859
7 changed files with 66 additions and 3 deletions
|
|
@ -8,9 +8,15 @@
|
|||
#define STATIC_ARRAY_FOREACH(arr, ptr) \
|
||||
for ((ptr) = (arr); (ptr) < (arr) + COUNT_OF(arr); (ptr)++)
|
||||
|
||||
#define STRX(x) #x
|
||||
#define STR(x) STRX(x)
|
||||
|
||||
#define HAS_FLAG(flags, flag) ((flags) & (flag))
|
||||
#define SET_FLAG(flags, flag) ((flags) |= (flag))
|
||||
#define CLEAR_FLAG(flags, flag) ((flags) &= ~(flag))
|
||||
#define TOGGLE_FLAG(flags, flag) ((flags) ^= (flag))
|
||||
|
||||
#define FOREACH_SECTION(item, type, section) \
|
||||
for (type *item = __start_##section; item < __stop_##section; ++item)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
29
includes/internal/dependencies.h
Normal file
29
includes/internal/dependencies.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef DEPENDENCIES_H
|
||||
#define DEPENDENCIES_H
|
||||
|
||||
#include <libcli_version.h>
|
||||
#include <libft_ssl_version.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
struct dep
|
||||
{
|
||||
const char *name;
|
||||
const char *version;
|
||||
const char *extra;
|
||||
};
|
||||
|
||||
#define ADD_DEPENDENCY(NAME, VER_MACRO, HAS_GIT_COMMIT_MACRO, GIT_COMMIT_MACRO) \
|
||||
static const struct dep dep_##NAME __attribute__((used, section("ft_ssl_deps"))) = { \
|
||||
.name = STR(NAME), \
|
||||
.version = (VER_MACRO), \
|
||||
.extra = (HAS_GIT_COMMIT_MACRO) ? " (" GIT_COMMIT_MACRO ")" : "" \
|
||||
};
|
||||
|
||||
extern const struct dep __start_ft_ssl_deps[] __attribute__((weak));
|
||||
extern const struct dep __stop_ft_ssl_deps[] __attribute__((weak));
|
||||
|
||||
ADD_DEPENDENCY(libcli, LIBCLI_VERSION, LIBCLI_HAS_GIT_COMMIT, LIBCLI_GIT_COMMIT)
|
||||
ADD_DEPENDENCY(libtf_ssl, LIBFT_SSL_VERSION, LIBFT_SSL_HAS_GIT_COMMIT, LIBFT_SSL_GIT_COMMIT)
|
||||
|
||||
#endif
|
||||
2
libcli
2
libcli
|
|
@ -1 +1 @@
|
|||
Subproject commit 9f179fa596b1f50007d4995256f47cf5edb4f5dc
|
||||
Subproject commit 17ba957ed647364f8f21e43ebf2445410dc5c494
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit f15a0a5cf2b0d4cf8e3eb509dde0b2a0acf9d5ab
|
||||
Subproject commit 0da22db6fadfc1d55acc35715e0bb065ed17c289
|
||||
|
|
@ -48,6 +48,7 @@ ft_ssl_SOURCES = \
|
|||
ssl/digest.c \
|
||||
ssl/output.c \
|
||||
cli/parse.c \
|
||||
cli/version.c \
|
||||
cli/interactive.c \
|
||||
cli/handlers/option_map.c \
|
||||
cli/handlers/handle_help.c \
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@
|
|||
#include <cli.h>
|
||||
#include "compiler.h"
|
||||
|
||||
void print_version(void);
|
||||
|
||||
int
|
||||
cli_handle_version(__unused const char *arg, __unused void *config_void)
|
||||
{
|
||||
printf("version x\n");
|
||||
print_version();
|
||||
return CLI_EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
26
src/cli/version.c
Normal file
26
src/cli/version.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "version_gen.h"
|
||||
#include "internal/dependencies.h"
|
||||
|
||||
void
|
||||
print_version(void)
|
||||
{
|
||||
printf("%s version %s\n", g_prog_name, FT_SSL_VERSION);
|
||||
|
||||
printf("Copyright (C) 2026 lohhiicccc\n");
|
||||
printf("License GPLv3+:");
|
||||
printf("GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>\n");
|
||||
printf("This is free software: ");
|
||||
printf("you are free to change and redistribute it.\n");
|
||||
printf("There is NO WARRANTY, to the extent permitted by law.\n");
|
||||
#if FT_SSL_HAS_GIT_COMMIT
|
||||
printf("Build: %s (commit %s)\n", FT_SSL_BUILD_DATE, FT_SSL_GIT_COMMIT);
|
||||
#endif
|
||||
printf("\n");
|
||||
|
||||
printf("\nDependencies:\n");
|
||||
FOREACH_SECTION(p, const struct dep, ft_ssl_deps)
|
||||
printf("%-15s %s%s\n", p->name, p->version, p->extra);
|
||||
}
|
||||
|
||||
Loading…
Add table
Reference in a new issue