Author: pschweitzer
Date: Tue Sep 5 13:24:00 2017
New Revision: 75766
URL:
http://svn.reactos.org/svn/reactos?rev=75766&view=rev
Log:
[FSUTIL]
Avoid code duplication++
Modified:
trunk/reactos/base/applications/cmdutils/fsutil/common.c
trunk/reactos/base/applications/cmdutils/fsutil/dirty.c
trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c
trunk/reactos/base/applications/cmdutils/fsutil/fsutil.h
Modified: trunk/reactos/base/applications/cmdutils/fsutil/common.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/common.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/common.c [iso-8859-1] Tue Sep 5
13:24:00 2017
@@ -45,3 +45,24 @@
return ret;
}
+
+void PrintDefaultUsage(const TCHAR * Command,
+ const TCHAR * SubCommand,
+ HandlerItem * HandlersList,
+ int HandlerListCount)
+{
+ int i;
+
+ /* If we were given a command, print it's not supported */
+ if (SubCommand != NULL)
+ {
+ _ftprintf(stderr, _T("Unhandled%scommand: %s\n"), Command,
SubCommand);
+ }
+
+ /* And dump any available command */
+ _ftprintf(stderr, _T("---- Handled%scommands ----\n\n"), Command);
+ for (i = 0; i < HandlerListCount; ++i)
+ {
+ _ftprintf(stderr, _T("%s\t%s\n"), HandlersList[i].Command,
HandlersList[i].Desc);
+ }
+}
Modified: trunk/reactos/base/applications/cmdutils/fsutil/dirty.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/dirty.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/dirty.c [iso-8859-1] Tue Sep 5
13:24:00 2017
@@ -74,20 +74,8 @@
static void
PrintUsage(const TCHAR * Command)
{
- int i;
-
- /* If we were given a command, print it's not supported */
- if (Command != NULL)
- {
- _ftprintf(stderr, _T("Unhandled DIRTY command: %s\n"), Command);
- }
-
- /* And dump any available command */
- _ftprintf(stderr, _T("---- Handled DIRTY commands ----\n\n"));
- for (i = 0; i < (sizeof(HandlersList) / sizeof(HandlersList[0])); ++i)
- {
- _ftprintf(stderr, _T("%s\t%s\n"), HandlersList[i].Command,
HandlersList[i].Desc);
- }
+ PrintDefaultUsage(_T(" DIRTY "), Command, (HandlerItem
*)&HandlersList,
+ (sizeof(HandlersList) / sizeof(HandlersList[0])));
}
int
Modified: trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/fsutil.c [iso-8859-1] Tue Sep 5
13:24:00 2017
@@ -19,20 +19,8 @@
static void
PrintUsage(const TCHAR * Command)
{
- int i;
-
- /* If we were given a command, print it's not supported */
- if (Command != NULL)
- {
- _ftprintf(stderr, _T("Unhandled command: %s\n"), Command);
- }
-
- /* And dump any available command */
- _ftprintf(stderr, _T("---- Handled commands ----\n\n"));
- for (i = 0; i < (sizeof(HandlersList) / sizeof(HandlersList[0])); ++i)
- {
- _ftprintf(stderr, _T("%s\t%s\n"), HandlersList[i].Command,
HandlersList[i].Desc);
- }
+ PrintDefaultUsage(_T(" "), Command, (HandlerItem *)&HandlersList,
+ (sizeof(HandlersList) / sizeof(HandlersList[0])));
}
int
Modified: trunk/reactos/base/applications/cmdutils/fsutil/fsutil.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/fsutil/fsutil.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/fsutil/fsutil.h [iso-8859-1] Tue Sep 5
13:24:00 2017
@@ -18,4 +18,9 @@
int HandlerListCount,
void (*UsageHelper)(const TCHAR *));
+void PrintDefaultUsage(const TCHAR * Command,
+ const TCHAR * SubCommand,
+ HandlerItem * HandlersList,
+ int HandlerListCount);
+
#endif