ini_file_reader add function iniGetRequiredStrValueEx
parent
edced2173b
commit
0bdb5e4b03
3
HISTORY
3
HISTORY
|
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
Version 1.39 2018-07-19
|
Version 1.39 2018-07-23
|
||||||
* add #@function REPLACE_VARS
|
* add #@function REPLACE_VARS
|
||||||
* #@set value can embed %{VARIABLE}
|
* #@set value can embed %{VARIABLE}
|
||||||
* shared_func.h: add function starts_with and ends_with
|
* shared_func.h: add function starts_with and ends_with
|
||||||
* common_blocked_queue.h: add function common_blocked_queue_try_pop
|
* common_blocked_queue.h: add function common_blocked_queue_try_pop
|
||||||
* sched_thread.c: fix first schedule time
|
* sched_thread.c: fix first schedule time
|
||||||
|
* ini_file_reader add function iniGetRequiredStrValueEx
|
||||||
|
|
||||||
Version 1.38 2018-06-26
|
Version 1.38 2018-06-26
|
||||||
* connection_pool.c: set err_no to 0 when success
|
* connection_pool.c: set err_no to 0 when success
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ STATIC_LIBS = libfastcommon.a
|
||||||
ALL_LIBS = $(SHARED_LIBS) $(STATIC_LIBS)
|
ALL_LIBS = $(SHARED_LIBS) $(STATIC_LIBS)
|
||||||
|
|
||||||
all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)
|
all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)
|
||||||
libfastcommon.so:
|
libfastcommon.so: $(FAST_SHARED_OBJS)
|
||||||
$(COMPILE) -o $@ $< -shared $(FAST_SHARED_OBJS) $(LIB_PATH)
|
$(COMPILE) -o $@ -shared $(FAST_SHARED_OBJS) $(LIB_PATH)
|
||||||
libfastcommon.a: $(FAST_STATIC_OBJS)
|
libfastcommon.a: $(FAST_STATIC_OBJS)
|
||||||
ar rcs $@ $(FAST_STATIC_OBJS)
|
ar rcs $@ $(FAST_STATIC_OBJS)
|
||||||
.o:
|
.o:
|
||||||
|
|
|
||||||
|
|
@ -2839,4 +2839,39 @@ IniItem *iniGetSectionItems(const char *szSectionName, IniContext *pContext,
|
||||||
return pSection->items;
|
return pSection->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *iniGetRequiredStrValueEx(const char *szSectionName, const char *szItemName,
|
||||||
|
IniContext *pContext, const int nMinLength)
|
||||||
|
{
|
||||||
|
char *value;
|
||||||
|
value = iniGetStrValue(szSectionName, szItemName, pContext);
|
||||||
|
if (value == NULL)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"item: %s not exist", __LINE__, szItemName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nMinLength > 0)
|
||||||
|
{
|
||||||
|
if (nMinLength == 1 && *value == '\0')
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"item: %s, value is empty", __LINE__, szItemName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
len = strlen(value);
|
||||||
|
if (len < nMinLength)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"item: %s, value length: %d < min length: %d",
|
||||||
|
__LINE__, szItemName, len, nMinLength);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,25 @@ static inline IniItem *iniGetGlobalItems(IniContext *pContext, int *nCount)
|
||||||
IniItem *iniGetSectionItems(const char *szSectionName, IniContext *pContext,
|
IniItem *iniGetSectionItems(const char *szSectionName, IniContext *pContext,
|
||||||
int *nCount);
|
int *nCount);
|
||||||
|
|
||||||
|
/** get item string value
|
||||||
|
* parameters:
|
||||||
|
* szSectionName: the section name, NULL or empty string for
|
||||||
|
* global section
|
||||||
|
* szItemName: the item name
|
||||||
|
* pContext: the ini context
|
||||||
|
* nMinLength: the min value length
|
||||||
|
* return: item value, return NULL when the item not exist
|
||||||
|
*/
|
||||||
|
char *iniGetRequiredStrValueEx(const char *szSectionName, const char *szItemName,
|
||||||
|
IniContext *pContext, const int nMinLength);
|
||||||
|
|
||||||
|
static inline char *iniGetRequiredStrValue(const char *szSectionName,
|
||||||
|
const char *szItemName, IniContext *pContext)
|
||||||
|
{
|
||||||
|
const int nMinLength = 1;
|
||||||
|
return iniGetRequiredStrValueEx(szSectionName, szItemName, pContext, nMinLength);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue