NeoMutt  2025-12-11-435-g4ac674
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:85
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 589 of file version.c.

590{
591 if (!fp)
592 return false;
593
594 struct KeyValue *kv = NULL;
595 struct ListNode *np = NULL;
596 struct NeoMuttVersion *ver = version_get();
597
598 const char *col_cyan = "";
599 const char *col_bold = "";
600 const char *col_end = "";
601
602 if (use_ansi)
603 {
604 col_cyan = "\033[1;36m"; // Escape, cyan
605 col_bold = "\033[1m"; // Escape, bold
606 col_end = "\033[0m"; // Escape, end
607 }
608
609 fprintf(fp, "%sNeoMutt %s%s\n", col_cyan, ver->version, col_end);
610 fprintf(fp, "%s\n", _(Notice1));
611 fprintf(fp, "%s\n\n", _(Notice2));
612
613 ARRAY_FOREACH(kv, &ver->system)
614 {
615 fprintf(fp, "%s%s:%s %s\n", col_bold, kv->key, col_end, kv->value);
616 }
617
618 if (ver->storage)
619 {
620 fprintf(fp, "%sstorage:%s ", col_bold, col_end);
621 STAILQ_FOREACH(np, &ver->storage->head, entries)
622 {
623 fputs(np->data, fp);
624 if (STAILQ_NEXT(np, entries))
625 fputs(", ", fp);
626 }
627 fputs("\n", fp);
628 }
629
630 if (ver->compression)
631 {
632 fprintf(fp, "%scompression:%s ", col_bold, col_end);
633 STAILQ_FOREACH(np, &ver->compression->head, entries)
634 {
635 fputs(np->data, fp);
636 if (STAILQ_NEXT(np, entries))
637 fputs(", ", fp);
638 }
639 fputs("\n", fp);
640 }
641 fputs("\n", fp);
642
643 fprintf(fp, "%sConfigure options:%s ", col_bold, col_end);
644 if (ver->configure)
645 {
646 STAILQ_FOREACH(np, &ver->configure->head, entries)
647 {
648 if (!np || !np->data)
649 continue;
650 fputs(np->data, fp);
651 if (STAILQ_NEXT(np, entries))
652 fputs(" ", fp);
653 }
654 }
655 fputs("\n\n", fp);
656
657 if (ver->compilation)
658 {
659 fprintf(fp, "%sCompilation CFLAGS:%s ", col_bold, col_end);
660 STAILQ_FOREACH(np, &ver->compilation->head, entries)
661 {
662 if (!np || !np->data)
663 continue;
664 fputs(np->data, fp);
665 if (STAILQ_NEXT(np, entries))
666 fputs(" ", fp);
667 }
668 fputs("\n\n", fp);
669 }
670
671 fprintf(fp, "%s%s%s\n", col_bold, _("Compile options:"), col_end);
672 print_compile_options(ver->feature, fp, use_ansi);
673 fputs("\n", fp);
674
675 if (ver->devel)
676 {
677 fprintf(fp, "%s%s%s\n", col_bold, _("Devel options:"), col_end);
678 print_compile_options(ver->devel, fp, use_ansi);
679 fputs("\n", fp);
680 }
681
682 ARRAY_FOREACH(kv, &ver->paths)
683 {
684 fprintf(fp, "%s%s%s=\"%s\"\n", col_bold, kv->key, col_end, kv->value);
685 }
686 fputs("\n", fp);
687
688 fputs(_(ReachingUs), fp);
689
690 version_free(&ver);
691 return true;
692}
#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 701 of file version.c.

702{
703 printf("NeoMutt %s\n", mutt_make_version());
704 puts(Copyright);
705 puts(_(Thanks));
706 puts(_(License));
707 puts(_(ReachingUs));
708
709 fflush(stdout);
710 return !ferror(stdout);
711}
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 728 of file version.c.

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