NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
version.c File Reference

Display version and copyright about NeoMutt. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "version.h"
#include "compress/lib.h"
#include "address/lib.h"
#include "ncrypt/lib.h"
#include <openssl/opensslv.h>
#include <gnutls/gnutls.h>
+ Include dependency graph for version.c:

Go to the source code of this file.

Data Structures

struct  CompileOptions
 List of built-in capabilities. More...
 

Functions

const char * mutt_make_version (void)
 Generate the NeoMutt version string.
 
const char * store_backend_list (void)
 Get a list of backend names.
 
const char * store_compress_list (void)
 
static void print_compile_options (const struct CompileOptions *co, FILE *fp)
 Print a list of enabled/disabled features.
 
static char * rstrip_in_place (char *s)
 Strip a trailing carriage return.
 
bool print_version (FILE *fp)
 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.
 

Variables

static const int SCREEN_WIDTH = 80
 CLI: Width to wrap version info.
 
unsigned char cc_cflags []
 
unsigned char configure_options []
 
static const char * Copyright
 CLI Version: Authors' copyrights.
 
static const char * Thanks
 CLI Version: Thanks.
 
static const char * License
 CLI Version: License.
 
static const char * ReachingUs
 CLI Version: How to reach the NeoMutt Team.
 
static const char * Notice
 CLI Version: Warranty notice.
 
static const struct CompileOptions CompOpts []
 Compile options strings for neomutt -v output.
 
static const struct CompileOptions DebugOpts []
 Debug options strings for neomutt -v output.
 

Detailed Description

Display version and copyright about NeoMutt.

Authors
  • Pietro Cerutti
  • 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.c.

Function Documentation

◆ 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 893 of file muttlib.c.

894{
895 static char vstring[256];
896 snprintf(vstring, sizeof(vstring), "NeoMutt %s%s", PACKAGE_VERSION, GitVer);
897 return vstring;
898}
const char * GitVer
+ Here is the caller graph for this function:

◆ store_backend_list()

const char * store_backend_list ( void  )

Get a list of backend names.

Return values
ptrComma-space-separated list of names

The caller should free the string.

Definition at line 84 of file store.c.

85{
86 char tmp[256] = { 0 };
87 const struct StoreOps **store_ops = StoreOps;
88 size_t len = 0;
89
90 for (; *store_ops; store_ops++)
91 {
92 if (len != 0)
93 {
94 len += snprintf(tmp + len, sizeof(tmp) - len, ", ");
95 }
96 len += snprintf(tmp + len, sizeof(tmp) - len, "%s", (*store_ops)->name);
97 }
98
99 return mutt_str_dup(tmp);
100}
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
static const struct StoreOps * StoreOps[]
Backend implementations.
Definition: store.c:50
Definition: lib.h:69
+ Here is the caller graph for this function:

◆ store_compress_list()

const char * store_compress_list ( void  )

◆ print_compile_options()

static void print_compile_options ( const struct CompileOptions co,
FILE *  fp 
)
static

Print a list of enabled/disabled features.

Parameters
coArray of compile options
fpfile to write to

Two lists are generated and passed to this function:

One list which just uses the configure state of each feature. One list which just uses feature which are set to on directly in NeoMutt.

The output is of the form: "+enabled_feature -disabled_feature" and is wrapped to SCREEN_WIDTH characters.

Definition at line 319 of file version.c.

320{
321 if (!co || !fp)
322 return;
323
324 size_t used = 2;
325 bool tty = isatty(fileno(fp));
326
327 fprintf(fp, " ");
328 for (int i = 0; co[i].name; i++)
329 {
330 const size_t len = strlen(co[i].name) + 2; /* +/- and a space */
331 if ((used + len) > SCREEN_WIDTH)
332 {
333 used = 2;
334 fprintf(fp, "\n ");
335 }
336 used += len;
337 const char *fmt = "?%s ";
338 switch (co[i].enabled)
339 {
340 case 0: // Disabled
341 if (tty)
342 fmt = "\033[1;31m-%s\033[0m "; // Escape, red
343 else
344 fmt = "-%s ";
345 break;
346 case 1: // Enabled
347 if (tty)
348 fmt = "\033[1;32m+%s\033[0m "; // Escape, green
349 else
350 fmt = "+%s ";
351 break;
352 case 2: // Devel only
353 if (tty)
354 fmt = "\033[1;36m%s\033[0m "; // Escape, cyan
355 else
356 fmt = "%s ";
357 break;
358 }
359 fprintf(fp, fmt, co[i].name);
360 }
361 fprintf(fp, "\n");
362}
const char * name
Option name.
Definition: version.c:123
static const int SCREEN_WIDTH
CLI: Width to wrap version info.
Definition: version.c:65
+ Here is the caller graph for this function:

◆ rstrip_in_place()

static char * rstrip_in_place ( char *  s)
static

Strip a trailing carriage return.

Parameters
sString to be modified
Return values
ptrThe modified string

The string has its last carriage return set to NUL.

Definition at line 371 of file version.c.

372{
373 if (!s)
374 return NULL;
375
376 char *p = &s[strlen(s)];
377 if (p == s)
378 return s;
379 p--;
380 while ((p >= s) && ((*p == '\n') || (*p == '\r')))
381 *p-- = '\0';
382 return s;
383}
+ Here is the caller graph for this function:

◆ 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 393 of file version.c.

394{
395 if (!fp)
396 return false;
397
398 struct utsname uts = { 0 };
399 bool tty = isatty(fileno(fp));
400
401 const char *col_cyan = "";
402 const char *col_bold = "";
403 const char *col_end = "";
404
405 if (tty)
406 {
407 col_cyan = "\033[1;36m"; // Escape, cyan
408 col_bold = "\033[1m"; // Escape, bold
409 col_end = "\033[0m"; // Escape, end
410 }
411
412 fprintf(fp, "%s%s%s\n", col_cyan, mutt_make_version(), col_end);
413 fprintf(fp, "%s\n", _(Notice));
414
415 uname(&uts);
416
417 fprintf(fp, "%sSystem:%s ", col_bold, col_end);
418#ifdef SCO
419 fprintf(fp, "SCO %s", uts.release);
420#else
421 fprintf(fp, "%s %s", uts.sysname, uts.release);
422#endif
423
424 fprintf(fp, " (%s)", uts.machine);
425
426 fprintf(fp, "\n%sncurses:%s %s", col_bold, col_end, curses_version());
427#ifdef NCURSES_VERSION
428 fprintf(fp, " (compiled with %s.%d)", NCURSES_VERSION, NCURSES_VERSION_PATCH);
429#endif
430
431#ifdef _LIBICONV_VERSION
432 fprintf(fp, "\n%slibiconv:%s %d.%d", col_bold, col_end,
433 _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff);
434#endif
435
436#ifdef HAVE_LIBIDN
437 fprintf(fp, "\n%slibidn2:%s %s", col_bold, col_end, mutt_idna_print_version());
438#endif
439
440#ifdef CRYPT_BACKEND_GPGME
441 fprintf(fp, "\n%sGPGME:%s %s", col_bold, col_end, mutt_gpgme_print_version());
442#endif
443
444#ifdef USE_SSL_OPENSSL
445#ifdef LIBRESSL_VERSION_TEXT
446 fprintf(fp, "\n%sLibreSSL:%s %s", col_bold, col_end, LIBRESSL_VERSION_TEXT);
447#endif
448#ifdef OPENSSL_VERSION_TEXT
449 fprintf(fp, "\n%sOpenSSL:%s %s", col_bold, col_end, OPENSSL_VERSION_TEXT);
450#endif
451#endif
452
453#ifdef USE_SSL_GNUTLS
454 fprintf(fp, "\n%sGnuTLS:%s %s", col_bold, col_end, GNUTLS_VERSION);
455#endif
456
457#ifdef HAVE_NOTMUCH
458 fprintf(fp, "\n%slibnotmuch:%s %d.%d.%d", col_bold, col_end, LIBNOTMUCH_MAJOR_VERSION,
459 LIBNOTMUCH_MINOR_VERSION, LIBNOTMUCH_MICRO_VERSION);
460#endif
461
462#ifdef HAVE_PCRE2
463 {
464 char version[24] = { 0 };
465 pcre2_config(PCRE2_CONFIG_VERSION, version);
466 fprintf(fp, "\n%sPCRE2:%s %s", col_bold, col_end, version);
467 }
468#endif
469
470#ifdef USE_HCACHE
471 const char *backends = store_backend_list();
472 fprintf(fp, "\n%sstorage:%s %s", col_bold, col_end, backends);
473 FREE(&backends);
474#ifdef USE_HCACHE_COMPRESSION
475 backends = compress_list();
476 fprintf(fp, "\n%scompression:%s %s", col_bold, col_end, backends);
477 FREE(&backends);
478#endif
479#endif
480
482 fprintf(fp, "\n\n%sConfigure options:%s %s\n", col_bold, col_end, (char *) configure_options);
483
484 rstrip_in_place((char *) cc_cflags);
485 fprintf(fp, "\n%sCompilation CFLAGS:%s %s\n", col_bold, col_end, (char *) cc_cflags);
486
487 fprintf(fp, "\n%s%s%s\n", col_bold, _("Compile options:"), col_end);
489
490 if (DebugOpts[0].name)
491 {
492 fprintf(fp, "\n%s%s%s\n", col_bold, _("Devel options:"), col_end);
494 }
495
496 fprintf(fp, "\n");
497#ifdef DOMAIN
498 fprintf(fp, "DOMAIN=\"%s\"\n", DOMAIN);
499#endif
500#ifdef ISPELL
501 fprintf(fp, "ISPELL=\"%s\"\n", ISPELL);
502#endif
503 fprintf(fp, "MAILPATH=\"%s\"\n", MAILPATH);
504#ifdef MIXMASTER
505 fprintf(fp, "MIXMASTER=\"%s\"\n", MIXMASTER);
506#endif
507 fprintf(fp, "PKGDATADIR=\"%s\"\n", PKGDATADIR);
508 fprintf(fp, "SENDMAIL=\"%s\"\n", SENDMAIL);
509 fprintf(fp, "SYSCONFDIR=\"%s\"\n", SYSCONFDIR);
510
511 fprintf(fp, "\n");
512 fputs(_(ReachingUs), fp);
513
514 fflush(fp);
515 return !ferror(fp);
516}
#define ISPELL
Definition: config.c:39
const char * compress_list(void)
Get a list of compression backend names.
Definition: compress.c:58
const char * mutt_gpgme_print_version(void)
Get version of GPGME.
Definition: crypt_gpgme.c:4121
const char * mutt_idna_print_version(void)
Create an IDN version string.
Definition: idna.c:272
#define FREE(x)
Definition: memory.h:45
#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:319
static const char * ReachingUs
CLI Version: How to reach the NeoMutt Team.
Definition: version.c:104
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:893
static const struct CompileOptions CompOpts[]
Compile options strings for neomutt -v output.
Definition: version.c:130
unsigned char configure_options[]
static const struct CompileOptions DebugOpts[]
Debug options strings for neomutt -v output.
Definition: version.c:266
unsigned char cc_cflags[]
static char * rstrip_in_place(char *s)
Strip a trailing carriage return.
Definition: version.c:371
static const char * Notice
CLI Version: Warranty notice.
Definition: version.c:111
const char * store_backend_list(void)
Get a list of backend names.
Definition: store.c:84
+ 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 525 of file version.c.

526{
527 puts(mutt_make_version());
528 puts(Copyright);
529 puts(_(Thanks));
530 puts(_(License));
531 puts(_(ReachingUs));
532
533 fflush(stdout);
534 return !ferror(stdout);
535}
static const char * Thanks
CLI Version: Thanks.
Definition: version.c:84
static const char * License
CLI Version: License.
Definition: version.c:88
static const char * Copyright
CLI Version: Authors' copyrights.
Definition: version.c:71
+ 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 552 of file version.c.

553{
554 if (!name)
555 return false;
556 for (int i = 0; CompOpts[i].name; i++)
557 {
558 if (mutt_str_equal(name, CompOpts[i].name))
559 {
560 return CompOpts[i].enabled;
561 }
562 }
563 return false;
564}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:654
int enabled
0 Disabled, 1 Enabled, 2 Devel only
Definition: version.c:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SCREEN_WIDTH

const int SCREEN_WIDTH = 80
static

CLI: Width to wrap version info.

Definition at line 65 of file version.c.

◆ cc_cflags

unsigned char cc_cflags[]
extern

◆ configure_options

unsigned char configure_options[]
extern

◆ Copyright

const char* Copyright
static
Initial value:
=
"Copyright (C) 2015-2024 Richard Russon <rich@flatcap.org>\n"
"Copyright (C) 2016-2023 Pietro Cerutti <gahr@gahr.ch>\n"
"Copyright (C) 2017-2019 Mehdi Abaakouk <sileht@sileht.net>\n"
"Copyright (C) 2018-2020 Federico Kircheis <federico.kircheis@gmail.com>\n"
"Copyright (C) 2017-2022 Austin Ray <austin@austinray.io>\n"
"Copyright (C) 2023-2024 Dennis Schön <mail@dennis-schoen.de>\n"
"Copyright (C) 2016-2017 Damien Riegel <damien.riegel@gmail.com>\n"
"Copyright (C) 2023 Rayford Shireman\n"
"Copyright (C) 2021-2023 David Purton <dcpurton@marshwiggle.net>\n"
"Copyright (C) 2020-2023 наб <nabijaczleweli@nabijaczleweli.xyz>\n"

CLI Version: Authors' copyrights.

Definition at line 71 of file version.c.

◆ Thanks

const char* Thanks
static
Initial value:
= N_(
"Many others not mentioned here contributed code, fixes and suggestions.\n")
#define N_(a)
Definition: message.h:32

CLI Version: Thanks.

Definition at line 84 of file version.c.

◆ License

const char* License
static
Initial value:
= N_(
"This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 2 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program; if not, write to the Free Software\n"
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n")

CLI Version: License.

Definition at line 88 of file version.c.

◆ ReachingUs

const char* ReachingUs
static
Initial value:
= N_("To learn more about NeoMutt, visit: https://neomutt.org\n"
"If you find a bug in NeoMutt, please raise an issue at:\n"
" https://github.com/neomutt/neomutt/issues\n"
"or send an email to: <neomutt-devel@neomutt.org>\n")

CLI Version: How to reach the NeoMutt Team.

Definition at line 104 of file version.c.

◆ Notice

const char* Notice
static
Initial value:
=
N_("Copyright (C) 2015-2024 Richard Russon and friends\n"
"NeoMutt comes with ABSOLUTELY NO WARRANTY; for details type 'neomutt -vv'.\n"
"NeoMutt is free software, and you are welcome to redistribute it\n"
"under certain conditions; type 'neomutt -vv' for details.\n")

CLI Version: Warranty notice.

Definition at line 111 of file version.c.

◆ CompOpts

const struct CompileOptions CompOpts[]
static

Compile options strings for neomutt -v output.

Definition at line 130 of file version.c.

◆ DebugOpts

const struct CompileOptions DebugOpts[]
static

Debug options strings for neomutt -v output.

Definition at line 266 of file version.c.