aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2017-11-28 17:48:59 -0800
committerMichael Mann <mmann78@netscape.net>2017-11-29 03:36:30 +0000
commit18b240d7d2d8a138a1837dcbcd3b0706353a007f (patch)
treee96cf860041797c51d80b7c9d28fb16046b0b134 /ui
parentd1a79a6cac7a4d5a3f3fd3f92330686047e34d2c (diff)
Normalize ui/win32 indentation and switch to SPDX.
Switch ui/win32/console_win32.[ch] to 4-space indentation to match the other files in that directory. Remove ui/.editorconfig. SPDX-abbreviate the license blurb in all files in that directory. Change-Id: I68aa5a3ae7ae184ea8d27d9dba06b968ac3d2472 Reviewed-on: https://code.wireshark.org/review/24636 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r--ui/win32/.editorconfig8
-rw-r--r--ui/win32/console_win32.c280
-rw-r--r--ui/win32/console_win32.h24
-rw-r--r--ui/win32/file_dlg_win32.c14
-rw-r--r--ui/win32/file_dlg_win32.h14
-rw-r--r--ui/win32/print_win32.c15
-rw-r--r--ui/win32/print_win32.h14
-rw-r--r--ui/win32/settings.ini1
8 files changed, 144 insertions, 226 deletions
diff --git a/ui/win32/.editorconfig b/ui/win32/.editorconfig
deleted file mode 100644
index 530460bd5f..0000000000
--- a/ui/win32/.editorconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Editor configuration
-#
-# http://editorconfig.org/
-#
-
-[console_win32.[ch]]
-indent_size = 2
diff --git a/ui/win32/console_win32.c b/ui/win32/console_win32.c
index 8856f805d7..9392989d7e 100644
--- a/ui/win32/console_win32.c
+++ b/ui/win32/console_win32.c
@@ -5,21 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2002, Jeffrey C. Foster <jfoste@woodward.com>
*
- * 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+
*/
#ifdef _WIN32
@@ -60,51 +46,51 @@ static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */
static gboolean
needs_redirection(int std_handle)
{
- HANDLE fd;
- DWORD handle_type;
- DWORD error;
+ HANDLE fd;
+ DWORD handle_type;
+ DWORD error;
+
+ fd = GetStdHandle(std_handle);
+ if (fd == NULL) {
+ /*
+ * No standard handle. According to Microsoft's
+ * documentation for GetStdHandle(), one reason for
+ * this would be that the process is "a service on
+ * an interactive desktop"; I'm not sure whether
+ * such a process should be popping up a console.
+ *
+ * However, it also appears to be the case for
+ * the standard input and standard error, but
+ * *not* the standard output, for something run
+ * with a double-click in Windows Explorer,
+ * sow we'll say it needs redirection.
+ */
+ return TRUE;
+ }
+ if (fd == INVALID_HANDLE_VALUE) {
+ /*
+ * OK, I'm not when this would happen; return
+ * "no redirection" for now.
+ */
+ return FALSE;
+ }
+ handle_type = GetFileType(fd);
+ if (handle_type == FILE_TYPE_UNKNOWN) {
+ error = GetLastError();
+ if (error == ERROR_INVALID_HANDLE) {
+ /*
+ * OK, this appears to be the case where we're
+ * running something in a mode that needs a
+ * console.
+ */
+ return TRUE;
+ }
+ }
- fd = GetStdHandle(std_handle);
- if (fd == NULL) {
- /*
- * No standard handle. According to Microsoft's
- * documentation for GetStdHandle(), one reason for
- * this would be that the process is "a service on
- * an interactive desktop"; I'm not sure whether
- * such a process should be popping up a console.
- *
- * However, it also appears to be the case for
- * the standard input and standard error, but
- * *not* the standard output, for something run
- * with a double-click in Windows Explorer,
- * sow we'll say it needs redirection.
- */
- return TRUE;
- }
- if (fd == INVALID_HANDLE_VALUE) {
/*
- * OK, I'm not when this would happen; return
- * "no redirection" for now.
+ * Assume no redirection is needed for all other cases.
*/
return FALSE;
- }
- handle_type = GetFileType(fd);
- if (handle_type == FILE_TYPE_UNKNOWN) {
- error = GetLastError();
- if (error == ERROR_INVALID_HANDLE) {
- /*
- * OK, this appears to be the case where we're
- * running something in a mode that needs a
- * console.
- */
- return TRUE;
- }
- }
-
- /*
- * Assume no redirection is needed for all other cases.
- */
- return FALSE;
}
/* The code to create and desstroy console windows should not be necessary,
@@ -126,144 +112,144 @@ needs_redirection(int std_handle)
void
create_console(void)
{
- gboolean must_redirect_stdin;
- gboolean must_redirect_stdout;
- gboolean must_redirect_stderr;
-
- if (stdin_capture) {
- /* We've been handed "-i -". Don't mess with stdio. */
- return;
- }
-
- if (!has_console) {
- /* Are the standard input, output, and error invalid handles? */
- must_redirect_stdin = needs_redirection(STD_INPUT_HANDLE);
- must_redirect_stdout = needs_redirection(STD_OUTPUT_HANDLE);
- must_redirect_stderr = needs_redirection(STD_ERROR_HANDLE);
-
- /* If none of them are invalid, we don't need to do anything. */
- if (!must_redirect_stdin && !must_redirect_stdout && !must_redirect_stderr)
- return;
-
- /* OK, at least one of them needs to be redirected to a console;
- try to attach to the parent process's console and, if that fails,
- try to create one. */
- /*
- * See if we have an existing console (i.e. we were run from a
- * command prompt).
- */
- if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
- /* Probably not, as we couldn't attach to the parent process's console.
- Try to create a console.
-
- According to a comment on
-
- http://msdn.microsoft.com/en-us/library/windows/desktop/ms681952(v=vs.85).aspx
-
- and according to
-
- http://connect.microsoft.com/VisualStudio/feedback/details/689696/installing-security-update-kb2507938-prevents-console-allocation
-
- and
+ gboolean must_redirect_stdin;
+ gboolean must_redirect_stdout;
+ gboolean must_redirect_stderr;
- http://answers.microsoft.com/en-us/windows/forum/windows_xp-windows_update/kb2567680-andor-kb2507938-breaks-attachconsole-api/e8191280-2d49-4be4-9918-18486fba0afa
-
- even a failed attempt to attach to another process's console
- will cause subsequent AllocConsole() calls to fail, possibly due
- to bugs introduced by a security patch. To work around this, we
- do a FreeConsole() first. */
- FreeConsole();
- if (AllocConsole()) {
- /* That succeeded. */
- console_wait = TRUE;
- SetConsoleTitle(_T("Wireshark Debug Console"));
- } else {
- /* On Windows XP, this still fails; FreeConsole() apparently
- doesn't clear the state, as it does on Windows 7. */
- return; /* couldn't create console */
- }
+ if (stdin_capture) {
+ /* We've been handed "-i -". Don't mess with stdio. */
+ return;
}
- if (must_redirect_stdin)
- ws_freopen("CONIN$", "r", stdin);
- if (must_redirect_stdout) {
- ws_freopen("CONOUT$", "w", stdout);
- fprintf(stdout, "\n");
- }
- if (must_redirect_stderr) {
- ws_freopen("CONOUT$", "w", stderr);
- fprintf(stderr, "\n");
+ if (!has_console) {
+ /* Are the standard input, output, and error invalid handles? */
+ must_redirect_stdin = needs_redirection(STD_INPUT_HANDLE);
+ must_redirect_stdout = needs_redirection(STD_OUTPUT_HANDLE);
+ must_redirect_stderr = needs_redirection(STD_ERROR_HANDLE);
+
+ /* If none of them are invalid, we don't need to do anything. */
+ if (!must_redirect_stdin && !must_redirect_stdout && !must_redirect_stderr)
+ return;
+
+ /* OK, at least one of them needs to be redirected to a console;
+ try to attach to the parent process's console and, if that fails,
+ try to create one. */
+ /*
+ * See if we have an existing console (i.e. we were run from a
+ * command prompt).
+ */
+ if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
+ /* Probably not, as we couldn't attach to the parent process's console.
+ Try to create a console.
+
+ According to a comment on
+
+http://msdn.microsoft.com/en-us/library/windows/desktop/ms681952(v=vs.85).aspx
+
+and according to
+
+http://connect.microsoft.com/VisualStudio/feedback/details/689696/installing-security-update-kb2507938-prevents-console-allocation
+
+and
+
+http://answers.microsoft.com/en-us/windows/forum/windows_xp-windows_update/kb2567680-andor-kb2507938-breaks-attachconsole-api/e8191280-2d49-4be4-9918-18486fba0afa
+
+even a failed attempt to attach to another process's console
+will cause subsequent AllocConsole() calls to fail, possibly due
+to bugs introduced by a security patch. To work around this, we
+do a FreeConsole() first. */
+ FreeConsole();
+ if (AllocConsole()) {
+ /* That succeeded. */
+ console_wait = TRUE;
+ SetConsoleTitle(_T("Wireshark Debug Console"));
+ } else {
+ /* On Windows XP, this still fails; FreeConsole() apparently
+ doesn't clear the state, as it does on Windows 7. */
+ return; /* couldn't create console */
+ }
+ }
+
+ if (must_redirect_stdin)
+ ws_freopen("CONIN$", "r", stdin);
+ if (must_redirect_stdout) {
+ ws_freopen("CONOUT$", "w", stdout);
+ fprintf(stdout, "\n");
+ }
+ if (must_redirect_stderr) {
+ ws_freopen("CONOUT$", "w", stderr);
+ fprintf(stderr, "\n");
+ }
+
+ /* Now register "destroy_console()" as a routine to be called just
+ before the application exits, so that we can destroy the console
+ after the user has typed a key (so that the console doesn't just
+ disappear out from under them, giving the user no chance to see
+ the message(s) we put in there). */
+ atexit(destroy_console);
+
+ /* Well, we have a console now. */
+ has_console = TRUE;
}
-
- /* Now register "destroy_console()" as a routine to be called just
- before the application exits, so that we can destroy the console
- after the user has typed a key (so that the console doesn't just
- disappear out from under them, giving the user no chance to see
- the message(s) we put in there). */
- atexit(destroy_console);
-
- /* Well, we have a console now. */
- has_console = TRUE;
- }
}
void
destroy_console(void)
{
- if (console_wait) {
- printf("\n\nPress any key to exit\n");
- _getch();
- }
- FreeConsole();
+ if (console_wait) {
+ printf("\n\nPress any key to exit\n");
+ _getch();
+ }
+ FreeConsole();
}
void
set_console_wait(gboolean set_console_wait)
{
- console_wait = set_console_wait;
+ console_wait = set_console_wait;
}
gboolean
get_console_wait(void)
{
- return console_wait;
+ return console_wait;
}
void
set_has_console(gboolean set_has_console)
{
- has_console = set_has_console;
+ has_console = set_has_console;
}
gboolean
get_has_console(void)
{
- return has_console;
+ return has_console;
}
void
set_stdin_capture(gboolean set_stdin_capture)
{
- stdin_capture = set_stdin_capture;
+ stdin_capture = set_stdin_capture;
}
gboolean
get_stdin_capture(void)
{
- return stdin_capture;
+ return stdin_capture;
}
#endif /* _WIN32 */
/*
- * Editor modelines
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local Variables:
- * c-basic-offset: 2
+ * Local variables:
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/win32/console_win32.h b/ui/win32/console_win32.h
index 0f61ffd04e..de2a6fcd6c 100644
--- a/ui/win32/console_win32.h
+++ b/ui/win32/console_win32.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2002, Jeffrey C. Foster <jfoste@woodward.com>
*
- * 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+
*/
#ifndef __CONSOLE_WIN32_H__
@@ -77,14 +65,14 @@ gboolean get_stdin_capture(void);
#endif /* __CONSOLE_WIN32_H__ */
/*
- * Editor modelines
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local Variables:
- * c-basic-offset: 2
+ * Local variables:
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index 84b0174847..5ac3afecb9 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -5,19 +5,7 @@
* 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"
diff --git a/ui/win32/file_dlg_win32.h b/ui/win32/file_dlg_win32.h
index 16f4bb5780..ca1a7518a4 100644
--- a/ui/win32/file_dlg_win32.h
+++ b/ui/win32/file_dlg_win32.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2006 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+
*/
#ifndef __FILE_DLG_WIN32_H__
diff --git a/ui/win32/print_win32.c b/ui/win32/print_win32.c
index 7ccb36c465..7a495eaa52 100644
--- a/ui/win32/print_win32.c
+++ b/ui/win32/print_win32.c
@@ -5,20 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2002, Jeffrey C. Foster <jfoste@woodward.com>
*
- * 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+
*
* This original code was from the Technet Article Q139652 :
* HOWTO: Print a Document
diff --git a/ui/win32/print_win32.h b/ui/win32/print_win32.h
index 6bcf773c34..4005ce47e1 100644
--- a/ui/win32/print_win32.h
+++ b/ui/win32/print_win32.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2002, Jeffrey C. Foster <jfoste@woodward.com>
*
- * 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+
*/
#ifndef __PRINT_MSWIN_H__
diff --git a/ui/win32/settings.ini b/ui/win32/settings.ini
index af41c6f7e5..13d8b783be 100644
--- a/ui/win32/settings.ini
+++ b/ui/win32/settings.ini
@@ -1,3 +1,4 @@
+# Gtk+ only.
[Settings]
gtk-toolbar-icon-size=GTK_ICON_SIZE_SMALL_TOOLBAR
# disable images in buttons.