1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #15769 from jia200x/pr/deprecate/gcoap_add_string

gcoap: remove deprecated gcoap_add_qstring
This commit is contained in:
Leandro Lanzieri 2021-01-14 17:20:47 +01:00 committed by GitHub
commit af042934da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 43 deletions

View File

@ -917,26 +917,6 @@ int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf);
ssize_t gcoap_encode_link(const coap_resource_t *resource, char *buf,
size_t maxlen, coap_link_encoder_ctx_t *context);
/**
* @brief Adds a single Uri-Query option to a CoAP request
*
* To add multiple Uri-Query options, simply call this function multiple times.
* The Uri-Query options will be added in the order those calls.
*
* @deprecated Will not be available after the 2020.10 release. Use
* coap_opt_add_uri_query() instead.
*
* @param[out] pdu The package that is being build
* @param[in] key Key to add to the query string
* @param[in] val Value to assign to @p key (may be NULL)
*
* @pre ((pdu != NULL) && (key != NULL))
*
* @return overall length of new query string
* @return -1 on error
*/
int gcoap_add_qstring(coap_pkt_t *pdu, const char *key, const char *val);
#ifdef __cplusplus
}
#endif

View File

@ -1067,27 +1067,4 @@ ssize_t gcoap_encode_link(const coap_resource_t *resource, char *buf,
return exp_size;
}
int gcoap_add_qstring(coap_pkt_t *pdu, const char *key, const char *val)
{
char qs[CONFIG_NANOCOAP_QS_MAX];
size_t len = strlen(key);
size_t val_len = (val) ? (strlen(val) + 1) : 0;
/* test if the query string fits, account for the zero termination */
if ((len + val_len + 1) >= CONFIG_NANOCOAP_QS_MAX) {
return -1;
}
memcpy(&qs[0], key, len);
if (val) {
qs[len] = '=';
/* the `=` character was already counted in `val_len`, so subtract it here */
memcpy(&qs[len + 1], val, (val_len - 1));
len += val_len;
}
qs[len] = '\0';
return coap_opt_add_string(pdu, COAP_OPT_URI_QUERY, qs, '&');
}
/** @} */