mirror of https://github.com/arendst/Tasmota.git
Added valueGet_P option
This commit is contained in:
parent
d18e040c27
commit
b98fa03dd0
|
@ -436,6 +436,44 @@ char * TInfo::valueGet(char * name, char * value)
|
|||
return ( NULL);
|
||||
}
|
||||
|
||||
/* ======================================================================
|
||||
Function: valueGet_P
|
||||
Purpose : get value of one element
|
||||
Input : Pointer to the label name
|
||||
pointer to the value where we fill data
|
||||
Output : pointer to the value where we filled data NULL is not found
|
||||
====================================================================== */
|
||||
char * TInfo::valueGet_P(const char * name, char * value)
|
||||
{
|
||||
// Get our linked list
|
||||
ValueList * me = &_valueslist;
|
||||
uint8_t lgname = strlen_P(name);
|
||||
|
||||
// Got one and all seems good ?
|
||||
if (me && lgname) {
|
||||
|
||||
// Loop thru the node
|
||||
while (me->next) {
|
||||
|
||||
// go to next node
|
||||
me = me->next;
|
||||
|
||||
// Check if we match this LABEL
|
||||
if (lgname==strlen(me->name) && strncmp_P(me->name, name, lgname)==0) {
|
||||
// this one has a value ?
|
||||
if (me->value) {
|
||||
// copy to dest buffer
|
||||
uint8_t lgvalue = strlen(me->value);
|
||||
strlcpy(value, me->value , lgvalue + 1 );
|
||||
return ( value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// not found
|
||||
return ( NULL);
|
||||
}
|
||||
|
||||
/* ======================================================================
|
||||
Function: getTopList
|
||||
Purpose : return a pointer on the top of the linked list
|
||||
|
|
|
@ -117,6 +117,7 @@ class TInfo
|
|||
ValueList * getList(void);
|
||||
uint8_t valuesDump(void);
|
||||
char * valueGet(char * name, char * value);
|
||||
char * valueGet_P(const char * name, char * value);
|
||||
boolean listDelete();
|
||||
unsigned char calcChecksum(char *etiquette, char *valeur) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue