comparison src/g23m-fad/app/app_util.h @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +------------------------------------------------------------------------------
3 | File: app.h
4 +------------------------------------------------------------------------------
5 | Copyright 2003 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : Definitions for the Protocol Stack Entity app.
17 +-----------------------------------------------------------------------------
18 */
19
20 #ifndef APP_UTIL_H
21 #define APP_UTIL_H
22
23
24 #define __STR2__(x) #x
25 #define __STR1__(x) __STR2__(x)
26 #define __TODO__ __FILE__ "("__STR1__(__LINE__)") : T O D O: "
27
28 /*==== INCLUDES =============================================================*/
29
30 #include "typedefs.h" /* Condat data types. */
31
32 /*==== CONSTS ===============================================================*/
33 /*==== DEFINES =========================================================*/
34
35 #define BAT_MAX_TEST_CLNT_NUM 4
36 #define BAT_MAX_TEST_INST_NUM 2
37
38 /* Result of test case */
39 #define BAT_TEST_PASS 0
40 #define BAT_TEST_FAIL 1
41
42 /* Indicate no additional values for test result */
43 #define NO_ADD_VAL 0xFFFFFFFF
44
45 /* Macros for easier coding */
46 #define BAT_TEST_PASSED() app_bat_send_result_prim(BAT_TEST_PASS, NO_ADD_VAL)
47 #define BAT_TEST_FAILED() app_bat_send_result_prim(BAT_TEST_FAIL, NO_ADD_VAL)
48
49 /*==== TYPES ================================================================*/
50
51 /* Type of command table entry. */
52 typedef struct APP_CMD_ENTRY app_cmd_entry_t ;
53
54 /* Type of some application core functions. */
55 typedef void (*core_func_t)(int , char* , char*) ;
56
57 /* Type of command handler functions. */
58 typedef char *(*cmd_handler_t)(app_cmd_entry_t *cmd_entry_ptr,
59 char *param1,
60 char *param2,
61 char *param3,
62 core_func_t core_func) ;
63
64 /* Struct for command table entry. */
65 struct APP_CMD_ENTRY {
66 char *cmd_name ; /* Command string. */
67 cmd_handler_t cmd_func ; /* Command handler function. */
68 core_func_t core_func ; /* Related core function (if applicable). */
69 char *cmd_usage ; /* Command usage string (informative only). */
70 } ;
71
72
73 /*==== FUNCTIONS ============================================================*/
74
75 /** Parse a command and execute it if it is valid. Return appropriate error
76 * message if the command is invalid or fails.
77 *
78 * @param command command line to execute
79 * @return an error message or NULL on success
80 */
81 char *app_handle_command(char *command, app_cmd_entry_t * cmd_table);
82
83 /**
84 * Convert a string into an integer.
85 * If not possibly, assume the default value.
86 */
87 int get_item(char *param, int default_item, BOOL can_null);
88
89 /**
90 * Convert a string to lower case
91 */
92 char *string_to_lower(char *s) ;
93
94 /**
95 * Send a T_APP_BAT_TEST_RSLT result primitive.
96 * Result can be either BAT_TEST_PASS or BAT_TEST_FAIL.
97 */
98 void app_bat_send_result_prim (U8 result, U32 add_info);
99
100
101 #endif /* !APP_UTIL_H */