NeoMutt  2020-06-26-30-g76c339
Teaching an old dog new tricks
DOXYGEN
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 "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. More...
 
const char * store_backend_list (void)
 Get a list of backend names. More...
 
const char * store_compress_list (void)
 
static void print_compile_options (struct CompileOptions *co, FILE *fp)
 Print a list of enabled/disabled features. More...
 
static char * rstrip_in_place (char *s)
 Strip a trailing carriage return. More...
 
void print_version (FILE *fp)
 Print system and compile info to a file. More...
 
void print_copyright (void)
 Print copyright message. More...
 
bool feature_enabled (const char *name)
 Test if a compile-time feature is enabled. More...
 

Variables

const int SCREEN_WIDTH = 80
 
unsigned char cc_cflags []
 
unsigned char configure_options []
 
static const char * Copyright
 
static const char * Thanks
 
static const char * License
 
static const char * ReachingUs
 
static const char * Notice
 
static struct CompileOptions comp_opts_default []
 
static struct CompileOptions comp_opts []
 

Detailed Description

Display version and copyright about NeoMutt.

Authors
  • Michael R. Elkins
  • Thomas Roessler
  • 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 1550 of file muttlib.c.

1551 {
1552  static char vstring[256];
1553  snprintf(vstring, sizeof(vstring), "NeoMutt %s%s", PACKAGE_VERSION, GitVer);
1554  return vstring;
1555 }
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 **ops = store_ops;
88  size_t len = 0;
89 
90  for (; *ops; 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", (*ops)->name);
97  }
98 
99  return mutt_str_dup(tmp);
100 }
const struct StoreOps * store_ops[]
Backend implementations.
Definition: store.c:50
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
Key Value Store API.
Definition: lib.h:61
+ Here is the call graph for this function:
+ 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 ( 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 351 of file version.c.

352 {
353  if (!co || !fp)
354  return;
355 
356  size_t used = 2;
357  bool tty = isatty(fileno(fp));
358 
359  fprintf(fp, " ");
360  for (int i = 0; co[i].name; i++)
361  {
362  const size_t len = strlen(co[i].name) + 2; /* +/- and a space */
363  if ((used + len) > SCREEN_WIDTH)
364  {
365  used = 2;
366  fprintf(fp, "\n ");
367  }
368  used += len;
369  const char *fmt = "?%s ";
370  switch (co[i].enabled)
371  {
372  case 0: // Disabled
373  if (tty)
374  fmt = "\033[1;31m-%s\033[0m "; // Escape, red
375  else
376  fmt = "-%s ";
377  break;
378  case 1: // Enabled
379  if (tty)
380  fmt = "\033[1;32m+%s\033[0m "; // Escape, green
381  else
382  fmt = "+%s ";
383  break;
384  case 2: // Devel only
385  if (tty)
386  fmt = "\033[1;36m!%s\033[0m "; // Escape, cyan
387  else
388  fmt = "!%s ";
389  break;
390  }
391  fprintf(fp, fmt, co[i].name);
392  }
393  fprintf(fp, "\n");
394 }
static int const char * fmt
Definition: acutest.h:488
const char * name
Definition: version.c:123
const char * name
Store name.
Definition: lib.h:63
const int SCREEN_WIDTH
Definition: version.c:67
+ 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 403 of file version.c.

404 {
405  if (!s)
406  return NULL;
407 
408  char *p = &s[strlen(s)];
409  if (p == s)
410  return s;
411  p--;
412  while ((p >= s) && ((*p == '\n') || (*p == '\r')))
413  *p-- = '\0';
414  return s;
415 }
+ Here is the caller graph for this function:

◆ print_version()

void print_version ( FILE *  fp)

Print system and compile info to a file.

Parameters
fp- file to print to

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

Definition at line 424 of file version.c.

425 {
426  if (!fp)
427  return;
428 
429  struct utsname uts;
430  bool tty = isatty(fileno(fp));
431  const char *fmt = "%s\n";
432 
433  if (tty)
434  fmt = "\033[1;36m%s\033[0m\n"; // Escape, cyan
435 
436  fprintf(fp, fmt, mutt_make_version());
437  fprintf(fp, "%s\n", _(Notice));
438 
439  uname(&uts);
440 
441 #ifdef SCO
442  fprintf(fp, "System: SCO %s", uts.release);
443 #else
444  fprintf(fp, "System: %s %s", uts.sysname, uts.release);
445 #endif
446 
447  fprintf(fp, " (%s)", uts.machine);
448 
449 #ifdef NCURSES_VERSION
450  fprintf(fp, "\nncurses: %s (compiled with %s.%d)", curses_version(),
451  NCURSES_VERSION, NCURSES_VERSION_PATCH);
452 #elif defined(USE_SLANG_CURSES)
453  fprintf(fp, "\nslang: %s", SLANG_VERSION_STRING);
454 #endif
455 
456 #ifdef _LIBICONV_VERSION
457  fprintf(fp, "\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff);
458 #endif
459 
460 #ifdef HAVE_LIBIDN
461  fprintf(fp, "\n%s", mutt_idna_print_version());
462 #endif
463 
464 #ifdef CRYPT_BACKEND_GPGME
465  fprintf(fp, "\nGPGME: %s", mutt_gpgme_print_version());
466 #endif
467 
468 #ifdef USE_SSL_OPENSSL
469 #ifdef LIBRESSL_VERSION_TEXT
470  fprintf(fp, "\nLibreSSL: %s", LIBRESSL_VERSION_TEXT);
471 #endif
472 #ifdef OPENSSL_VERSION_TEXT
473  fprintf(fp, "\nOpenSSL: %s", OPENSSL_VERSION_TEXT);
474 #endif
475 #endif
476 
477 #ifdef USE_SSL_GNUTLS
478  fprintf(fp, "\nGnuTLS: %s", GNUTLS_VERSION);
479 #endif
480 
481 #ifdef HAVE_NOTMUCH
482  fprintf(fp, "\nlibnotmuch: %d.%d.%d", LIBNOTMUCH_MAJOR_VERSION,
483  LIBNOTMUCH_MINOR_VERSION, LIBNOTMUCH_MICRO_VERSION);
484 #endif
485 
486 #ifdef HAVE_PCRE2
487  {
488  char version[24];
489  pcre2_config(PCRE2_CONFIG_VERSION, version);
490  fprintf(fp, "\nPCRE2: %s", version);
491  }
492 #endif
493 
494 #ifdef USE_HCACHE
495  const char *backends = store_backend_list();
496  fprintf(fp, "\nstorage: %s", backends);
497  FREE(&backends);
498 #ifdef USE_HCACHE_COMPRESSION
499  backends = compress_list();
500  fprintf(fp, "\ncompression: %s", backends);
501  FREE(&backends);
502 #endif
503 #endif
504 
506  fprintf(fp, "\n\nConfigure options: %s\n", (char *) configure_options);
507 
508  rstrip_in_place((char *) cc_cflags);
509  fprintf(fp, "\nCompilation CFLAGS: %s\n", (char *) cc_cflags);
510 
511  fprintf(fp, "\n%s\n", _("Default options:"));
513 
514  fprintf(fp, "\n%s\n", _("Compile options:"));
516 
517 #ifdef DOMAIN
518  fprintf(fp, "DOMAIN=\"%s\"\n", DOMAIN);
519 #endif
520 #ifdef ISPELL
521  fprintf(fp, "ISPELL=\"%s\"\n", ISPELL);
522 #endif
523  fprintf(fp, "MAILPATH=\"%s\"\n", MAILPATH);
524 #ifdef MIXMASTER
525  fprintf(fp, "MIXMASTER=\"%s\"\n", MIXMASTER);
526 #endif
527  fprintf(fp, "PKGDATADIR=\"%s\"\n", PKGDATADIR);
528  fprintf(fp, "SENDMAIL=\"%s\"\n", SENDMAIL);
529  fprintf(fp, "SYSCONFDIR=\"%s\"\n", SYSCONFDIR);
530 
531  fprintf(fp, "\n");
532  fputs(_(ReachingUs), fp);
533 }
unsigned char configure_options[]
static struct CompileOptions comp_opts[]
Definition: version.c:163
static int const char * fmt
Definition: acutest.h:488
#define _(a)
Definition: message.h:28
#define ISPELL
Definition: mutt_config.c:88
const char * store_backend_list(void)
Get a list of backend names.
Definition: store.c:84
static struct CompileOptions comp_opts_default[]
Definition: version.c:129
static char * rstrip_in_place(char *s)
Strip a trailing carriage return.
Definition: version.c:403
static const char * ReachingUs
Definition: version.c:104
unsigned char cc_cflags[]
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:5875
const char * mutt_idna_print_version(void)
Create an IDN version string.
Definition: idna.c:313
#define FREE(x)
Definition: memory.h:40
static void print_compile_options(struct CompileOptions *co, FILE *fp)
Print a list of enabled/disabled features.
Definition: version.c:351
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1550
static const char * Notice
Definition: version.c:111
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_copyright()

void print_copyright ( void  )

Print copyright message.

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

Definition at line 541 of file version.c.

542 {
543  puts(mutt_make_version());
544  puts(Copyright);
545  puts(_(Thanks));
546  puts(_(License));
547  puts(_(ReachingUs));
548 }
#define _(a)
Definition: message.h:28
static const char * Copyright
Definition: version.c:72
static const char * ReachingUs
Definition: version.c:104
static const char * Thanks
Definition: version.c:84
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1550
static const char * License
Definition: version.c:88
+ 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 comp_opts[]" 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 565 of file version.c.

566 {
567  if (!name)
568  return false;
569  for (int i = 0; comp_opts_default[i].name; i++)
570  {
571  if (mutt_str_equal(name, comp_opts_default[i].name))
572  {
573  return true;
574  }
575  }
576  for (int i = 0; comp_opts[i].name; i++)
577  {
578  if (mutt_str_equal(name, comp_opts[i].name))
579  {
580  return comp_opts[i].enabled;
581  }
582  }
583  return false;
584 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
static struct CompileOptions comp_opts[]
Definition: version.c:163
const char * name
Definition: version.c:123
static struct CompileOptions comp_opts_default[]
Definition: version.c:129
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

Definition at line 67 of file version.c.

◆ cc_cflags

unsigned char cc_cflags[]

◆ configure_options

unsigned char configure_options[]

◆ Copyright

const char* Copyright
static
Initial value:
=
"Copyright (C) 1996-2016 Michael R. Elkins <me@mutt.org>\n"
"Copyright (C) 1996-2002 Brandon Long <blong@fiction.net>\n"
"Copyright (C) 1997-2009 Thomas Roessler <roessler@does-not-exist.org>\n"
"Copyright (C) 1998-2005 Werner Koch <wk@isil.d.shuttle.de>\n"
"Copyright (C) 1999-2017 Brendan Cully <brendan@kublai.com>\n"
"Copyright (C) 1999-2002 Tommi Komulainen <Tommi.Komulainen@iki.fi>\n"
"Copyright (C) 2000-2004 Edmund Grimley Evans <edmundo@rano.org>\n"
"Copyright (C) 2006-2009 Rocco Rutte <pdmef@gmx.net>\n"
"Copyright (C) 2014-2019 Kevin J. McCarthy <kevin@8t8.us>\n"
"Copyright (C) 2015-2019 Richard Russon <rich@flatcap.org>\n"

Definition at line 72 of file version.c.

◆ Thanks

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

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")
#define N_(a)
Definition: message.h:32

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")
#define N_(a)
Definition: message.h:32

Definition at line 104 of file version.c.

◆ Notice

const char* Notice
static
Initial value:
=
N_("Copyright (C) 1996-2016 Michael R. Elkins and others.\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")
#define N_(a)
Definition: message.h:32

Definition at line 111 of file version.c.

◆ comp_opts_default

struct CompileOptions comp_opts_default[]
static

Definition at line 129 of file version.c.

◆ comp_opts

struct CompileOptions comp_opts[]
static

Definition at line 163 of file version.c.