2 * Reports capture file type
5 * Copyright 2004 Ian Schorr
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39 #ifdef HAVE_SYS_TIME_H
45 #include <wsutil/privileges.h>
46 #include <wsutil/filesystem.h>
47 #include <wsutil/file_util.h>
50 #include <wsutil/plugins.h>
54 #include <wsutil/report_err.h>
55 #include <wsutil/privileges.h>
56 #include <wsutil/str_util.h>
59 #include <wsutil/unicode-utils.h>
67 fprintf(stderr, "Captype %s"
69 " (" GITVERSION " from " GITBRANCH ")"
72 fprintf(stderr, "Prints the file types of capture files.\n");
73 fprintf(stderr, "See http://www.wireshark.org for more information.\n");
74 fprintf(stderr, "\n");
75 fprintf(stderr, "Usage: captype <infile> ...\n");
80 * Don't report failures to load plugins because most (non-wiretap) plugins
81 * *should* fail to load (because we're not linked against libwireshark and
82 * dissector plugins need libwireshark).
85 failure_message(const char *msg_format _U_, va_list ap _U_)
92 main(int argc, char *argv[])
98 int overall_error_status;
101 char *init_progfile_dir_error;
105 arg_list_utf_16to8(argc, argv);
106 create_app_running_mutex();
110 * Get credential information for later use.
112 init_process_policies();
113 init_open_routines();
116 if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
117 g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
118 g_free(init_progfile_dir_error);
120 /* Register all the plugin types we have. */
121 wtap_register_plugin_types(); /* Types known to libwiretap */
123 init_report_err(failure_message,NULL,NULL,NULL);
125 /* Scan for plugins. This does *not* call their registration routines;
126 that's done later. */
129 /* Register all libwiretap plugin modules. */
130 register_all_wiretap_modules();
134 /* Set the C-language locale to the native environment. */
135 setlocale(LC_ALL, "");
142 overall_error_status = 0;
144 for (i = 1; i < argc; i++) {
145 wth = wtap_open_offline(argv[i], WTAP_TYPE_AUTO, &err, &err_info, FALSE);
148 printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wtap_file_type_subtype(wth)));
151 if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT)
152 printf("%s: unknown\n", argv[i]);
154 fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
158 case WTAP_ERR_UNSUPPORTED:
159 case WTAP_ERR_UNSUPPORTED_ENCAP:
160 case WTAP_ERR_BAD_FILE:
161 fprintf(stderr, "(%s)\n", err_info);
165 overall_error_status = 1; /* remember that an error has occurred */
171 return overall_error_status;
175 * Editor modelines - http://www.wireshark.org/tools/modelines.html
180 * indent-tabs-mode: nil
183 * vi: set shiftwidth=2 tabstop=8 expandtab:
184 * :indentSize=2:tabSize=8:noTabs=true: