NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
version.h File Reference

Display version and copyright about NeoMutt. More...

#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
Include dependency graph for version.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  KeyValue
 Key/Value pairs. More...
struct  CompileOption
 Built-in capability. More...
struct  NeoMuttVersion
 Version info about NeoMutt. More...

Functions

 ARRAY_HEAD (KeyValueArray, struct KeyValue)
struct NeoMuttVersionversion_get (void)
 Get NeoMutt version info.
void version_free (struct NeoMuttVersion **ptr)
 Free a NeoMuttVersion.
const char * mutt_make_version (void)
 Generate the NeoMutt version string.
bool print_version (FILE *fp, bool use_ansi)
 Print system and compile info to a file.
bool print_copyright (void)
 Print copyright message.
bool feature_enabled (const char *name)
 Test if a compile-time feature is enabled.

Detailed Description

Display version and copyright about NeoMutt.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file version.h.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( KeyValueArray ,
struct KeyValue  )

◆ version_get()

struct NeoMuttVersion * version_get ( void )

Get NeoMutt version info.

Return values
ptrNeoMuttVersion

Definition at line 467 of file version.c.

468{
469 struct NeoMuttVersion *ver = MUTT_MEM_CALLOC(1, struct NeoMuttVersion);
470
472
473 ARRAY_INIT(&ver->system);
474 system_get(&ver->system);
475
476#ifdef USE_HCACHE
478#ifdef USE_HCACHE_COMPRESSION
479 ver->compression = compress_list();
480#endif
481#endif
482
485
486 rstrip_in_place((char *) cc_cflags);
488
489 ver->feature = CompOpts;
490
491 if (DevelOpts[0].name)
492 ver->devel = DevelOpts;
493
494 ARRAY_INIT(&ver->paths);
495 paths_get(&ver->paths);
496
497 return ver;
498}
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
struct Slist * compress_list(void)
Get a list of compression backend names.
Definition compress.c:59
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
struct Slist * slist_parse(const char *str, uint32_t flags)
Parse a list of strings into a list.
Definition slist.c:177
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
struct Slist * store_backend_list(void)
Get a list of backend names.
Definition store.c:69
Version info about NeoMutt.
Definition version.h:53
struct KeyValueArray paths
Compiled-in paths.
Definition version.h:67
struct Slist * configure
Configure options.
Definition version.h:61
const char * version
Version of NeoMutt: YYYYMMDD-NUM-HASH (number of commits, git hash).
Definition version.h:54
struct Slist * compression
Compression methods, e.g. zlib.
Definition version.h:59
struct Slist * storage
Storage backends, e.g. lmdb.
Definition version.h:58
const struct CompileOption * devel
Compiled-in development features.
Definition version.h:65
const struct CompileOption * feature
Compiled-in features.
Definition version.h:64
struct Slist * compilation
Compilation CFLAGS.
Definition version.h:62
struct KeyValueArray system
System information.
Definition version.h:56
#define D_SLIST_SEP_SPACE
Slist items are space-separated.
Definition types.h:110
static const struct CompileOption DevelOpts[]
Devel options strings for neomutt -v output.
Definition version.c:247
static void paths_get(struct KeyValueArray *kva)
Get compiled-in paths.
Definition version.c:412
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition version.c:293
unsigned char configure_options[]
static void system_get(struct KeyValueArray *kva)
Get info about system libraries.
Definition version.c:325
unsigned char cc_cflags[]
static char * rstrip_in_place(char *s)
Strip a trailing carriage return.
Definition version.c:307
static const struct CompileOption CompOpts[]
Compile options strings for neomutt -v output.
Definition version.c:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ version_free()

void version_free ( struct NeoMuttVersion ** ptr)

Free a NeoMuttVersion.

Parameters
ptrNeoMuttVersion to free

Definition at line 504 of file version.c.

505{
506 if (!ptr || !*ptr)
507 return;
508
509 struct NeoMuttVersion *ver = *ptr;
510
511 FREE(&ver->version);
512
513 kva_clear(&ver->system);
514 kva_clear(&ver->paths);
515
516 slist_free(&ver->storage);
517 slist_free(&ver->compression);
518 slist_free(&ver->configure);
519 slist_free(&ver->compilation);
520
521 FREE(ptr);
522}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void slist_free(struct Slist **ptr)
Free an Slist object.
Definition slist.c:124
static void kva_clear(struct KeyValueArray *kva)
Free the strings of a KeyValueArray.
Definition version.c:450
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mutt_make_version()

const char * mutt_make_version ( void )

Generate the NeoMutt version string.

Return values
ptrVersion string
Note
This returns a pointer to a static buffer

Definition at line 293 of file version.c.

294{
295 static char vstring[256];
296 snprintf(vstring, sizeof(vstring), "%s%s", PACKAGE_VERSION, GitVer);
297 return vstring;
298}
const char * GitVer
Here is the caller graph for this function:

◆ print_version()

bool print_version ( FILE * fp,
bool use_ansi )

Print system and compile info to a file.

Parameters
fpFile to print to
use_ansiUse ANSI colour escape sequences
Return values
trueText displayed

Print information about the current system NeoMutt is running on. Also print a list of all the compile-time information.

Definition at line 591 of file version.c.

592{
593 if (!fp)
594 return false;
595
596 struct KeyValue *kv = NULL;
597 struct ListNode *np = NULL;
598 struct NeoMuttVersion *ver = version_get();
599
600 const char *col_cyan = "";
601 const char *col_bold = "";
602 const char *col_end = "";
603
604 if (use_ansi)
605 {
606 col_cyan = "\033[1;36m"; // Escape, cyan
607 col_bold = "\033[1m"; // Escape, bold
608 col_end = "\033[0m"; // Escape, end
609 }
610
611 fprintf(fp, "%sNeoMutt %s%s\n", col_cyan, ver->version, col_end);
612 fprintf(fp, "%s\n", _(Notice1));
613 fprintf(fp, "%s\n\n", _(Notice2));
614
615 ARRAY_FOREACH(kv, &ver->system)
616 {
617 fprintf(fp, "%s%s:%s %s\n", col_bold, kv->key, col_end, kv->value);
618 }
619
620 if (ver->storage)
621 {
622 fprintf(fp, "%sstorage:%s ", col_bold, col_end);
623 STAILQ_FOREACH(np, &ver->storage->head, entries)
624 {
625 fputs(np->data, fp);
626 if (STAILQ_NEXT(np, entries))
627 fputs(", ", fp);
628 }
629 fputs("\n", fp);
630 }
631
632 if (ver->compression)
633 {
634 fprintf(fp, "%scompression:%s ", col_bold, col_end);
635 STAILQ_FOREACH(np, &ver->compression->head, entries)
636 {
637 fputs(np->data, fp);
638 if (STAILQ_NEXT(np, entries))
639 fputs(", ", fp);
640 }
641 fputs("\n", fp);
642 }
643 fputs("\n", fp);
644
645 fprintf(fp, "%sConfigure options:%s ", col_bold, col_end);
646 if (ver->configure)
647 {
648 STAILQ_FOREACH(np, &ver->configure->head, entries)
649 {
650 if (!np || !np->data)
651 continue;
652 fputs(np->data, fp);
653 if (STAILQ_NEXT(np, entries))
654 fputs(" ", fp);
655 }
656 }
657 fputs("\n\n", fp);
658
659 if (ver->compilation)
660 {
661 fprintf(fp, "%sCompilation CFLAGS:%s ", col_bold, col_end);
662 STAILQ_FOREACH(np, &ver->compilation->head, entries)
663 {
664 if (!np || !np->data)
665 continue;
666 fputs(np->data, fp);
667 if (STAILQ_NEXT(np, entries))
668 fputs(" ", fp);
669 }
670 fputs("\n\n", fp);
671 }
672
673 fprintf(fp, "%s%s%s\n", col_bold, _("Compile options:"), col_end);
674 print_compile_options(ver->feature, fp, use_ansi);
675 fputs("\n", fp);
676
677 if (ver->devel)
678 {
679 fprintf(fp, "%s%s%s\n", col_bold, _("Devel options:"), col_end);
680 print_compile_options(ver->devel, fp, use_ansi);
681 fputs("\n", fp);
682 }
683
684 ARRAY_FOREACH(kv, &ver->paths)
685 {
686 fprintf(fp, "%s%s%s=\"%s\"\n", col_bold, kv->key, col_end, kv->value);
687 }
688 fputs("\n", fp);
689
690 fputs(_(ReachingUs), fp);
691
692 version_free(&ver);
693 return true;
694}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define _(a)
Definition message.h:28
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
#define STAILQ_NEXT(elm, field)
Definition queue.h:439
Key/Value pairs.
Definition version.h:34
const char * key
Key name.
Definition version.h:35
const char * value
Key value.
Definition version.h:36
A List node for strings.
Definition list.h:37
char * data
String.
Definition list.h:38
struct ListHead head
List containing values.
Definition slist.h:38
void version_free(struct NeoMuttVersion **ptr)
Free a NeoMuttVersion.
Definition version.c:504
static const char * ReachingUs
CLI Version: How to reach the NeoMutt Team.
Definition version.c:103
static const char * Notice1
CLI Version: Warranty notice.
Definition version.c:110
static const char * Notice2
Definition version.c:111
struct NeoMuttVersion * version_get(void)
Get NeoMutt version info.
Definition version.c:467
static void print_compile_options(const struct CompileOption *co, FILE *fp, bool use_ansi)
Print a list of enabled/disabled features.
Definition version.c:537
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_copyright()

bool print_copyright ( void )

Print copyright message.

Return values
trueText displayed

Print the authors' copyright messages, the GPL license and some contact information for the NeoMutt project.

Definition at line 703 of file version.c.

704{
705 printf("NeoMutt %s\n", mutt_make_version());
706 puts(Copyright);
707 puts(_(Thanks));
708 puts(_(License));
709 puts(_(ReachingUs));
710
711 fflush(stdout);
712 return !ferror(stdout);
713}
static const char * Thanks
CLI Version: Thanks.
Definition version.c:83
static const char * License
CLI Version: License.
Definition version.c:87
static const char * Copyright
CLI Version: Authors' copyrights.
Definition version.c:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ feature_enabled()

bool feature_enabled ( const char * name)

Test if a compile-time feature is enabled.

Parameters
nameCompile-time symbol of the feature
Return values
trueFeature enabled
falseFeature not enabled, or not compiled in

Many of the larger features of neomutt can be disabled at compile time. They define a symbol and use ifdef's around their code. The symbols are mirrored in "CompileOption CompOpts[]" in this file.

This function checks if one of these symbols is present in the code.

These symbols are also seen in the output of "neomutt -v".

Definition at line 730 of file version.c.

731{
732 if (!name)
733 return false;
734 for (int i = 0; CompOpts[i].name; i++)
735 {
736 if (mutt_str_equal(name, CompOpts[i].name))
737 {
738 return CompOpts[i].enabled;
739 }
740 }
741 return false;
742}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
Here is the call graph for this function:
Here is the caller graph for this function: