Skip to content

Commit

Permalink
Fix travis issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
  • Loading branch information
dthaler committed Jan 27, 2017
1 parent ccc0f01 commit bc69a9f
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 55 deletions.
9 changes: 9 additions & 0 deletions coap_config.h.contiki
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,14 @@ typedef void FILE;
#include <stdio.h>
#define coap_log(fd, ...) printf(__VA_ARGS__)

/* Make libcoap headers safe to use from C++ */
#ifndef COAP_STATIC_INLINE
# if defined(__cplusplus)
# define COAP_STATIC_INLINE inline
# else
# define COAP_STATIC_INLINE static inline
# endif
#endif

#endif /* _CONFIG_H_ */

9 changes: 9 additions & 0 deletions coap_config.h.lwip
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@

#define COAP_RESOURCES_NOHASH

/* Make libcoap headers safe to use from C++ */
#ifndef COAP_STATIC_INLINE
# if defined(__cplusplus)
# define COAP_STATIC_INLINE inline
# else
# define COAP_STATIC_INLINE static inline
# endif
#endif

#endif /* _CONFIG_H_ */
3 changes: 3 additions & 0 deletions coap_config.h.windows
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
/* Define to the full name of this package. */
#define PACKAGE_NAME "libcoap"

/* Define to the version of this package. */
#define PACKAGE_VERSION "4.1.1"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libcoap 4.1.1"

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fi

# Checks for header files.
AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h \
stdlib.h string.h strings.h sys/socket.h sys/time.h \
stdlib.h string.h strings.h sys/select.h sys/socket.h sys/time.h \
time.h unistd.h sys/unistd.h syslog.h])

# Checks for typedefs, structures, and compiler characteristics.
Expand Down
47 changes: 32 additions & 15 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#else
# include "getopt.h"
#endif
#include <stdio.h>
#include <ctype.h>
#include <sys/select.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif

#include "coap.h"
#include "coap_append.h"
#include "coap_list.h"

int flags = 0;
Expand Down Expand Up @@ -61,7 +76,9 @@ coap_tick_t max_wait; /* global timeout (changed by set_timeou
unsigned int obs_seconds = 30; /* default observe time */
coap_tick_t obs_wait = 0; /* timeout for current subscription */

#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif

#ifdef __GNUC__
#define UNUSED_PARAM __attribute__ ((unused))
Expand Down Expand Up @@ -694,7 +711,7 @@ cmdline_uri(char *arg, int create_uri_opts) {
if (proxy.length) { /* create Proxy-Uri from argument */
size_t len = strlen(arg);
while (len > 270) {
coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_PROXY_URI,
270,
(unsigned char *)arg));
Expand All @@ -703,7 +720,7 @@ cmdline_uri(char *arg, int create_uri_opts) {
arg += 270;
}

coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_PROXY_URI,
len,
(unsigned char *)arg));
Expand All @@ -714,7 +731,7 @@ cmdline_uri(char *arg, int create_uri_opts) {
}

if (uri.port != COAP_DEFAULT_PORT && create_uri_opts) {
coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_URI_PORT,
coap_encode_var_bytes(portbuf, uri.port),
portbuf));
Expand All @@ -725,7 +742,7 @@ cmdline_uri(char *arg, int create_uri_opts) {
res = coap_split_path(uri.path.s, uri.path.length, buf, &buflen);

while (res--) {
coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_URI_PATH,
COAP_OPT_LENGTH(buf),
COAP_OPT_VALUE(buf)));
Expand All @@ -740,7 +757,7 @@ cmdline_uri(char *arg, int create_uri_opts) {
res = coap_split_query(uri.query.s, uri.query.length, buf, &buflen);

while (res--) {
coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_URI_QUERY,
COAP_OPT_LENGTH(buf),
COAP_OPT_VALUE(buf)));
Expand Down Expand Up @@ -792,14 +809,14 @@ set_blocksize(void) {
opt_length = coap_encode_var_bytes(buf,
(block.num << 4 | block.m << 3 | block.szx));

coap_insert(&optlist, new_option_node(opt, opt_length, buf));
coap_append(&optlist, new_option_node(opt, opt_length, buf));
}
}

static void
cmdline_subscribe(char *arg) {
obs_seconds = atoi(arg);
coap_insert(&optlist, new_option_node(COAP_OPTION_SUBSCRIPTION, 0, NULL));
coap_append(&optlist, new_option_node(COAP_OPTION_SUBSCRIPTION, 0, NULL));
}

static int
Expand Down Expand Up @@ -852,7 +869,7 @@ cmdline_option(char *arg) {
if (*arg == ',')
++arg;

coap_insert(&optlist,
coap_append(&optlist,
new_option_node(num, strlen(arg), (unsigned char *)arg));
}

Expand Down Expand Up @@ -1212,7 +1229,7 @@ main(int argc, char **argv) {
&& create_uri_opts) {
/* add Uri-Host */

coap_insert(&optlist,
coap_append(&optlist,
new_option_node(COAP_OPTION_URI_HOST,
uri.host.length,
uri.host.s));
Expand Down
26 changes: 2 additions & 24 deletions examples/coap_list.c → examples/coap_append.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@

#include "debug.h"
#include "mem.h"
#include "coap_list.h"

#include "coap_append.h"

int
coap_insert(coap_list_t **head, coap_list_t *node) {
coap_append(coap_list_t **head, coap_list_t *node) {
if (!node) {
coap_log(LOG_WARNING, "cannot create option Proxy-Uri\n");
} else {
Expand All @@ -30,24 +29,3 @@ coap_insert(coap_list_t **head, coap_list_t *node) {

return node != NULL;
}

int
coap_delete(coap_list_t *node) {
if (node) {
coap_free(node);
}
return 1;
}

void
coap_delete_list(coap_list_t *queue) {
coap_list_t *elt, *tmp;

if (!queue)
return;

LL_FOREACH_SAFE(queue, elt, tmp) {
coap_delete(elt);
}
}

20 changes: 5 additions & 15 deletions examples/coap_list.h → examples/coap_append.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,16 @@
* use.
*/

#ifndef _COAP_LIST_H_
#define _COAP_LIST_H_
#ifndef _COAP_APPEND_H_
#define _COAP_APPEND_H_

#include "utlist.h"

typedef struct coap_list_t {
struct coap_list_t *next;
char data[];
} coap_list_t;
#include "coap_list.h"

/**
* Adds node to given queue, ordered by specified order function. Returns 1
* when insert was successful, 0 otherwise.
*/
int coap_insert(coap_list_t **queue, coap_list_t *node);

/* destroys specified node */
int coap_delete(coap_list_t *node);

/* removes all items from given queue and frees the allocated storage */
void coap_delete_list(coap_list_t *queue);
int coap_append(coap_list_t **queue, coap_list_t *node);

#endif /* _COAP_LIST_H_ */
#endif /* _COAP_APPEND_H_ */
4 changes: 4 additions & 0 deletions include/coap/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ typedef struct coap_context_t {
int sockfd; /**< send/receive socket */
#endif /* WITH_POSIX */

#ifdef HAVE_WS2TCPIP_H
SOCKET sockfd; /**< send/receive socket */
#endif /* HAVE_WS2TCPIP_H */

#ifdef WITH_CONTIKI
struct uip_udp_conn *conn; /**< uIP connection object */
struct etimer retransmit_timer; /**< fires when the next packet must be sent */
Expand Down
1 change: 1 addition & 0 deletions include/coap/utlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ do {
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
LDECLTYPE(list) _tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
Expand Down

0 comments on commit bc69a9f

Please sign in to comment.