Cthulhu  0.2.10
Cthulhu compiler collection
version.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #include "format/version.h"
4 #include "base/panic.h"
5 
6 #include "io/io.h"
7 
9 void print_version(print_version_t config, version_info_t version, const char *name)
10 {
11  CTASSERT(name != NULL);
12 
13  print_options_t base = config.options;
14 
15  int major = CT_VERSION_MAJOR(version.version);
16  int minor = CT_VERSION_MINOR(version.version);
17  int patch = CT_VERSION_PATCH(version.version);
18 
19  io_printf(base.io, "%s %d.%d.%d\n", name, major, minor, patch);
20  io_printf(base.io, "written by %s and licensed under %s\n", version.author, version.license);
21  io_printf(base.io, "%s\n", version.desc);
22 }
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
#define CT_VERSION_MAJOR(version)
returns the major version of version
Definition: version_def.h:37
#define CT_VERSION_MINOR(version)
returns the minor version of version
Definition: version_def.h:38
#define CT_VERSION_PATCH(version)
returns the patch version of version
Definition: version_def.h:39
STA_DECL void print_version(print_version_t config, version_info_t version, const char *name)
print the version of the program
Definition: version.c:9
CT_IO_API size_t io_printf(io_t *io, STA_FORMAT_STRING const char *fmt,...)
printf to an io object
#define CTASSERT(expr)
assert a condition, prints the condition as a message
Definition: panic.h:130
generic print options
Definition: format.h:35
io_t * io
io buffer
Definition: format.h:40
version formatting config
Definition: version.h:21
print_options_t options
the options to use when printing
Definition: version.h:23
version information for a driver/interface/plugin
Definition: version_def.h:48
const char * license
the license of this component
Definition: version_def.h:49
const char * author
the author of this component
Definition: version_def.h:51
const char * desc
a short description of this component
Definition: version_def.h:50
ctu_version_t version
the version info for this component
Definition: version_def.h:52