CVS: libraries/include commandline.h,1.3,1.4
Chris Liechti <[email protected]> Wed, 11 Oct 2006 11:47:30 -0700
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mspgcc/libraries/include
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12454/libraries/include
Modified Files:
commandline.h
Log Message:
- commandline_usage helper function
- support for separator entries in command list
- switch to case insensitive string compares
Index: commandline.h
===================================================================
RCS file: /cvsroot/mspgcc/libraries/include/commandline.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- commandline.h 4 Apr 2006 23:20:56 -0000 1.3
+++ commandline.h 11 Oct 2006 18:47:28 -0000 1.4
@@ -2,11 +2,20 @@
#define MSPGCC_COMMANDLINE_H
#include <mspgcc/util.h>
+#include <stdbool.h>
+
+/**
+ * Use the following macro to create separator entries command table.
+ *
+ * @param text text that is displayed for the separator
+ */
+#define COMMANDLINE_SEP(text) {"", command_help, text} //table entry generation
/**
* Use the following macro to create entries in the command table.
* the command function is prefixed with "command_".
* The help text should be short (<60 characters).
+ *
* @param name name of the command and it's function
* @param hlp short help string
*/
@@ -27,6 +36,11 @@
#define COMMANDLINE_SUCCESS 0
/**
+ * Return value for commands: parameter(s) invalid of wrong type or unexpected.
+ */
+#define COMMANDLINE_ERROR_PARAMETER 1
+
+/**
* Special return value of commandline_eval. Returned if the command is not
* found in the provided table.
*/
@@ -47,7 +61,7 @@
* striped away/ignored.
*
* Example:
- *
+ * @code
* static int command_hello(int argc, char *argv[]) {
* printf("hello world!\n");
* }
@@ -71,20 +85,35 @@
* printf("-- retval: %d\n", retval);
* } //no output for successful commands
* }
+ * @endcode
*
- * NOTE: The number of parameter that are processed is limited, defined by
+ * @note The number of parameter that are processed is limited, defined by
* the implementation.
*
* @param commandline [in/out] the command line string.
* Some whitespace characters are overwritten!
* @param command_table [in] table containing the supported commands.
* @return the return value of the called function, 0 on success. or
- * COMMANDLINE_NO_SUCH_COMMNAD if the command was not found
+ * ::COMMANDLINE_NO_SUCH_COMMNAD if the command was not found
* in the table.
*/
int commandline_eval(char *commandline, const COMMANDLINE_TABLE *command_table);
/**
+ * Print the full help sting corresponding to the given command. Typically used
+ * for usage info if a command is called the wrong way. For example:
+ * @code
+ * if (argc < 2) {
+ * commandline_usage(argv[0]);
+ * }
+ * @endcode
+ *
+ * @param s [in] the string that is converted
+ * @return true if the command was found and the help printed, false otherwise
+ */
+bool commandline_usage(const char *s);
+
+/**
* Parse string and try to convert it to a number. hex, dec and octal is
* suported.
*
@@ -93,6 +122,7 @@
* typecasting of the result uses some code.
*
* @param s [in] the string that is converted
+ * @return the converted number. 0 if the number could not be decoded.
*/
unsigned int commandline_number(const char *s);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642