-/* win32-file-dlg.c
+/* file_dlg_win32.c
* Native Windows file dialog routines
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2004 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
-#include <stdio.h>
#include <tchar.h>
-#include <wchar.h>
#include <stdlib.h>
-#include <sys/stat.h>
-#include <io.h>
#include <fcntl.h>
#include <windows.h>
-#include <windowsx.h>
#include <commdlg.h>
#include <richedit.h>
#include <strsafe.h>
-#include "file.h"
+#include "globals.h"
#include "wsutil/file_util.h"
+#include "wsutil/str_util.h"
#include "wsutil/unicode-utils.h"
-#include "wiretap/merge.h"
-
#include "wsutil/filesystem.h"
-#include "epan/addr_resolv.h"
#include "epan/prefs.h"
-#include "epan/print.h"
-#include "color.h"
-#include "color_filters.h"
+#include "epan/color_filters.h"
#include "ui/alert_box.h"
#include "ui/help_url.h"
-#include "ui/file_dialog.h"
#include "ui/last_open_dir.h"
#include "ui/simple_dialog.h"
#include "ui/ssl_key_export.h"
#include "ui/util.h"
+#include "ui/ws_ui_util.h"
+#include "ui/all_files_wildcard.h"
#include "file_dlg_win32.h"
_T("CSV (Comma Separated Values summary) (*.csv)\0") _T("*.csv\0") \
_T("PSML (XML packet summary) (*.psml)\0") _T("*.psml\0") \
_T("PDML (XML packet detail) (*.pdml)\0") _T("*.pdml\0") \
- _T("C Arrays (packet bytes) (*.c)\0") _T("*.c\0")
+ _T("C Arrays (packet bytes) (*.c)\0") _T("*.c\0") \
+ _T("JSON (*.json)\0") _T("*.json\0")
#define FILE_TYPES_RAW \
_T("Raw data (*.bin, *.dat, *.raw)\0") _T("*.bin;*.dat;*.raw\0") \
- _T("All Files (*.*)\0") _T("*.*\0")
+ _T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
#define FILE_RAW_DEFAULT 1
#define FILE_TYPES_SSLKEYS \
_T("SSL Session Keys (*.keys)\0") _T("*.keys\0") \
- _T("All Files (*.*)\0") _T("*.*\0")
+ _T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
#define FILE_SSLKEYS_DEFAULT 1
#define FILE_TYPES_COLOR \
_T("Text Files (*.txt)\0") _T("*.txt\0") \
- _T("All Files (*.*)\0") _T("*.*\0")
+ _T("All Files (") _T(ALL_FILES_WILDCARD) _T(")\0") _T(ALL_FILES_WILDCARD) _T("\0")
#define FILE_DEFAULT_COLOR 2
comment_types = cf_comment_types(cf);
/* Does the file's format support all the comments we have? */
- if (wtap_dump_supports_comment_types(cf->cd_t, comment_types)) {
+ if (wtap_dump_supports_comment_types(file_type, comment_types)) {
/* Yes. Let the save happen; we can save all the comments, so
there's no need to delete them. */
return SAVE;
format you selected", or "Cancel", meaning "don't bother
saving the file at all".
- XXX - sadly, customizing buttons in a MessageBox() is
- Really Painful; there are tricks out there to do it
- with a "computer-based training" hook that gets called
- before the window is activated and sets the text of the
- buttons, but if you change the text of the buttons you
- also have to make the buttons bigger. There *has* to
- be a better way of doing that, given that Microsoft's
- own UI guidelines have examples of dialog boxes with
- action buttons that have custom labels, but maybe we'd
- have to go with Windows Forms or XAML or whatever the
- heck the technology of the week is.
-
- Therefore, we ask a yes-or-no question - "do you want
- to discard the comments and save in the format you
- chose?" - and have "no" mean "I want to save the
- file but I don't want to discard the comments, meaning
- we should reopen the dialog and not offer the user any
- choices that would involve discarding the comments. */
+ XXX - given that we no longer support releases prior to
+ Windows Vista, we should use a task dialog:
+
+ https://msdn.microsoft.com/en-us/library/windows/desktop/ff486057(v=vs.85).aspx
+
+ created with TaskDialogIndirect():
+
+ https://msdn.microsoft.com/en-us/library/windows/desktop/bb760544(v=vs.85).aspx
+
+ because the TASKDIALOGCONFIG structure
+
+ https://msdn.microsoft.com/en-us/library/windows/desktop/bb787473(v=vs.85).aspx
+
+ supports adding custom buttons, with custom labels, unlike
+ a MessageBox(), which doesn't appear to offer a clean way to
+ do that. */
response = MessageBox(parent,
_T("The capture has comments, but the file format you chose ")
_T("doesn't support comments. Do you want to discard the comments ")
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
gboolean gsfn_ok;
- gboolean discard_comments = FALSE;
if (!file_name || !file_type || !compressed)
return FALSE;
print_args.print_dissections = print_dissections_as_displayed;
print_args.print_hex = FALSE;
print_args.print_formfeed = FALSE;
+ print_args.stream = NULL;
if (GetSaveFileName(ofn)) {
print_args.file = utf_16to8(file_name);
g_free( (void *) ofn);
return;
}
- status = cf_print_packets(cf, &print_args);
+ status = cf_print_packets(cf, &print_args, TRUE);
break;
case export_type_ps: /* PostScript (r) */
print_args.stream = print_stream_ps_new(TRUE, print_args.file);
g_free( (void *) ofn);
return;
}
- status = cf_print_packets(cf, &print_args);
+ status = cf_print_packets(cf, &print_args, TRUE);
break;
case export_type_csv: /* CSV */
status = cf_write_csv_packets(cf, &print_args);
case export_type_pdml: /* PDML */
status = cf_write_pdml_packets(cf, &print_args);
break;
+ case export_type_json: /* JSON */
+ status = cf_write_json_packets(cf, &print_args);
+ break;
default:
g_free( (void *) ofn);
return;
open_failure_alert_box(file_name8, errno, TRUE);
return;
}
- if (write(fd, data_p, cf->finfo_selected->length) < 0) {
+ if (ws_write(fd, data_p, cf->finfo_selected->length) < 0) {
write_failure_alert_box(file_name8, errno);
- close(fd);
+ ws_close(fd);
return;
}
- if (close(fd) < 0) {
+ if (ws_close(fd) < 0) {
write_failure_alert_box(file_name8, errno);
return;
}
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
+ gchar *err_msg = NULL;
ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
/* XXX - Support marked filters */
if (GetSaveFileName(ofn)) {
g_free( (void *) ofn);
- if (!color_filters_export(utf_16to8(file_name), filter_list, FALSE /* all filters */))
+ if (!color_filters_export(utf_16to8(file_name), filter_list, FALSE /* all filters */, &err_msg))
+ {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
+ g_free(err_msg);
return;
+ }
/* Save the directory name for future file dialogs. */
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
+ gchar *err_msg = NULL;
ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
/* XXX - Support export limited to selected filters */
if (GetOpenFileName(ofn)) {
g_free( (void *) ofn);
- if (!color_filters_import(utf_16to8(file_name), color_filters))
+ if (!color_filters_import(utf_16to8(file_name), color_filters, &err_msg, color_filter_add_cb)) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
+ g_free(err_msg);
return;
+ }
/* Save the directory name for future file dialogs. */
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
HWND cur_ctrl;
int i;
- gboolean enable = FALSE;
wtap *wth;
const struct wtap_pkthdr *phdr;
int err = 0;
gchar *err_info;
TCHAR string_buff[PREVIEW_STR_MAX];
+ TCHAR first_buff[PREVIEW_STR_MAX];
gint64 data_offset;
guint packet = 0;
gint64 filesize;
+ gchar *size_str;
time_t ti_time;
struct tm *ti_tm;
guint elapsed_time;
double cur_time;
gboolean is_breaked = FALSE;
- for (i = EWFD_PTX_FORMAT; i <= EWFD_PTX_ELAPSED; i++) {
+ for (i = EWFD_PTX_FORMAT; i <= EWFD_PTX_START_ELAPSED; i++) {
cur_ctrl = GetDlgItem(of_hwnd, i);
if (cur_ctrl) {
EnableWindow(cur_ctrl, FALSE);
}
}
- for (i = EWFD_PTX_FORMAT; i <= EWFD_PTX_ELAPSED; i++) {
+ for (i = EWFD_PTX_FORMAT; i <= EWFD_PTX_START_ELAPSED; i++) {
cur_ctrl = GetDlgItem(of_hwnd, i);
if (cur_ctrl) {
SetWindowText(cur_ctrl, _T("-"));
}
/* Success! */
- for (i = EWFD_PT_FORMAT; i <= EWFD_PTX_ELAPSED; i++) {
+ for (i = EWFD_PT_FORMAT; i <= EWFD_PTX_START_ELAPSED; i++) {
cur_ctrl = GetDlgItem(of_hwnd, i);
if (cur_ctrl) {
EnableWindow(cur_ctrl, TRUE);
/* Size */
filesize = wtap_file_size(wth, &err);
- utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%" G_GINT64_FORMAT " bytes", filesize);
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
- SetWindowText(cur_ctrl, string_buff);
+ // Windows Explorer uses IEC.
+ size_str = format_size(filesize, format_size_unit_bytes|format_size_prefix_iec);
time(&time_preview);
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
}
if(err != 0) {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet);
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
+ utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%s, error after %u packets",
+ size_str, packet);
+ g_free(size_str);
+ cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
SetWindowText(cur_ctrl, string_buff);
wtap_close(wth);
return TRUE;
/* Packets */
if(is_breaked) {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet);
+ utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%s, timed out at %u packets",
+ size_str, packet);
} else {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
+ utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%s, %u packets",
+ size_str, packet);
}
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
+ g_free(size_str);
+ cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
SetWindowText(cur_ctrl, string_buff);
- /* First packet */
+ /* First packet / elapsed time */
ti_time = (long)start_time;
ti_tm = localtime( &ti_time );
if(ti_tm) {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX,
+ StringCchPrintf(first_buff, PREVIEW_STR_MAX,
_T("%04d-%02d-%02d %02d:%02d:%02d"),
ti_tm->tm_year + 1900,
ti_tm->tm_mon + 1,
ti_tm->tm_min,
ti_tm->tm_sec);
} else {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("?"));
+ StringCchPrintf(first_buff, PREVIEW_STR_MAX, _T("?"));
}
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_FIRST_PKT);
- SetWindowText(cur_ctrl, string_buff);
- /* Elapsed time */
elapsed_time = (unsigned int)(stop_time-start_time);
if(elapsed_time/86400) {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%02u days %02u:%02u:%02u"),
- elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%s / %02u days %02u:%02u:%02u"),
+ first_buff, elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
} else {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%02u:%02u:%02u"),
- elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%s / %02u:%02u:%02u"),
+ first_buff, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
}
if(is_breaked) {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("unknown"));
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%s / unknown"), first_buff);
}
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_ELAPSED);
+ cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_START_ELAPSED);
SetWindowText(cur_ctrl, string_buff);
wtap_close(wth);
/* Default window background */
SendMessage(hwnd, EM_SETBKGNDCOLOR, (WPARAM) 1, COLOR_WINDOW);
return;
- } else if (dfilter_compile(utf_16to8(strval), &dfp)) { /* colorize filter string entry */
- if (dfp != NULL)
- dfilter_free(dfp);
+ } else if (dfilter_compile(utf_16to8(strval), &dfp, NULL)) { /* colorize filter string entry */
+ dfilter_free(dfp);
/* Valid (light green) */
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xe4, 0xff, 0xc7)); /* tango_chameleon_1 */
} else {
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xcc, 0xcc)); /* tango_scarlet_red_1 */
}
- if (strval) g_free(strval);
+ g_free(strval);
}
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FORMAT_TYPE);
- SendMessage(cur_ctrl, CB_ADDSTRING, 0, (WPARAM) _T("Automatic"));
+ SendMessage(cur_ctrl, CB_ADDSTRING, 0, (WPARAM) _T("Automatically detect file type"));
for (i = 0; open_routines[i].name != NULL; i += 1) {
SendMessage(cur_ctrl, CB_ADDSTRING, 0, (WPARAM) utf_8to16(open_routines[i].name));
}
SendMessage(cur_ctrl, CB_SETCURSEL, 0, 0);
- /* Fill in our resolution values */
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
- SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.mac_name, 0);
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB);
- SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.network_name, 0);
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB);
- SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.transport_name, 0);
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_EXTERNAL_NR_CB);
- SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.use_external_net_name_resolver, 0);
-
preview_set_file_info(of_hwnd, NULL);
break;
case WM_NOTIFY:
case CDN_FILEOK:
/* Fetch the read filter */
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FILTER_EDIT);
- if (g_dfilter_str)
- g_free(g_dfilter_str);
+ g_free(g_dfilter_str);
g_dfilter_str = filter_tb_get(cur_ctrl);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_FORMAT_TYPE);
g_format_type = (unsigned int) SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
- /* Fetch our resolution values */
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
- if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
- gbl_resolv_flags.mac_name = TRUE;
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB);
- if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
- gbl_resolv_flags.network_name = TRUE;
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB);
- if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
- gbl_resolv_flags.transport_name = TRUE;
- cur_ctrl = GetDlgItem(of_hwnd, EWFD_EXTERNAL_NR_CB);
- if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
- gbl_resolv_flags.use_external_net_name_resolver = TRUE;
break;
case CDN_SELCHANGE:
/* This _almost_ works correctly. We need to handle directory
GString* description_str = g_string_new("");
gchar sep;
GSList *extensions_list, *extension;
- TCHAR *str16;
+ const TCHAR *str16;
guint16 zero = 0;
/* Construct the list of patterns. */
static TCHAR *
build_file_open_type_list(void) {
- TCHAR *str16;
+ const TCHAR *str16;
int et;
GArray* sa;
static const guint16 zero = 0;
str16 = utf_8to16("All Files");
sa = g_array_append_vals(sa, str16, (guint) strlen("All Files"));
sa = g_array_append_val(sa, zero);
- str16 = utf_8to16("*.*");
- sa = g_array_append_vals(sa, str16, (guint) strlen("*.*"));
+ str16 = utf_8to16(ALL_FILES_WILDCARD);
+ sa = g_array_append_vals(sa, str16, (guint) strlen(ALL_FILES_WILDCARD));
sa = g_array_append_val(sa, zero);
/*
- * Add an "All Capture Files" entry, with all the extensions we
- * know about.
+ * Add an "All Capture Files" entry, with all the capture file
+ * extensions we know about.
*/
str16 = utf_8to16("All Capture Files");
sa = g_array_append_vals(sa, str16, (guint) strlen("All Capture Files"));
sa = g_array_append_val(sa, zero);
/*
- * Construct its list of patterns from a list of all extensions
- * we support.
+ * Construct its list of patterns.
*/
pattern_str = g_string_new("");
- extensions_list = wtap_get_all_file_extensions_list();
+ extensions_list = wtap_get_all_capture_file_extensions_list();
sep = '\0';
for (extension = extensions_list; extension != NULL;
extension = g_slist_next(extension)) {
GString* description_str = g_string_new("");
gchar sep;
GSList *extensions_list, *extension;
- TCHAR *str16;
+ const TCHAR *str16;
guint16 zero = 0;
extensions_list = wtap_get_file_extensions_list(ft, TRUE);
if (extensions_list == NULL) {
/* This file type doesn't have any particular extension
- conventionally used for it, so we'll just use "*.*"
- as the pattern; on Windows, that matches all file names
- - even those with no extension - so we don't need to
- worry about compressed file extensions. (It does not
- do so on UN*X; the right pattern on UN*X would just
- be "*".) */
- g_string_printf(pattern_str, "*.*");
+ conventionally used for it, so we'll just use a
+ wildcard that matches all file names - even those with
+ no extension, so we don't need to worry about compressed
+ file extensions. */
+ g_string_printf(pattern_str, ALL_FILES_WILDCARD);
} else {
/* Construct the list of patterns. */
g_string_printf(pattern_str, "");
build_file_format_list(HWND sf_hwnd) {
HWND format_cb;
int ft;
- guint index;
+ guint file_index;
guint item_to_select;
gchar *s;
SendMessage(format_cb, CB_RESETCONTENT, 0, 0);
/* Check all file types. */
- index = 0;
+ file_index = 0;
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
if (ft == WTAP_FILE_UNKNOWN)
continue; /* not a real file type */
if(wtap_file_extensions_string(ft) != NULL) {
s = g_strdup_printf("%s (%s)", wtap_file_type_string(ft), wtap_file_extensions_string(ft));
} else {
- s = g_strdup_printf("%s (*.*)", wtap_file_type_string(ft));
+ s = g_strdup_printf("%s (" ALL_FILES_WILDCARD ")", wtap_file_type_string(ft));
}
SendMessage(format_cb, CB_ADDSTRING, 0, (LPARAM) utf_8to16(s));
g_free(s);
- SendMessage(format_cb, CB_SETITEMDATA, (LPARAM) index, (WPARAM) ft);
+ SendMessage(format_cb, CB_SETITEMDATA, (LPARAM) file_index, (WPARAM) ft);
if (ft == g_filetype) {
/* Default to the same format as the file, if it's supported. */
- item_to_select = index;
+ item_to_select = file_index;
}
- index++;
+ file_index++;
}
SendMessage(format_cb, CB_SETCURSEL, (WPARAM) item_to_select, 0);
save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
HWND cur_ctrl;
OFNOTIFY *notify = (OFNOTIFY *) l_param;
- /*int new_filetype, index;*/
+ /*int new_filetype, file_index;*/
switch(msg) {
case WM_INITDIALOG: {
switch (w_param) {
#if 0
case (CBN_SELCHANGE << 16) | EWFD_FILE_TYPE_COMBO:
- index = SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
- if (index != CB_ERR) {
- new_filetype = SendMessage(cur_ctrl, CB_GETITEMDATA, (WPARAM) index, 0);
+ file_index = SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
+ if (file_index != CB_ERR) {
+ new_filetype = SendMessage(cur_ctrl, CB_GETITEMDATA, (WPARAM) file_index, 0);
if (new_filetype != CB_ERR) {
if (g_filetype != new_filetype) {
if (wtap_can_save_with_wiretap(new_filetype, cfile.linktypes)) {
}
g_filetype = new_filetype;
cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
- if (wtap_dump_can_compress(file_type) {
+ if (wtap_dump_can_compress(file_type)) {
EnableWindow(cur_ctrl);
} else {
g_compressed = FALSE;
export_specified_packets_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
HWND cur_ctrl;
OFNOTIFY *notify = (OFNOTIFY *) l_param;
- /*int new_filetype, index;*/
+ /*int new_filetype, file_index;*/
switch(msg) {
case WM_INITDIALOG: {
switch (w_param) {
#if 0
case (CBN_SELCHANGE << 16) | EWFD_FILE_TYPE_COMBO:
- index = SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
- if (index != CB_ERR) {
- new_filetype = SendMessage(cur_ctrl, CB_GETITEMDATA, (WPARAM) index, 0);
+ file_index = SendMessage(cur_ctrl, CB_GETCURSEL, 0, 0);
+ if (file_index != CB_ERR) {
+ new_filetype = SendMessage(cur_ctrl, CB_GETITEMDATA, (WPARAM) file_index, 0);
if (new_filetype != CB_ERR) {
if (g_filetype != new_filetype) {
if (wtap_can_save_with_wiretap(new_filetype, cfile.linktypes)) {
if (range->remove_ignored && g_cf->current_frame && g_cf->current_frame->flags.ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("0"));
} else {
- StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
+ StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%d"), selected_num ? 1 : 0);
}
SetWindowText(cur_ctrl, static_val);
if (range->remove_ignored && g_cf->current_frame && g_cf->current_frame->flags.ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("0"));
} else {
- StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), selected_num ? 1 : 0);
+ StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%d"), selected_num ? 1 : 0);
}
SetWindowText(cur_ctrl, static_val);
/* Retain the filter text, and fill it in. */
if(range->user_range != NULL) {
+ char* tmp_str;
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_EDIT);
- SetWindowText(cur_ctrl, utf_8to16(range_convert_range(range->user_range)));
+ tmp_str = range_convert_range(NULL, range->user_range);
+ SetWindowText(cur_ctrl, utf_8to16(tmp_str));
+ wmem_free(NULL, tmp_str);
}
/* dynamic values in the range frame */
case CDN_FILEOK:
/* Fetch the read filter */
cur_ctrl = GetDlgItem(mf_hwnd, EWFD_FILTER_EDIT);
- if (g_dfilter_str)
- g_free(g_dfilter_str);
+ g_free(g_dfilter_str);
g_dfilter_str = filter_tb_get(cur_ctrl);
cur_ctrl = GetDlgItem(mf_hwnd, EWFD_MERGE_CHRONO_BTN);
HWND cur_ctrl;
OFNOTIFY *notify = (OFNOTIFY *) l_param;
gboolean pkt_fmt_enable;
- int i, index;
+ int i, filter_index;
switch(msg) {
case WM_INITDIALOG: {
case CDN_FILEOK:
break;
case CDN_TYPECHANGE:
- index = notify->lpOFN->nFilterIndex;
+ filter_index = notify->lpOFN->nFilterIndex;
- if (index == 2) /* PostScript */
+ if (filter_index == 2) /* PostScript */
print_args.format = PR_FMT_TEXT;
else
print_args.format = PR_FMT_PS;
- if (index == 3 || index == 4 || index == 5 || index == 6)
+ if (filter_index == 3 || filter_index == 4 || filter_index == 5 || filter_index == 6)
pkt_fmt_enable = FALSE;
else
pkt_fmt_enable = TRUE;