comparison g23m/condat/ms/src/atb/ATBPb.h @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 #ifndef ATBPB_H
2 #define ATBPB_H
3
4 #define BLOCKING
5
6 #define trace(x) TRACE_EVENT(x)
7 #define tracefunction(x) TRACE_FUNCTION(x)
8 #define trace_P1(x,a) TRACE_EVENT_P1(x,a)
9 #define trace_P2(x,a,b) TRACE_EVENT_P2(x,a,b)
10 #define trace_P3(x,a,b,c) TRACE_EVENT_P3(x,a,b,c)
11 #define trace_P4(x,a,b,c,d) TRACE_EVENT_P4(x,a,b,c,d)
12 #define trace_P5(x,a,b,c,d,e) TRACE_EVENT_P5(x,a,b,c,d,e)
13 #define trace_P6(x,a,b,c,d,e,f) TRACE_EVENT_P6(x,a,b,c,d,e,f)
14
15 /**********************************************
16 * STANDARD DEFINITIONS
17 *
18 **********************************************/
19
20 #define UBYTE unsigned char
21 #define USHORT unsigned short
22 #define ULONG unsigned long
23
24 #define TRUE 1
25 #define FALSE 0
26
27 /**********************************************
28 * CONSTANTS
29 *
30 **********************************************/
31
32 #define PB_BOOK_DEFAULT 0 /* Default phonebook id */
33 #define PB_PHONEBOOKS_MAX 1 /* Maximum number of concurrent phonebooks possible */
34 #define PB_RECORDS_MAX 50 /* Max number of records per phonebook */
35 #define PB_CACHE_MAX 5 /* Maximum records stored in the RAM cache */
36 #define PB_ALPHATAG_MAX 20 /* Maximum length of alpha tag in characters */
37 #define PB_NUMBER_MAX 41 /* Maximum length of BCD number in digits*/
38 #define PB_EXT_MAX 0 /* Maximum length of extended data in bytes */
39 #define PB_NEW_RECORD -1 /* Indicate that a new record is to be created. */
40 #define PB_EMPTY_RECORD -1 /* Indicates that the physical record is empty */
41
42
43 /**********************************************
44 * PB_RET
45 *
46 * Standard return type from functions
47 *
48 **********************************************/
49
50 typedef enum
51 {
52 PB_OK,
53 PB_EXCT,
54 PB_ERROR, /* Generic error */
55
56 PB_BUSY, /* Phonebook is busy */
57 PB_FILEREADFAIL, /* File read encountered an error */
58 PB_FILEWRITEFAIL, /* File write encountered an error */
59 PB_BOOKDOESNOTEXIST, /* Tried to access a phonebook that does not exist */
60 PB_BOOKALREADYEXISTS, /* Tried to create a phonebook that exists already */
61 PB_BOOKFULL, /* Tried to add a record to a full phonebook */
62 PB_RECDOESNOTEXIST, /* Tried to access a record that does not exist */
63 PB_INDEXINVALID /* Index type is not valid for this operation */
64 } PB_RET;
65
66
67 /**********************************************
68 * T_PB_TYPE
69 *
70 * Type of phonebook (storage type)
71 *
72 **********************************************/
73
74 typedef enum
75 {
76 PB_TYPE_FFS = 0,
77 PB_TYPE_SIM = 1
78 } T_PB_TYPE;
79
80
81 /**************************************************
82 * T_PB_INFO
83 *
84 * Data structure to contain phonebook information.
85 *
86 **************************************************/
87
88 typedef struct
89 {
90 SHORT records_max; /* Total number of records available */
91 SHORT records_used; /* Number of records that are in use */
92 SHORT records_free; /* Number of free records */
93 SHORT search_results; /* Number of search results in search table */
94 }
95 T_PB_INFO;
96
97
98 /**************************************************
99 * T_PB_ALPHA
100 *
101 * Phonebook string type
102 *
103 **************************************************/
104
105 typedef struct
106 {
107 UBYTE dcs; /* Data coding scheme */
108 USHORT length; /* Length of the alpha tag */
109 USHORT *data; /* Alpha tag data */
110 }
111 T_PB_ALPHA;
112
113
114 /**************************************************
115 * T_PB_RECORD
116 *
117 * Phonebook record
118 *
119 **************************************************/
120
121 typedef struct
122 {
123 T_PB_ALPHA alpha; /* Alpha tag */
124 UBYTE *number; /* Number - BCD format */
125 UBYTE ton_npi;
126 void *ext_data; /* Extended data */
127 } T_PB_RECORD;
128
129
130 /**************************************************
131 * T_PB_LIST
132 *
133 * List of records
134 *
135 **************************************************/
136
137 typedef struct
138 {
139 SHORT records_max; /* Maximum number of items in list */
140 SHORT records_used; /* Occupied items in list */
141 T_PB_RECORD *record; /* Array of records */
142 }
143 T_PB_LIST;
144
145
146
147 /**********************************************
148 * T_PB_INDEX
149 *
150 * Type of index list
151 *
152 **********************************************/
153
154 typedef enum
155 {
156 INDEX_PHYSICAL = 0, /* Direct mapping logical-physical */
157 INDEX_NAME = 1, /*Index list sorted by the name field*/
158 INDEX_NUMBER = 2, /*Index list sorted by the number field*/
159 INDEX_SEARCH = 3, /* Index list created by search */
160 INDEX_DEFAULT_MAX /*Anything above this is a user-specific index */
161 } T_PB_INDEX;
162
163
164 /**********************************************
165 * T_PB_MATCH
166 *
167 * Result of matching operation
168 *
169 **********************************************/
170
171 typedef enum
172 {
173 MATCH_DEFAULT, /* No match made - use the default matching method */
174 MATCH_EXACT, /* The string matches a record exactly */
175 MATCH_START, /* The string is found at the start of a record */
176 MATCH_FRAGMENT, /* The string is found within a record */
177 MATCH_NONE /* The string does not match any record */
178 }
179 T_PB_MATCH;
180
181
182 /**********************************************
183 * T_PB_COMPARE
184 *
185 * Result of comparison operation
186 *
187 **********************************************/
188
189 typedef enum
190 {
191 COMPARE_DEFAULT, /* No comparison made - use the default comparison method*/
192 COMPARE_IDENTICAL, /* The two records are identical */
193 COMPARE_FIRSTBEFORE, /* The first record should come before the second record*/
194 COMPARE_FIRSTAFTER /* The first record should come after the second record*/
195 }
196 T_PB_COMPARE;
197
198
199 /**********************************************
200 * ATB PB FUNCTION PROTOTYPES
201 *
202 **********************************************/
203
204 PB_RET ATB_pb_GetPhonebook(SHORT phonebook_id, T_PB_TYPE *current_type);
205 PB_RET ATB_pb_Initialise(SHORT phonebook_id, T_PB_TYPE type, SHORT records_max, SHORT cache_max,
206 SHORT alpha_max, SHORT number_max, SHORT ext_max);
207 PB_RET ATB_pb_Exit(SHORT phonebook_id);
208 PB_RET ATB_pb_Status(SHORT phonebook_id);
209 PB_RET ATB_pb_Info(SHORT phonebook_id, T_PB_INFO *phonebook_info);
210 PB_RET ATB_pb_ReadRec(SHORT phonebook_id, T_PB_INDEX index_type, SHORT log_index, T_PB_RECORD *record);
211 PB_RET ATB_pb_WriteRec(SHORT phonebook_id, T_PB_TYPE index_type, SHORT log_index, T_PB_RECORD *record);
212 PB_RET ATB_pb_DeleteRec(SHORT phonebook_id, T_PB_TYPE index_type, SHORT log_index);
213 PB_RET ATB_pb_Find (SHORT phonebook_id, T_PB_INDEX index_type, T_PB_RECORD *record, SHORT *new_log_index, T_PB_MATCH *match);
214 PB_RET ATB_pb_ReadRecList(SHORT phonebook_id, T_PB_INDEX index_type, SHORT start_log_index, SHORT num_recs, T_PB_LIST *list);
215 PB_RET ATB_pb_Search(SHORT phonebook_id, T_PB_INDEX index_type, T_PB_RECORD *record, SHORT *recs_count);
216 PB_RET ATB_pb_ConvIndex(SHORT phonebook_id, T_PB_INDEX src_index_type, SHORT log_index,
217 T_PB_INDEX dest_index_type, SHORT *new_log_index);
218 PB_RET ATB_pb_OK(SHORT phonebook_id);
219 void ATB_pb_Error(SHORT phonebook_id, SHORT error_id);
220 T_PB_RECORD *ATB_pb_AllocRec(SHORT phonebook_id);
221 void ATB_pb_FreeRec(SHORT phonebook_id, T_PB_RECORD *record);
222 T_PB_LIST *ATB_pb_AllocRecList(SHORT phonebook_id, SHORT num_recs);
223 void ATB_pb_FreeRecList(SHORT phonebook_id, T_PB_LIST *list);
224 void ATB_pb_CopyRec(SHORT phonebook_id, T_PB_RECORD *dest_record, T_PB_RECORD *src_record);
225 void ATB_pb_CharToBCD(UBYTE *dest, char *src, int max_len);
226 void ATB_pb_BCDToChar(char *dest, UBYTE *src, int max_len);
227
228
229 /**********************************************
230 * GI FUNCTION PROTOTYPES
231 *
232 * Functions in GI called by ATB PB
233 *
234 **********************************************/
235
236 void GI_pb_OK(SHORT phonebook_id, SHORT command_id, void *param);
237 void GI_pb_Error(SHORT phonebook_id, SHORT command_id, SHORT error_id);
238 // Dec 22, 2004 REF: CRR MFW-SPR-27847 xnkulkar
239 // Description: MFW memory size variable changed from U16 -> U32
240 // Solution: The use of variable U16 has been replaced with U32
241 UBYTE* GI_pb_MemAlloc(U32 size);
242 void GI_pb_MemFree(UBYTE *mem, U32 size);
243 T_PB_COMPARE GI_pb_Compare (T_PB_RECORD *record1,T_PB_RECORD *record2, T_PB_INDEX index_type);
244 T_PB_MATCH GI_pb_Match(T_PB_RECORD *record1,T_PB_RECORD *record2, T_PB_INDEX index_type);
245 SHORT* GI_pb_GetTable (T_PB_INDEX index_type);
246
247
248 /**********************************************
249 * FS FUNCTION PROTOTYPES
250 *
251 * Functions in FS called by ATB PB
252 *
253 **********************************************/
254
255 PB_RET FS_pb_GetPhonebook(SHORT phonebook_id, T_PB_TYPE *current_type);
256 PB_RET FS_pb_SetPhonebook(SHORT phonebook_id, T_PB_TYPE current_type);
257 PB_RET FS_pb_Initialise(SHORT phonebook_id, T_PB_TYPE type, SHORT records_max, SHORT alpha_max, SHORT number_max, SHORT ext_max);
258 PB_RET FS_pb_ReadRec(SHORT phonebook_id, SHORT phys_index, T_PB_RECORD *record);
259 PB_RET FS_pb_WriteRec(SHORT phonebook_id, SHORT phys_index, T_PB_RECORD *record);
260 PB_RET FS_pb_DeleteRec(SHORT phonebook_id, SHORT phys_index);
261 PB_RET FS_pb_Finished(SHORT phonebook_id);
262 PB_RET FS_pb_ReadTables(SHORT phonebook_id, SHORT *records_used, SHORT *name_table, SHORT *number_table);
263 PB_RET FS_pb_WriteTables(SHORT phonebook_id, SHORT records_used, SHORT *name_table, SHORT *number_table);
264
265 #endif