2 * Reports capture file type
5 * Copyright 2004 Ian Schorr
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
41 #ifdef HAVE_SYS_TIME_H
47 #include <wsutil/privileges.h>
48 #include <wsutil/filesystem.h>
49 #include <wsutil/file_util.h>
52 #include <wsutil/plugins.h>
56 #include <wsutil/report_err.h>
57 #include <wsutil/privileges.h>
58 #include <wsutil/str_util.h>
61 #include <wsutil/unicode-utils.h>
64 #include "svnversion.h"
69 fprintf(stderr, "Captype %s"
71 " (" SVNVERSION " from " SVNPATH ")"
74 fprintf(stderr, "Prints the file types of capture files.\n");
75 fprintf(stderr, "See http://www.wireshark.org for more information.\n");
76 fprintf(stderr, "\n");
77 fprintf(stderr, "Usage: captype <infile> ...\n");
82 * Don't report failures to load plugins because most (non-wiretap) plugins
83 * *should* fail to load (because we're not linked against libwireshark and
84 * dissector plugins need libwireshark).
87 failure_message(const char *msg_format _U_, va_list ap _U_)
94 main(int argc, char *argv[])
100 int overall_error_status;
103 char *init_progfile_dir_error;
107 arg_list_utf_16to8(argc, argv);
108 create_app_running_mutex();
112 * Get credential information for later use.
114 init_process_policies();
117 if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
118 g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
119 g_free(init_progfile_dir_error);
121 /* Register all the plugin types we have. */
122 wtap_register_plugin_types(); /* Types known to libwiretap */
124 init_report_err(failure_message,NULL,NULL,NULL);
126 /* Scan for plugins. This does *not* call their registration routines;
127 that's done later. */
130 /* Register all libwiretap plugin modules. */
131 register_all_wiretap_modules();
135 /* Set the C-language locale to the native environment. */
136 setlocale(LC_ALL, "");
143 overall_error_status = 0;
145 for (i = 1; i < argc; i++) {
146 wth = wtap_open_offline(argv[i], &err, &err_info, FALSE);
149 printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wtap_file_type_subtype(wth)));
152 if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT)
153 printf("%s: unknown\n", argv[i]);
155 fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
159 case WTAP_ERR_UNSUPPORTED:
160 case WTAP_ERR_UNSUPPORTED_ENCAP:
161 case WTAP_ERR_BAD_FILE:
162 fprintf(stderr, "(%s)\n", err_info);
166 overall_error_status = 1; /* remember that an error has occurred */
172 return overall_error_status;
176 * Editor modelines - http://www.wireshark.org/tools/modelines.html
181 * indent-tabs-mode: nil
184 * vi: set shiftwidth=2 tabstop=2 expandtab:
185 * :indentSize=2:tabSize=2:noTabs=true: