C15ch: fix o previous prototype for function [-Wmissing-prototypes]
[metze/wireshark/wip.git] / captype.c
index 6f6cac02428a5605fbeabdb05da789b2d3c160ff..2488ddda6992bbbed08ec261d51c7eb3961458d1 100644 (file)
--- a/captype.c
+++ b/captype.c
 
 #include <glib.h>
 
-#include <wsutil/privileges.h>
-#include <wsutil/filesystem.h>
-#include <wsutil/file_util.h>
 #include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
-#include <wsutil/os_version_info.h>
+#include <wsutil/file_util.h>
+#include <wsutil/filesystem.h>
+#include <wsutil/privileges.h>
+#include <wsutil/ws_diag_control.h>
 #include <wsutil/ws_version_info.h>
 
 #ifdef HAVE_PLUGINS
 
 #include "wtap.h"
 #include <wsutil/report_err.h>
-#include <wsutil/privileges.h>
 #include <wsutil/str_util.h>
 
 #ifdef _WIN32
 #include <wsutil/unicode-utils.h>
 #endif /* _WIN32 */
 
-#ifndef HAVE_GETOPT
+#ifndef HAVE_GETOPT_LONG
 #include "wsutil/wsgetopt.h"
 #endif
 
-#include "version_info.h"
-
-static void
-show_version(GString *comp_info_str, GString *runtime_info_str)
-{
-    printf("Captype (Wireshark) %s\n"
-           "\n"
-           "%s"
-           "\n"
-           "%s"
-           "\n"
-           "%s",
-           get_ws_vcs_version_info(), get_copyright_info(),
-           comp_info_str->str, runtime_info_str->str);
-}
-
 static void
 print_usage(FILE *output)
 {
@@ -148,23 +130,26 @@ main(int argc, char *argv[])
   int    i;
   int    opt;
   int    overall_error_status;
+DIAG_OFF(cast-qual)
   static const struct option long_options[] = {
       {(char *)"help", no_argument, NULL, 'h'},
       {(char *)"version", no_argument, NULL, 'v'},
       {0, 0, 0, 0 }
   };
+DIAG_ON(cast-qual)
 
 #ifdef HAVE_PLUGINS
   char  *init_progfile_dir_error;
 #endif
 
-  /* Assemble the compile-time version information string */
-  comp_info_str = g_string_new("Compiled ");
-  get_compiled_version_info(comp_info_str, NULL, get_captype_compiled_info);
+  /* Set the C-language locale to the native environment. */
+  setlocale(LC_ALL, "");
+
+  /* Get the compile-time version information string */
+  comp_info_str = get_compiled_version_info(NULL, get_captype_compiled_info);
 
-  /* Assemble the run-time version information string */
-  runtime_info_str = g_string_new("Running ");
-  get_runtime_version_info(runtime_info_str, get_captype_runtime_info);
+  /* Get the run-time version information string */
+  runtime_info_str = get_runtime_version_info(get_captype_runtime_info);
 
   /* Add it to the information to be reported on a crash. */
   ws_add_crash_info("Captype (Wireshark) %s\n"
@@ -186,7 +171,7 @@ main(int argc, char *argv[])
   init_open_routines();
 
 #ifdef HAVE_PLUGINS
-  if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
+  if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
     g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
     g_free(init_progfile_dir_error);
   } else {
@@ -219,7 +204,7 @@ main(int argc, char *argv[])
         break;
 
       case 'v':
-        show_version(comp_info_str, runtime_info_str);
+        show_version("Captype (Wireshark)", comp_info_str, runtime_info_str);
         g_string_free(comp_info_str, TRUE);
         g_string_free(runtime_info_str, TRUE);
         exit(0);
@@ -232,9 +217,6 @@ main(int argc, char *argv[])
     }
   }
 
-  /* Set the C-language locale to the native environment. */
-  setlocale(LC_ALL, "");
-
   if (argc < 2) {
     print_usage(stderr);
     return 1;
@@ -254,14 +236,9 @@ main(int argc, char *argv[])
       else {
         fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
                 wtap_strerror(err));
-        switch (err) {
-
-        case WTAP_ERR_UNSUPPORTED:
-        case WTAP_ERR_UNWRITABLE_ENCAP:
-        case WTAP_ERR_BAD_FILE:
+        if (err_info != NULL) {
           fprintf(stderr, "(%s)\n", err_info);
           g_free(err_info);
-          break;
         }
         overall_error_status = 1; /* remember that an error has occurred */
       }