Add query parameter to generic resouce macros

Modify all callback functions to use new signature.
ota-update now uses this to pass the partition to some get/put methods.
This commit is contained in:
Ralf Schlatterbeck 2017-08-20 15:01:30 +02:00
parent 954da749eb
commit e3784fa9c7
20 changed files with 357 additions and 82 deletions

View file

@ -81,7 +81,13 @@ uint8_t led_status;
static size_t
ip_to_string (const char *name, const char *uri, char *buf, size_t bsize)
ip_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
#define IP(x) UIP_NTOHS(server_ipaddr.u16[x])
return snprintf
@ -90,7 +96,8 @@ ip_to_string (const char *name, const char *uri, char *buf, size_t bsize)
);
}
int ip_from_string (const char *name, const char *uri, const char *s)
int ip_from_string
(const char *name, const char *uri, const char *query, const char *s)
{
/* Returns 1 if successful, only copy valid address */
if (uiplib_ip6addrconv (s, &tmp_addr)) {
@ -110,12 +117,19 @@ GENERIC_RESOURCE
);
static size_t
resource_to_string (const char *name, const char *uri, char *buf, size_t bsize)
resource_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%s", server_resource);
}
int resource_from_string (const char *name, const char *uri, const char *s)
int resource_from_string
(const char *name, const char *uri, const char *query, const char *s)
{
strncpy (server_resource, s, sizeof (server_resource));
server_resource [sizeof (server_resource) - 1] = 0;
@ -132,12 +146,19 @@ GENERIC_RESOURCE
);
static size_t
interval_to_string (const char *name, const char *uri, char *buf, size_t bsize)
interval_to_string
( const char *name
, const char *uri
, const char *query
, char *buf
, size_t bsize
)
{
return snprintf (buf, bsize, "%d", interval);
}
int interval_from_string (const char *name, const char *uri, const char *s)
int interval_from_string
( const char *name, const char *uri, const char *query, const char *s)
{
interval = atoi (s);
return 0;