Commit d77666c0 authored by sergio's avatar sergio Committed by Terry Ellison
Browse files

trailing spaces cleanup (#2659)

parent d7583040
# #
# This is very much a work in progress to show how we can use macros to make the # This is very much a work in progress to show how we can use macros to make the
# GDB interface a lot more useable. For example the next / step commands only # GDB interface a lot more useable. For example the next / step commands only
# work if the stepper doesn't leave the current scope. Beyond that you have a # work if the stepper doesn't leave the current scope. Beyond that you have a
# single hardware breakpoint which can be used as an hb or a wa. You have to # single hardware breakpoint which can be used as an hb or a wa. You have to
# remember to delete the previous one, so the br macro does this for you. # remember to delete the previous one, so the br macro does this for you.
# #
file app/.output/eagle/debug/image/eagle.app.v6.out file app/.output/eagle/debug/image/eagle.app.v6.out
#set remotedebug 1 #set remotedebug 1
...@@ -16,12 +16,12 @@ target remote /dev/ttyUSB0 ...@@ -16,12 +16,12 @@ target remote /dev/ttyUSB0
set confirm off set confirm off
set print null-stop set print null-stop
define br define br
d d
hb $arg0 hb $arg0
end end
define upto define upto
d d
hb $arg0 hb $arg0
c c
......
...@@ -15,7 +15,7 @@ Provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/h ...@@ -15,7 +15,7 @@ Provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/h
Which branch are you on? If you know the Git revision then add it here as well. Which branch are you on? If you know the Git revision then add it here as well.
### Hardware ### Hardware
Describe which ESP8266 device you use and document any special hardware setup Describe which ESP8266 device you use and document any special hardware setup
required to reproduce the problem. required to reproduce the problem.
8<------------------------ END BUG REPORT ------------------------------------- 8<------------------------ END BUG REPORT -------------------------------------
......
...@@ -65,7 +65,7 @@ Avoid intermediate merge commits. [Rebase](https://www.atlassian.com/git/tutoria ...@@ -65,7 +65,7 @@ Avoid intermediate merge commits. [Rebase](https://www.atlassian.com/git/tutoria
This is just one way of doing things. If you're proficient in Git matters you're free to choose your own. If you want to read more then the [GitHub chapter in the Git book](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project#The-GitHub-Flow) is a way to start. [GitHub's own documentation](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/) contains a wealth of information as well. This is just one way of doing things. If you're proficient in Git matters you're free to choose your own. If you want to read more then the [GitHub chapter in the Git book](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project#The-GitHub-Flow) is a way to start. [GitHub's own documentation](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/) contains a wealth of information as well.
As a Windows or Mac user you could also resort to [GitHub Desktop](https://desktop.github.com/). It's a mature GUI application that supports most of the tasks outlined above. As a Windows or Mac user you could also resort to [GitHub Desktop](https://desktop.github.com/). It's a mature GUI application that supports most of the tasks outlined above.
### Keeping your fork in sync ### Keeping your fork in sync
You need to sync your fork with the NodeMCU upstream repository from time to time, latest before you rebase (see flow above). You need to sync your fork with the NodeMCU upstream repository from time to time, latest before you rebase (see flow above).
......
...@@ -46,7 +46,7 @@ wifi.sta.config{ssid="SSID", pwd="password"} ...@@ -46,7 +46,7 @@ wifi.sta.config{ssid="SSID", pwd="password"}
# Documentation # Documentation
The entire [NodeMCU documentation](https://nodemcu.readthedocs.io) is maintained right in this repository at [/docs](docs). The fact that the API documentation is maintained in the same repository as the code that *provides* the API ensures consistency between the two. With every commit the documentation is rebuilt by Read the Docs and thus transformed from terse Markdown into a nicely browsable HTML site at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io). The entire [NodeMCU documentation](https://nodemcu.readthedocs.io) is maintained right in this repository at [/docs](docs). The fact that the API documentation is maintained in the same repository as the code that *provides* the API ensures consistency between the two. With every commit the documentation is rebuilt by Read the Docs and thus transformed from terse Markdown into a nicely browsable HTML site at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io).
- How to [build the firmware](https://nodemcu.readthedocs.io/en/master/en/build/) - How to [build the firmware](https://nodemcu.readthedocs.io/en/master/en/build/)
- How to [flash the firmware](https://nodemcu.readthedocs.io/en/master/en/flash/) - How to [flash the firmware](https://nodemcu.readthedocs.io/en/master/en/flash/)
......
...@@ -22,7 +22,7 @@ endif ...@@ -22,7 +22,7 @@ endif
# makefile at its root level - these are then overridden # makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein # for a subtree within the makefile rooted therein
# #
#DEFINES += #DEFINES +=
############################################################# #############################################################
# Recursion Magic - Don't touch this!! # Recursion Magic - Don't touch this!!
......
...@@ -24,8 +24,8 @@ typedef struct ...@@ -24,8 +24,8 @@ typedef struct
uint8_t ver; /* CoAP version number */ uint8_t ver; /* CoAP version number */
uint8_t t; /* CoAP Message Type */ uint8_t t; /* CoAP Message Type */
uint8_t tkl; /* Token length: indicates length of the Token field */ uint8_t tkl; /* Token length: indicates length of the Token field */
uint8_t code; /* CoAP status code. Can be request (0.xx), success reponse (2.xx), uint8_t code; /* CoAP status code. Can be request (0.xx), success reponse (2.xx),
* client error response (4.xx), or rever error response (5.xx) * client error response (4.xx), or rever error response (5.xx)
* For possible values, see http://tools.ietf.org/html/rfc7252#section-12.1 */ * For possible values, see http://tools.ietf.org/html/rfc7252#section-12.1 */
uint8_t id[2]; uint8_t id[2];
} coap_header_t; } coap_header_t;
...@@ -164,14 +164,14 @@ struct coap_luser_entry{ ...@@ -164,14 +164,14 @@ struct coap_luser_entry{
struct coap_endpoint_t{ struct coap_endpoint_t{
coap_method_t method; /* (i.e. POST, PUT or GET) */ coap_method_t method; /* (i.e. POST, PUT or GET) */
coap_endpoint_func handler; /* callback function which handles this coap_endpoint_func handler; /* callback function which handles this
* type of endpoint (and calls * type of endpoint (and calls
* coap_make_response() at some point) */ * coap_make_response() at some point) */
const coap_endpoint_path_t *path; /* path towards a resource (i.e. foo/bar/) */ const coap_endpoint_path_t *path; /* path towards a resource (i.e. foo/bar/) */
const char *core_attr; /* the 'ct' attribute, as defined in RFC7252, section 7.2.1.: const char *core_attr; /* the 'ct' attribute, as defined in RFC7252, section 7.2.1.:
* "The Content-Format code "ct" attribute * "The Content-Format code "ct" attribute
* provides a hint about the * provides a hint about the
* Content-Formats this resource returns." * Content-Formats this resource returns."
* (Section 12.3. lists possible ct values.) */ * (Section 12.3. lists possible ct values.) */
coap_luser_entry *user_entry; coap_luser_entry *user_entry;
}; };
......
...@@ -64,7 +64,7 @@ coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu) { ...@@ -64,7 +64,7 @@ coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu) {
*/ */
coap_timer_stop(); coap_timer_stop();
coap_timer_update(&gQueue); coap_timer_update(&gQueue);
node->t = node->timeout; node->t = node->timeout;
coap_insert_node(&gQueue, node); coap_insert_node(&gQueue, node);
coap_timer_start(&gQueue); coap_timer_start(&gQueue);
return node->id; return node->id;
......
...@@ -10,7 +10,7 @@ extern "C" { ...@@ -10,7 +10,7 @@ extern "C" {
#include "espconn.h" #include "espconn.h"
#include "pdu.h" #include "pdu.h"
#include "hash.h" #include "hash.h"
coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu); coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu);
coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu); coap_tid_t coap_send_confirmed(struct espconn *pesp_conn, coap_pdu_t *pdu);
......
...@@ -29,14 +29,14 @@ void coap_timer_tick(void *arg){ ...@@ -29,14 +29,14 @@ void coap_timer_tick(void *arg){
node->retransmit_cnt++; node->retransmit_cnt++;
node->t = node->timeout << node->retransmit_cnt; node->t = node->timeout << node->retransmit_cnt;
NODE_DBG("** retransmission #%d of transaction %d\n", NODE_DBG("** retransmission #%d of transaction %d\n",
node->retransmit_cnt, (((uint16_t)(node->pdu->pkt->hdr.id[0]))<<8)+node->pdu->pkt->hdr.id[1]); node->retransmit_cnt, (((uint16_t)(node->pdu->pkt->hdr.id[0]))<<8)+node->pdu->pkt->hdr.id[1]);
node->id = coap_send(node->pconn, node->pdu); node->id = coap_send(node->pconn, node->pdu);
if (COAP_INVALID_TID == node->id) { if (COAP_INVALID_TID == node->id) {
NODE_DBG("retransmission: error sending pdu\n"); NODE_DBG("retransmission: error sending pdu\n");
coap_delete_node(node); coap_delete_node(node);
} else { } else {
coap_insert_node(queue, node); coap_insert_node(queue, node);
} }
} else { } else {
/* And finally delete the node */ /* And finally delete the node */
......
...@@ -141,7 +141,7 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr ...@@ -141,7 +141,7 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr
NODE_DBG("\n"); NODE_DBG("\n");
lua_settop(L, n); lua_settop(L, n);
return coap_make_response(scratch, outpkt, ret, len, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN); return coap_make_response(scratch, outpkt, ret, len, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
} }
} else { } else {
lua_settop(L, n); lua_settop(L, n);
return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN); return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
...@@ -157,7 +157,7 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr ...@@ -157,7 +157,7 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr
goto end; goto end;
} }
} }
NODE_DBG("none match.\n"); NODE_DBG("none match.\n");
end: end:
return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_NOT_FOUND, COAP_CONTENTTYPE_NONE); return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_NOT_FOUND, COAP_CONTENTTYPE_NONE);
} }
...@@ -226,7 +226,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen) ...@@ -226,7 +226,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
c_strncat(rsp, ",", len); c_strncat(rsp, ",", len);
len--; len--;
} }
c_strncat(rsp, "<", len); c_strncat(rsp, "<", len);
len--; len--;
...@@ -250,7 +250,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen) ...@@ -250,7 +250,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
c_strncat(rsp, ",", len); c_strncat(rsp, ",", len);
len--; len--;
} }
c_strncat(rsp, "<", len); c_strncat(rsp, "<", len);
len--; len--;
...@@ -272,7 +272,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen) ...@@ -272,7 +272,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
len -= 2; len -= 2;
c_strncat(rsp, ep->core_attr, len); c_strncat(rsp, ep->core_attr, len);
len -= c_strlen(ep->core_attr); len -= c_strlen(ep->core_attr);
h = h->next; h = h->next;
} }
......
...@@ -8,7 +8,7 @@ void coap_hash(const unsigned char *s, unsigned int len, coap_key_t h) { ...@@ -8,7 +8,7 @@ void coap_hash(const unsigned char *s, unsigned int len, coap_key_t h) {
while (len--) { while (len--) {
j = sizeof(coap_key_t)-1; j = sizeof(coap_key_t)-1;
while (j) { while (j) {
h[j] = ((h[j] << 7) | (h[j-1] >> 1)) + h[j]; h[j] = ((h[j] << 7) | (h[j-1] >> 1)) + h[j];
--j; --j;
...@@ -23,8 +23,8 @@ void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_pack ...@@ -23,8 +23,8 @@ void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_pack
c_memset(h, 0, sizeof(coap_key_t)); c_memset(h, 0, sizeof(coap_key_t));
/* Compare the transport address. */ /* Compare the transport address. */
coap_hash((const unsigned char *)&(port), sizeof(port), h); coap_hash((const unsigned char *)&(port), sizeof(port), h);
coap_hash((const unsigned char *)&(ip), sizeof(ip), h); coap_hash((const unsigned char *)&(ip), sizeof(ip), h);
coap_hash((const unsigned char *)(pkt->hdr.id), sizeof(pkt->hdr.id), h); coap_hash((const unsigned char *)(pkt->hdr.id), sizeof(pkt->hdr.id), h);
*id = ((h[0] << 8) | h[1]) ^ ((h[2] << 8) | h[3]); *id = ((h[0] << 8) | h[1]) ^ ((h[2] << 8) | h[3]);
} }
...@@ -101,7 +101,7 @@ coap_queue_t * coap_pop_next( coap_queue_t **queue ) { // this function is call ...@@ -101,7 +101,7 @@ coap_queue_t * coap_pop_next( coap_queue_t **queue ) { // this function is call
int coap_remove_node( coap_queue_t **queue, const coap_tid_t id){ int coap_remove_node( coap_queue_t **queue, const coap_tid_t id){
coap_queue_t *p, *q, *node; coap_queue_t *p, *q, *node;
if ( !queue ) if ( !queue )
return 0; return 0;
if ( !*queue ) // if empty if ( !*queue ) // if empty
return 0; return 0;
......
...@@ -16,7 +16,7 @@ coap_pdu_t * coap_new_pdu(void) { ...@@ -16,7 +16,7 @@ coap_pdu_t * coap_new_pdu(void) {
return NULL; return NULL;
} }
pdu->scratch.len = MAX_REQ_SCRATCH_SIZE; pdu->scratch.len = MAX_REQ_SCRATCH_SIZE;
pdu->pkt = (coap_packet_t *)c_zalloc(sizeof(coap_packet_t)); pdu->pkt = (coap_packet_t *)c_zalloc(sizeof(coap_packet_t));
if(!pdu->pkt){ if(!pdu->pkt){
NODE_DBG("coap_new_pdu malloc error.\n"); NODE_DBG("coap_new_pdu malloc error.\n");
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org> * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
* *
* This file is part of the CoAP library libcoap. Please see * This file is part of the CoAP library libcoap. Please see
* README for terms of use. * README for terms of use.
*/ */
#include "c_stdlib.h" #include "c_stdlib.h"
#include "c_types.h" #include "c_types.h"
#include "str.h" #include "str.h"
str * coap_new_string(size_t size) { str * coap_new_string(size_t size) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org> * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
* *
* This file is part of the CoAP library libcoap. Please see * This file is part of the CoAP library libcoap. Please see
* README for terms of use. * README for terms of use.
*/ */
#ifndef _COAP_STR_H_ #ifndef _COAP_STR_H_
......
...@@ -17,22 +17,22 @@ ...@@ -17,22 +17,22 @@
#endif #endif
/** /**
* A length-safe version of strchr(). This function returns a pointer * A length-safe version of strchr(). This function returns a pointer
* to the first occurrence of @p c in @p s, or @c NULL if not found. * to the first occurrence of @p c in @p s, or @c NULL if not found.
* *
* @param s The string to search for @p c. * @param s The string to search for @p c.
* @param len The length of @p s. * @param len The length of @p s.
* @param c The character to search. * @param c The character to search.
* *
* @return A pointer to the first occurence of @p c, or @c NULL * @return A pointer to the first occurence of @p c, or @c NULL
* if not found. * if not found.
*/ */
static inline unsigned char * static inline unsigned char *
strnchr(unsigned char *s, size_t len, unsigned char c) { strnchr(unsigned char *s, size_t len, unsigned char c) {
while (len && *s++ != c) while (len && *s++ != c)
--len; --len;
return len ? s : NULL; return len ? s : NULL;
} }
...@@ -57,7 +57,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -57,7 +57,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
while (len && *q && tolower(*p) == *q) { while (len && *q && tolower(*p) == *q) {
++p; ++q; --len; ++p; ++q; --len;
} }
/* If q does not point to the string end marker '\0', the schema /* If q does not point to the string end marker '\0', the schema
* identifier is wrong. */ * identifier is wrong. */
if (*q) { if (*q) {
...@@ -84,7 +84,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -84,7 +84,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
q = p; q = p;
if (len && *p == '[') { /* IPv6 address reference */ if (len && *p == '[') { /* IPv6 address reference */
++p; ++p;
while (len && *q != ']') { while (len && *q != ']') {
++q; --len; ++q; --len;
} }
...@@ -92,7 +92,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -92,7 +92,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
if (!len || *q != ']' || p == q) { if (!len || *q != ']' || p == q) {
res = -3; res = -3;
goto error; goto error;
} }
COAP_SET_STR(&uri->host, q - p, p); COAP_SET_STR(&uri->host, q - p, p);
++q; --len; ++q; --len;
...@@ -115,7 +115,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -115,7 +115,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
if (len && *q == ':') { if (len && *q == ':') {
p = ++q; p = ++q;
--len; --len;
while (len && isdigit(*q)) { while (len && isdigit(*q)) {
++q; ++q;
--len; --len;
...@@ -123,19 +123,19 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -123,19 +123,19 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
if (p < q) { /* explicit port number given */ if (p < q) { /* explicit port number given */
int uri_port = 0; int uri_port = 0;
while (p < q) while (p < q)
uri_port = uri_port * 10 + (*p++ - '0'); uri_port = uri_port * 10 + (*p++ - '0');
uri->port = uri_port; uri->port = uri_port;
} }
} }
path: /* at this point, p must point to an absolute path */ path: /* at this point, p must point to an absolute path */
if (!len) if (!len)
goto end; goto end;
if (*q == '/') { if (*q == '/') {
p = ++q; p = ++q;
--len; --len;
...@@ -144,7 +144,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -144,7 +144,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
++q; ++q;
--len; --len;
} }
if (p < q) { if (p < q) {
COAP_SET_STR(&uri->path, q - p, p); COAP_SET_STR(&uri->path, q - p, p);
p = q; p = q;
...@@ -161,28 +161,28 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) { ...@@ -161,28 +161,28 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
end: end:
return len ? -1 : 0; return len ? -1 : 0;
error: error:
return res; return res;
} }
/** /**
* Calculates decimal value from hexadecimal ASCII character given in * Calculates decimal value from hexadecimal ASCII character given in
* @p c. The caller must ensure that @p c actually represents a valid * @p c. The caller must ensure that @p c actually represents a valid
* heaxdecimal character, e.g. with isxdigit(3). * heaxdecimal character, e.g. with isxdigit(3).
* *
* @hideinitializer * @hideinitializer
*/ */
#define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F)) #define hexchar_to_dec(c) ((c) & 0x40 ? ((c) & 0x0F) + 9 : ((c) & 0x0F))
/** /**
* Decodes percent-encoded characters while copying the string @p seg * Decodes percent-encoded characters while copying the string @p seg
* of size @p length to @p buf. The caller of this function must * of size @p length to @p buf. The caller of this function must
* ensure that the percent-encodings are correct (i.e. the character * ensure that the percent-encodings are correct (i.e. the character
* '%' is always followed by two hex digits. and that @p buf provides * '%' is always followed by two hex digits. and that @p buf provides
* sufficient space to hold the result. This function is supposed to * sufficient space to hold the result. This function is supposed to
* be called by make_decoded_option() only. * be called by make_decoded_option() only.
* *
* @param seg The segment to decode and copy. * @param seg The segment to decode and copy.
* @param length Length of @p seg. * @param length Length of @p seg.
* @param buf The result buffer. * @param buf The result buffer.
...@@ -193,12 +193,12 @@ void decode_segment(const unsigned char *seg, size_t length, unsigned char *buf) ...@@ -193,12 +193,12 @@ void decode_segment(const unsigned char *seg, size_t length, unsigned char *buf)
if (*seg == '%') { if (*seg == '%') {
*buf = (hexchar_to_dec(seg[1]) << 4) + hexchar_to_dec(seg[2]); *buf = (hexchar_to_dec(seg[1]) << 4) + hexchar_to_dec(seg[2]);
seg += 2; length -= 2; seg += 2; length -= 2;
} else { } else {
*buf = *seg; *buf = *seg;
} }
++buf; ++seg; ++buf; ++seg;
} }
} }
...@@ -216,18 +216,18 @@ int check_segment(const unsigned char *s, size_t length) { ...@@ -216,18 +216,18 @@ int check_segment(const unsigned char *s, size_t length) {
if (*s == '%') { if (*s == '%') {
if (length < 2 || !(isxdigit(s[1]) && isxdigit(s[2]))) if (length < 2 || !(isxdigit(s[1]) && isxdigit(s[2])))
return -1; return -1;
s += 2; s += 2;
length -= 2; length -= 2;
} }
++s; ++n; --length; ++s; ++n; --length;
} }
return n; return n;
} }
/** /**
* Writes a coap option from given string @p s to @p buf. @p s should * Writes a coap option from given string @p s to @p buf. @p s should
* point to a (percent-encoded) path or query segment of a coap_uri_t * point to a (percent-encoded) path or query segment of a coap_uri_t
* object. The created option will have type @c 0, and the length * object. The created option will have type @c 0, and the length
...@@ -235,18 +235,18 @@ int check_segment(const unsigned char *s, size_t length) { ...@@ -235,18 +235,18 @@ int check_segment(const unsigned char *s, size_t length) {
* On success, this function returns the option's size, or a value * On success, this function returns the option's size, or a value
* less than zero on error. This function must be called from * less than zero on error. This function must be called from
* coap_split_path_impl() only. * coap_split_path_impl() only.
* *
* @param s The string to decode. * @param s The string to decode.
* @param length The size of the percent-encoded string @p s. * @param length The size of the percent-encoded string @p s.
* @param buf The buffer to store the new coap option. * @param buf The buffer to store the new coap option.
* @param buflen The maximum size of @p buf. * @param buflen The maximum size of @p buf.
* *
* @return The option's size, or @c -1 on error. * @return The option's size, or @c -1 on error.
* *
* @bug This function does not split segments that are bigger than 270 * @bug This function does not split segments that are bigger than 270
* bytes. * bytes.
*/ */
int make_decoded_option(const unsigned char *s, size_t length, int make_decoded_option(const unsigned char *s, size_t length,
unsigned char *buf, size_t buflen) { unsigned char *buf, size_t buflen) {
int res; int res;
size_t written; size_t written;
...@@ -289,32 +289,32 @@ int make_decoded_option(const unsigned char *s, size_t length, ...@@ -289,32 +289,32 @@ int make_decoded_option(const unsigned char *s, size_t length,
typedef void (*segment_handler_t)(unsigned char *, size_t, void *); typedef void (*segment_handler_t)(unsigned char *, size_t, void *);
/** /**
* Splits the given string into segments. You should call one of the * Splits the given string into segments. You should call one of the
* macros coap_split_path() or coap_split_query() instead. * macros coap_split_path() or coap_split_query() instead.
* *
* @param parse_iter The iterator used for tokenizing. * @param parse_iter The iterator used for tokenizing.
* @param h A handler that is called with every token. * @param h A handler that is called with every token.
* @param data Opaque data that is passed to @p h when called. * @param data Opaque data that is passed to @p h when called.
* *
* @return The number of characters that have been parsed from @p s. * @return The number of characters that have been parsed from @p s.
*/ */
size_t coap_split_path_impl(coap_parse_iterator_t *parse_iter, size_t coap_split_path_impl(coap_parse_iterator_t *parse_iter,
segment_handler_t h, void *data) { segment_handler_t h, void *data) {
unsigned char *seg; unsigned char *seg;
size_t length; size_t length;
assert(parse_iter); assert(parse_iter);
assert(h); assert(h);
length = parse_iter->n; length = parse_iter->n;
while ( (seg = coap_parse_next(parse_iter)) ) { while ( (seg = coap_parse_next(parse_iter)) ) {
/* any valid path segment is handled here: */ /* any valid path segment is handled here: */
h(seg, parse_iter->segment_length, data); h(seg, parse_iter->segment_length, data);
} }
return length - (parse_iter->n - parse_iter->segment_length); return length - (parse_iter->n - parse_iter->segment_length);
} }
...@@ -332,7 +332,7 @@ void write_option(unsigned char *s, size_t len, void *data) { ...@@ -332,7 +332,7 @@ void write_option(unsigned char *s, size_t len, void *data) {
/* skip empty segments and those that consist of only one or two dots */ /* skip empty segments and those that consist of only one or two dots */
if (memcmp(s, "..", min(len,2)) == 0) if (memcmp(s, "..", min(len,2)) == 0)
return; return;
res = check_segment(s, len); res = check_segment(s, len);
if (res < 0){ if (res < 0){
NODE_DBG("not a valid segment\n"); NODE_DBG("not a valid segment\n");
...@@ -360,7 +360,7 @@ int coap_split_path(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsigne ...@@ -360,7 +360,7 @@ int coap_split_path(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsigne
struct pkt_scr tmp = { pkt, scratch, 0 }; struct pkt_scr tmp = { pkt, scratch, 0 };
coap_parse_iterator_t pi; coap_parse_iterator_t pi;
coap_parse_iterator_init((unsigned char *)s, length, coap_parse_iterator_init((unsigned char *)s, length,
'/', (unsigned char *)"?#", 2, &pi); '/', (unsigned char *)"?#", 2, &pi);
coap_split_path_impl(&pi, write_option, &tmp); coap_split_path_impl(&pi, write_option, &tmp);
...@@ -376,7 +376,7 @@ int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsign ...@@ -376,7 +376,7 @@ int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsign
struct pkt_scr tmp = { pkt, scratch, 0 }; struct pkt_scr tmp = { pkt, scratch, 0 };
coap_parse_iterator_t pi; coap_parse_iterator_t pi;
coap_parse_iterator_init((unsigned char *)s, length, coap_parse_iterator_init((unsigned char *)s, length,
'&', (unsigned char *)"#", 1, &pi); '&', (unsigned char *)"#", 1, &pi);
coap_split_path_impl(&pi, write_option, &tmp); coap_split_path_impl(&pi, write_option, &tmp);
...@@ -411,7 +411,7 @@ coap_uri_t * coap_new_uri(const unsigned char *uri, unsigned int length) { ...@@ -411,7 +411,7 @@ coap_uri_t * coap_new_uri(const unsigned char *uri, unsigned int length) {
/* iterator functions */ /* iterator functions */
coap_parse_iterator_t * coap_parse_iterator_init(unsigned char *s, size_t n, coap_parse_iterator_t * coap_parse_iterator_init(unsigned char *s, size_t n,
unsigned char separator, unsigned char separator,
unsigned char *delim, size_t dlen, unsigned char *delim, size_t dlen,
coap_parse_iterator_t *pi) { coap_parse_iterator_t *pi) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org> * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
* *
* This file is part of the CoAP library libcoap. Please see * This file is part of the CoAP library libcoap. Please see
* README for terms of use. * README for terms of use.
*/ */
#ifndef _COAP_URI_H_ #ifndef _COAP_URI_H_
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
typedef struct { typedef struct {
str host; /**< host part of the URI */ str host; /**< host part of the URI */
unsigned short port; /**< The port in host byte order */ unsigned short port; /**< The port in host byte order */
str path; /**< Beginning of the first path segment. str path; /**< Beginning of the first path segment.
Use coap_split_path() to create Uri-Path options */ Use coap_split_path() to create Uri-Path options */
str query; /**< The query part if present */ str query; /**< The query part if present */
} coap_uri_t; } coap_uri_t;
...@@ -44,7 +44,7 @@ coap_uri_t *coap_new_uri(const unsigned char *uri, unsigned int length); ...@@ -44,7 +44,7 @@ coap_uri_t *coap_new_uri(const unsigned char *uri, unsigned int length);
* @{ * @{
*/ */
/** /**
* Iterator to for tokenizing a URI path or query. This structure must * Iterator to for tokenizing a URI path or query. This structure must
* be initialized with coap_parse_iterator_init(). Call * be initialized with coap_parse_iterator_init(). Call
* coap_parse_next() to walk through the tokens. * coap_parse_next() to walk through the tokens.
...@@ -68,45 +68,45 @@ typedef struct { ...@@ -68,45 +68,45 @@ typedef struct {
size_t segment_length; /**< length of current segment */ size_t segment_length; /**< length of current segment */
} coap_parse_iterator_t; } coap_parse_iterator_t;
/** /**
* Initializes the given iterator @p pi. * Initializes the given iterator @p pi.
* *
* @param s The string to tokenize. * @param s The string to tokenize.
* @param n The length of @p s. * @param n The length of @p s.
* @param separator The separator character that delimits tokens. * @param separator The separator character that delimits tokens.
* @param delim A set of characters that delimit @s. * @param delim A set of characters that delimit @s.
* @param dlen The length of @p delim. * @param dlen The length of @p delim.
* @param pi The iterator object to initialize. * @param pi The iterator object to initialize.
* *
* @return The initialized iterator object @p pi. * @return The initialized iterator object @p pi.
*/ */
coap_parse_iterator_t * coap_parse_iterator_t *
coap_parse_iterator_init(unsigned char *s, size_t n, coap_parse_iterator_init(unsigned char *s, size_t n,
unsigned char separator, unsigned char separator,
unsigned char *delim, size_t dlen, unsigned char *delim, size_t dlen,
coap_parse_iterator_t *pi); coap_parse_iterator_t *pi);
/** /**
* Updates the iterator @p pi to point to the next token. This * Updates the iterator @p pi to point to the next token. This
* function returns a pointer to that token or @c NULL if no more * function returns a pointer to that token or @c NULL if no more
* tokens exist. The contents of @p pi will be updated. In particular, * tokens exist. The contents of @p pi will be updated. In particular,
* @c pi->segment_length specifies the length of the current token, @c * @c pi->segment_length specifies the length of the current token, @c
* pi->pos points to its beginning. * pi->pos points to its beginning.
* *
* @param pi The iterator to update. * @param pi The iterator to update.
* *
* @return The next token or @c NULL if no more tokens exist. * @return The next token or @c NULL if no more tokens exist.
*/ */
unsigned char *coap_parse_next(coap_parse_iterator_t *pi); unsigned char *coap_parse_next(coap_parse_iterator_t *pi);
/** /**
* Parses a given string into URI components. The identified syntactic * Parses a given string into URI components. The identified syntactic
* components are stored in the result parameter @p uri. Optional URI * components are stored in the result parameter @p uri. Optional URI
* components that are not specified will be set to { 0, 0 }, except * components that are not specified will be set to { 0, 0 }, except
* for the port which is set to @c COAP_DEFAULT_PORT. This function * for the port which is set to @c COAP_DEFAULT_PORT. This function
* returns @p 0 if parsing succeeded, a value less than zero * returns @p 0 if parsing succeeded, a value less than zero
* otherwise. * otherwise.
* *
* @param str_var The string to split up. * @param str_var The string to split up.
* @param len The actual length of @p str_var * @param len The actual length of @p str_var
* @param uri The coap_uri_t object to store the result. * @param uri The coap_uri_t object to store the result.
...@@ -118,47 +118,47 @@ unsigned char *coap_parse_next(coap_parse_iterator_t *pi); ...@@ -118,47 +118,47 @@ unsigned char *coap_parse_next(coap_parse_iterator_t *pi);
int int
coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri); coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri);
/** /**
* Splits the given URI path into segments. Each segment is preceded * Splits the given URI path into segments. Each segment is preceded
* by an option pseudo-header with delta-value 0 and the actual length * by an option pseudo-header with delta-value 0 and the actual length
* of the respective segment after percent-decoding. * of the respective segment after percent-decoding.
* *
* @param s The path string to split. * @param s The path string to split.
* @param length The actual length of @p s. * @param length The actual length of @p s.
* @param buf Result buffer for parsed segments. * @param buf Result buffer for parsed segments.
* @param buflen Maximum length of @p buf. Will be set to the actual number * @param buflen Maximum length of @p buf. Will be set to the actual number
* of bytes written into buf on success. * of bytes written into buf on success.
* *
* @return The number of segments created or @c -1 on error. * @return The number of segments created or @c -1 on error.
*/ */
#if 0 #if 0
int coap_split_path(const unsigned char *s, size_t length, int coap_split_path(const unsigned char *s, size_t length,
unsigned char *buf, size_t *buflen); unsigned char *buf, size_t *buflen);
#else #else
int int
coap_split_path(coap_rw_buffer_t *scratch, coap_packet_t *pkt, coap_split_path(coap_rw_buffer_t *scratch, coap_packet_t *pkt,
const unsigned char *s, size_t length); const unsigned char *s, size_t length);
#endif #endif
/** /**
* Splits the given URI query into segments. Each segment is preceded * Splits the given URI query into segments. Each segment is preceded
* by an option pseudo-header with delta-value 0 and the actual length * by an option pseudo-header with delta-value 0 and the actual length
* of the respective query term. * of the respective query term.
* *
* @param s The query string to split. * @param s The query string to split.
* @param length The actual length of @p s. * @param length The actual length of @p s.
* @param buf Result buffer for parsed segments. * @param buf Result buffer for parsed segments.
* @param buflen Maximum length of @p buf. Will be set to the actual number * @param buflen Maximum length of @p buf. Will be set to the actual number
* of bytes written into buf on success. * of bytes written into buf on success.
* *
* @return The number of segments created or @c -1 on error. * @return The number of segments created or @c -1 on error.
* *
* @bug This function does not reserve additional space for delta > 12. * @bug This function does not reserve additional space for delta > 12.
*/ */
#if 0 #if 0
int coap_split_query(const unsigned char *s, size_t length, int coap_split_query(const unsigned char *s, size_t length,
unsigned char *buf, size_t *buflen); unsigned char *buf, size_t *buflen);
#else #else
int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt, int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt,
const unsigned char *s, size_t length); const unsigned char *s, size_t length);
#endif #endif
/** @} */ /** @} */
......
...@@ -140,7 +140,7 @@ int ICACHE_FLASH_ATTR crypto_fhash (const digest_mech_info_t *mi, ...@@ -140,7 +140,7 @@ int ICACHE_FLASH_ATTR crypto_fhash (const digest_mech_info_t *mi,
uint8_t* buffer = (uint8_t*)os_malloc (mi->block_size); uint8_t* buffer = (uint8_t*)os_malloc (mi->block_size);
if (!buffer) if (!buffer)
return ENOMEM; return ENOMEM;
int read_len = 0; int read_len = 0;
do { do {
read_len = read(readarg, buffer, mi->block_size); read_len = read(readarg, buffer, mi->block_size);
......
/* /*
* FILE: sha2.c * FILE: sha2.c
* AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
* *
* Copyright (c) 2000-2001, Aaron D. Gifford * Copyright (c) 2000-2001, Aaron D. Gifford
* Copyright (c) 2015, DiUS Computing Pty Ltd (jmattsson@dius.com.au) * Copyright (c) 2015, DiUS Computing Pty Ltd (jmattsson@dius.com.au)
* All rights reserved. * All rights reserved.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* 3. Neither the name of the copyright holder nor the names of contributors * 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
...@@ -424,11 +424,11 @@ void ICACHE_FLASH_ATTR SHA256_Transform(SHA256_CTX* context, const sha2_word32* ...@@ -424,11 +424,11 @@ void ICACHE_FLASH_ATTR SHA256_Transform(SHA256_CTX* context, const sha2_word32*
/* Part of the message block expansion: */ /* Part of the message block expansion: */
s0 = W256[(j+1)&0x0f]; s0 = W256[(j+1)&0x0f];
s0 = sigma0_256(s0); s0 = sigma0_256(s0);
s1 = W256[(j+14)&0x0f]; s1 = W256[(j+14)&0x0f];
s1 = sigma1_256(s1); s1 = sigma1_256(s1);
/* Apply the SHA-256 compression function to update a..h */ /* Apply the SHA-256 compression function to update a..h */
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
(W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
T2 = Sigma0_256(a) + Maj(a, b, c); T2 = Sigma0_256(a) + Maj(a, b, c);
h = g; h = g;
......
...@@ -23,7 +23,7 @@ endif ...@@ -23,7 +23,7 @@ endif
# makefile at its root level - these are then overridden # makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein # for a subtree within the makefile rooted therein
# #
#DEFINES += #DEFINES +=
############################################################# #############################################################
# Recursion Magic - Don't touch this!! # Recursion Magic - Don't touch this!!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment