VS 2013 changes for csdk
authorDave Thaler <dthaler@microsoft.com>
Fri, 27 May 2016 01:06:41 +0000 (18:06 -0700)
committerDavid Antler <david.a.antler@intel.com>
Thu, 2 Jun 2016 17:42:02 +0000 (17:42 +0000)
Change-Id: Ib4c437c96c80327eb80e259d4f937696afbe1002
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8361
Reviewed-by: David Antler <david.a.antler@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
22 files changed:
resource/c_common/platform_features.h
resource/c_common/windows/include/vs12_snprintf.h
resource/c_common/windows/include/win_sleep.h
resource/csdk/connectivity/common/src/camutex_pthreads.c
resource/csdk/connectivity/lib/libcoap-4.1.1/address.h
resource/csdk/connectivity/lib/libcoap-4.1.1/async.h
resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h
resource/csdk/connectivity/lib/libcoap-4.1.1/block.h
resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h
resource/csdk/connectivity/lib/libcoap-4.1.1/config.h
resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c
resource/csdk/connectivity/lib/libcoap-4.1.1/net.c
resource/csdk/connectivity/lib/libcoap-4.1.1/net.h
resource/csdk/connectivity/lib/libcoap-4.1.1/option.c
resource/csdk/connectivity/lib/libcoap-4.1.1/option.h
resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h
resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h
resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c
resource/csdk/security/src/directpairing.c
resource/examples/winuiclientgui.cpp
resource/src/OCResource.cpp

index e2289d4..762d26e 100644 (file)
@@ -50,7 +50,7 @@
 #  if defined(__cplusplus)
 #    define INLINE_API inline
 #  else
-#    ifdef _WIN32
+#    ifdef _MSC_VER
 #      define INLINE_API static __inline
 #    else
 #      define INLINE_API static inline
index 6595b95..37f1d3f 100644 (file)
@@ -24,6 +24,8 @@
 extern "C" {
 #endif
 
+#include <stdlib.h>
+
 int vs12_snprintf(char *buffer, size_t count, const char *format, ...);
 
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
index c9b8fd7..8cd1479 100644 (file)
 extern "C" {
 #endif
 
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+struct timespec
+{
+    time_t tv_sec;  // Seconds - >= 0
+    long   tv_nsec; // Nanoseconds - [0, 999999999]
+};
+#endif
+
 int nanosleep(const struct timespec *req, struct timespec *rem);
 int usleep(unsigned int usec);
 
index 564a354..aa77eb0 100644 (file)
@@ -58,6 +58,7 @@
 #include <errno.h>
 #include <assert.h>
 #include <oic_malloc.h>
+#include "platform_features.h"
 #include "camutex.h"
 #include "logger.h"
 
index 37e8235..c26784c 100644 (file)
@@ -99,7 +99,7 @@ typedef struct coap_address_t
     }addr;
 }coap_address_t;
 
-static inline int
+INLINE_API int
 _coap_address_equals_impl(const coap_address_t *a,
         const coap_address_t *b)
 {
@@ -124,7 +124,7 @@ _coap_address_equals_impl(const coap_address_t *a,
     return 0;
 }
 
-static inline int
+INLINE_API int
 _coap_is_mcast_impl(const coap_address_t *a)
 {
     if (!a)
@@ -151,7 +151,7 @@ typedef struct coap_address_t
     uint8_t      addr[DEV_ADDR_SIZE_MAX]; /**< device address. */
 } coap_address_t;
 
-static inline int
+INLINE_API int
 _coap_address_equals_impl(const coap_address_t *a,
                           const coap_address_t *b)
 {
@@ -171,7 +171,7 @@ _coap_address_equals_impl(const coap_address_t *a,
     return 1;
 }
 
-static inline int
+INLINE_API int
 _coap_is_mcast_impl(const coap_address_t *a)
 {
     if (!a)
@@ -190,7 +190,7 @@ _coap_is_mcast_impl(const coap_address_t *a)
  *
  * @param addr The coap_address_t object to initialize.
  */
-static inline void coap_address_init(coap_address_t *addr)
+INLINE_API void coap_address_init(coap_address_t *addr)
 {
     assert(addr);
     memset(addr, 0, sizeof(coap_address_t));
@@ -205,7 +205,7 @@ static inline void coap_address_init(coap_address_t *addr)
  * @c 1 if addresses are equal, @c 0 otherwise. The parameters @p a
  * and @p b must not be @c NULL;
  */
-static inline int coap_address_equals(const coap_address_t *a, const coap_address_t *b)
+INLINE_API int coap_address_equals(const coap_address_t *a, const coap_address_t *b)
 {
     assert(a);
     assert(b);
@@ -216,7 +216,7 @@ static inline int coap_address_equals(const coap_address_t *a, const coap_addres
  * Checks if given address @p a denotes a multicast address.  This
  * function returns @c 1 if @p a is multicast, @c 0 otherwise.
  */
-static inline int coap_is_mcast(const coap_address_t *a)
+INLINE_API int coap_is_mcast(const coap_address_t *a)
 {
     return a && _coap_is_mcast_impl(a);
 }
index 879cb38..0319827 100644 (file)
@@ -136,7 +136,7 @@ coap_async_state_t *coap_find_async(coap_context_t *context, coap_tid_t id);
  *
  * @param s The state object to update.
  */
-static inline void coap_touch_async(coap_async_state_t *s)
+INLINE_API void coap_touch_async(coap_async_state_t *s)
 {
     coap_ticks(&s->created);
 }
index 9add64f..3ac7fe1 100644 (file)
@@ -31,7 +31,7 @@
  *
  * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise.
  */
-inline static int bits_setb(uint8_t *vec, size_t size, uint8_t bit)
+INLINE_API int bits_setb(uint8_t *vec, size_t size, uint8_t bit)
 {
     if (size <= (size_t)(bit >> 3))
         return -1;
@@ -51,7 +51,7 @@ inline static int bits_setb(uint8_t *vec, size_t size, uint8_t bit)
  *
  * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise.
  */
-inline static int bits_clrb(uint8_t *vec, size_t size, uint8_t bit)
+INLINE_API int bits_clrb(uint8_t *vec, size_t size, uint8_t bit)
 {
     if (size <= (size_t)(bit >> 3))
         return -1;
@@ -70,7 +70,7 @@ inline static int bits_clrb(uint8_t *vec, size_t size, uint8_t bit)
  *
  * @return @c 1 if the bit is set, @c 0 otherwise.
  */
-inline static int bits_getb(const uint8_t *vec, size_t size, uint8_t bit)
+INLINE_API int bits_getb(const uint8_t *vec, size_t size, uint8_t bit)
 {
     if (size <= (size_t)(bit >> 3))
         return -1;
index 2d5ef07..bd660ef 100644 (file)
@@ -71,13 +71,13 @@ unsigned int coap_opt_block_num(const coap_opt_t *block_opt);
  * Checks if more than @p num blocks are required to deliver @p data_len
  * bytes of data for a block size of 1 << (@p szx + 4).
  */
-static inline int coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx)
+INLINE_API int coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx)
 {
     return ((num + 1) << (szx + 4)) < data_len;
 }
 
 /** Sets the More-bit in @p block_opt */
-static inline void coap_opt_block_set_m(coap_opt_t *block_opt, int m)
+INLINE_API void coap_opt_block_set_m(coap_opt_t *block_opt, int m)
 {
     if (m)
         *(COAP_OPT_VALUE(block_opt) + (COAP_OPT_LENGTH(block_opt) - 1)) |= 0x08;
index b2c70e4..64d1b26 100644 (file)
@@ -47,12 +47,12 @@ extern "C"
 
     typedef uint32_t coap_tick_t;
 
-    static inline void coap_ticks_impl(coap_tick_t *t)
+    INLINE_API void coap_ticks_impl(coap_tick_t *t)
     {
         *t = sys_now();
     }
 
-    static inline void coap_clock_init_impl(void)
+    INLINE_API void coap_clock_init_impl(void)
     {
     }
 
@@ -78,7 +78,7 @@ extern "C"
     /** Set at startup to initialize the internal clock (time in seconds). */
     extern clock_time_t clock_offset;
 
-    static inline void
+    INLINE_API void
     contiki_clock_init_impl(void)
     {
         clock_init();
@@ -87,7 +87,7 @@ extern "C"
 
 #define coap_clock_init contiki_clock_init_impl
 
-    static inline void
+    INLINE_API void
     contiki_ticks_impl(coap_tick_t *t)
     {
         *t = clock_time();
@@ -137,7 +137,7 @@ extern time_t clock_offset;
 #endif /* WITH_ARDUINO */
 
 #ifndef coap_clock_init
-    static inline void coap_clock_init_impl(void)
+    INLINE_API void coap_clock_init_impl(void)
     {
 #ifdef HAVE_TIME_H
         clock_offset = time(NULL);
@@ -162,7 +162,7 @@ extern time_t clock_offset;
 #endif /* coap_clock_init */
 
 #ifndef coap_ticks
-    static inline void coap_ticks_impl(coap_tick_t *t)
+    INLINE_API void coap_ticks_impl(coap_tick_t *t)
     {
 #ifdef HAVE_SYS_TIME_H
         struct timeval tv;
@@ -195,7 +195,7 @@ extern time_t clock_offset;
      * Returns @c 1 if and only if @p a is less than @p b where less is
      * defined on a signed data type.
      */
-    static inline
+    INLINE_API
     int coap_time_lt(coap_tick_t a, coap_tick_t b)
     {
         return ((coap_tick_diff_t)(a - b)) < 0;
@@ -205,7 +205,7 @@ extern time_t clock_offset;
      * Returns @c 1 if and only if @p a is less than or equal @p b where
      * less is defined on a signed data type.
      */
-    static inline
+    INLINE_API
     int coap_time_le(coap_tick_t a, coap_tick_t b)
     {
         return a == b || coap_time_lt(a, b);
index 1f3bc9b..622e795 100644 (file)
 # endif
 #endif
 
+#ifndef INLINE_API
+#  if defined(__cplusplus)
+#    define INLINE_API inline
+#  else
+#    ifdef _MSC_VER
+#      define INLINE_API static __inline
+#    else
+#      define INLINE_API static inline
+#    endif
+#  endif
+#endif
+
 /* Define to rpl_malloc if the replacement function should be used. */
 /* #undef malloc */
 
index 0169ae8..589e1c3 100644 (file)
@@ -53,7 +53,7 @@ static char *loglevels[] =
 
 #ifdef HAVE_TIME_H
 
-static inline size_t print_timestamp(char *s, size_t len, coap_tick_t t)
+INLINE_API size_t print_timestamp(char *s, size_t len, coap_tick_t t)
 {
     struct tm *tmp;
     time_t now = clock_offset + (t / COAP_TICKS_PER_SECOND);
@@ -63,7 +63,7 @@ static inline size_t print_timestamp(char *s, size_t len, coap_tick_t t)
 
 #else /* alternative implementation: just print the timestamp */
 
-static inline size_t
+INLINE_API size_t
 print_timestamp(char *s, size_t len, coap_tick_t t)
 {
 #ifdef HAVE_SNPRINTF
@@ -89,7 +89,7 @@ print_timestamp(char *s, size_t len, coap_tick_t t)
  *
  * @return The length of @p s.
  */
-static inline size_t
+INLINE_API size_t
 strnlen(const char *s, size_t maxlen)
 {
     size_t n = 0;
index 8e6f3b6..48e0455 100644 (file)
 
 time_t clock_offset=0;
 
-static inline coap_queue_t *
+INLINE_API coap_queue_t *
 coap_malloc_node()
 {
     return (coap_queue_t *)coap_malloc(sizeof(coap_queue_t));
 }
 
-static inline void
+INLINE_API void
 coap_free_node(coap_queue_t *node)
 {
     coap_free(node);
@@ -79,13 +79,13 @@ coap_free_node(coap_queue_t *node)
 static void coap_retransmittimer_execute(void *arg);
 static void coap_retransmittimer_restart(coap_context_t *ctx);
 
-static inline coap_queue_t *
+INLINE_API coap_queue_t *
 coap_malloc_node()
 {
     return (coap_queue_t *)memp_malloc(MEMP_COAP_NODE);
 }
 
-static inline void
+INLINE_API void
 coap_free_node(coap_queue_t *node)
 {
     memp_free(MEMP_COAP_NODE, node);
@@ -115,13 +115,13 @@ MEMB(node_storage, coap_queue_t, COAP_PDU_MAXCNT);
 
 PROCESS(coap_retransmit_process, "message retransmit process");
 
-static inline coap_queue_t *
+INLINE_API coap_queue_t *
 coap_malloc_node()
 {
     return (coap_queue_t *)memb_alloc(&node_storage);
 }
 
-static inline void
+INLINE_API void
 coap_free_node(coap_queue_t *node)
 {
     memb_free(&node_storage, node);
@@ -888,7 +888,7 @@ coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node)
  * This function returns @c 1 on success, or @c 0 if the option @p opt
  * would exceed @p maxpos.
  */
-static inline int check_opt_size(coap_opt_t *opt, unsigned char *maxpos)
+INLINE_API int check_opt_size(coap_opt_t *opt, unsigned char *maxpos)
 {
     if (opt && opt < maxpos)
     {
@@ -1076,7 +1076,7 @@ int coap_remove_from_queue(coap_queue_t **queue, coap_tid_t id, coap_queue_t **n
 
 }
 
-static inline int token_match(const unsigned char *a, size_t alen, const unsigned char *b,
+INLINE_API int token_match(const unsigned char *a, size_t alen, const unsigned char *b,
         size_t blen)
 {
     return alen == blen && (alen == 0 || memcmp(a, b, alen) == 0);
@@ -1238,7 +1238,7 @@ coap_new_error_response(coap_pdu_t *request, unsigned char code, coap_opt_filter
  * Quick hack to determine the size of the resource description for
  * .well-known/core.
  */
-static inline size_t get_wkc_len(coap_context_t *context, coap_opt_t *query_filter)
+INLINE_API size_t get_wkc_len(coap_context_t *context, coap_opt_t *query_filter)
 {
     unsigned char buf[1];
     size_t len = 0;
@@ -1513,7 +1513,7 @@ void handle_request(coap_context_t *context, coap_queue_t *node, const char* res
     }
 }
 
-static inline void handle_response(coap_context_t *context, coap_queue_t *sent, coap_queue_t *rcvd)
+INLINE_API void handle_response(coap_context_t *context, coap_queue_t *sent, coap_queue_t *rcvd)
 {
 
     /* Call application-specific reponse handler when available.  If
@@ -1531,7 +1531,7 @@ static inline void handle_response(coap_context_t *context, coap_queue_t *sent,
     }
 }
 
-static inline int
+INLINE_API int
 #ifdef __GNUC__
 handle_locally(coap_context_t *context __attribute__ ((unused)),
         coap_queue_t *node __attribute__ ((unused)))
index d2868b5..bd86b19 100644 (file)
@@ -155,7 +155,7 @@ extern "C"
      * @param context The context to register the handler for.
      * @param handler The response handler to register.
      */
-    static inline void coap_register_response_handler(coap_context_t *context,
+    INLINE_API void coap_register_response_handler(coap_context_t *context,
             coap_response_handler_t handler)
     {
         context->response_handler = handler;
@@ -168,7 +168,7 @@ extern "C"
      * @param ctx  The context to use.
      * @param type The option type to register.
      */
-    inline static void coap_register_option(coap_context_t *ctx, unsigned char type)
+    INLINE_API void coap_register_option(coap_context_t *ctx, unsigned char type)
     {
         coap_option_setb(ctx->known_options, type);
     }
@@ -197,7 +197,7 @@ extern "C"
  * @param context the current coap_context_t object
  * @return incremented message id in network byte order
  */
-static inline unsigned short coap_new_message_id(coap_context_t *context)
+INLINE_API unsigned short coap_new_message_id(coap_context_t *context)
 {
     ++(context->message_id);
 #if defined(WITH_ARDUINO)
@@ -317,7 +317,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context)
      * @return The transaction id if RST was sent or @c COAP_INVALID_TID
      * on error.
      */
-    static inline coap_tid_t coap_send_rst(coap_context_t *context, const coap_address_t *dst,
+    INLINE_API coap_tid_t coap_send_rst(coap_context_t *context, const coap_address_t *dst,
             coap_pdu_t *request)
     {
         return coap_send_message_type(context, dst, request, COAP_MESSAGE_RST);
@@ -372,7 +372,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context)
      *
      * @return @c 1 if node was found, removed and destroyed, @c 0 otherwise.
      */
-    inline static int coap_remove_transaction(coap_queue_t **queue, coap_tid_t id)
+    INLINE_API int coap_remove_transaction(coap_queue_t **queue, coap_tid_t id)
     {
         coap_queue_t *node;
         if (!coap_remove_from_queue(queue, id, &node))
index ea60aab..60bb865 100644 (file)
@@ -208,7 +208,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi,
     return oi;
 }
 
-static inline int opt_finished(coap_opt_iterator_t *oi)
+INLINE_API int opt_finished(coap_opt_iterator_t *oi)
 {
     assert(oi);
 
index 9c33ac8..8441d5a 100644 (file)
@@ -112,7 +112,7 @@ typedef unsigned char coap_opt_filter_t[(COAP_MAX_OPT >> 3) + 1];
  *
  * @param f The filter to clear.
  */
-static inline void coap_option_filter_clear(coap_opt_filter_t f)
+INLINE_API void coap_option_filter_clear(coap_opt_filter_t f)
 {
     memset(f, 0, sizeof(coap_opt_filter_t));
 }
@@ -127,7 +127,7 @@ static inline void coap_option_filter_clear(coap_opt_filter_t f)
  *
  * @return @c 1 if bit was set, @c -1 otherwise.
  */
-inline static int coap_option_setb(coap_opt_filter_t filter, unsigned short type)
+INLINE_API int coap_option_setb(coap_opt_filter_t filter, unsigned short type)
 {
     return bits_setb((uint8_t *) filter, sizeof(coap_opt_filter_t), type);
 }
@@ -142,7 +142,7 @@ inline static int coap_option_setb(coap_opt_filter_t filter, unsigned short type
  *
  * @return @c 1 if bit was set, @c -1 otherwise.
  */
-inline static int coap_option_clrb(coap_opt_filter_t filter, unsigned short type)
+INLINE_API int coap_option_clrb(coap_opt_filter_t filter, unsigned short type)
 {
     return bits_clrb((uint8_t *) filter, sizeof(coap_opt_filter_t), type);
 }
@@ -157,7 +157,7 @@ inline static int coap_option_clrb(coap_opt_filter_t filter, unsigned short type
  *
  * @return @c 1 if bit was set, @c 0 if not, @c -1 on error.
  */
-inline static int coap_option_getb(const coap_opt_filter_t filter, unsigned short type)
+INLINE_API int coap_option_getb(const coap_opt_filter_t filter, unsigned short type)
 {
     return bits_getb((uint8_t *) filter, sizeof(coap_opt_filter_t), type);
 }
index 25e7720..8e2b85b 100644 (file)
@@ -29,7 +29,7 @@
  * implementation for prng().  You might want to change prng() to use
  * a better PRNG on your specific platform.
  */
-static inline int coap_prng_impl(unsigned char *buf, size_t len)
+INLINE_API int coap_prng_impl(unsigned char *buf, size_t len)
 {
     while (len--)
         *buf++ = rand() & 0xFF;
@@ -43,7 +43,7 @@ static inline int coap_prng_impl(unsigned char *buf, size_t len)
  * implementation for prng().  You might want to change prng() to use
  * a better PRNG on your specific platform.
  */
-static inline int
+INLINE_API int
 contiki_prng_impl(unsigned char *buf, size_t len)
 {
     unsigned short v = random_rand();
index 9382615..2349be1 100644 (file)
@@ -220,7 +220,7 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, unsigned ch
  * @param method   The CoAP request method to handle.
  * @param handler  The handler to register with @p resource.
  */
-static inline void coap_register_handler(coap_resource_t *resource, unsigned char method,
+INLINE_API void coap_register_handler(coap_resource_t *resource, unsigned char method,
         coap_method_handler_t handler)
 {
     assert(resource);
index 5f25f96..60fb972 100644 (file)
@@ -91,30 +91,30 @@ struct list
     (struct_ptr)->LIST_CONCAT(name,_list) = NULL;           \
   }
 
-static inline void *
+INLINE_API void *
 list_head(list_t the_list)
 {
     return *the_list;
 }
 
-static inline void list_remove(list_t the_list, void *item)
+INLINE_API void list_remove(list_t the_list, void *item)
 {
     if (list_head(the_list))
         LL_DELETE(*(struct list **)the_list, (struct list *)item);
 }
 
-static inline void list_add(list_t the_list, void *item)
+INLINE_API void list_add(list_t the_list, void *item)
 {
     list_remove(the_list, item);
     LL_APPEND(*(struct list **)the_list, (struct list *)item);
 }
 
-static inline void list_push(list_t the_list, void *item)
+INLINE_API void list_push(list_t the_list, void *item)
 {
     LL_PREPEND(*(struct list **)the_list, (struct list *)item);
 }
 
-static inline void *
+INLINE_API void *
 list_pop(list_t the_list)
 {
     struct list *l;
@@ -125,7 +125,7 @@ list_pop(list_t the_list)
     return l;
 }
 
-static inline void list_insert(list_t the_list, void *previtem, void *newitem)
+INLINE_API void list_insert(list_t the_list, void *previtem, void *newitem)
 {
     if (previtem == NULL)
     {
@@ -138,7 +138,7 @@ static inline void list_insert(list_t the_list, void *previtem, void *newitem)
     }
 }
 
-static inline void *
+INLINE_API void *
 list_item_next(void *item)
 {
     return item == NULL ? NULL : ((struct list *) item)->next;
index 42dab60..d496e72 100644 (file)
@@ -32,7 +32,7 @@
  * @return A pointer to the first occurence of @p c, or @c NULL
  * if not found.
  */
-static inline unsigned char *
+INLINE_API unsigned char *
 strnchr(unsigned char *s, size_t len, unsigned char c)
 {
     while (len && *s++ != c)
@@ -493,7 +493,7 @@ coap_clone_uri(const coap_uri_t *uri)
 
 /* The function signature of coap_hash() is different from
  * segment_handler_t hence we use this wrapper as safe typecast. */
-static inline void hash_segment(unsigned char *s, size_t len, void *data)
+INLINE_API void hash_segment(unsigned char *s, size_t len, void *data)
 {
     coap_hash(s, len, (unsigned char *) data);
 }
index 68eb118..b22ca5b 100644 (file)
@@ -956,9 +956,6 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime)
     }\r
 \r
     OCStackResult ret;\r
-    struct timespec startTime = {.tv_sec=0, .tv_nsec=0};\r
-    struct timespec currTime  = {.tv_sec=0, .tv_nsec=0};\r
-    struct timespec timeout;\r
 \r
     const char DP_DISCOVERY_QUERY[] = "/oic/sec/pconf";\r
 \r
@@ -979,13 +976,17 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime)
     }\r
 \r
     // wait..\r
-    timeout.tv_sec  = 0;\r
-    timeout.tv_nsec = 100000000L;\r
 \r
     int clock_res = -1;\r
+#if defined(_MSC_VER)\r
+    time_t startTime;\r
+    clock_res = (time(&startTime) == -1);\r
+#else\r
+    struct timespec startTime = {.tv_sec=0, .tv_nsec=0};\r
 #if defined(__ANDROID__) || _POSIX_TIMERS > 0\r
     clock_res = clock_gettime(CLOCK_MONOTONIC, &startTime);\r
 #endif\r
+#endif\r
     if (0 != clock_res)\r
     {\r
         OIC_LOG(ERROR, TAG, "clock error");\r
@@ -998,31 +999,38 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime)
 \r
     while (1)\r
     {\r
+#if defined(_MSC_VER)\r
+        time_t currTime;\r
+        clock_res = (time(&currTime) == -1);\r
+#else\r
+        struct timespec currTime  = {.tv_sec=0, .tv_nsec=0};\r
 #if defined(__ANDROID__) || _POSIX_TIMERS > 0\r
         clock_res = clock_gettime(CLOCK_MONOTONIC, &currTime);\r
 #endif\r
+#endif\r
         if (0 != clock_res)\r
         {\r
             OIC_LOG(ERROR, TAG, "clock error");\r
             ret = OC_STACK_ERROR;\r
             break;\r
         }\r
+#if defined(_MSC_VER)\r
+        long elapsed = currTime - startTime;\r
+#else\r
         long elapsed = (currTime.tv_sec - startTime.tv_sec);\r
+#endif\r
         if (elapsed > waittime)\r
         {\r
             break;\r
         }\r
         else\r
         {\r
-#if defined(_WIN32)\r
-            Sleep(100);\r
-#else\r
+            struct timespec timeout = {.tv_sec=0, .tv_nsec=100000000L};\r
             nanosleep(&timeout, NULL);\r
-#endif // defined (_WIN32)\r
         }\r
     }\r
 \r
-    //Waiting for each response.\r
+    // Waiting for each response.\r
     ret = OCCancel(handle, OC_LOW_QOS, NULL, 0);\r
     if (OC_STACK_OK != ret)\r
     {\r
index c8273a8..596bb4e 100644 (file)
@@ -171,15 +171,17 @@ WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
         }
         break;
       case WM_CREATE:
-          hIcon1 = LoadIcon (NULL, IDI_WARNING);
-          SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1);
-          GetClientRect(hwnd, &rect);
-          g_BkgndBrush = GetSysColorBrush(COLOR_MENU);
-
-          app = new WinUIClient::WinUIClientApp({client_open, fread, fwrite, fclose, unlink });
-          app->Initialize();
-          app->Run();
-
+          {
+              hIcon1 = LoadIcon (NULL, IDI_WARNING);
+              SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1);
+              GetClientRect(hwnd, &rect);
+              g_BkgndBrush = GetSysColorBrush(COLOR_MENU);
+
+              OCPersistentStorage ps = {client_open, fread, fwrite, fclose, unlink };
+              app = new WinUIClient::WinUIClientApp(ps);
+              app->Initialize();
+              app->Run();
+          }
           break;
       case WM_DESTROY:
 
index 49a9703..b381b9f 100644 (file)
@@ -75,15 +75,15 @@ OCResource::OCResource(std::weak_ptr<IClientWrapper> clientWrapper,
                         const std::vector<std::string>& interfaces)
  :  m_clientWrapper(clientWrapper), m_uri(uri),
     m_resourceId(serverId, m_uri),
-    m_devAddr{ OC_DEFAULT_ADAPTER, OC_DEFAULT_FLAGS, 0, {0}, 0
-#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
-    , {0}
-#endif
-    },
     m_isObservable(observable), m_isCollection(false),
     m_resourceTypes(resourceTypes), m_interfaces(interfaces),
     m_observeHandle(nullptr)
 {
+    m_devAddr = OCDevAddr{OC_DEFAULT_ADAPTER, OC_DEFAULT_FLAGS, 0, {0}, 0,
+#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
+                          {0}
+#endif
+                        };
     m_isCollection = std::find(m_interfaces.begin(), m_interfaces.end(), LINK_INTERFACE)
                         != m_interfaces.end();
 
@@ -464,7 +464,7 @@ OCStackResult OCResource::cancelObserve(QualityOfService QoS)
 
     OCStackResult result =  checked_guard(m_clientWrapper.lock(),
             &IClientWrapper::CancelObserveResource,
-            m_observeHandle, "", m_uri, m_headerOptions, QoS);
+            m_observeHandle, (const char*)"", m_uri, m_headerOptions, QoS);
 
     if(result == OC_STACK_OK)
     {