From ae438cb4bb62dce3ddb1fef27ebf6a6cf1b01902 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Wed, 24 Apr 2024 21:11:26 +0100 Subject: [PATCH] man: Format examples as per CONTRIBUTION guidelines --- man/coap_address.txt.in | 16 +++---- man/coap_async.txt.in | 9 ++-- man/coap_block.txt.in | 27 ++++++------ man/coap_cache.txt.in | 57 ++++++++++++------------- man/coap_encryption.txt.in | 74 +++++++++++++++------------------ man/coap_endpoint_client.txt.in | 50 ++++++++++------------ man/coap_endpoint_server.txt.in | 66 +++++++++++++---------------- man/coap_handler.txt.in | 13 +++--- man/coap_io.txt.in | 5 +-- man/coap_observe.txt.in | 35 +++++++--------- man/coap_oscore.txt.in | 51 +++++++++++------------ man/coap_pdu_access.txt.in | 6 +-- man/coap_pdu_setup.txt.in | 29 ++++++------- man/coap_persist.txt.in | 25 +++++------ man/coap_resource.txt.in | 31 ++++++++------ man/coap_uri.txt.in | 3 +- 16 files changed, 235 insertions(+), 262 deletions(-) diff --git a/man/coap_address.txt.in b/man/coap_address.txt.in index 7be8552127..6d71e6bdd2 100644 --- a/man/coap_address.txt.in +++ b/man/coap_address.txt.in @@ -277,14 +277,14 @@ static int get_address(coap_uri_t *uri, coap_address_t *dst) { coap_addr_info_t *info_list; - info_list = coap_resolve_address_info(&uri->host, uri->port, uri->port, - uri->port, uri->port,0, - 1 << uri->scheme, COAP_RESOLVE_TYPE_LOCAL); - if (info_list == NULL) - return 0; - memcpy(dst, &info_list->addr, sizeof(*dst)); - coap_free_address_info(info_list); - return 1; + info_list = coap_resolve_address_info(&uri->host, uri->port, uri->port, + uri->port, uri->port,0, + 1 << uri->scheme, COAP_RESOLVE_TYPE_LOCAL); + if (info_list == NULL) + return 0; + memcpy(dst, &info_list->addr, sizeof(*dst)); + coap_free_address_info(info_list); + return 1; } ---- diff --git a/man/coap_async.txt.in b/man/coap_async.txt.in index 43acb3fdea..838510400f 100644 --- a/man/coap_async.txt.in +++ b/man/coap_async.txt.in @@ -151,10 +151,10 @@ EXAMPLES */ static void hnd_get_with_delay(coap_session_t *session, - coap_resource_t *resource, - coap_pdu_t *request, - coap_string_t *query, - coap_pdu_t *response) { + coap_resource_t *resource, + coap_pdu_t *request, + coap_string_t *query, + coap_pdu_t *response) { unsigned long delay = 5; size_t size; coap_async_t *async; @@ -204,7 +204,6 @@ hnd_get_with_delay(coap_session_t *session, /* async is automatically removed by libcoap on return from this handler */ } - ---- SEE ALSO diff --git a/man/coap_block.txt.in b/man/coap_block.txt.in index 4db60541c2..a3f1438f33 100644 --- a/man/coap_block.txt.in +++ b/man/coap_block.txt.in @@ -341,9 +341,9 @@ EXAMPLES static int build_send_pdu(coap_context_t *context, coap_session_t *session, -uint8_t msgtype, uint8_t request_code, const char *uri, const char *query, -unsigned char *data, size_t length, int observe) { - + uint8_t msgtype, uint8_t request_code, const char *uri, + const char *query, unsigned char *data, size_t length, + int observe) { coap_pdu_t *pdu; uint8_t buf[1024]; size_t buflen; @@ -372,11 +372,11 @@ unsigned char *data, size_t length, int observe) { if (uri) { /* Add in the URI options */ buflen = sizeof(buf); - res = coap_split_path((const uint8_t*)uri, strlen(uri), sbuf, &buflen); + res = coap_split_path((const uint8_t *)uri, strlen(uri), sbuf, &buflen); while (res--) { if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_URI_PATH, - coap_opt_length(sbuf), coap_opt_value(sbuf)))) + coap_opt_length(sbuf), coap_opt_value(sbuf)))) goto error; sbuf += coap_opt_size(sbuf); } @@ -385,11 +385,11 @@ unsigned char *data, size_t length, int observe) { if (query) { /* Add in the QUERY options */ buflen = sizeof(buf); - res = coap_split_query((const uint8_t*)query, strlen(query), sbuf, &buflen); + res = coap_split_query((const uint8_t *)query, strlen(query), sbuf, &buflen); while (res--) { if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_URI_QUERY, - coap_opt_length(sbuf), coap_opt_value(sbuf)))) + coap_opt_length(sbuf), coap_opt_value(sbuf)))) goto error; sbuf += coap_opt_size(sbuf); } @@ -399,9 +399,9 @@ unsigned char *data, size_t length, int observe) { /* Indicate that we want to observe this resource */ if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_OBSERVE, - coap_encode_var_safe(buf, sizeof(buf), - COAP_OBSERVE_ESTABLISH), buf) - )) + coap_encode_var_safe(buf, sizeof(buf), + COAP_OBSERVE_ESTABLISH), buf) + )) goto error; } @@ -472,8 +472,8 @@ main(int argc, char *argv[]) { static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[40]; size_t len; time_t now; @@ -487,8 +487,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { if (query != NULL && coap_string_equal(query, coap_make_str_const("secs"))) { /* Output secs since Jan 1 1970 */ len = snprintf((char *)buf, sizeof(buf), "%lu", now); - } - else { + } else { /* Output human-readable time */ struct tm *tmp; tmp = gmtime(&now); diff --git a/man/coap_cache.txt.in b/man/coap_cache.txt.in index 48892996d0..716a8ea825 100644 --- a/man/coap_cache.txt.in +++ b/man/coap_cache.txt.in @@ -245,7 +245,7 @@ static int example_data_media_type = COAP_MEDIATYPE_TEXT_PLAIN; static void cache_free_app_data(void *data) { - coap_binary_t *bdata = (coap_binary_t*)data; + coap_binary_t *bdata = (coap_binary_t *)data; coap_delete_binary(bdata); } @@ -255,13 +255,12 @@ cache_free_app_data(void *data) { static void hnd_put_example_data(coap_context_t *ctx, - coap_resource_t *resource, - coap_session_t *session, - coap_pdu_t *request, - coap_binary_t *token, - coap_string_t *query, - coap_pdu_t *response -) { + coap_resource_t *resource, + coap_session_t *session, + coap_pdu_t *request, + coap_binary_t *token, + coap_string_t *query, + coap_pdu_t *response) { size_t size; const uint8_t *data; coap_opt_iterator_t opt_iter; @@ -276,7 +275,7 @@ hnd_put_example_data(coap_context_t *ctx, (void)query; if (coap_get_data_large(request, &size, &data, &offset, &total) && - size != total) { + size != total) { /* * A part of the data has been received (COAP_BLOCK_SINGLE_BODY not set). * However, total unfortunately is only an indication, so it is not safe to @@ -291,7 +290,7 @@ hnd_put_example_data(coap_context_t *ctx, */ coap_cache_entry_t *cache_entry = coap_cache_get_by_pdu(session, request, - COAP_CACHE_IS_SESSION_BASED); + COAP_CACHE_IS_SESSION_BASED); if (offset == 0) { if (!cache_entry) { @@ -301,10 +300,9 @@ hnd_put_example_data(coap_context_t *ctx, * the session is deleted as session_based is set here. */ cache_entry = coap_new_cache_entry(session, request, - COAP_CACHE_NOT_RECORD_PDU, - COAP_CACHE_IS_SESSION_BASED, 0); - } - else { + COAP_CACHE_NOT_RECORD_PDU, + COAP_CACHE_IS_SESSION_BASED, 0); + } else { data_so_far = coap_cache_get_app_data(cache_entry); if (data_so_far) { coap_delete_binary(data_so_far); @@ -316,10 +314,9 @@ hnd_put_example_data(coap_context_t *ctx, if (!cache_entry) { if (offset == 0) { coap_log_warn("Unable to create a new cache entry\n"); - } - else { + } else { coap_log_warn( - "No cache entry available for the non-first BLOCK\n"); + "No cache entry available for the non-first BLOCK\n"); } coap_pdu_set_code(response, COAP_RESPONSE_CODE_INTERNAL_ERROR); return; @@ -337,14 +334,12 @@ hnd_put_example_data(coap_context_t *ctx, /* All the data is now in */ data_so_far = coap_cache_get_app_data(cache_entry); coap_cache_set_app_data(cache_entry, NULL, NULL); - } - else { + } else { /* Give us the next block response */ coap_pdu_set_code(response, COAP_RESPONSE_CODE_CONTINUE); return; } - } - else { + } else { /* single body of data received */ data_so_far = coap_new_binary(size); if (data_so_far) { @@ -356,19 +351,18 @@ hnd_put_example_data(coap_context_t *ctx, /* pre-existed response */ coap_pdu_set_code(response, COAP_RESPONSE_CODE_CHANGED); coap_delete_binary(example_data_ptr); - } - else + } else { /* just generated response */ coap_pdu_set_code(response, COAP_RESPONSE_CODE_CREATED); + } example_data_ptr = data_so_far; if ((option = coap_check_option(request, COAP_OPTION_CONTENT_FORMAT, &opt_iter)) != NULL) { example_data_media_type = - coap_decode_var_bytes (coap_opt_value (option), - coap_opt_length (option)); - } - else { + coap_decode_var_bytes(coap_opt_value(option), + coap_opt_length(option)); + } else { example_data_media_type = COAP_MEDIATYPE_TEXT_PLAIN; } @@ -377,11 +371,12 @@ hnd_put_example_data(coap_context_t *ctx, } int -main(int argc, char* argv[]) { +main(int argc, char *argv[]) { coap_context_t *ctx = NULL; /* Set up as normal */ /* ... */ uint16_t cache_ignore_options[] = { COAP_OPTION_BLOCK1, - COAP_OPTION_BLOCK2 }; + COAP_OPTION_BLOCK2 + }; /* Initialize libcoap library */ coap_startup(); @@ -392,9 +387,9 @@ main(int argc, char* argv[]) { /* ... */ - /** Define the options to ignore when setting up cache-keys */ + /* Define the options to ignore when setting up cache-keys */ coap_cache_ignore_options(ctx, cache_ignore_options, - sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0])); + sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0])); /* ... */ coap_cleanup(); diff --git a/man/coap_encryption.txt.in b/man/coap_encryption.txt.in index 22855316e6..a49050ee11 100644 --- a/man/coap_encryption.txt.in +++ b/man/coap_encryption.txt.in @@ -884,9 +884,8 @@ verify_cn_callback(const char *cn, coap_session_t *c_session, unsigned depth, int validated, - void *arg -) { - valid_cns_t *valid_cn_list = (valid_cns_t*)arg; + void *arg) { + valid_cns_t *valid_cn_list = (valid_cns_t *)arg; int i; /* Remove (void) definition if variable is used */ (void)asn1_public_cert; @@ -905,7 +904,7 @@ verify_cn_callback(const char *cn, } typedef struct sni_def_t { - char* sni; + char *sni; coap_dtls_key_t key; } sni_def_t; @@ -928,8 +927,7 @@ typedef struct valid_snis_t { */ static coap_dtls_key_t * verify_pki_sni_callback(const char *sni, - void *arg -) { + void *arg) { valid_snis_t *valid_sni_list = (valid_snis_t *)arg; int i; @@ -946,12 +944,11 @@ verify_pki_sni_callback(const char *sni, * Set up PKI encryption information */ static coap_context_t * -setup_server_context_pki (const char *public_cert_file, - const char *private_key_file, - const char *ca_file, - valid_cns_t *valid_cn_list, - valid_snis_t *valid_sni_list -) { +setup_server_context_pki(const char *public_cert_file, + const char *private_key_file, + const char *ca_file, + valid_cns_t *valid_cn_list, + valid_snis_t *valid_sni_list) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_dtls_pki_t dtls_pki; @@ -970,7 +967,7 @@ setup_server_context_pki (const char *public_cert_file, COAP_BLOCK_USE_LIBCOAP | COAP_BLOCK_SINGLE_BODY); - memset (&dtls_pki, 0, sizeof (dtls_pki)); + memset(&dtls_pki, 0, sizeof(dtls_pki)); dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; dtls_pki.verify_peer_cert = 1; @@ -1004,7 +1001,7 @@ setup_server_context_pki (const char *public_cert_file, coap_address_init(&listen_addr); listen_addr.addr.sa.sa_family = AF_INET; - listen_addr.addr.sin.sin_port = htons (5684); + listen_addr.addr.sin.sin_port = htons(5684); /* See coap_context(3) */ endpoint = coap_new_endpoint(context, &listen_addr, COAP_PROTO_DTLS); @@ -1041,9 +1038,8 @@ typedef struct valid_ids_t { static const coap_bin_const_t * verify_id_callback(coap_bin_const_t *identity, coap_session_t *c_session, - void *arg -) { - valid_ids_t *valid_id_list = (valid_ids_t*)arg; + void *arg) { + valid_ids_t *valid_id_list = (valid_ids_t *)arg; const coap_bin_const_t *s_psk_hint = coap_session_get_psk_hint(c_session); size_t i; @@ -1062,7 +1058,7 @@ verify_id_callback(coap_bin_const_t *identity, } typedef struct sni_psk_def_t { - char* sni; + char *sni; coap_dtls_spsk_info_t psk_info; } sni_psk_def_t; @@ -1077,8 +1073,7 @@ typedef struct valid_psk_snis_t { static const coap_dtls_spsk_info_t * verify_psk_sni_callback(const char *sni, coap_session_t *c_session, - void *arg -) { + void *arg) { valid_psk_snis_t *valid_sni_list = (valid_psk_snis_t *)arg; int i; /* Remove (void) definition if variable is used */ @@ -1094,12 +1089,11 @@ verify_psk_sni_callback(const char *sni, } static coap_context_t * -setup_server_context_psk (const char *hint, - const uint8_t *key, - unsigned int key_len, - valid_ids_t *valid_id_list, - valid_psk_snis_t *valid_sni_list -) { +setup_server_context_psk(const char *hint, + const uint8_t *key, + unsigned int key_len, + valid_ids_t *valid_id_list, + valid_psk_snis_t *valid_sni_list) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_context_t *context; @@ -1117,7 +1111,7 @@ setup_server_context_psk (const char *hint, COAP_BLOCK_USE_LIBCOAP | COAP_BLOCK_SINGLE_BODY); - memset (&dtls_psk, 0, sizeof (dtls_psk)); + memset(&dtls_psk, 0, sizeof(dtls_psk)); /* see coap_encryption(3) */ dtls_psk.version = COAP_DTLS_SPSK_SETUP_VERSION; @@ -1125,7 +1119,7 @@ setup_server_context_psk (const char *hint, dtls_psk.id_call_back_arg = valid_id_list; dtls_psk.validate_sni_call_back = verify_psk_sni_callback; dtls_psk.sni_call_back_arg = valid_sni_list; - dtls_psk.psk_info.hint.s = (const uint8_t*)hint; + dtls_psk.psk_info.hint.s = (const uint8_t *)hint; dtls_psk.psk_info.hint.length = hint ? strlen(hint) : 0; dtls_psk.psk_info.key.s = key; dtls_psk.psk_info.key.length = key_len; @@ -1137,7 +1131,7 @@ setup_server_context_psk (const char *hint, coap_address_init(&listen_addr); listen_addr.addr.sa.sa_family = AF_INET; - listen_addr.addr.sin.sin_port = htons (5684); + listen_addr.addr.sin.sin_port = htons(5684); endpoint = coap_new_endpoint(context, &listen_addr, COAP_PROTO_DTLS); if (!endpoint) { @@ -1165,8 +1159,7 @@ setup_server_context_psk (const char *hint, static const coap_dtls_cpsk_info_t * verify_ih_callback(coap_str_const_t *hint, coap_session_t *c_session, - void *arg -) { + void *arg) { coap_dtls_cpsk_info_t *psk_info = (coap_dtls_cpsk_info_t *)arg; /* Remove (void) definition if variable is used */ (void)c_session; @@ -1181,13 +1174,12 @@ static coap_dtls_cpsk_t dtls_psk; static char client_sni[256]; static coap_session_t * -setup_client_session_psk (const char *uri, - struct in_addr ip_address, - const uint8_t *identity, - unsigned int identity_len, - const uint8_t *key, - unsigned int key_len -) { +setup_client_session_psk(const char *uri, + struct in_addr ip_address, + const uint8_t *identity, + unsigned int identity_len, + const uint8_t *key, + unsigned int key_len) { coap_session_t *session; coap_address_t server; /* See coap_context(3) */ @@ -1203,10 +1195,10 @@ setup_client_session_psk (const char *uri, coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5684); + server.addr.sin.sin_port = htons(5684); /* See coap_encryption(3) */ - memset (&dtls_psk, 0, sizeof(dtls_psk)); + memset(&dtls_psk, 0, sizeof(dtls_psk)); dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION; dtls_psk.validate_ih_call_back = verify_ih_callback; dtls_psk.ih_call_back_arg = &dtls_psk.psk_info; @@ -1220,7 +1212,7 @@ setup_client_session_psk (const char *uri, dtls_psk.psk_info.key.s = key; dtls_psk.psk_info.key.length = key_len; session = coap_new_client_session_psk2(context, NULL, &server, - COAP_PROTO_DTLS, &dtls_psk); + COAP_PROTO_DTLS, &dtls_psk); if (!session) { coap_free_context(context); return NULL; diff --git a/man/coap_endpoint_client.txt.in b/man/coap_endpoint_client.txt.in index 6793e7fa8c..33892c45cf 100644 --- a/man/coap_endpoint_client.txt.in +++ b/man/coap_endpoint_client.txt.in @@ -221,7 +221,7 @@ EXAMPLES #include static coap_session_t * -setup_client_session (struct in_addr ip_address) { +setup_client_session(struct in_addr ip_address) { coap_session_t *session; coap_address_t server; /* See coap_context(3) */ @@ -238,7 +238,7 @@ setup_client_session (struct in_addr ip_address) { coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5683); + server.addr.sin.sin_port = htons(5683); session = coap_new_client_session(context, NULL, &server, COAP_PROTO_UDP); if (!session) { @@ -260,7 +260,7 @@ setup_client_session (struct in_addr ip_address) { #include static coap_session_t * -setup_client_session (const char *server_ud) { +setup_client_session(const char *server_ud) { coap_session_t *session; coap_address_t server; coap_address_t local; @@ -312,8 +312,7 @@ verify_cn_callback(const char *cn, coap_session_t *c_session, unsigned int depth, int validated, - void *arg -) { + void *arg) { /* Remove (void) definition if variable is used */ (void)cn; (void)asn1_public_cert; @@ -331,11 +330,10 @@ verify_cn_callback(const char *cn, } static coap_session_t * -setup_client_session_pki (struct in_addr ip_address, - const char *public_cert_file, - const char *private_key_file, - const char *ca_file -) { +setup_client_session_pki(struct in_addr ip_address, + const char *public_cert_file, + const char *private_key_file, + const char *ca_file) { coap_session_t *session; coap_address_t server; coap_dtls_pki_t dtls_pki; @@ -353,9 +351,9 @@ setup_client_session_pki (struct in_addr ip_address, coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5684); + server.addr.sin.sin_port = htons(5684); - memset (&dtls_pki, 0, sizeof (dtls_pki)); + memset(&dtls_pki, 0, sizeof(dtls_pki)); /* See coap_encryption(3) */ dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; @@ -408,8 +406,7 @@ setup_client_session_pki (struct in_addr ip_address, static const coap_dtls_cpsk_info_t * verify_ih_callback(coap_str_const_t *hint, coap_session_t *c_session, - void *arg -) { + void *arg) { coap_dtls_cpsk_info_t *psk_info = (coap_dtls_cpsk_info_t *)arg; /* Remove (void) definition if variable is used */ (void)c_session; @@ -424,13 +421,12 @@ static coap_dtls_cpsk_t dtls_psk; static char client_sni[256]; static coap_session_t * -setup_client_session_psk (const char *uri, - struct in_addr ip_address, - const uint8_t *identity, - unsigned int identity_len, - const uint8_t *key, - unsigned int key_len -) { +setup_client_session_psk(const char *uri, + struct in_addr ip_address, + const uint8_t *identity, + unsigned int identity_len, + const uint8_t *key, + unsigned int key_len) { coap_session_t *session; coap_address_t server; /* See coap_context(3) */ @@ -447,10 +443,10 @@ setup_client_session_psk (const char *uri, coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5684); + server.addr.sin.sin_port = htons(5684); /* See coap_encryption(3) */ - memset (&dtls_psk, 0, sizeof(dtls_psk)); + memset(&dtls_psk, 0, sizeof(dtls_psk)); dtls_psk.version = COAP_DTLS_CPSK_SETUP_VERSION; dtls_psk.validate_ih_call_back = verify_ih_callback; dtls_psk.ih_call_back_arg = &dtls_psk.psk_info; @@ -464,7 +460,7 @@ setup_client_session_psk (const char *uri, dtls_psk.psk_info.key.s = key; dtls_psk.psk_info.key.length = key_len; session = coap_new_client_session_psk2(context, NULL, &server, - COAP_PROTO_DTLS, &dtls_psk); + COAP_PROTO_DTLS, &dtls_psk); if (!session) { coap_free_context(context); return NULL; @@ -482,7 +478,7 @@ setup_client_session_psk (const char *uri, #include static coap_session_t * -setup_client_session_dtls (struct in_addr ip_address) { +setup_client_session_dtls(struct in_addr ip_address) { coap_session_t *session; coap_address_t server; /* See coap_context(3) */ @@ -499,10 +495,10 @@ setup_client_session_dtls (struct in_addr ip_address) { coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5683); + server.addr.sin.sin_port = htons(5683); session = coap_new_client_session(context, NULL, &server, - COAP_PROTO_DTLS); + COAP_PROTO_DTLS); if (!session) { coap_free_context(context); return NULL; diff --git a/man/coap_endpoint_server.txt.in b/man/coap_endpoint_server.txt.in index ee4d984f29..402b87df1a 100644 --- a/man/coap_endpoint_server.txt.in +++ b/man/coap_endpoint_server.txt.in @@ -219,7 +219,7 @@ EXAMPLES #include static coap_context_t * -setup_server_context (void) { +setup_server_context(void) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_context_t *context = coap_new_context(NULL); @@ -234,7 +234,7 @@ setup_server_context (void) { /* See coap_address(3) */ coap_address_init(&listen_addr); listen_addr.addr.sa.sa_family = AF_INET; - listen_addr.addr.sin.sin_port = htons (5683); + listen_addr.addr.sin.sin_port = htons(5683); endpoint = coap_new_endpoint(context, &listen_addr, COAP_PROTO_UDP); if (!endpoint) { @@ -261,7 +261,7 @@ setup_server_context (void) { #define UNIX_DOMAIN_LISTEN_DGRAM "/tmp/server.dgram" static coap_context_t * -setup_server_context (void) { +setup_server_context(void) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_context_t *context = coap_new_context(NULL); @@ -275,8 +275,8 @@ setup_server_context (void) { /* See coap_address(3) */ coap_address_set_unix_domain(&listen_addr, - (const uint8_t *)UNIX_DOMAIN_LISTEN_DGRAM, - strlen(UNIX_DOMAIN_LISTEN_DGRAM)); + (const uint8_t *)UNIX_DOMAIN_LISTEN_DGRAM, + strlen(UNIX_DOMAIN_LISTEN_DGRAM)); /* Only do this if you know it is safe to do so */ unlink(listen_addr.addr.cun.sun_path); @@ -312,9 +312,8 @@ verify_cn_callback(const char *cn, coap_session_t *c_session, unsigned depth, int validated, - void *arg -) { - valid_cns_t *valid_cn_list = (valid_cns_t*)arg; + void *arg) { + valid_cns_t *valid_cn_list = (valid_cns_t *)arg; size_t i; /* Remove (void) definition if variable is used */ (void)asn1_public_cert; @@ -333,7 +332,7 @@ verify_cn_callback(const char *cn, } typedef struct sni_def_t { - char* sni; + char *sni; coap_dtls_key_t key; } sni_def_t; @@ -347,8 +346,7 @@ typedef struct valid_snis_t { */ static coap_dtls_key_t * verify_pki_sni_callback(const char *sni, - void *arg -) { + void *arg) { valid_snis_t *valid_sni_list = (valid_snis_t *)arg; size_t i; @@ -365,12 +363,11 @@ verify_pki_sni_callback(const char *sni, * Set up PKI encryption information */ static coap_context_t * -setup_server_context_pki (const char *public_cert_file, - const char *private_key_file, - const char *ca_file, - valid_cns_t *valid_cn_list, - valid_snis_t *valid_sni_list -) { +setup_server_context_pki(const char *public_cert_file, + const char *private_key_file, + const char *ca_file, + valid_cns_t *valid_cn_list, + valid_snis_t *valid_sni_list) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_dtls_pki_t dtls_pki; @@ -388,7 +385,7 @@ setup_server_context_pki (const char *public_cert_file, COAP_BLOCK_USE_LIBCOAP | COAP_BLOCK_SINGLE_BODY); - memset (&dtls_pki, 0, sizeof (dtls_pki)); + memset(&dtls_pki, 0, sizeof(dtls_pki)); /* see coap_encryption(3) */ dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION; @@ -423,7 +420,7 @@ setup_server_context_pki (const char *public_cert_file, /* See coap_address(3) */ coap_address_init(&listen_addr); listen_addr.addr.sa.sa_family = AF_INET; - listen_addr.addr.sin.sin_port = htons (5684); + listen_addr.addr.sin.sin_port = htons(5684); endpoint = coap_new_endpoint(context, &listen_addr, COAP_PROTO_DTLS); if (!endpoint) { @@ -443,7 +440,7 @@ setup_server_context_pki (const char *public_cert_file, #include typedef struct id_def_t { - char* id; + char *id; coap_bin_const_t key; } id_def_t; @@ -458,16 +455,15 @@ typedef struct valid_ids_t { static const coap_bin_const_t * verify_id_callback(coap_bin_const_t *identity, coap_session_t *c_session, - void *arg -) { - valid_ids_t *valid_id_list = (valid_ids_t*)arg; + void *arg) { + valid_ids_t *valid_id_list = (valid_ids_t *)arg; int i; /* Remove (void) definition if variable is used */ (void)c_session; /* Check that the Identity is valid */ for (i = 0; i < valid_id_list->count; i++) { - if (!strcasecmp((const char*)identity->s, valid_id_list->id_list[i].id)) { + if (!strcasecmp((const char *)identity->s, valid_id_list->id_list[i].id)) { return &valid_id_list->id_list[i].key; } } @@ -475,7 +471,7 @@ verify_id_callback(coap_bin_const_t *identity, } typedef struct sni_psk_def_t { - char* sni; + char *sni; coap_dtls_spsk_info_t psk_info; } sni_psk_def_t; @@ -490,8 +486,7 @@ typedef struct valid_psk_snis_t { static const coap_dtls_spsk_info_t * verify_psk_sni_callback(const char *sni, coap_session_t *c_session, - void *arg -) { + void *arg) { valid_psk_snis_t *valid_sni_list = (valid_psk_snis_t *)arg; int i; /* Remove (void) definition if variable is used */ @@ -507,12 +502,11 @@ verify_psk_sni_callback(const char *sni, } static coap_context_t * -setup_server_context_psk (const char *hint, - const uint8_t *key, - unsigned int key_len, - valid_ids_t *valid_id_list, - valid_psk_snis_t *valid_sni_list -) { +setup_server_context_psk(const char *hint, + const uint8_t *key, + unsigned int key_len, + valid_ids_t *valid_id_list, + valid_psk_snis_t *valid_sni_list) { coap_endpoint_t *endpoint; coap_address_t listen_addr; coap_context_t *context; @@ -530,7 +524,7 @@ setup_server_context_psk (const char *hint, COAP_BLOCK_USE_LIBCOAP | COAP_BLOCK_SINGLE_BODY); - memset (&dtls_psk, 0, sizeof (dtls_psk)); + memset(&dtls_psk, 0, sizeof(dtls_psk)); /* see coap_encryption(3) */ dtls_psk.version = COAP_DTLS_SPSK_SETUP_VERSION; @@ -538,7 +532,7 @@ setup_server_context_psk (const char *hint, dtls_psk.id_call_back_arg = valid_id_list; dtls_psk.validate_sni_call_back = verify_psk_sni_callback; dtls_psk.sni_call_back_arg = valid_sni_list; - dtls_psk.psk_info.hint.s = (const uint8_t*)hint; + dtls_psk.psk_info.hint.s = (const uint8_t *)hint; dtls_psk.psk_info.hint.length = hint ? strlen(hint) : 0; dtls_psk.psk_info.key.s = key; dtls_psk.psk_info.key.length = key_len; @@ -551,7 +545,7 @@ setup_server_context_psk (const char *hint, /* See coap_address(3) */ coap_address_init(&listen_addr); listen_addr.addr.sa.sa_family = AF_INET; - listen_addr.addr.sin.sin_port = htons (5684); + listen_addr.addr.sin.sin_port = htons(5684); endpoint = coap_new_endpoint(context, &listen_addr, COAP_PROTO_DTLS); if (!endpoint) { diff --git a/man/coap_handler.txt.in b/man/coap_handler.txt.in index 5598ca31be..cbb9c1c817 100644 --- a/man/coap_handler.txt.in +++ b/man/coap_handler.txt.in @@ -291,8 +291,8 @@ EXAMPLES static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -coap_pdu_t *request, coap_string_t *query, coap_pdu_t *response) { - + coap_pdu_t *request, coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[40]; size_t len; time_t now; @@ -306,8 +306,7 @@ coap_pdu_t *request, coap_string_t *query, coap_pdu_t *response) { if (query != NULL && coap_string_equal(query, coap_make_str_const("secs"))) { /* Output secs since Jan 1 1970 */ len = snprintf((char *)buf, sizeof(buf), "%lu", now); - } - else { + } else { /* Output human-readable time */ struct tm *tmp; tmp = gmtime(&now); @@ -342,7 +341,8 @@ coap_pdu_t *request, coap_string_t *query, coap_pdu_t *response) { ---- #include -static int check_token(coap_pdu_t *received) { +static int +check_token(coap_pdu_t *received) { /* Remove (void) definition if variable is used */ (void)received; @@ -353,7 +353,8 @@ static int check_token(coap_pdu_t *received) { static coap_response_t response_handler(coap_context_t *ctx, coap_session_t *session, -coap_pdu_t *sent, coap_pdu_t *received, const coap_mid_t mid) { + coap_pdu_t *sent, coap_pdu_t *received, + const coap_mid_t mid) { /* Remove (void) definition if variable is used */ (void)ctx; (void)session; diff --git a/man/coap_io.txt.in b/man/coap_io.txt.in index 9be629ac56..d3439a1473 100644 --- a/man/coap_io.txt.in +++ b/man/coap_io.txt.in @@ -374,7 +374,7 @@ main(int argc, char *argv[]) { fd_set readfds = m_readfds; int result; /* Wait until any i/o takes place */ - result = select (nfds, &readfds, NULL, NULL, NULL); + result = select(nfds, &readfds, NULL, NULL, NULL); if (result == -1) { if (errno != EAGAIN) { coap_log_debug("select: %s (%d)\n", coap_socket_strerror(), errno); @@ -473,8 +473,7 @@ main(int argc, char *argv[]) { /* There is an internal issue */ break; } - } - else { + } else { /* Process other events */ } } diff --git a/man/coap_observe.txt.in b/man/coap_observe.txt.in index cfdfd1064d..4271105742 100644 --- a/man/coap_observe.txt.in +++ b/man/coap_observe.txt.in @@ -168,8 +168,8 @@ coap_resource_t *time_resource = NULL; static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[40]; size_t len; time_t now; @@ -187,8 +187,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { if (query != NULL && coap_string_equal(query, coap_make_str_const("secs"))) { /* Output secs since Jan 1 1970 */ len = snprintf((char *)buf, sizeof(buf), "%lu", now); - } - else { + } else { /* Output human-readable time */ struct tm *tmp; tmp = gmtime(&now); @@ -221,8 +220,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_get_generic(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { coap_str_const_t *uri_path = coap_resource_get_uri_path(resource); if (!uri_path) { @@ -246,9 +245,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { /* Initialize generic GET handler */ static void -init_resources(coap_context_t *ctx) -{ - +init_resources(coap_context_t *ctx) { coap_resource_t *r; /* Create a resource to return return or update time */ @@ -281,7 +278,7 @@ main(int argc, char *argv[]) { (void)argc; (void)argv; - memset (&tv_last, 0, sizeof(tv_last)); + memset(&tv_last, 0, sizeof(tv_last)); /* Create the libcoap context */ ctx = coap_new_context(NULL); @@ -304,10 +301,10 @@ main(int argc, char *argv[]) { wait_ms = COAP_RESOURCE_CHECK_TIME * 1000; while (1) { - int result = coap_io_process( ctx, wait_ms ); - if ( result < 0 ) { + int result = coap_io_process(ctx, wait_ms); + if (result < 0) { break; - } else if ( result && (unsigned)result < wait_ms ) { + } else if (result && (unsigned)result < wait_ms) { /* decrement if there is a result wait time returned */ wait_ms -= result; } else { @@ -321,7 +318,7 @@ main(int argc, char *argv[]) { } if (time_resource) { struct timeval tv_now; - if (gettimeofday (&tv_now, NULL) == 0) { + if (gettimeofday(&tv_now, NULL) == 0) { if (tv_last.tv_sec != tv_now.tv_sec) { /* Happens once per second */ tv_last = tv_now; @@ -355,9 +352,9 @@ static unsigned char msgtype = COAP_MESSAGE_CON; static unsigned int token = 0; static coap_pdu_t * -coap_new_request(coap_context_t *context, coap_session_t *session, char request_code, -coap_optlist_t **options, unsigned char *data, size_t length, int observe) { - +coap_new_request(coap_context_t *context, coap_session_t *session, + char request_code, coap_optlist_t **options, + unsigned char *data, size_t length, int observe) { coap_pdu_t *pdu; /* Remove (void) definition if variable is used */ (void)context; @@ -373,7 +370,7 @@ coap_optlist_t **options, unsigned char *data, size_t length, int observe) { * delayed responses */ token++; - if (!coap_add_token(pdu, sizeof(token), (unsigned char*)&token)) { + if (!coap_add_token(pdu, sizeof(token), (unsigned char *)&token)) { coap_log_debug("cannot add token to request\n"); goto error; } @@ -382,7 +379,7 @@ coap_optlist_t **options, unsigned char *data, size_t length, int observe) { /* Indicate that we want to observe this resource */ if (!coap_insert_optlist(options, coap_new_optlist(COAP_OPTION_OBSERVE, - COAP_OBSERVE_ESTABLISH, NULL))) + COAP_OBSERVE_ESTABLISH, NULL))) goto error; } diff --git a/man/coap_oscore.txt.in b/man/coap_oscore.txt.in index efc371aa83..35f594f8ac 100644 --- a/man/coap_oscore.txt.in +++ b/man/coap_oscore.txt.in @@ -217,17 +217,17 @@ EXAMPLES #include static uint8_t oscore_config[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "server_id,ascii,\"client\"\n" - "recipient_id,ascii,\"server\"\n" - "replay_window,integer,30\n" - "aead_alg,integer,10\n" - "hkdf_alg,integer,-10\n" -; + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "server_id,ascii,\"client\"\n" + "recipient_id,ascii,\"server\"\n" + "replay_window,integer,30\n" + "aead_alg,integer,10\n" + "hkdf_alg,integer,-10\n" + ; static FILE *oscore_seq_num_fp = NULL; /* Not a particularly safe place to keep next Sender Sequence Number ... */ -static const char* oscore_seq_save_file = "/tmp/client.seq"; +static const char *oscore_seq_save_file = "/tmp/client.seq"; static int oscore_save_seq_num(uint64_t sender_seq_num, void *param COAP_UNUSED) { @@ -240,7 +240,7 @@ oscore_save_seq_num(uint64_t sender_seq_num, void *param COAP_UNUSED) { } static coap_session_t * -setup_client_session (struct in_addr ip_address) { +setup_client_session(struct in_addr ip_address) { coap_session_t *session; coap_address_t server; /* See coap_context(3) */ @@ -257,10 +257,10 @@ setup_client_session (struct in_addr ip_address) { coap_address_init(&server); server.addr.sa.sa_family = AF_INET; server.addr.sin.sin_addr = ip_address; - server.addr.sin.sin_port = htons (5683); + server.addr.sin.sin_port = htons(5683); if (coap_oscore_is_supported()) { - coap_str_const_t config = { sizeof (oscore_config), oscore_config }; + coap_str_const_t config = { sizeof(oscore_config), oscore_config }; uint64_t start_seq_num = 0; coap_oscore_conf_t *oscore_conf; @@ -271,7 +271,7 @@ setup_client_session (struct in_addr ip_address) { oscore_seq_num_fp = fopen(oscore_seq_save_file, "w+"); if (oscore_seq_num_fp == NULL) { coap_log_err("OSCORE save restart info file error: %s\n", - oscore_seq_save_file); + oscore_seq_save_file); return NULL; } } @@ -305,17 +305,17 @@ setup_client_session (struct in_addr ip_address) { #include static uint8_t oscore_config[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,ascii,\"server\"\n" - "recipient_id,ascii,\"client\"\n" - "replay_window,integer,30\n" - "aead_alg,integer,10\n" - "hkdf_alg,integer,-10\n" -; + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,ascii,\"server\"\n" + "recipient_id,ascii,\"client\"\n" + "replay_window,integer,30\n" + "aead_alg,integer,10\n" + "hkdf_alg,integer,-10\n" + ; static FILE *oscore_seq_num_fp = NULL; /* Not a particularly safe place to keep next Sender Sequence Number ... */ -static const char* oscore_seq_save_file = "/tmp/server.seq"; +static const char *oscore_seq_save_file = "/tmp/server.seq"; static int oscore_save_seq_num(uint64_t sender_seq_num, void *param COAP_UNUSED) { @@ -328,7 +328,7 @@ oscore_save_seq_num(uint64_t sender_seq_num, void *param COAP_UNUSED) { } static int -setup_context (void) { +setup_context(void) { /* See coap_context(3) */ coap_context_t *context = coap_new_context(NULL); @@ -340,7 +340,7 @@ setup_context (void) { COAP_BLOCK_USE_LIBCOAP | COAP_BLOCK_SINGLE_BODY); if (coap_oscore_is_supported()) { - coap_str_const_t config = { sizeof (oscore_config), oscore_config }; + coap_str_const_t config = { sizeof(oscore_config), oscore_config }; uint64_t start_seq_num = 0; coap_oscore_conf_t *oscore_conf; @@ -351,7 +351,7 @@ setup_context (void) { oscore_seq_num_fp = fopen(oscore_seq_save_file, "w+"); if (oscore_seq_num_fp == NULL) { coap_log_err("OSCORE save restart info file error: %s\n", - oscore_seq_save_file); + oscore_seq_save_file); return 0; } } @@ -367,7 +367,6 @@ setup_context (void) { } return 1; } - ---- SEE ALSO diff --git a/man/coap_pdu_access.txt.in b/man/coap_pdu_access.txt.in index d0b8fd50d4..e946f5bc3a 100644 --- a/man/coap_pdu_access.txt.in +++ b/man/coap_pdu_access.txt.in @@ -396,7 +396,7 @@ get_pdu_information(coap_pdu_t *pdu) { coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL); while ((option = coap_option_next(&opt_iter))) { coap_log_info("A: Option %d, Length %u\n", - opt_iter.number, coap_opt_length(option)); + opt_iter.number, coap_opt_length(option)); } /* Iterate through options, some ignored */ coap_option_filter_clear(&ignore_options); @@ -404,12 +404,10 @@ get_pdu_information(coap_pdu_t *pdu) { coap_option_iterator_init(pdu, &opt_iter, &ignore_options); while ((option = coap_option_next(&opt_iter))) { coap_log_info("I: Option %d, Length %u\n", - opt_iter.number, coap_opt_length(option)); + opt_iter.number, coap_opt_length(option)); } /* Pull in the payload information */ - ret = coap_get_data(pdu, &pdu_data_length, &pdu_data); - /* or */ ret = coap_get_data_large(pdu, &pdu_data_length, &pdu_data, &pdu_data_offset, &pdu_data_total_length); diff --git a/man/coap_pdu_setup.txt.in b/man/coap_pdu_setup.txt.in index 46251a4249..481af390aa 100644 --- a/man/coap_pdu_setup.txt.in +++ b/man/coap_pdu_setup.txt.in @@ -569,9 +569,9 @@ EXAMPLES static int build_send_pdu(coap_context_t *context, coap_session_t *session, -uint8_t msgtype, uint8_t request_code, const char *uri, const char *query, -unsigned char *data, size_t length, int observe) { - + uint8_t msgtype, uint8_t request_code, const char *uri, + const char *query, unsigned char *data, size_t length, + int observe) { coap_pdu_t *pdu; uint8_t buf[1024]; size_t buflen; @@ -600,11 +600,12 @@ unsigned char *data, size_t length, int observe) { if (uri) { /* Add in the URI options */ buflen = sizeof(buf); - res = coap_split_path((const uint8_t*)uri, strlen(uri), sbuf, &buflen); + res = coap_split_path((const uint8_t *)uri, strlen(uri), sbuf, &buflen); while (res--) { if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_URI_PATH, - coap_opt_length(sbuf), coap_opt_value(sbuf)))) + coap_opt_length(sbuf), + coap_opt_value(sbuf)))) goto error; sbuf += coap_opt_size(sbuf); } @@ -613,11 +614,12 @@ unsigned char *data, size_t length, int observe) { if (query) { /* Add in the QUERY options */ buflen = sizeof(buf); - res = coap_split_query((const uint8_t*)query, strlen(query), sbuf, &buflen); + res = coap_split_query((const uint8_t *)query, strlen(query), sbuf, &buflen); while (res--) { if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_URI_QUERY, - coap_opt_length(sbuf), coap_opt_value(sbuf)))) + coap_opt_length(sbuf), + coap_opt_value(sbuf)))) goto error; sbuf += coap_opt_size(sbuf); } @@ -627,9 +629,9 @@ unsigned char *data, size_t length, int observe) { /* Indicate that we want to observe this resource */ if (!coap_insert_optlist(&optlist_chain, coap_new_optlist(COAP_OPTION_OBSERVE, - coap_encode_var_safe(buf, sizeof(buf), - COAP_OBSERVE_ESTABLISH), buf) - )) + coap_encode_var_safe(buf, sizeof(buf), + COAP_OBSERVE_ESTABLISH), buf) + )) goto error; } @@ -668,8 +670,8 @@ error: static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[40]; size_t len; time_t now; @@ -683,8 +685,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { if (query != NULL && coap_string_equal(query, coap_make_str_const("secs"))) { /* Output secs since Jan 1 1970 */ len = snprintf((char *)buf, sizeof(buf), "%lu", now); - } - else { + } else { /* Output human-readable time */ struct tm *tmp; tmp = gmtime(&now); diff --git a/man/coap_persist.txt.in b/man/coap_persist.txt.in index bd279218f2..0daa001970 100644 --- a/man/coap_persist.txt.in +++ b/man/coap_persist.txt.in @@ -213,8 +213,8 @@ coap_resource_t *time_resource = NULL; static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[40]; size_t len; time_t now; @@ -232,8 +232,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { if (query != NULL && coap_string_equal(query, coap_make_str_const("secs"))) { /* Output secs since Jan 1 1970 */ len = snprintf((char *)buf, sizeof(buf), "%lu", now); - } - else { + } else { /* Output human-readable time */ struct tm *tmp; tmp = gmtime(&now); @@ -266,8 +265,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_get_generic(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { coap_str_const_t *uri_path = coap_resource_get_uri_path(resource); if (!uri_path) { @@ -291,9 +290,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { /* Initialize generic GET handler */ static void -init_resources(coap_context_t *ctx) -{ - +init_resources(coap_context_t *ctx) { coap_resource_t *r; /* Create a resource to return return or update time */ @@ -325,7 +322,7 @@ main(int argc, char *argv[]) { /* Initialize libcoap library */ coap_startup(); - memset (&tv_last, 0, sizeof(tv_last)); + memset(&tv_last, 0, sizeof(tv_last)); /* Create the libcoap context */ ctx = coap_new_context(NULL); @@ -356,10 +353,10 @@ main(int argc, char *argv[]) { wait_ms = COAP_RESOURCE_CHECK_TIME * 1000; while (1) { - int result = coap_io_process( ctx, wait_ms ); - if ( result < 0 ) { + int result = coap_io_process(ctx, wait_ms); + if (result < 0) { break; - } else if ( result && (unsigned)result < wait_ms ) { + } else if (result && (unsigned)result < wait_ms) { /* decrement if there is a result wait time returned */ wait_ms -= result; } else { @@ -373,7 +370,7 @@ main(int argc, char *argv[]) { } if (time_resource) { struct timeval tv_now; - if (gettimeofday (&tv_now, NULL) == 0) { + if (gettimeofday(&tv_now, NULL) == 0) { if (tv_last.tv_sec != tv_now.tv_sec) { /* Happens once per second */ tv_last = tv_now; diff --git a/man/coap_resource.txt.in b/man/coap_resource.txt.in index 731687224e..e0043619a0 100644 --- a/man/coap_resource.txt.in +++ b/man/coap_resource.txt.in @@ -311,7 +311,8 @@ EXAMPLES static void hnd_get_index(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { unsigned char buf[3]; /* Remove (void) definition if variable is used */ (void)resource; @@ -338,7 +339,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_delete_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)resource; (void)session; @@ -352,7 +354,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_get_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)resource; (void)session; @@ -367,7 +370,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_put_time(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)resource; (void)session; @@ -429,7 +433,8 @@ init_resources(coap_context_t *ctx) { static void hnd_delete(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)session; (void)request; @@ -449,8 +454,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_get(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { - + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { coap_str_const_t *get_uri_path; /* Remove (void) definition if variable is used */ @@ -476,7 +481,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { static void hnd_put(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)resource; (void)session; @@ -525,7 +531,8 @@ check_url_fn(coap_string_t *uri_path, uint8_t code) { static void hnd_put_unknown(coap_resource_t *resource, coap_session_t *session, -const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { + const coap_pdu_t *request, const coap_string_t *query, + coap_pdu_t *response) { /* Remove (void) definition if variable is used */ (void)resource; coap_pdu_code_t req_code = coap_pdu_get_code(request); @@ -541,7 +548,7 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { } /* Check if new URI Path is valid */ - if (!check_url_fn (uri_path, req_code)) { + if (!check_url_fn(uri_path, req_code)) { coap_pdu_set_code(response, COAP_RESPONSE_CODE_NOT_FOUND); coap_delete_string(uri_path); return; @@ -551,8 +558,8 @@ const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response) { * Create a resource to handle the new URI * uri_path will get deleted when the resource is removed */ - r = coap_resource_init((coap_str_const_t*)uri_path, - COAP_RESOURCE_FLAGS_RELEASE_URI | COAP_RESOURCE_FLAGS_NOTIFY_NON); + r = coap_resource_init((coap_str_const_t *)uri_path, + COAP_RESOURCE_FLAGS_RELEASE_URI | COAP_RESOURCE_FLAGS_NOTIFY_NON); coap_register_request_handler(r, COAP_REQUEST_PUT, hnd_put); coap_register_request_handler(r, COAP_REQUEST_DELETE, hnd_delete); /* We possibly want to Observe the GETs */ diff --git a/man/coap_uri.txt.in b/man/coap_uri.txt.in index 971ada2748..c4d397a084 100644 --- a/man/coap_uri.txt.in +++ b/man/coap_uri.txt.in @@ -175,7 +175,7 @@ parse_and_send_uri(coap_session_t *session, const char *do_uri) { unsigned char buf[BUFSIZE]; /* Parse the URI */ - res = coap_split_uri((const uint8_t*)do_uri, strlen(do_uri), &uri); + res = coap_split_uri((const uint8_t *)do_uri, strlen(do_uri), &uri); if (res != 0) return 0; @@ -240,7 +240,6 @@ parse_and_send_uri(coap_session_t *session, const char *do_uri) { return 0; return 1; } - ---- SEE ALSO