/drivers/net/wireless/tiwlan1251/CUDK/CLI/console.h

http://github.com/CyanogenMod/cm-kernel · C Header · 214 lines · 129 code · 36 blank · 49 comment · 1 complexity · cb922e635672a9e1282674cd7949f519 MD5 · raw file

  1. /*******************************************************************************
  2. **+--------------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
  5. **| |**
  6. **| Licensed under the Apache License, Version 2.0 (the "License"); |**
  7. **| you may not use this file except in compliance with the License. |**
  8. **| You may obtain a copy of the License at |**
  9. **| |**
  10. **| http://www.apache.org/licenses/LICENSE-2.0 |**
  11. **| |**
  12. **| Unless required by applicable law or agreed to in writing, software |**
  13. **| distributed under the License is distributed on an "AS IS" BASIS, |**
  14. **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
  15. **| See the License for the specific language governing permissions and |**
  16. **| limitations under the License. |**
  17. **| |**
  18. **+--------------------------------------------------------------------------+**
  19. *******************************************************************************/
  20. #ifndef tiwlan_console_h
  21. #define tiwlan_console_h
  22. #include <stdio.h>
  23. #include <assert.h>
  24. /*
  25. * --------------------- *
  26. * error codes
  27. * --------------------- *
  28. */
  29. typedef enum
  30. {
  31. E_OK = 0
  32. , E_BADPARM
  33. , E_TOOMANY
  34. , E_NOMEMORY
  35. , E_NOT_FOUND
  36. , E_EXISTS
  37. , E_DUMMY
  38. } consoleErr_t;
  39. typedef consoleErr_t consoleErr;
  40. typedef void * handle_t;
  41. typedef unsigned char U8;
  42. typedef signed char S8;
  43. typedef unsigned short U16;
  44. typedef signed short S16;
  45. typedef unsigned long U32;
  46. typedef signed long S32;
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif /* __cplusplus */
  50. /* Monitor parameter flags */
  51. #define CON_PARM_OPTIONAL 0x01 /* Parameter is optional */
  52. #define CON_PARM_DEFVAL 0x02 /* Default value is set */
  53. #define CON_PARM_RANGE 0x04 /* Range is set */
  54. #define CON_PARM_STRING 0x08 /* String parm */
  55. #define CON_PARM_LINE 0x10 /* String from the current parser position till EOL */
  56. #define CON_PARM_SIGN 0x20 /* Signed param */
  57. #define CON_PARM_NOVAL 0x80 /* Internal flag: parameter is anassigned */
  58. /* Function parameter structure */
  59. typedef struct ConParm_t
  60. {
  61. const char *name; /* Parameter name. Shouldn't be allocated on stack! */
  62. U8 flags; /* Combination of CON_PARM_??? flags */
  63. U32 low_val; /* Low val for range checking */
  64. U32 hi_val; /* Hi val for range checking/max length of string */
  65. U32 value; /* Value/address of string parameter */
  66. } ConParm_t;
  67. #define CON_LAST_PARM { NULL, 0, 0, 0, 0 }
  68. /* Monitor command handler prototype */
  69. typedef void (*FuncToken_t)(ConParm_t parm[], U16 nParms);
  70. /* Add subdirectory to the p_root directory
  71. Returns the new directory handle
  72. */
  73. handle_t consoleAddDirExt(
  74. handle_t hRoot, /* Upper directory handle. NULL=root */
  75. const char *name, /* New directory name */
  76. const char *desc ); /* Optional directory description */
  77. /* Add token */
  78. consoleErr consoleAddToken( handle_t hDir, /* Directory handle. NULL=root */
  79. const char *name, /* Token name. Shouldn't be allocated on stack! */
  80. const char *help, /* Token help. Shouldn't be allocated on stack! */
  81. FuncToken_t p_func, /* Token handler */
  82. ConParm_t p_parms[]);/* Array of token parameters. */
  83. /* The last array element has parameter */
  84. /* name = NULL */
  85. /* Monitor driver.
  86. Calls XX_Gets in infinite loop to get input string.
  87. Gives the string to console_ParseString for processing.
  88. Monitor token handler can call consoleStop() to exit the
  89. consoleStart.
  90. */
  91. void consoleStart( void );
  92. /* Parse the given input string and exit.
  93. All commands in the input string are executed one by one.
  94. */
  95. void console_ParseString( char *input_string );
  96. /* Stop monitor driver */
  97. void consoleStop( void );
  98. /* Execute commands from 'script_file' */
  99. int consoleRunScript( char *script_file );
  100. #ifdef _WINDOWS
  101. #endif
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. /* ----------------------------------------------------- */
  106. #define ALIAS_LEN 1
  107. #define MAX_NAME_LEN 80
  108. #define MAX_HELP_LEN 80
  109. #define MAX_PARM_LEN 20
  110. #define MAX_NUM_OF_PARMS 30
  111. #define TOKEN_UP ".."
  112. #define TOKEN_ROOT "/"
  113. #define TOKEN_BREAK "#"
  114. #define TOKEN_HELP "?"
  115. #define TOKEN_DIRHELP "help"
  116. #ifndef FALSE
  117. #define FALSE 0
  118. #endif
  119. #ifndef TRUE
  120. #define TRUE 1
  121. #endif
  122. #ifndef __LINUX__ // TRS:WDK
  123. #define perror(str) printf("\nError at %s:%d - %s.\n", __FILE__, __LINE__, (str))
  124. #endif /* __LINUX__ */
  125. //TRS end
  126. #ifdef __cplusplus
  127. extern "C" {
  128. #endif /* __cplusplus */
  129. #ifndef _WINDOWS /* TRS:WDK __LINUX__ */
  130. #ifdef ERRCHK
  131. # define ASSERT(p) assert(p)
  132. #else
  133. # define ASSERT(p) do {} while (0)
  134. #endif
  135. #endif /* TRS:WDK __LINUX__ */
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. typedef enum { Dir, Token } ConEntry_type_t;
  140. /* Parameter name and format */
  141. typedef char (ParmName_t)[MAX_NAME_LEN+1];
  142. /* Monitor token structure */
  143. typedef struct ConEntry_t
  144. {
  145. struct ConEntry_t *next;
  146. char name[MAX_NAME_LEN+1]; /* Entry name */
  147. char help[MAX_HELP_LEN+1]; /* Help string */
  148. char *alias; /* Alias - always in upper case*/
  149. ConEntry_type_t sel; /* Entry selector */
  150. union {
  151. struct
  152. {
  153. struct ConEntry_t *upper; /* Upper directory */
  154. struct ConEntry_t *first; /* First entry */
  155. } dir;
  156. struct t_Token
  157. {
  158. FuncToken_t f_tokenFunc; /* Token handler */
  159. ConParm_t parm[MAX_NUM_OF_PARMS]; /* Parameters array */
  160. ParmName_t name[MAX_NUM_OF_PARMS]; /* Parameter name */
  161. } token;
  162. } u;
  163. } ConEntry_t;
  164. /* Token types */
  165. typedef enum
  166. {
  167. EmptyToken,
  168. UpToken,
  169. RootToken,
  170. BreakToken,
  171. HelpToken,
  172. DirHelpToken,
  173. NameToken
  174. } t_TokenType;
  175. char * console_strlwr( char *s );
  176. int console_stricmp( char *s1, char *s2, U16 len );
  177. char * console_ltrim( char *s );
  178. #endif /* #ifndef tiwlan_console_h */