FireBirdLib - Topfield TMS PVR TAP Programming Library
INIGetString.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_ini.h"
3#include "libFireBird.h"
4
5bool INIGetString(char *Key, char *Value, char *DefaultValue, dword MaxLength)
6{
8
9 char *i = NULL, *j = NULL;
10 char TempKey[80];
11 dword l;
12
13 if(!Key || !Value || !DefaultValue || !MaxLength)
14 {
15 TRACEEXIT();
16 return FALSE;
17 }
18
19 strncpy(TempKey, Key, sizeof(TempKey) - 2);
20 TempKey[sizeof(TempKey) - 2] = '\0';
21 strcat(TempKey, "=");
22 l = strlen(TempKey);
23
24 INIFindStartEnd(TempKey, &i, &j, l + MaxLength);
25
26 if(!i || !j || (j < i + l))
27 {
28 strncpy(Value, DefaultValue, MaxLength);
29 Value[MaxLength - 1] = 0;
30 }
31 else
32 {
33 strncpy(Value, i + l, j - i - l + 1 );
34 Value[j - i - l + 1] = 0;
35 }
36
37 TRACEEXIT();
38 return TRUE;
39}
void INIFindStartEnd(char *, char **, char **, dword)
bool INIGetString(char *Key, char *Value, char *DefaultValue, dword MaxLength)
Definition: INIGetString.c:5
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243