1/*
2 * Copyright 1999-2009 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Jeremy Friesner
7 */
8#ifndef _PARSE_COMMAND_STRING_H
9#define _PARSE_COMMAND_STRING_H
10
11
12#include <String.h>
13
14
15// Utility methods to extract arguments from a typed-in string.
16
17// Returns an NULL-terminated argv array. Sets (setArgc) to the number of
18// valid arguments in the array. It becomes the responsibility of the calling
19// code to delete[] the array and each string in it. If (padFront > 0), then
20// (padFront) extra "slots" will be allocated at the beginning of the returned
21// argv array. These slots will be NULL, and will be counted in the (setArgc)
22// result. It is the caller's responsibility to fill them...
23char** ParseArgvFromString(const char* string, int32& setArgc);
24
25// Call this to free the argv array returned by ParseArgvFromString().
26char** CloneArgv(char** argv);
27
28// Call this to free the argv array returned by ParseArgvFromString().
29void FreeArgv(char** argv);
30
31// Returns the first argument in the string.
32BString ParseArgvZeroFromString(const char* string);
33
34// Calls EscapeChars() on (string) for the following characters: backslash,
35// single quote, double quote, space, and tab. The returns string should be
36// parsable as a single word by the functions above.
37bool DoStandardEscapes(BString& string);
38
39// Modifies (string) by inserting slashes in front of each instance of badChar.
40// Returns false iff no modifications were done.
41bool EscapeChars(BString& string, char badChar);
42
43// Launch an app, Tracker style. Put here so that it can be shared amongst
44// my various apps...
45status_t LaunchCommand(char** argv, int32 argc);
46
47
48#endif	// _PARSE_COMMAND_STRING_H
49