NeoMutt  2023-05-17-33-gce4425
Teaching an old dog new tricks
DOXYGEN
version.h File Reference

Display version and copyright about NeoMutt. More...

#include <stdbool.h>
#include <stdio.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.

Functions

bool print_version (FILE *fp)
 Print system and compile info to a file. More...
 
bool print_copyright (void)
 Print copyright message. More...
 
bool feature_enabled (const char *name)
 Test if a compile-time feature is enabled. More...
 

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

◆ print_version()

bool print_version ( FILE *  fp)

Print system and compile info to a file.

Parameters
fpFile to print to
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 420 of file version.c.

421{
422 if (!fp)
423 return false;
424
425 struct utsname uts;
426 bool tty = isatty(fileno(fp));
427 const char *fmt = "%s\n";
428
429 if (tty)
430 fmt = "\033[1;36m%s\033[0m\n"; // Escape, cyan
431
432 fprintf(fp, fmt, mutt_make_version());
433 fprintf(fp, "%s\n", _(Notice));
434
435 uname(&uts);
436
437#ifdef SCO
438 fprintf(fp, "System: SCO %s", uts.release);
439#else
440 fprintf(fp, "System: %s %s", uts.sysname, uts.release);
441#endif
442
443 fprintf(fp, " (%s)", uts.machine);
444
445#ifdef NCURSES_VERSION
446 fprintf(fp, "\nncurses: %s (compiled with %s.%d)", curses_version(),
447 NCURSES_VERSION, NCURSES_VERSION_PATCH);
448#else
449 fprintf(fp, "\nncurses: %s", curses_version());
450#endif
451
452#ifdef _LIBICONV_VERSION
453 fprintf(fp, "\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff);
454#endif
455
456#ifdef HAVE_LIBIDN
457 fprintf(fp, "\n%s", mutt_idna_print_version());
458#endif
459
460#ifdef CRYPT_BACKEND_GPGME
461 fprintf(fp, "\nGPGME: %s", mutt_gpgme_print_version());
462#endif
463
464#ifdef USE_SSL_OPENSSL
465#ifdef LIBRESSL_VERSION_TEXT
466 fprintf(fp, "\nLibreSSL: %s", LIBRESSL_VERSION_TEXT);
467#endif
468#ifdef OPENSSL_VERSION_TEXT
469 fprintf(fp, "\nOpenSSL: %s", OPENSSL_VERSION_TEXT);
470#endif
471#endif
472
473#ifdef USE_SSL_GNUTLS
474 fprintf(fp, "\nGnuTLS: %s", GNUTLS_VERSION);
475#endif
476
477#ifdef HAVE_NOTMUCH
478 fprintf(fp, "\nlibnotmuch: %d.%d.%d", LIBNOTMUCH_MAJOR_VERSION,
479 LIBNOTMUCH_MINOR_VERSION, LIBNOTMUCH_MICRO_VERSION);
480#endif
481
482#ifdef HAVE_PCRE2
483 {
484 char version[24] = { 0 };
485 pcre2_config(PCRE2_CONFIG_VERSION, version);
486 fprintf(fp, "\nPCRE2: %s", version);
487 }
488#endif
489
490#ifdef USE_HCACHE
491 const char *backends = store_backend_list();
492 fprintf(fp, "\nstorage: %s", backends);
493 FREE(&backends);
494#ifdef USE_HCACHE_COMPRESSION
495 backends = compress_list();
496 fprintf(fp, "\ncompression: %s", backends);
497 FREE(&backends);
498#endif
499#endif
500
502 fprintf(fp, "\n\nConfigure options: %s\n", (char *) configure_options);
503
504 rstrip_in_place((char *) cc_cflags);
505 fprintf(fp, "\nCompilation CFLAGS: %s\n", (char *) cc_cflags);
506
507 fprintf(fp, "\n%s\n", _("Default options:"));
509
510 fprintf(fp, "\n%s\n", _("Compile options:"));
512
513 if (DebugOpts[0].name)
514 {
515 fprintf(fp, "\n%s\n", _("Devel options:"));
517 }
518
519 fprintf(fp, "\n");
520#ifdef DOMAIN
521 fprintf(fp, "DOMAIN=\"%s\"\n", DOMAIN);
522#endif
523#ifdef ISPELL
524 fprintf(fp, "ISPELL=\"%s\"\n", ISPELL);
525#endif
526 fprintf(fp, "MAILPATH=\"%s\"\n", MAILPATH);
527#ifdef MIXMASTER
528 fprintf(fp, "MIXMASTER=\"%s\"\n", MIXMASTER);
529#endif
530 fprintf(fp, "PKGDATADIR=\"%s\"\n", PKGDATADIR);
531 fprintf(fp, "SENDMAIL=\"%s\"\n", SENDMAIL);
532 fprintf(fp, "SYSCONFDIR=\"%s\"\n", SYSCONFDIR);
533
534 fprintf(fp, "\n");
535 fputs(_(ReachingUs), fp);
536
537 fflush(fp);
538 return !ferror(fp);
539}
#define ISPELL
Definition: config.c:35
const char * compress_list(void)
Get a list of compression backend names.
Definition: compress.c:56
const char * mutt_gpgme_print_version(void)
Get version of GPGME.
Definition: crypt_gpgme.c:4053
const char * mutt_idna_print_version(void)
Create an IDN version string.
Definition: idna.c:273
#define FREE(x)
Definition: memory.h:43
#define _(a)
Definition: message.h:28
static void print_compile_options(const struct CompileOptions *co, FILE *fp)
Print a list of enabled/disabled features.
Definition: version.c:346
static const char * ReachingUs
CLI Version: How to reach the NeoMutt Team.
Definition: version.c:105
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1439
static const struct CompileOptions CompOpts[]
Compile options strings for neomutt -v output.
Definition: version.c:166
unsigned char configure_options[]
static const struct CompileOptions DebugOpts[]
Debug options strings for neomutt -v output.
Definition: version.c:302
unsigned char cc_cflags[]
static char * rstrip_in_place(char *s)
Strip a trailing carriage return.
Definition: version.c:398
static const char * Notice
CLI Version: Warranty notice.
Definition: version.c:112
const char * store_backend_list(void)
Get a list of backend names.
Definition: store.c:83
static const struct CompileOptions CompOptsDefault[]
Default options strings for neomutt -v output.
Definition: version.c:131
+ 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 548 of file version.c.

549{
550 puts(mutt_make_version());
551 puts(Copyright);
552 puts(_(Thanks));
553 puts(_(License));
554 puts(_(ReachingUs));
555
556 fflush(stdout);
557 return !ferror(stdout);
558}
static const char * Thanks
CLI Version: Thanks.
Definition: version.c:85
static const char * License
CLI Version: License.
Definition: version.c:89
static const char * Copyright
CLI Version: Authors' copyrights.
Definition: version.c:72
+ 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 "CompileOptions 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 575 of file version.c.

576{
577 if (!name)
578 return false;
579 for (int i = 0; CompOptsDefault[i].name; i++)
580 {
581 if (mutt_str_equal(name, CompOptsDefault[i].name))
582 {
583 return true;
584 }
585 }
586 for (int i = 0; CompOpts[i].name; i++)
587 {
588 if (mutt_str_equal(name, CompOpts[i].name))
589 {
590 return CompOpts[i].enabled;
591 }
592 }
593 return false;
594}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
const char * name
Option name.
Definition: version.c:124
int enabled
0 Disabled, 1 Enabled, 2 Devel only
Definition: version.c:125
+ Here is the call graph for this function:
+ Here is the caller graph for this function: