]> granicus.if.org Git - neomutt/commitdiff
Move IDN version string to mutt/idna.c
authorBo YU <tsu.yubo@gmail.com>
Fri, 27 Apr 2018 11:14:34 +0000 (19:14 +0800)
committerRichard Russon <rich@flatcap.org>
Fri, 27 Apr 2018 14:22:32 +0000 (15:22 +0100)
mutt/idna.c
mutt/idna2.h
version.c

index ceb893f17a35fd02054909cd90721e3d8dc81f59..c1fb360adc61cac1b3fe2082c605aa125e9ac6b2 100644 (file)
 #include "logging.h"
 #include "memory.h"
 #include "string2.h"
+#ifdef HAVE_STRINGPREP_H
+#include <stringprep.h>
+#elif defined(HAVE_IDN_STRINGPREP_H)
+#include <idn/stringprep.h>
+#endif
 #ifdef HAVE_IDN2_H
 #include <idn2.h>
 #elif defined(HAVE_IDN_IDN2_H)
@@ -265,3 +270,24 @@ cleanup:
 
   return mailbox;
 }
+
+/**
+ * mutt_idna_print_version - Create an IDN version string
+ * @retval str Version string
+ *
+ * @note This is a static string and must not be freed.
+ */
+const char *mutt_idna_print_version(void)
+{
+  static char vstring[STRING];
+
+#ifdef HAVE_IDN2_H
+  snprintf(vstring, sizeof(vstring), "libidn2: %s (compiled with %s)",
+           idn2_check_version(NULL), IDN2_VERSION);
+#elif defined(HAVE_LIBIDN)
+  snprintf(vstring, sizeof(vstring), "libidn: %s (compiled with %s)",
+           stringprep_check_version(NULL), STRINGPREP_VERSION);
+#endif
+
+  return vstring;
+}
index bd20a1753667c166943281a25c7a9b01d936c09e..7715d721c46dba4911668d971ff13ff279a0f6ff 100644 (file)
@@ -33,5 +33,7 @@ extern bool IdnEncode;
 int   mutt_idna_to_ascii_lz(const char *input, char **output, int flags);
 char *mutt_idna_intl_to_local(const char *user, const char *domain, int flags);
 char *mutt_idna_local_to_intl(const char *user, const char *domain);
+const char *mutt_idna_print_version(void);
+
 
 #endif /* _MUTT_IDNA_H */
index 36d880841c3ede5920c13fe82267647a01cc0b5b..d0e6f21bd6b25dd986ee3da19833b765fc7dc9c6 100644 (file)
--- a/version.c
+++ b/version.c
 #include <unistd.h>
 #include "mutt/mutt.h"
 #include "mutt_curses.h"
-#ifdef HAVE_STRINGPREP_H
-#include <stringprep.h>
-#elif defined(HAVE_IDN_STRINGPREP_H)
-#include <idn/stringprep.h>
-#endif
-#ifdef HAVE_IDN2_H
-#include <idn2.h>
-#elif defined(HAVE_IDN_IDN2_H)
-#include <idn/idn2.h>
-#elif defined(HAVE_IDNA_H)
-#include <idna.h>
-#elif defined(HAVE_IDN_IDNA_H)
-#include <idn/idna.h>
-#endif
 
 /* #include "protos.h" */
 const char *mutt_make_version(void);
@@ -392,10 +378,8 @@ void print_version(void)
   printf("\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff);
 #endif
 
-#ifdef HAVE_IDN2_H
-  printf("\nlibidn: %s (compiled with %s)", idn2_check_version(NULL), IDN2_VERSION);
-#elif defined(HAVE_LIBIDN)
-  printf("\nlibidn: %s (compiled with %s)", stringprep_check_version(NULL), STRINGPREP_VERSION);
+#ifdef HAVE_LIBIDN
+  printf("\n%s", mutt_idna_print_version());
 #endif
 
 #ifdef USE_HCACHE