ca6cb95646cc09319ddec784b573064a6c37ef00
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS FS utility tool
4 * FILE: base/applications/cmdutils/common.c
5 * PURPOSE: FSutil common functions
6 * PROGRAMMERS: Pierre Schweitzer <pierre@reactos.org>
11 int FindHandler(int argc
,
13 HandlerItem
* HandlersList
,
15 void (*UsageHelper
)(const TCHAR
*))
19 const TCHAR
* Command
;
25 /* If we have a command, does it match a known one? */
28 /* Browse all the known commands finding the right one */
30 for (i
= 0; i
< HandlerListCount
; ++i
)
32 if (_tcsicmp(Command
, HandlersList
[i
].Command
) == 0)
34 ret
= HandlersList
[i
].Handler(argc
- 1, &argv
[1]);
40 /* We failed finding someone to handle the caller's needs, print out */
41 if (i
== HandlerListCount
)
49 void PrintDefaultUsage(const TCHAR
* Command
,
50 const TCHAR
* SubCommand
,
51 HandlerItem
* HandlersList
,
56 /* If we were given a command, print it's not supported */
57 if (SubCommand
!= NULL
)
59 _ftprintf(stderr
, _T("Unhandled%scommand: %s\n"), Command
, SubCommand
);
62 /* And dump any available command */
63 _ftprintf(stderr
, _T("---- Handled%scommands ----\n\n"), Command
);
64 for (i
= 0; i
< HandlerListCount
; ++i
)
66 _ftprintf(stderr
, _T("%s\t%s\n"), HandlersList
[i
].Command
, HandlersList
[i
].Desc
);