NeoMutt  2018-07-16 +952-a2da0a
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/mutt.h"
#include "email/lib.h"
#include "mutt_curses.h"
#include "ncrypt/crypt_gpgme.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 * mutt_hcache_backend_list (void)
 Get a list of backend names. More...
 
static void print_compile_options (struct CompileOptions *co)
 Print a list of enabled/disabled features. More...
 
static char * rstrip_in_place (char *s)
 Strip a trailing carriage return. More...
 
void print_version (void)
 Print system and compile info. 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_version []
 
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

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

1493 {
1494  static char vstring[STRING];
1495  snprintf(vstring, sizeof(vstring), "NeoMutt %s%s", PACKAGE_VERSION, GitVer);
1496  return vstring;
1497 }
const char * GitVer
#define STRING
Definition: string2.h:35

+ Here is the caller graph for this function:

const char* mutt_hcache_backend_list ( void  )

Get a list of backend names.

get a list of backend identification strings

Return values
ptrComma-space-separated list of names

The caller should free the string.

Definition at line 463 of file hcache.c.

464 {
465  char tmp[STRING] = { 0 };
466  const struct HcacheOps **ops = hcache_ops;
467  size_t len = 0;
468 
469  for (; *ops; ++ops)
470  {
471  if (len != 0)
472  {
473  len += snprintf(tmp + len, STRING - len, ", ");
474  }
475  len += snprintf(tmp + len, STRING - len, "%s", (*ops)->name);
476  }
477 
478  return mutt_str_strdup(tmp);
479 }
const struct HcacheOps * hcache_ops[]
Backend implementations.
Definition: hcache.c:79
#define STRING
Definition: string2.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:384
Header Cache API.
Definition: backend.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void print_compile_options ( struct CompileOptions co)
static

Print a list of enabled/disabled features.

Parameters
coArray of compile options

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

304 {
305  size_t used = 2;
306  bool tty = stdout ? isatty(fileno(stdout)) : false;
307 
308  printf(" ");
309  for (int i = 0; co[i].name; i++)
310  {
311  const size_t len = strlen(co[i].name) + 2; /* +/- and a space */
312  if ((used + len) > SCREEN_WIDTH)
313  {
314  used = 2;
315  printf("\n ");
316  }
317  used += len;
318  if (co[i].enabled)
319  {
320  if (tty)
321  printf("\033[1;32m+%s\033[0m ", co[i].name);
322  else
323  printf("+%s ", co[i].name);
324  }
325  else
326  {
327  if (tty)
328  printf("\033[1;31m-%s\033[0m ", co[i].name);
329  else
330  printf("-%s ", co[i].name);
331  }
332  }
333  puts("");
334 }
const char * name
Definition: version.c:107
const char * name
Definition: pgpmicalg.c:42
const int SCREEN_WIDTH
Definition: version.c:50

+ Here is the caller graph for this function:

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

344 {
345  if (!s)
346  return NULL;
347 
348  char *p = &s[strlen(s)];
349  if (p == s)
350  return s;
351  p--;
352  while ((p >= s) && ((*p == '\n') || (*p == '\r')))
353  *p-- = '\0';
354  return s;
355 }

+ Here is the caller graph for this function:

void print_version ( void  )

Print system and compile info.

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

Definition at line 363 of file version.c.

364 {
365  struct utsname uts;
366 
367  puts(mutt_make_version());
368  puts(_(Notice));
369 
370  uname(&uts);
371 
372 #ifdef SCO
373  printf("System: SCO %s", uts.release);
374 #else
375  printf("System: %s %s", uts.sysname, uts.release);
376 #endif
377 
378  printf(" (%s)", uts.machine);
379 
380 #ifdef NCURSES_VERSION
381  printf("\nncurses: %s (compiled with %s.%d)", curses_version(),
382  NCURSES_VERSION, NCURSES_VERSION_PATCH);
383 #elif defined(USE_SLANG_CURSES)
384  printf("\nslang: %s", SLANG_VERSION_STRING);
385 #endif
386 
387 #ifdef _LIBICONV_VERSION
388  printf("\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff);
389 #endif
390 
391 #ifdef HAVE_LIBIDN
392  printf("\n%s", mutt_idna_print_version());
393 #endif
394 
395 #ifdef CRYPT_BACKEND_GPGME
396  printf("\nGPGme: %s", mutt_gpgme_print_version());
397 #endif
398 
399 #ifdef USE_HCACHE
400  const char *backends = mutt_hcache_backend_list();
401  printf("\nhcache backends: %s", backends);
402  FREE(&backends);
403 #endif
404 
405  puts("\n\nCompiler:");
406  rstrip_in_place((char *) cc_version);
407  puts((char *) cc_version);
408 
410  printf("\nConfigure options: %s\n", (char *) configure_options);
411 
412  rstrip_in_place((char *) cc_cflags);
413  printf("\nCompilation CFLAGS: %s\n", (char *) cc_cflags);
414 
415  printf("\n%s\n", _("Default options:"));
417 
418  printf("\n%s\n", _("Compile options:"));
420 
421 #ifdef DOMAIN
422  printf("DOMAIN=\"%s\"\n", DOMAIN);
423 #endif
424 #ifdef ISPELL
425  printf("ISPELL=\"%s\"\n", ISPELL);
426 #endif
427  printf("MAILPATH=\"%s\"\n", MAILPATH);
428 #ifdef MIXMASTER
429  printf("MIXMASTER=\"%s\"\n", MIXMASTER);
430 #endif
431  printf("PKGDATADIR=\"%s\"\n", PKGDATADIR);
432  printf("SENDMAIL=\"%s\"\n", SENDMAIL);
433  printf("SYSCONFDIR=\"%s\"\n", SYSCONFDIR);
434 
435  puts("");
436  puts(_(ReachingUs));
437 }
unsigned char configure_options[]
static struct CompileOptions comp_opts[]
Definition: version.c:147
const char * mutt_hcache_backend_list(void)
Get a list of backend names.
Definition: hcache.c:463
#define _(a)
Definition: message.h:28
#define ISPELL
Definition: init.h:111
static struct CompileOptions comp_opts_default[]
Definition: version.c:113
static char * rstrip_in_place(char *s)
Strip a trailing carriage return.
Definition: version.c:343
static const char * ReachingUs
Definition: version.c:88
unsigned char cc_cflags[]
const char * mutt_gpgme_print_version(void)
Get version of GPGME.
Definition: crypt_gpgme.c:5564
const char * mutt_idna_print_version(void)
Create an IDN version string.
Definition: idna.c:278
#define FREE(x)
Definition: memory.h:46
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1492
static void print_compile_options(struct CompileOptions *co)
Print a list of enabled/disabled features.
Definition: version.c:303
static const char * Notice
Definition: version.c:95
unsigned char cc_version[]

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

446 {
447  puts(mutt_make_version());
448  puts(Copyright);
449  puts(_(Thanks));
450  puts(_(License));
451  puts(_(ReachingUs));
452 }
#define _(a)
Definition: message.h:28
static const char * Copyright
Definition: version.c:56
static const char * ReachingUs
Definition: version.c:88
static const char * Thanks
Definition: version.c:68
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1492
static const char * License
Definition: version.c:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

470 {
471  if (!name)
472  return false;
473  for (int i = 0; comp_opts_default[i].name; i++)
474  {
476  {
477  return true;
478  }
479  }
480  for (int i = 0; comp_opts[i].name; i++)
481  {
482  if (mutt_str_strcmp(name, comp_opts[i].name) == 0)
483  {
484  return comp_opts[i].enabled;
485  }
486  }
487  return false;
488 }
static struct CompileOptions comp_opts[]
Definition: version.c:147
const char * name
Definition: version.c:107
static struct CompileOptions comp_opts_default[]
Definition: version.c:113
const char * name
Definition: pgpmicalg.c:42
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612
bool enabled
Definition: version.c:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const int SCREEN_WIDTH = 80

Definition at line 50 of file version.c.

unsigned char cc_version[]
unsigned char cc_cflags[]
unsigned char configure_options[]
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-2018 Kevin J. McCarthy <kevin@8t8.us>\n"
"Copyright (C) 2015-2018 Richard Russon <rich@flatcap.org>\n"

Definition at line 56 of file version.c.

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

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

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

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

struct CompileOptions comp_opts_default[]
static

Definition at line 113 of file version.c.

struct CompileOptions comp_opts[]
static

Definition at line 147 of file version.c.