19
|
1 |
/*
|
25
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Framework Manager. Parses the CFG file
|
|
15 |
*
|
|
16 |
*/
|
19
|
17 |
|
|
18 |
#include <stdio.h>
|
|
19 |
#include <string.h>
|
25
|
20 |
#include "xaframeworkmgr.h"
|
19
|
21 |
|
|
22 |
/* Default line width permitted in the cfg file + 2 to hold "\r\n"*/
|
|
23 |
#define LINEWIDTH 82
|
|
24 |
|
|
25 |
typedef enum
|
25
|
26 |
{
|
19
|
27 |
FWMgrTagNone,
|
|
28 |
FWMgrTagURIScheme,
|
|
29 |
FWMgrTagFileExt
|
25
|
30 |
} FWMgrTagType;
|
19
|
31 |
|
|
32 |
/* Config file location */
|
21
|
33 |
const char configFileLocationZ[] = "z:/openmaxal/openmaxal.cfg";
|
|
34 |
const char configFileLocationC[] = "c:/openmaxal/openmaxal.cfg";
|
19
|
35 |
|
|
36 |
/* Tags used for parsing */
|
|
37 |
const char mediaPlayerBeginTag[] = "<mediaplayer>";
|
|
38 |
const char mediaPlayerEndTag[] = "</mediaplayer>";
|
|
39 |
const char mediaRecorderBeginTag[] = "<mediarecorder>";
|
|
40 |
const char mediaRecorderEndTag[] = "</mediarecorder>";
|
|
41 |
const char mediaFrameworkMmfBeginTag[] = "<mmf>";
|
|
42 |
const char mediaFrameworkMmfEndTag[] = "</mmf>";
|
|
43 |
const char mediaFrameworkGstBeginTag[] = "<gst>";
|
|
44 |
const char uriSchemeBeginTag[] = "<urischeme>";
|
|
45 |
const char uriSchemeEndTag[] = "</urischeme>";
|
|
46 |
const char mediaFrameworkGstEndTag[] = "</gst>";
|
|
47 |
const char fileExtBeginTag[] = "<fileext>";
|
|
48 |
const char fileExtEndTag[] = "</fileext>";
|
|
49 |
|
|
50 |
/* Local function definitions */
|
|
51 |
/* returns FWMgrTrue if processed successfully */
|
25
|
52 |
static FWMgrBool processConfigEntry(const char* buffer,
|
|
53 |
FWMgrMOType *mediaType, FWMgrFwType *frameworkType,
|
|
54 |
FWMgrTagType *tagType, FWMgrBool *newNode, FrameworkMap **node);
|
|
55 |
|
|
56 |
/* returns FWMgrTrue if processed successfully */
|
|
57 |
static FWMgrBool processTagType(const char* buffer,
|
|
58 |
FWMgrFwType *frameworkType, FWMgrTagType *tagType,
|
19
|
59 |
FrameworkMap **node);
|
|
60 |
|
|
61 |
/* returns FWMgrTrue if processed successfully */
|
25
|
62 |
static FWMgrBool tokenizeTag(FWMgrTagType tagType, const char* buffer,
|
19
|
63 |
FrameworkMap **node);
|
|
64 |
|
|
65 |
/* Global functions from header file */
|
|
66 |
|
|
67 |
/* FrameworkMap* XAFrameworkMgr_CreateFrameworkMap
|
|
68 |
* Description: Creates a list of framework and use-case map.
|
|
69 |
*/
|
|
70 |
FrameworkMap* XAFrameworkMgr_CreateFrameworkMap()
|
25
|
71 |
{
|
19
|
72 |
char buffer[LINEWIDTH];
|
|
73 |
int readSize;
|
|
74 |
int lineNumber = 0;
|
|
75 |
FWMgrBool processedEntry = FWMgrTrue;
|
|
76 |
FWMgrMOType currentMediaType = FWMgrMOUnknown;
|
|
77 |
FWMgrFwType currentFrameworkType = FWMgrFWUknown;
|
|
78 |
FWMgrTagType currentTagType = FWMgrTagNone;
|
|
79 |
FrameworkMap *curNode = NULL;
|
|
80 |
FWMgrBool newNode;
|
|
81 |
FrameworkMap *frameworkMap = NULL;
|
25
|
82 |
|
36
|
83 |
FILE* fp = fopen(configFileLocationC, "r");
|
19
|
84 |
if (fp == NULL)
|
|
85 |
{
|
36
|
86 |
fp = fopen(configFileLocationZ, "r");
|
19
|
87 |
}
|
|
88 |
|
|
89 |
if (fp != NULL)
|
|
90 |
{
|
25
|
91 |
while ((fgets(buffer, LINEWIDTH, fp) != NULL) && processedEntry)
|
|
92 |
{
|
19
|
93 |
/* keep looping until NULL pointer OR error... */
|
|
94 |
lineNumber++;
|
|
95 |
readSize = strlen(buffer);
|
|
96 |
/* Ignore comments line */
|
|
97 |
if (buffer[0] == '#')
|
|
98 |
continue;
|
|
99 |
|
|
100 |
/* Ignore replace "\r\n" with '\0' */
|
25
|
101 |
if ((readSize >= 2) && (buffer[readSize - 2] == '\r')
|
|
102 |
&& (buffer[readSize - 1] == '\n'))
|
|
103 |
buffer[readSize - 2] = '\0';
|
19
|
104 |
|
|
105 |
/* Ignore new line... */
|
|
106 |
if (readSize == 2)
|
|
107 |
continue;
|
|
108 |
|
25
|
109 |
processedEntry = processConfigEntry(buffer, ¤tMediaType,
|
|
110 |
¤tFrameworkType, ¤tTagType, &newNode,
|
|
111 |
&curNode);
|
19
|
112 |
if (newNode)
|
25
|
113 |
{
|
19
|
114 |
/*Just link to the last element in the chain*/
|
|
115 |
if (!frameworkMap)
|
25
|
116 |
{
|
19
|
117 |
frameworkMap = curNode;
|
25
|
118 |
}
|
19
|
119 |
else
|
25
|
120 |
{
|
19
|
121 |
FrameworkMap *lastNode = frameworkMap;
|
|
122 |
while (lastNode->next)
|
25
|
123 |
{
|
19
|
124 |
lastNode = lastNode->next;
|
25
|
125 |
}
|
|
126 |
lastNode->next = curNode;
|
19
|
127 |
}
|
|
128 |
}
|
|
129 |
}
|
25
|
130 |
fclose(fp);
|
19
|
131 |
}
|
|
132 |
else
|
25
|
133 |
{
|
19
|
134 |
printf("unable to open config file!\n");
|
25
|
135 |
}
|
|
136 |
return frameworkMap;
|
19
|
137 |
}
|
|
138 |
|
|
139 |
#ifdef _DEBUG
|
|
140 |
/* void XAFrameworkMgr_DumpFrameworkMap
|
|
141 |
* Description: Prints map to std console.
|
|
142 |
*/
|
|
143 |
void XAFrameworkMgr_DumpFrameworkMap(FrameworkMap *map)
|
25
|
144 |
{
|
19
|
145 |
FrameworkMap *node = map;
|
|
146 |
int i;
|
|
147 |
int loopIndex = 0;
|
|
148 |
while (node)
|
25
|
149 |
{
|
19
|
150 |
loopIndex++;
|
|
151 |
printf("%d>", loopIndex);
|
|
152 |
if (node->moType == FWMgrMOPlayer)
|
|
153 |
printf("MediaPlayer-");
|
|
154 |
else if (node->moType == FWMgrMORecorder)
|
|
155 |
printf("MediaRecrdr-");
|
|
156 |
else
|
|
157 |
printf("UKNOWN-");
|
|
158 |
if (node->fwType == FWMgrFWMMF)
|
|
159 |
printf("MMF-");
|
|
160 |
else if (node->fwType == FWMgrFWGST)
|
|
161 |
printf("GST-");
|
|
162 |
else
|
|
163 |
printf("UKNOWN-");
|
|
164 |
printf("Scheme[");
|
25
|
165 |
for (i = 0; i < node->uriSchemeCount; i++)
|
19
|
166 |
printf(" %s", node->uriSchemes[i]);
|
|
167 |
printf("]FileExt[");
|
25
|
168 |
for (i = 0; i < node->fileExtCount; i++)
|
19
|
169 |
printf(" %s", node->fileExts[i]);
|
|
170 |
printf("]\n");
|
|
171 |
node = node->next;
|
25
|
172 |
}
|
19
|
173 |
}
|
|
174 |
#endif
|
|
175 |
|
|
176 |
/* void XAFrameworkMgr_DeleteFrameworkMap
|
|
177 |
* Description: Deletes the list of framework and use-case map.
|
|
178 |
*/
|
|
179 |
void XAFrameworkMgr_DeleteFrameworkMap(FrameworkMap **map)
|
25
|
180 |
{
|
19
|
181 |
FrameworkMap *node = *map;
|
|
182 |
FrameworkMap *nextNode = NULL;
|
|
183 |
int i;
|
|
184 |
while (node)
|
25
|
185 |
{
|
|
186 |
for (i = 0; i < node->uriSchemeCount; i++)
|
|
187 |
free(node->uriSchemes[i]);
|
|
188 |
free(node->uriSchemes);
|
19
|
189 |
|
25
|
190 |
for (i = 0; i < node->fileExtCount; i++)
|
|
191 |
free(node->fileExts[i]);
|
|
192 |
free(node->fileExts);
|
19
|
193 |
|
|
194 |
nextNode = node->next;
|
25
|
195 |
free(node);
|
19
|
196 |
node = nextNode;
|
25
|
197 |
}
|
|
198 |
*map = NULL;
|
19
|
199 |
}
|
|
200 |
|
|
201 |
/* FWMgrFwType XAFrameworkMgr_GetFramework
|
|
202 |
* Description: Returns the framework enum that handles uri.
|
|
203 |
*/
|
25
|
204 |
FWMgrFwType XAFrameworkMgr_GetFramework(FrameworkMap *map, const char *uri,
|
|
205 |
FWMgrMOType mediaObject)
|
|
206 |
{
|
19
|
207 |
FWMgrFwType retVal = FWMgrFWUknown;
|
|
208 |
char fileScheme[] = "file";
|
|
209 |
char *uriScheme = NULL;
|
|
210 |
char *fileExt = NULL;
|
|
211 |
FrameworkMap *node = map;
|
|
212 |
FWMgrBool uriMatchFound = FWMgrFalse;
|
|
213 |
FWMgrBool fileExtMatchFound = FWMgrFalse;
|
|
214 |
int i = 0;
|
|
215 |
int copyLen = 0;
|
|
216 |
|
|
217 |
if (!map || !uri)
|
25
|
218 |
{
|
19
|
219 |
/* TODO Log invalid uri */
|
|
220 |
return retVal;
|
25
|
221 |
}
|
19
|
222 |
|
|
223 |
/* Get uri scheme */
|
|
224 |
uriScheme = strchr(uri, ':');
|
25
|
225 |
if (uriScheme == NULL)
|
|
226 |
{
|
19
|
227 |
/* TODO Log invalid uri */
|
|
228 |
return retVal;
|
25
|
229 |
}
|
19
|
230 |
|
|
231 |
copyLen = (uriScheme - uri);
|
25
|
232 |
uriScheme = (char*) calloc(copyLen + 1, sizeof(char));
|
19
|
233 |
strncpy(uriScheme, uri, copyLen);
|
|
234 |
uriScheme[copyLen] = '\0'; /*Null terminate it*/
|
|
235 |
|
|
236 |
if (strcasecmp(uriScheme, fileScheme) == 0)
|
25
|
237 |
{
|
19
|
238 |
/* Get uri extension */
|
|
239 |
char* dotLoc = strrchr(uri, '.');
|
25
|
240 |
if (dotLoc == NULL)
|
|
241 |
{
|
19
|
242 |
/* TODO Log invalid uri */
|
|
243 |
free(uriScheme);
|
|
244 |
return retVal;
|
25
|
245 |
}
|
19
|
246 |
/* We need to add 1 to exclude '.'*/
|
|
247 |
copyLen = strlen(uri) - (dotLoc + 1 - uri);
|
25
|
248 |
fileExt = (char*) calloc(copyLen + 1, sizeof(char));
|
19
|
249 |
strncpy(fileExt, dotLoc + 1, copyLen);
|
|
250 |
fileExt[copyLen] = '\0'; /*Null terminate it*/
|
25
|
251 |
}
|
19
|
252 |
|
|
253 |
while (node)
|
25
|
254 |
{
|
19
|
255 |
if (mediaObject == node->moType)
|
|
256 |
{
|
|
257 |
uriMatchFound = FWMgrFalse;
|
|
258 |
fileExtMatchFound = FWMgrFalse;
|
|
259 |
/* Match for uri*/
|
25
|
260 |
for (i = 0; i < node->uriSchemeCount; i++)
|
|
261 |
{
|
19
|
262 |
if (strcasecmp(uriScheme, node->uriSchemes[i]) == 0)
|
|
263 |
{
|
25
|
264 |
uriMatchFound = FWMgrTrue;
|
|
265 |
break;
|
19
|
266 |
}
|
25
|
267 |
}
|
19
|
268 |
/* if uri scheme is not file, we only need to check for uri */
|
|
269 |
if (!fileExt)
|
25
|
270 |
{
|
19
|
271 |
fileExtMatchFound = FWMgrTrue;
|
25
|
272 |
}
|
19
|
273 |
else
|
|
274 |
{
|
25
|
275 |
for (i = 0; i < node->fileExtCount; i++)
|
|
276 |
{
|
19
|
277 |
if (strcasecmp(fileExt, node->fileExts[i]) == 0)
|
25
|
278 |
{
|
19
|
279 |
fileExtMatchFound = FWMgrTrue;
|
|
280 |
break;
|
25
|
281 |
}
|
19
|
282 |
}
|
|
283 |
}
|
|
284 |
|
25
|
285 |
if ((uriMatchFound == FWMgrTrue) && (fileExtMatchFound
|
|
286 |
== FWMgrTrue))
|
19
|
287 |
{
|
25
|
288 |
retVal = node->fwType;
|
|
289 |
break;
|
19
|
290 |
}
|
|
291 |
}
|
|
292 |
node = node->next;
|
25
|
293 |
}
|
19
|
294 |
free(uriScheme);
|
|
295 |
free(fileExt);
|
|
296 |
return retVal;
|
25
|
297 |
}
|
19
|
298 |
|
|
299 |
/* Local functions */
|
|
300 |
|
|
301 |
/* FWMgrBool processConfigEntry
|
|
302 |
* Description: Processes a single line entry from the config file.
|
|
303 |
*/
|
25
|
304 |
FWMgrBool processConfigEntry(const char* buffer, FWMgrMOType *mediaType,
|
|
305 |
FWMgrFwType *frameworkType, FWMgrTagType *tagType,
|
|
306 |
FWMgrBool *newNode, FrameworkMap **node)
|
|
307 |
{
|
19
|
308 |
FWMgrBool processedSuccessfully = FWMgrTrue;
|
25
|
309 |
|
|
310 |
if (!buffer || !mediaType || !frameworkType || !tagType || !newNode)
|
|
311 |
{
|
|
312 |
processedSuccessfully = FWMgrFalse;
|
|
313 |
return processedSuccessfully;
|
|
314 |
}
|
|
315 |
|
|
316 |
*newNode = FWMgrFalse;
|
19
|
317 |
switch (*mediaType)
|
25
|
318 |
{
|
19
|
319 |
case FWMgrMOUnknown:
|
25
|
320 |
{
|
19
|
321 |
if (strcmp(buffer, mediaPlayerBeginTag) == 0)
|
25
|
322 |
{
|
19
|
323 |
*mediaType = FWMgrMOPlayer;
|
|
324 |
*frameworkType = FWMgrFWUknown;
|
|
325 |
*tagType = FWMgrTagNone;
|
|
326 |
*node = NULL;
|
25
|
327 |
}
|
19
|
328 |
else if (strcmp(buffer, mediaRecorderBeginTag) == 0)
|
25
|
329 |
{
|
19
|
330 |
*mediaType = FWMgrMORecorder;
|
|
331 |
*frameworkType = FWMgrFWUknown;
|
|
332 |
*tagType = FWMgrTagNone;
|
|
333 |
*node = NULL;
|
25
|
334 |
}
|
19
|
335 |
}
|
|
336 |
break;
|
|
337 |
case FWMgrMOPlayer:
|
|
338 |
case FWMgrMORecorder:
|
25
|
339 |
{
|
19
|
340 |
switch (*frameworkType)
|
|
341 |
{
|
25
|
342 |
case FWMgrFWUknown:
|
|
343 |
{
|
|
344 |
if ((*mediaType == FWMgrMOPlayer) && (strcmp(buffer,
|
|
345 |
mediaPlayerEndTag) == 0))
|
19
|
346 |
*mediaType = FWMgrMOUnknown;
|
25
|
347 |
else if ((*mediaType == FWMgrMORecorder) && (strcmp(
|
|
348 |
buffer, mediaRecorderEndTag) == 0))
|
|
349 |
*mediaType = FWMgrMOUnknown;
|
|
350 |
else if ((strcmp(buffer, mediaFrameworkMmfBeginTag) == 0)
|
|
351 |
|| (strcmp(buffer, mediaFrameworkGstBeginTag)
|
|
352 |
== 0))
|
|
353 |
{
|
|
354 |
|
19
|
355 |
*frameworkType = FWMgrFWMMF;
|
|
356 |
if (strcmp(buffer, mediaFrameworkGstBeginTag) == 0)
|
|
357 |
*frameworkType = FWMgrFWGST;
|
|
358 |
if (*node)
|
25
|
359 |
{
|
|
360 |
printf(
|
|
361 |
"Fatal error error. Entry already exists and creating another one!!!");
|
|
362 |
processedSuccessfully = FWMgrFalse;
|
|
363 |
}
|
|
364 |
else
|
|
365 |
{
|
|
366 |
*node = (FrameworkMap*) calloc(1,
|
|
367 |
sizeof(FrameworkMap));
|
|
368 |
if (!(*node))
|
|
369 |
{
|
|
370 |
printf(
|
|
371 |
"Fatal error. No memory to create an Entry!!!");
|
|
372 |
processedSuccessfully = FWMgrFalse;
|
|
373 |
}
|
|
374 |
else
|
|
375 |
{
|
|
376 |
*newNode = FWMgrTrue;
|
|
377 |
(*node)->moType = *mediaType;
|
|
378 |
(*node)->fwType = *frameworkType;
|
|
379 |
}
|
|
380 |
}
|
19
|
381 |
}
|
|
382 |
}
|
|
383 |
break;
|
|
384 |
case FWMgrFWMMF:
|
25
|
385 |
{
|
|
386 |
processedSuccessfully = processTagType(buffer,
|
|
387 |
frameworkType, tagType, node);
|
|
388 |
}
|
19
|
389 |
break;
|
|
390 |
case FWMgrFWGST:
|
25
|
391 |
{
|
|
392 |
processedSuccessfully = processTagType(buffer,
|
|
393 |
frameworkType, tagType, node);
|
|
394 |
}
|
19
|
395 |
break;
|
|
396 |
default:
|
|
397 |
processedSuccessfully = FWMgrFalse;
|
|
398 |
break;
|
25
|
399 |
};
|
|
400 |
}
|
19
|
401 |
break;
|
|
402 |
default:
|
|
403 |
processedSuccessfully = FWMgrFalse;
|
|
404 |
break;
|
25
|
405 |
};
|
19
|
406 |
return processedSuccessfully;
|
25
|
407 |
}
|
19
|
408 |
|
|
409 |
/* FWMgrBool processTagType
|
25
|
410 |
* Description: Processes a framework type, uri, file tags entry from
|
|
411 |
* the config file.
|
19
|
412 |
*/
|
25
|
413 |
FWMgrBool processTagType(const char* buffer, FWMgrFwType *frameworkType,
|
|
414 |
FWMgrTagType *tagType, FrameworkMap **node)
|
|
415 |
{
|
19
|
416 |
FWMgrBool processedSuccessfully = FWMgrTrue;
|
25
|
417 |
|
|
418 |
if (!buffer || !frameworkType || !tagType || (*node == NULL))
|
19
|
419 |
{
|
25
|
420 |
processedSuccessfully = FWMgrFalse;
|
|
421 |
return processedSuccessfully;
|
|
422 |
}
|
|
423 |
|
|
424 |
switch (*tagType)
|
|
425 |
{
|
|
426 |
case FWMgrTagNone:
|
19
|
427 |
{
|
25
|
428 |
if (((*frameworkType == FWMgrFWMMF) && (strcmp(buffer,
|
|
429 |
mediaFrameworkMmfEndTag) == 0)) || ((*frameworkType
|
|
430 |
== FWMgrFWGST)
|
|
431 |
&& (strcmp(buffer, mediaFrameworkGstEndTag) == 0)))
|
|
432 |
{
|
19
|
433 |
*node = NULL;
|
|
434 |
*frameworkType = FWMgrFWUknown;
|
25
|
435 |
}
|
19
|
436 |
else if (strcmp(buffer, uriSchemeBeginTag) == 0)
|
|
437 |
*tagType = FWMgrTagURIScheme;
|
|
438 |
else if (strcmp(buffer, fileExtBeginTag) == 0)
|
|
439 |
*tagType = FWMgrTagFileExt;
|
25
|
440 |
}
|
19
|
441 |
break;
|
|
442 |
case FWMgrTagURIScheme:
|
25
|
443 |
{
|
19
|
444 |
if (strcmp(buffer, uriSchemeEndTag) == 0)
|
|
445 |
*tagType = FWMgrTagNone;
|
|
446 |
else
|
25
|
447 |
{
|
19
|
448 |
processedSuccessfully = FWMgrFalse;
|
|
449 |
if (*node)
|
25
|
450 |
processedSuccessfully = tokenizeTag(FWMgrTagURIScheme,
|
|
451 |
buffer, node);
|
|
452 |
}
|
19
|
453 |
}
|
|
454 |
break;
|
|
455 |
case FWMgrTagFileExt:
|
25
|
456 |
{
|
19
|
457 |
if (strcmp(buffer, fileExtEndTag) == 0)
|
|
458 |
*tagType = FWMgrTagNone;
|
|
459 |
else
|
25
|
460 |
{
|
19
|
461 |
processedSuccessfully = FWMgrFalse;
|
|
462 |
if (*node)
|
25
|
463 |
processedSuccessfully = tokenizeTag(FWMgrTagFileExt,
|
|
464 |
buffer, node);
|
|
465 |
}
|
19
|
466 |
}
|
|
467 |
break;
|
|
468 |
default:
|
25
|
469 |
processedSuccessfully = FWMgrFalse;
|
19
|
470 |
break;
|
25
|
471 |
};
|
19
|
472 |
return processedSuccessfully;
|
25
|
473 |
}
|
19
|
474 |
|
|
475 |
/* FWMgrBool processTagType
|
25
|
476 |
* Description: Processes a framework type, uri, file tags entry from
|
|
477 |
* the config file.
|
19
|
478 |
*/
|
25
|
479 |
FWMgrBool tokenizeTag(FWMgrTagType tagType, const char* buffer,
|
|
480 |
FrameworkMap **node)
|
|
481 |
{
|
|
482 |
char* tempStartPtr;
|
|
483 |
char* tempEndPtr;
|
19
|
484 |
int index = 0;
|
|
485 |
int strLen = 0;
|
|
486 |
|
25
|
487 |
if (!buffer || (*node == NULL))
|
|
488 |
{
|
|
489 |
return FWMgrFalse;
|
|
490 |
}
|
|
491 |
|
|
492 |
tempStartPtr = /*const_cast<char*>*/(char*) (buffer);
|
|
493 |
tempEndPtr = /*const_cast<char*>*/(char*) (buffer);
|
|
494 |
|
19
|
495 |
if (tagType == FWMgrTagURIScheme)
|
25
|
496 |
{
|
19
|
497 |
(*node)->uriSchemeCount = atoi(buffer);
|
25
|
498 |
(*node)->uriSchemes = (char**) calloc((*node)->uriSchemeCount,
|
|
499 |
sizeof(*((*node)->uriSchemes)));
|
19
|
500 |
if (!(*node)->uriSchemes)
|
25
|
501 |
{
|
19
|
502 |
printf("Fatal error. No memory to create an Entry!!!");
|
|
503 |
return FWMgrFalse;
|
25
|
504 |
}
|
19
|
505 |
}
|
|
506 |
else if (tagType == FWMgrTagFileExt)
|
25
|
507 |
{
|
19
|
508 |
(*node)->fileExtCount = atoi(buffer);
|
25
|
509 |
(*node)->fileExts = (char**) calloc((*node)->fileExtCount,
|
|
510 |
sizeof(*((*node)->fileExts)));
|
19
|
511 |
if (!(*node)->fileExts)
|
25
|
512 |
{
|
19
|
513 |
printf("Fatal error. No memory to create an Entry!!!");
|
|
514 |
return FWMgrFalse;
|
25
|
515 |
}
|
19
|
516 |
}
|
|
517 |
else
|
|
518 |
return FWMgrFalse;
|
|
519 |
|
|
520 |
/*Find the index of :*/
|
|
521 |
tempStartPtr = strchr(tempStartPtr, ',');
|
|
522 |
index = 0;
|
|
523 |
while (tempStartPtr && (strlen(tempStartPtr) > 1))
|
25
|
524 |
{
|
19
|
525 |
tempStartPtr++; /* Ignore separator ','*/
|
|
526 |
tempEndPtr = strchr(tempStartPtr, ',');
|
|
527 |
strLen = (tempEndPtr - tempStartPtr) + 1; /* To hold null terminator */
|
|
528 |
if (strLen > 0)
|
25
|
529 |
{
|
19
|
530 |
if (tagType == FWMgrTagURIScheme)
|
25
|
531 |
{
|
|
532 |
(*node)->uriSchemes[index] = (char*) calloc(strLen,
|
|
533 |
sizeof(char));
|
19
|
534 |
strncpy((*node)->uriSchemes[index], tempStartPtr, strLen);
|
25
|
535 |
(*node)->uriSchemes[index][strLen - 1] = '\0'; /*Null terminate it*/
|
19
|
536 |
index++;
|
25
|
537 |
}
|
19
|
538 |
else if (tagType == FWMgrTagFileExt)
|
25
|
539 |
{
|
|
540 |
(*node)->fileExts[index] = (char*) calloc(strLen,
|
|
541 |
sizeof(char));
|
19
|
542 |
strncpy((*node)->fileExts[index], tempStartPtr, strLen);
|
25
|
543 |
(*node)->fileExts[index][strLen - 1] = '\0'; /*Null terminate it*/
|
19
|
544 |
index++;
|
25
|
545 |
}
|
19
|
546 |
}
|
25
|
547 |
tempStartPtr = tempEndPtr;
|
19
|
548 |
}
|
25
|
549 |
return FWMgrTrue;
|
19
|
550 |
}
|
36
|
551 |
|