solaris: define ioctl

solaris: define ioctl

git-svn-id: 27e0aca8c7a52a9ae65dfba2e16879604119af8c@1127 93a4e39c-3214-0410-bb16-828d8e3bcd0f

--- lib/apr_net.c
+++ lib/apr_net.c
@@ -22,6 +22,8 @@

 #ifdef SOLARIS
 #include <sys/sockio.h>  /* for SIOCGIFADDR */
+#include <unistd.h>      /* for ioctl */
+#include <stropts.h>
 #endif

 #include "error.h"


[mod_cgi] fix detection of failing error handler (fixes #3157)

(thx sparlane)

failing error handler produced no output and POLLRDHUP received with
POLLIN.

commit dd23fcb2 changed return value from HANDER_FINISHED to
HANDLER_GO_ON when introducing cgi_process_rd_revents(), and POLLRDHUP
case which previously fell through needed to continue to return
HANDLER_FINISHED after calling cgi_connection_close()

x-ref:
  "fall-back with cgi error handler no longer works"
  https://redmine.lighttpd.net/issues/3157

--- src/mod_cgi.c
+++ src/mod_cgi.c
@@ -639,6 +639,7 @@
 			if (0 == r->http_status) r->http_status = 200; /* OK */
 		}
 		cgi_connection_close(hctx);
+		return HANDLER_FINISHED;
 	} else if (revents & FDEVENT_ERR) {
 		/* kill all connections to the cgi process */
 		cgi_connection_close(hctx);


[cgi] cgi start and parse request immediatly

--- src/mod_cgi.c
+++ src/mod_cgi.c
@@ -388,7 +388,7 @@
 	int ret;

 	ret = httpmessage_parsecgi(response, chunk, &rest);
-	cgi_dbg("cgi: parse %d data %d %d\n%s#", ret, size, rest, chunk);
+	cgi_dbg("cgi: parse %d data %d\n%s#", ret, rest, chunk);
 	if (ret == ECONTINUE && ctx->state < STATE_HEADERCOMPLETE)
 	{
 #if defined(RESULT_302)
@@ -432,6 +432,7 @@
 		}
 		else if (size < 1)
 		{
+			warn("cgi died");
 			ctx->state = STATE_CONTENTCOMPLETE;
 		}
 		else
@@ -470,16 +471,17 @@
 	if (ctx == NULL)
 	{
 		ret = _cgi_start(mod, request, response);
-		if (ret == EINCOMPLETE)
-		{
-			ctx = httpmessage_private(request, NULL);
-			_cgi_request(ctx, request);
-		}
-		return ret;
+		if (ret != EINCOMPLETE)
+			return ret;
+		ctx = httpmessage_private(request, NULL);
+		_cgi_request(ctx, request);
 	}
 	else if (ctx->tocgi[1] > 0 && ctx->state == STATE_START)
 	{
 		_cgi_request(ctx, request);
+		/**
+		 * Read the request. The connector is still EINCOMPLETE
+		 */
 	}
 	/**
 	 * when the request is complete the module must check the CGI immedialty
@@ -500,15 +502,15 @@
 	else if ((ctx->state & STATE_MASK) == STATE_CONTENTCOMPLETE)
 	{
 		close(ctx->fromcgi[0]);
-		httpmessage_parsecgi(response, NULL, 0);
+		ret = httpmessage_parsecgi(response, NULL, 0);
 		ret = ECONTINUE;
 		ctx->state = STATE_OUTFINISH | STATE_SHUTDOWN;
 	}
 	else if ((ctx->state & STATE_MASK) == STATE_OUTFINISH)
 	{
-		long long length;
+		unsigned long long length;
 		ret = httpmessage_content(response, NULL, &length);
-		cgi_dbg("content len %d %lld", ret, length);
+		cgi_dbg("content len %d %llu", ret, length);
 		if (ret == 0)
 			ctx->state = STATE_END | STATE_SHUTDOWN;
 		ret = ECONTINUE;


mod_psa: change !psa to list only IDs, unless ID given as argument.

--- src/mod_psa.c
+++ src/mod_psa.c
@@ -38,7 +38,7 @@
 		[PSA_ADD]  = "<name> [+live] [+trigger '<str>'] <N>m <text> | Adds/updates a PSA named <name> to occur every <N> mins."
 		             "With +live, only show when the channel is live. With +trigger, only show when <str> is said.",
 		[PSA_DEL]  = "<name> | Remove the psa identified by <name>.",
-		[PSA_LIST] = "| Show the PSAs for the current channel."
+		[PSA_LIST] = "[id] | Show info about a PSA or list them all."
 	),
 	.help_url = "https://insobot.handmade.network/forums/t/2393",
 };
@@ -124,7 +124,7 @@
 		[-S_NEGATIVE_FREQ] = "The minute frequency must be > 0",
 		[-S_UNKNOWN_TOKEN] = "Could not parse command",
 	};
-
+
 	static struct {
 		const char* name;
 		int state;
@@ -251,6 +251,36 @@
 	}
 }

+static void psa_info(const char* chan, const char* name, const char* id) {
+	PSAData* psa = NULL;
+
+	sb_each(p, psa_data) {
+		if(strcmp(p->channel, chan) == 0 && strcmp(p->id, id) == 0) {
+			psa = p;
+			break;
+		}
+	}
+
+	if(!psa) {
+		ctx->send_msg(chan, "%s: psa [%s] not found.", name, id);
+		return;
+	}
+
+	char buf[1024] = "";
+	char* p = buf;
+	size_t sz = sizeof(buf);
+
+	if(psa->trigger)
+		snprintf_chain(&p, &sz, " (trigger:%s)", psa->trigger);
+	if(psa->when_live)
+		snprintf_chain(&p, &sz, " (live)");
+	if(*psa->message == '!')
+		snprintf_chain(&p, &sz, " (alias:%.*s)", (int)strcspn(psa->message, " "), psa->message);
+
+	ctx->send_msg(chan, "psa [%s]: %dm%s", psa->id, psa->freq_mins, buf);
+
+}
+
 static void psa_cmd(const char* chan, const char* name, const char* arg, int cmd){
 	if(!inso_is_wlist(ctx, name)) return;

@@ -278,26 +308,24 @@
 		} break;

 		case PSA_LIST: {
-			char psa_buf[512] = "(none)";
+
+			if(*arg++) {
+				psa_info(chan, name, arg);
+				break;
+			}
+
+			char psa_buf[512] = "";
 			char* psa_ptr = psa_buf;
 			size_t psa_sz = sizeof(psa_buf);

 			sb_each(p, psa_data){
-				if(strcmp(p->channel, chan) != 0) continue;
-
-				char optbuf[128] = "";
-				char* o = optbuf;
-				size_t osz = sizeof(optbuf);
-
-				if(p->trigger)
-					snprintf_chain(&o, &osz, " (trigger:%s)", p->trigger);
-				if(p->when_live)
-					snprintf_chain(&o, &osz, " (live)");
-				if(*p->message == '!')
-					snprintf_chain(&o, &osz, " (alias:%.*s)", (int)strcspn(p->message, " "), p->message);
-
-				snprintf_chain(&psa_ptr, &psa_sz, "[%s: %dm%s] ", p->id, p->freq_mins, optbuf);
-			}
+				if(strcmp(p->channel, chan) != 0)
+					continue;
+				snprintf_chain(&psa_ptr, &psa_sz, "%s ", p->id);
+			}
+
+			if(!*psa_buf)
+				strcpy(psa_buf, "(none)");

 			ctx->send_msg(chan, "Current PSAs: %s", psa_buf);


Monitor: remove auto-renewing subscription when device logs out.

--- src/monitor.c
+++ src/monitor.c
@@ -21,8 +21,8 @@
 }

 // function prototypes
-void monitor_subscribe_internal(mapper_monitor mon, const char *device_name,
-                                int subscribe_flags, int timeout);
+static void monitor_subscribe_internal(mapper_monitor mon, const char *device_name,
+                                       int subscribe_flags, int timeout);

 typedef enum _db_request_direction {
     DIRECTION_IN,
@@ -121,8 +121,8 @@
     mapper_admin_set_bundle_dest_bus(mon->admin);
 }

-void monitor_subscribe_internal(mapper_monitor mon, const char *device_name,
-                                int subscribe_flags, int timeout)
+static void monitor_subscribe_internal(mapper_monitor mon, const char *device_name,
+                                       int subscribe_flags, int timeout)
 {
     char cmd[1024];
     snprintf(cmd, 1024, "%s/subscribe", device_name);
@@ -194,15 +194,9 @@
     monitor_subscribe_internal(mon, device_name, subscribe_flags, timeout);
 }

-void mapper_monitor_unsubscribe(mapper_monitor mon, const char *device_name)
-{
-    char cmd[1024];
-    snprintf(cmd, 1024, "%s/unsubscribe", device_name);
-    mapper_monitor_set_bundle_dest(mon, device_name);
-    lo_message m = lo_message_new();
-    if (m)
-        mapper_admin_bundle_message(mon->admin, -1, cmd, "");
-
+static void mapper_monitor_remove_subscription_internal(mapper_monitor mon,
+                                                        const char *device_name)
+{
     // check if autorenewing subscription exists
     mapper_monitor_subscription *s = &mon->subscriptions;
     while (*s) {
@@ -217,6 +211,18 @@
         }
         s = &(*s)->next;
     }
+}
+
+void mapper_monitor_unsubscribe(mapper_monitor mon, const char *device_name)
+{
+    char cmd[1024];
+    snprintf(cmd, 1024, "%s/unsubscribe", device_name);
+    mapper_monitor_set_bundle_dest(mon, device_name);
+    lo_message m = lo_message_new();
+    if (m)
+        mapper_admin_bundle_message(mon->admin, -1, cmd, "");
+
+    mapper_monitor_remove_subscription_internal(mon, device_name);
 }

 static int request_signals_by_device_name_internal(mapper_monitor mon,
@@ -781,13 +787,15 @@
                                     mapper_db_action_t a,
                                     void *user)
 {
-    if (a == MDB_NEW)
-    {
-        mapper_monitor mon = (mapper_monitor)(user);
-
+    mapper_monitor mon = (mapper_monitor)(user);
+
+    if (a == MDB_NEW) {
         // Subscribe to signals, links, and/or connections for new devices.
         if (mon->autosubscribe)
             mapper_monitor_subscribe(mon, dev->name, mon->autosubscribe, -1);
+    }
+    else if (a == MDB_REMOVE) {
+        mapper_monitor_remove_subscription_internal(mon, dev->name);
     }
 }


Fixed typo in monitor.c (#414)

Fixed typo in monitor.c (#414)

--- src/monitor.c
+++ src/monitor.c
@@ -372,7 +372,7 @@
 static inline void check_max_sendto_failures(export_status_t *exp) {
 	if (zconf.max_sendto_failures >= 0 &&
 			exp->fail_total > (uint32_t)zconf.max_sendto_failures) {
-		log_fatal("monitor", "maxiumum number of sendto failures (%i) exceeded",
+		log_fatal("monitor", "maximum number of sendto failures (%i) exceeded",
 				zconf.max_sendto_failures);
 	}
 }
@@ -417,4 +417,3 @@
 		fclose(f);
 	}
 }
-


Arguments to mp_digit_msb_shift and mp_digit_lsb_shift must be non-zero.

--- src/mp_util.c
+++ src/mp_util.c
@@ -232,19 +232,17 @@
 unsigned
 mp_digit_msb_shift(mp_digit u)
 {
+	ASSERT(u);
+
+	unsigned steps = 0;
+#if MP_DIGIT_BITS != 8
 #if MP_DIGIT_BITS == 16
-	mp_digit high8 = UINT16_C(0xff00);
+	const mp_digit high8 = UINT16_C(0xff00);
 #elif MP_DIGIT_BITS == 32
-	mp_digit high8 = UINT32_C(0xff000000);
+	const mp_digit high8 = UINT32_C(0xff000000);
 #elif MP_DIGIT_BITS == 64
-	mp_digit high8 = UINT64_C(0xff00000000000000);
-#endif
-	unsigned steps = 0;
-
-	if (!u)
-		return -1;
-
-#if MP_DIGIT_BITS != 8
+	const mp_digit high8 = UINT64_C(0xff00000000000000);
+#endif
 	while (!(u & high8))
 		steps += 8, u <<= 8;
 #endif
@@ -258,8 +256,7 @@
 unsigned
 mp_digit_lsb_shift(mp_digit u)
 {
-	if (!u)
-		return -1;
+	ASSERT(u);

 	unsigned steps = 0;
 #if MP_DIGIT_BITS != 8
@@ -289,7 +286,8 @@
 unsigned
 mp_odd_shift(const mp_digit *u, mp_size size)
 {
-	if (!mp_rsize(u, size))
+	MP_NORMALIZE(u, size);
+	if (!size)
 		return 0;

 	unsigned bits = 0;


msgr: fix uninitialized memory on sockaddr_storage print

--- src/msg/tcp.h
+++ src/msg/tcp.h
@@ -14,7 +14,7 @@

 inline ostream& operator<<(ostream& out, const sockaddr_storage &ss)
 {
-  char buf[NI_MAXHOST];
+  char buf[NI_MAXHOST] = { 0 };
   getnameinfo((struct sockaddr *)&ss, sizeof(ss), buf, sizeof(buf), 0, 0, NI_NUMERICHOST);
   return out << buf;
 }


edit handler_dev_mod to be a device callback passed a local dev

still need to edit the part where the callbacks are registered...

--- src/network.c
+++ src/network.c
@@ -955,8 +955,7 @@
 static int handler_dev_mod(const char *path, const char *types, lo_arg **av,
                            int ac, lo_message msg, void *user)
 {
-    mpr_net net = (mpr_net)user;
-    mpr_local_dev dev = net->devs ? net->devs[0] : 0;
+    mpr_local_dev dev = (mpr_local_dev)user;
     mpr_msg props;

     RETURN_ARG_UNLESS(dev && mpr_dev_get_is_ready((mpr_dev)dev)
@@ -964,7 +963,7 @@
     props = mpr_msg_parse_props(ac, types, av);
     trace_dev(dev, "received /%s/modify + %d properties.\n", path, props->num_atoms);
     if (mpr_dev_set_from_msg((mpr_dev)dev, props)) {
-        inform_device_subscribers(net, dev);
+        inform_device_subscribers(&dev->graph.net, dev);
         mpr_tbl_clear_empty(dev->obj.props.synced);
     }
     mpr_msg_free(props);


Remove left-over debugging output

Remove left-over debugging output

--- src/mwindow.c
+++ src/mwindow.c
@@ -89,7 +89,6 @@
 {
 	git_mwindow *w, *w_l;

-	puts("LRU");
 	for (w_l = NULL, w = mwf->windows; w; w = w->next) {
 		if (!w->inuse_cnt) {
 			/*
@@ -247,7 +246,6 @@
 	if (left)
 		*left = (unsigned int)(w->window_map.len - offset);

-	fflush(stdout);
 	return (unsigned char *) w->window_map.data + offset;
 }


fix compile error when ssl is not enabled

git-svn-id: c4e9838fefcfae554524937a357000afc2bbf25b@2812 152afb58-edef-0310-8abb-c4023f1b3aa9

--- src/network.c
+++ src/network.c
@@ -27,6 +27,7 @@
 # include <openssl/rand.h>
 #endif

+#ifdef USE_OPENSSL
 static void ssl_info_callback(const SSL *ssl, int where, int ret) {
 	UNUSED(ret);

@@ -37,6 +38,7 @@
 		ssl->s3->flags |= SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS;
 	}
 }
+#endif

 static handler_t network_server_handle_fdevent(server *srv, void *context, int revents) {
 	server_socket *srv_socket = (server_socket *)context;


bug fix on battery image selection

bug fix on battery image selection

--- src/natural.c
+++ src/natural.c
@@ -110,12 +110,12 @@
   } else {
     int percentage = charge_state.charge_percent;
     snprintf(log_buffer, 32, "PEBBLE: %d charged", percentage);
-    if (percentage >= 90) bitmap_layer_set_bitmap(battery_layer, batt_100_image);
-    else if (percentage < 80 && percentage >= 60) bitmap_layer_set_bitmap(battery_layer, batt_80_image);
-    else if (percentage < 60 && percentage >= 40) bitmap_layer_set_bitmap(battery_layer, batt_60_image);
-    else if (percentage < 40 && percentage >= 20) bitmap_layer_set_bitmap(battery_layer, batt_40_image);
-    else if (percentage < 20 && percentage >= 10) bitmap_layer_set_bitmap(battery_layer, batt_20_image);
-    else if (percentage < 10) bitmap_layer_set_bitmap(battery_layer, batt_10_image);
+    if (percentage > 80) bitmap_layer_set_bitmap(battery_layer, batt_100_image);
+    else if (percentage <= 80 && percentage > 60) bitmap_layer_set_bitmap(battery_layer, batt_80_image);
+    else if (percentage <= 60 && percentage > 40) bitmap_layer_set_bitmap(battery_layer, batt_60_image);
+    else if (percentage <= 40 && percentage > 20) bitmap_layer_set_bitmap(battery_layer, batt_40_image);
+    else if (percentage <= 20 && percentage > 10) bitmap_layer_set_bitmap(battery_layer, batt_20_image);
+    else if (percentage <= 10) bitmap_layer_set_bitmap(battery_layer, batt_10_image);
   }
   APP_LOG(APP_LOG_LEVEL_DEBUG, log_buffer);
 }


added TRACE for the default network-backend

git-svn-id: e98c317c6679dcf055eb388f05b44c3a6d6b38c6@1763 152afb58-edef-0310-8abb-c4023f1b3aa9

--- src/network.c
+++ src/network.c
@@ -516,6 +516,8 @@

 			return -1;
 		}
+	} else {
+		TRACE("using default network-backend: %s", network_backends[0].name);
 	}

 #define SET_NETWORK_BACKEND(read, write) \


Prefix newly added internal functions with ne_ and move above the exported nestegg_ functions.  Reorder has_cues to match the header.

--- src/nestegg.c
+++ src/nestegg.c
@@ -1500,6 +1500,112 @@
   return 0;
 }

+
+/* Three functions that implement the nestegg_io interface, operating on a
+ * sniff_buffer. */
+struct sniff_buffer {
+  unsigned char const * buffer;
+  size_t length;
+  int64_t offset;
+};
+
+static int
+ne_buffer_read(void * buffer, size_t length, void * user_data)
+{
+  struct sniff_buffer * sb = user_data;
+
+  int rv = 1;
+  size_t available = sb->length - sb->offset;
+
+  if (available < length) {
+    return 0;
+  }
+  memcpy(buffer, sb->buffer + sb->offset, length);
+  sb->offset += length;
+
+  return rv;
+}
+
+static int
+ne_buffer_seek(int64_t offset, int whence, void * user_data)
+{
+  struct sniff_buffer * sb = user_data;
+  int64_t o = sb->offset;
+
+  switch(whence) {
+    case NESTEGG_SEEK_SET:
+      o = offset;
+      break;
+    case NESTEGG_SEEK_CUR:
+      o += offset;
+      break;
+    case NESTEGG_SEEK_END:
+      o = sb->length + offset;
+      break;
+  }
+
+  if (o < 0 || o > (int64_t) sb->length) {
+    return -1;
+  }
+
+  sb->offset = o;
+  return 0;
+}
+
+static int64_t
+ne_buffer_tell(void * user_data)
+{
+  struct sniff_buffer * sb = user_data;
+  return sb->offset;
+}
+
+static int
+ne_match_webm(nestegg_io io, int64_t max_offset)
+{
+  int r;
+  uint64_t id;
+  char * doctype;
+  nestegg * ctx;
+
+  if (!(io.read && io.seek && io.tell))
+    return -1;
+
+  ctx = ne_alloc(sizeof(*ctx));
+
+  ctx->io = ne_alloc(sizeof(*ctx->io));
+  *ctx->io = io;
+  ctx->alloc_pool = ne_pool_init();
+  ctx->log = ne_null_log_callback;
+
+  r = ne_peek_element(ctx, &id, NULL);
+  if (r != 1) {
+    nestegg_destroy(ctx);
+    return 0;
+  }
+
+  if (id != ID_EBML) {
+    nestegg_destroy(ctx);
+    return 0;
+  }
+
+  ne_ctx_push(ctx, ne_top_level_elements, ctx);
+
+  /* we don't check the return value of ne_parse, that might fail because
+   * max_offset is not on a valid element end point. We only want to check
+   * the EBML ID and that the doctype is "webm". */
+  ne_parse(ctx, NULL, max_offset);
+
+  if (ne_get_string(ctx->ebml.doctype, &doctype) != 0 ||
+      strcmp(doctype, "webm") != 0) {
+    nestegg_destroy(ctx);
+    return 0;
+  }
+
+  nestegg_destroy(ctx);
+
+  return 1;
+}
+
 int
 nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset)
 {
@@ -1620,13 +1726,6 @@
 {
   *tracks = ctx->track_count;
   return 0;
-}
-
-int
-nestegg_has_cues(nestegg * ctx)
-{
-  return ctx->segment.cues.cue_point.head ||
-         ne_find_seek_for_id(ctx->segment.seek_head.head, ID_CUES);
 }

 int
@@ -2096,127 +2195,27 @@
   return -1;
 }

-/* Three functions that implement the nestegg_io interface, operating on a
- * sniff_buffer. */
-struct sniff_buffer {
-  unsigned char const * buffer;
-  size_t length;
-  int64_t offset;
-};
-
-static int
-buffer_read(void * buffer, size_t length, void * user_data)
-{
-  struct sniff_buffer * sb = (struct sniff_buffer *) user_data;
-
-  int rv = 1;
-  size_t available = sb->length - sb->offset;
-
-  if (available < length) {
-    return 0;
-  }
-  memcpy(buffer, sb->buffer + sb->offset, length);
-  sb->offset += length;
-
-  return rv;
-}
-
-static int
-buffer_seek(int64_t offset, int whence, void * user_data)
-{
-  struct sniff_buffer * sb = (struct sniff_buffer *) user_data;
-  int64_t o = sb->offset;
-
-  switch(whence) {
-    case NESTEGG_SEEK_SET:
-      o = offset;
-      break;
-    case NESTEGG_SEEK_CUR:
-      o += offset;
-      break;
-    case NESTEGG_SEEK_END:
-      o = sb->length + offset;
-      break;
-  }
-
-  if (o < 0 || o > sb->length) {
-    return -1;
-  }
-
-  sb->offset = o;
-  return 0;
-}
-
-static int64_t
-buffer_tell(void * user_data)
-{
-  struct sniff_buffer * sb = (struct sniff_buffer *) user_data;
-  return sb->offset;
-}
-
-static int
-match_webm(nestegg ** context, nestegg_io io, int64_t max_offset)
-{
-  int r;
-  uint64_t id;
-  char * doctype;
-  nestegg * ctx;
-
-  if (!(io.read && io.seek && io.tell))
-    return -1;
-
-  ctx = ne_alloc(sizeof(*ctx));
-
-  ctx->io = ne_alloc(sizeof(*ctx->io));
-  *ctx->io = io;
-  ctx->alloc_pool = ne_pool_init();
-  ctx->log = ne_null_log_callback;
-
-  r = ne_peek_element(ctx, &id, NULL);
-  if (r != 1) {
-    nestegg_destroy(ctx);
-    return 0;
-  }
-
-  if (id != ID_EBML) {
-    nestegg_destroy(ctx);
-    return 0;
-  }
-
-  ne_ctx_push(ctx, ne_top_level_elements, ctx);
-
-  /* we don't check the return value of ne_parse, that might fail because
-   * max_offset is not on a valid element end point. We only want to check
-   * the EBML ID and that the doctype is "webm". */
-  ne_parse(ctx, NULL, max_offset);
-
-  if (ne_get_string(ctx->ebml.doctype, &doctype) != 0 ||
-      strcmp(doctype, "webm") != 0) {
-    nestegg_destroy(ctx);
-    return 0;
-  }
-
-  nestegg_destroy(ctx);
-
-  return 1;
+int
+nestegg_has_cues(nestegg * ctx)
+{
+  return ctx->segment.cues.cue_point.head ||
+         ne_find_seek_for_id(ctx->segment.seek_head.head, ID_CUES);
 }

 int
 nestegg_sniff(unsigned char const * buffer, size_t length)
 {
   nestegg_io io;
-  nestegg * context;
   struct sniff_buffer user_data;
-  int r;

   user_data.buffer = buffer;
   user_data.length = length;
   user_data.offset = 0;

-  io.read = buffer_read;
-  io.seek = buffer_seek;
-  io.tell = buffer_tell;
+  io.read = ne_buffer_read;
+  io.seek = ne_buffer_seek;
+  io.tell = ne_buffer_tell;
   io.userdata = &user_data;
-  return match_webm(&context, io, length);
-}
-
+  return ne_match_webm(io, length);
+}
+


Network: Remove explicit yield(), change type of timeout parameter.

--- src/network.h
+++ src/network.h
@@ -5,9 +5,9 @@
 #include <cstdint>
 #include <cstring>
 #include <functional>
+#include <memory>
 #include <mutex>
 #include <sstream>
-#include <thread>
 #include <unordered_map>
 #include <utility>

@@ -57,7 +57,7 @@
   T udpBlockingReceiveUnsafe();

   template <typename T>
-  void tcpReadFromBuffer(int32_t timeout);
+  void tcpReadFromBuffer(std::chrono::microseconds timeout);

   Poco::Net::StreamSocket tcp_socket_;
   Poco::Net::DatagramSocket udp_socket_;
@@ -122,8 +122,8 @@
 }

 template <typename T>
-void Network::tcpReadFromBuffer(int32_t timeout) try {
-  if (!tcp_socket_.poll(timeout, Poco::Net::Socket::SELECT_READ)) {
+void Network::tcpReadFromBuffer(std::chrono::microseconds timeout) try {
+  if (!tcp_socket_.poll(timeout.count(), Poco::Net::Socket::SELECT_READ)) {
     return;
   }

@@ -170,12 +170,13 @@
 template <typename T>
 bool Network::tcpReceiveResponse(uint32_t command_id,
                                  std::function<void(const typename T::Response&)> handler) {
+  using namespace std::literals::chrono_literals;  // NOLINT (google-build-using-namespace)
   std::unique_lock<std::mutex> lock(tcp_mutex_, std::try_to_lock);
   if (!lock.owns_lock()) {
     return false;
   }

-  tcpReadFromBuffer<T>(0);
+  tcpReadFromBuffer<T>(0us);
   decltype(received_responses_)::const_iterator it = received_responses_.find(command_id);
   if (it != received_responses_.end()) {
     auto message =
@@ -190,14 +191,14 @@
 template <typename T>
 typename T::Response Network::tcpBlockingReceiveResponse(uint32_t command_id,
                                                          std::vector<uint8_t>* buffer) {
+  using namespace std::literals::chrono_literals;  // NOLINT (google-build-using-namespace)
   std::unique_lock<std::mutex> lock(tcp_mutex_, std::defer_lock);
   decltype(received_responses_)::const_iterator it;
   do {
     lock.lock();
-    tcpReadFromBuffer<T>(1e4);
+    tcpReadFromBuffer<T>(10'000us);
     it = received_responses_.find(command_id);
     lock.unlock();
-    std::this_thread::yield();
   } while (it == received_responses_.end());

   auto message =


adds print_header() for native ping mode

--- src/nfsping.c
+++ src/nfsping.c
@@ -1,6 +1,7 @@
 #include "nfsping.h"
 #include "util.h"
 #include "rpc.h"
+#include <sys/ioctl.h> /* for checking terminal size */

 /* Globals! */
 extern volatile sig_atomic_t quitting;
@@ -21,6 +22,7 @@
 static void print_summary(enum ping_outputs, unsigned long, targets_t *);
 static void print_result(enum ping_outputs, char *, targets_t *, unsigned long, u_long, const struct timespec, unsigned long);
 static void print_lost(enum ping_outputs, char *, targets_t *, unsigned long, u_long, const struct timespec);
+static void print_header(enum ping_outputs, unsigned int, unsigned long, u_long);

 /* global config "object" */
 static struct config {
@@ -342,6 +344,27 @@
         }
     }
     fflush(stdout);
+}
+
+
+/* prints a header line */
+void print_header(enum ping_outputs format, unsigned int maxhost, unsigned long prognum_offset, u_long version) {
+    int spacing = 5;
+
+    if (format == ping_ping) {
+        /* check that the biggest hostname isn't smaller than the protocol name */
+        maxhost = (strlen(null_dispatch[prognum_offset][version].protocol) > maxhost) ?
+            strlen(null_dispatch[prognum_offset][version].protocol) : maxhost;
+
+        printf("%-*s     RTT    %*s %*s %*s %*s %*s\n",
+            maxhost,
+            null_dispatch[prognum_offset][version].protocol,
+            spacing, "min",
+            spacing, "p50",
+            spacing, "p90",
+            spacing, "p99",
+            spacing, "max");
+    }
 }

@@ -387,6 +410,9 @@
         .sin_family = AF_INET,
         .sin_addr = INADDR_ANY
     };
+    struct winsize winsz;
+    unsigned short rows = 0; /* number of rows in terminal window */
+    unsigned int maxhost = 0; /* has to be int not size_t for printf width */

     cfg = CONFIG_DEFAULT;

@@ -793,6 +819,7 @@
             /* don't allocate space for storing results */
             target->next = make_target(argv[index], &hints, port, cfg.reverse_dns, cfg.display_ips, multiple, timeout, 0);
         }
+
         target = target->next;
     }

@@ -800,26 +827,38 @@
     targets = targets->next;
     target = targets;

-    /* check that the total waiting time between targets isn't going to cause us to miss our frequency (Hertz) */
-    if (wait_time.tv_sec || wait_time.tv_nsec) {
-        /* add up the wait interval for each target */
-        while (target) {
+    while (target) {
+        /* find the longest name for output spacing */
+        maxhost = (strlen(target->display_name) > maxhost) ? strlen(target->display_name) : maxhost;
+
+        /* check that the total waiting time between targets isn't going to cause us to miss our frequency (Hertz) */
+        if (wait_time.tv_sec || wait_time.tv_nsec) {
+            /* add up the wait interval for each target */
             timespecadd(&wait_time, &sleepy, &sleepy);

-            target = target->next;
+            if (timespeccmp(&sleepy, &sleep_time, >=)) {
+                fatal("wait interval (-i) doesn't allow polling frequency (-H)!\n");
+            }
         }

-        if (timespeccmp(&sleepy, &sleep_time, >=)) {
-            fatal("wait interval (-i) doesn't allow polling frequency (-H)!\n");
-        }
+        target = target->next;
     }

     /* reset to start of target list */
     target = targets;
+
+    /* print a header at the start */
+    if (!quiet) {
+        print_header(format, maxhost, prognum_offset, version);
+    }

     /* the main loop */
     while(target) {
         loop_count++;
+
+        /* find the current number of rows in the terminal for printing the header once per screen */
+        ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz);
+        rows = winsz.ws_row;

         /* grab the starting time of each loop */
 #ifdef CLOCK_MONOTONIC_RAW
@@ -872,6 +911,10 @@
             /* count this no matter what to stop from looping in case server isn't listening */
             target->sent++;
             total_sent++;
+
+            if (!quiet && (total_sent % rows == 0)) {
+                print_header(format, maxhost, prognum_offset, version);
+            }

             /* check for success */
             if (status) {


usage

usage

--- src/nfsping.c
+++ src/nfsping.c
@@ -51,7 +51,7 @@
     -M    use the portmapper (default: NFS no, mount yes)\n\
     -n    check the mount protocol (default NFS)\n\
     -p n  pause between pings to target (in ms, default %lu)\n\
-    -P n  specify port (default NFS:%i)\n\
+    -P n  specify port (default: NFS %i)\n\
     -q    quiet, only print summary\n\
     -t n  timeout (in ms, default %lu)\n\
     -T    use TCP (default UDP)\n",


adds rcv (received) column to native interval output

--- src/nfsping.c
+++ src/nfsping.c
@@ -166,8 +166,9 @@
         case ping_ping:
             /* only print times if we got any responses */
             if (target->received) {
-                printf("%s : %7.3f %7.3f %7.3f %7.3f %7.3f ms\n",
+                printf("%s : %3u %7.3f %7.3f %7.3f %7.3f %7.3f ms\n",
                     target->display_name,
+                    target->received,
                     hdr_min(target->interval_histogram) / 1000.0,
                     /* median not mean! */
                     hdr_value_at_percentile(target->interval_histogram, 50.0) / 1000.0,
@@ -360,7 +361,9 @@
             maxhost,
             null_dispatch[prognum_offset][version].protocol);

-        if (cfg.summary_interval == 0) {
+        if (cfg.summary_interval) {
+            printf("rcv ");
+        } else {
             printf("    RTT ");
         }


Add option to signal parent process when ptys are ready

Adds a --signal-parent (-s) command line option which, when specifies,
causes nulltty to send the designated signal to its parent process when
the pseudoterminals are ready to be opened. The intended purpose for
this is in nulltty's "make check" test suite, so that the controlling
test program knows when it is safe to begin.

--- src/nulltty.c
+++ src/nulltty.c
@@ -12,13 +12,14 @@
 #include "ptys.h"

+#define SIG_NAME_MAX 128
+
 static volatile sig_atomic_t exit_flag = 0;

 static void sigterm_handler(int signum)
 {
     exit_flag = 1;
 }
-

 static void print_usage(int retval)
 {
@@ -37,8 +38,12 @@
         "\t-d, --daemonize\n"
         "\t\tDaemonize the program\n"
         "\n"
-        "\t-p, --pid-file=file\n"
+        "\t-p <file>, --pid-file=<file>\n"
         "\t\tWrite PID file\n"
+        "\n"
+        "\t-s <sig>, --signal-parent=<sig>\n"
+        "\t\tNotify nulltty's parent process with the given signal when\n"
+        "\t\tthe pseoduterminals are ready\n"
         "\n"
         "\t-h, --help\n"
         "\t\tShow this help message and exit\n"
@@ -69,23 +74,70 @@
     return -1;
 }

+static int upcase(char *str, size_t size)
+{
+    size_t i;
+
+    for ( i = 0; i < size && str[i] != '\0'; i++ ) {
+        if ( str[i] >= 0x61 && str[i] <= 0x7a )
+            str[i] -= 0x20;
+    }
+
+    return i;
+}
+
+static int sig_num(const char *sig_name)
+{
+    char name[SIG_NAME_MAX];
+    int result = -1;
+    char *endptr = name;
+
+    if ( strlcpy(name, sig_name, SIG_NAME_MAX) < 0 )
+        return -1;
+
+    upcase(name, SIG_NAME_MAX);
+
+    result = strtol(name, &endptr, 10);
+    if ( *endptr == '\0' && name[0] != '\0' )
+        return result;
+
+    /* wannabe lisper */
+#define CHECK_SIG(NAME) do {                                            \
+        if ( strncmp(#NAME, name, SIG_NAME_MAX) == 0 )                  \
+            return SIG ## NAME;                                         \
+    } while ( 0 )
+
+    CHECK_SIG(HUP);
+    CHECK_SIG(INT);
+    CHECK_SIG(KILL);
+    CHECK_SIG(TERM);
+#ifdef SIGINFO
+    CHECK_SIG(INFO);
+#endif
+    CHECK_SIG(USR1);
+    CHECK_SIG(USR2);
+
+    return -1;
+}

 int main(int argc, char* argv[])
 {
     nulltty_t nulltty;
     int longindex, c = 0;
-    const char *options = "hdp:v";
+    const char *options = "hdvp:s:";
     const struct option long_options[] = {
-        {"help",      no_argument,       NULL, 'h'},
-        {"daemonize", no_argument,       NULL, 'd'},
-        {"pid-file",  required_argument, NULL, 'p'},
-        {"verbose",   required_argument, NULL, 'v'},
+        {"help",          no_argument,       NULL, 'h'},
+        {"daemonize",     no_argument,       NULL, 'd'},
+        {"verbose",       no_argument,       NULL, 'v'},
+        {"pid-file",      required_argument, NULL, 'p'},
+        {"signal-parent", required_argument, NULL, 's'},
     };
     bool daemonize = false;
     char *pid_path = NULL;
     const char *link_a, *link_b;
     struct sigaction action;
     int status = 0;
+    int signum = -1;

     /*** Establish signal handlers ***/

@@ -122,6 +174,14 @@
         case 'p':
             pid_path = optarg;
             break;
+
+        case 's':
+            signum = sig_num(optarg);
+            if ( signum < 0 ) {
+                fprintf(stderr, "Invalid signal name: %s", optarg);
+                exit(1);
+            }
+            break;
         }
     }

@@ -158,6 +218,14 @@
         perror("Error opening requested PTYs");
         status = 1;
         goto end_pid;
+    }
+
+    if ( signum != -1 ) {
+        if ( kill(getppid(), signum) < 0 ) {
+            perror("Unable to signal parent");
+            status = 1;
+            goto end_nulltty;
+        }
     }

     /*** Pseudoterminal data shuffling main loop ***/


Consistent daemonized pid, symlink relative path handling

When daemonizing, change to the root directory before creating the pid
file and pty symlinks in order to allow cleanup of relative files and
links, without holding open the original working directory.
Unfortunately this requires full path names for files and links when
using the -d option.

--- src/nulltty.c
+++ src/nulltty.c
@@ -138,8 +138,6 @@
     int status = 0;
     int signum = -1;

-    /*** Establish signal handlers ***/
-
     memset(&action, 0, sizeof(action));
     sigemptyset(&action.sa_mask);

@@ -156,8 +154,6 @@
         perror("Unable to establish SIGHUP handler");
         return 1;
     }
-
-    /*** Process command-line arguments ***/

     while ( ( c = getopt_long(argc, argv, options,
                               long_options, &longindex) ) != -1 ) {
@@ -192,42 +188,47 @@
     link_a = argv[argc-2];
     link_b = argv[argc-1];

-    /*** Daemonization ***/
+    /* If we are to daemonize, the process will have to perform its cleanup
+     * code from the root directory. Therefore we change to the root before
+     * creating the pid file and pty symlinks so that relative paths are
+     * interpreted consistently.
+     *
+     * Unfortunately this requires specifying absolute symlink paths when
+     * running daemonized, but it prevents daemons from occupying whatever
+     * working directory they happened to be started from. */
+    if ( daemonize )
+        chdir("/");
+
+    if ( pid_path != NULL ) {
+        if ( write_pid(pid_path) < 0 ) {
+            perror("Error writing pid file");
+            status = 1;
+            goto end_nulltty;
+        }
+    }
+
+    nulltty = nulltty_open(link_a, link_b);
+    if ( nulltty == NULL ) {
+        perror("Error opening requested PTYs");
+        status = 1;
+        goto end;
+    }

     if ( daemonize ) {
         if ( daemon(0, 0) != 0 ) {
             perror("Error daemonizing");
             status = 1;
-            goto end;
-        }
-    }
-
-    if ( pid_path != NULL ) {
-        if ( write_pid(pid_path) < 0 ) {
-            perror("Error writing pid file");
-            status = 1;
-            goto end;
-        }
-    }
-
-    /*** Open pseudoterminals ***/
-
-    nulltty = nulltty_open(link_a, link_b);
-    if ( nulltty == NULL ) {
-        perror("Error opening requested PTYs");
-        status = 1;
-        goto end_pid;
+            goto end_nulltty;
+        }
     }

     if ( signum != -1 ) {
         if ( kill(getppid(), signum) < 0 ) {
             perror("Unable to signal parent");
             status = 1;
-            goto end_nulltty;
-        }
-    }
-
-    /*** Pseudoterminal data shuffling main loop ***/
+            goto end_pid;
+        }
+    }

     if ( nulltty_relay(nulltty, &exit_flag) < 0 ) {
         perror("Relaying failed");
@@ -235,10 +236,10 @@
         goto end_nulltty;
     }

+ end_pid:
+    unlink(pid_path);
  end_nulltty:
     nulltty_close(nulltty);
- end_pid:
-    unlink(pid_path);
  end:
     return status;
 }


log connection age on disconnect

log connection age on disconnect

--- src/objects.c
+++ src/objects.c
@@ -585,9 +585,11 @@
 	PgSocket *client = server->link;
 	static const uint8_t pkt_term[] = {'X', 0,0,0,4};
 	int send_term = 1;
+	usec_t now = get_cached_time();

 	if (cf_log_disconnections)
-		slog_info(server, "closing because: %s", reason);
+		slog_info(server, "closing because: %s (age=%llu)", reason,
+			  (now - server->connect_time) / USEC);

 	switch (server->state) {
 	case SV_ACTIVE:
@@ -629,8 +631,11 @@
 /* drop client connection */
 void disconnect_client(PgSocket *client, bool notify, const char *reason)
 {
+	usec_t now = get_cached_time();
+
 	if (cf_log_disconnections)
-		slog_info(client, "closing because: %s", reason);
+		slog_info(client, "closing because: %s (age=%llu)", reason,
+			  (now - client->connect_time) / USEC);

 	switch (client->state) {
 	case CL_ACTIVE:


Added stdio.h header to resolve implicit definitions as it had been forgotten previously.

--- src/objects.c
+++ src/objects.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <stdlib.h>

 #include "parse.h"


Fix sub-subclassing bug

Fix sub-subclassing bug

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@5528 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/objects.c
+++ src/objects.c
@@ -20,6 +20,21 @@

 #include "parrot/parrot.h"
 #include <assert.h>
+
+static PMC *
+clone_array(Parrot_Interp interpreter, PMC *source_array) {
+    PMC *new_array;
+    INTVAL count;
+    INTVAL i;
+    count = VTABLE_elements(interpreter, source_array);
+    new_array = pmc_new(interpreter, enum_class_Array);
+    VTABLE_set_integer_native(interpreter, new_array, count);
+    for (i = 0; i < count; i++) {
+        VTABLE_set_pmc_keyed_int(interpreter, new_array, i,
+                                 VTABLE_get_pmc_keyed_int(interpreter, source_array, i));
+    }
+    return new_array;
+}

 /*

@@ -231,24 +246,24 @@
     /* Our penultimate parent list is a clone of our parent's parent
        list, with our parent unshifted onto the beginning */
     temp_pmc =
-        VTABLE_clone(interpreter,
-                VTABLE_get_pmc_keyed_int(interpreter,
-                    (PMC *)PMC_data(base_class), PCD_ALL_PARENTS));
+        clone_array(interpreter,
+                   VTABLE_get_pmc_keyed_int(interpreter,
+                       (PMC *)PMC_data(base_class), PCD_ALL_PARENTS));
     VTABLE_unshift_pmc(interpreter, temp_pmc, base_class);
     VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ALL_PARENTS,
             temp_pmc);

     /* Our attribute list is our parent's attribute list */
-    temp_pmc = VTABLE_clone(interpreter,
-            VTABLE_get_pmc_keyed_int(interpreter,
-                (PMC *)PMC_data(base_class), PCD_ATTRIB_OFFS));
+    temp_pmc = clone_array(interpreter,
+                          VTABLE_get_pmc_keyed_int(interpreter,
+                              (PMC *)PMC_data(base_class), PCD_ATTRIB_OFFS));
     VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIB_OFFS,
             temp_pmc);

     /* And our full keyed attribute list is our parent's */
-    temp_pmc = VTABLE_clone(interpreter,
-            VTABLE_get_pmc_keyed_int(interpreter,
-                (PMC *)PMC_data(base_class), PCD_ATTRIBUTES));
+    temp_pmc = clone_array(interpreter,
+                          VTABLE_get_pmc_keyed_int(interpreter,
+                               (PMC *)PMC_data(base_class), PCD_ATTRIBUTES));
     VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIBUTES,
             temp_pmc);

@@ -415,8 +430,9 @@
     /* put in the real vtable
      * XXX we are leaking ths vtable
      */
+    /*    object->vtable = Parrot_base_vtables[class_enum];*/
     object->vtable = Parrot_clone_vtable(interpreter,
-                Parrot_base_vtables[enum_class_ParrotObject]);
+          Parrot_base_vtables[enum_class_ParrotObject]);
     /* and set type of class */
     object->vtable->base_type = class_enum;


Clean up internal POD (don't leak C code in docs).

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@5846 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/objects.c
+++ src/objects.c
@@ -1139,6 +1139,8 @@

 Returns attribute with full qualified name C<attr> from C<object>.

+=cut
+
 */

 PMC *
@@ -1208,6 +1210,8 @@

 Sets attribute with full qualified name C<attr> from C<object> to C<value>.

+=cut
+
 */

 void
@@ -1281,6 +1285,8 @@
 if you don't have an identifier token. Which, as they're currently
 undefined, is pretty likely

+=cut
+
 */

 PMC *


src/openssl.c: Remove redundant EVP_PKEY_type

--- src/openssl.c
+++ src/openssl.c
@@ -3338,7 +3338,7 @@
 		if (!(*ud = EVP_PKEY_new()))
 			return auxL_error(L, auxL_EOPENSSL, "pkey.new");

-		switch (EVP_PKEY_type(type)) {
+		switch (type) {
 		case EVP_PKEY_RSA: {
 			RSA *rsa;


bignum: Don't allow empty numbers/strings to pass

Previously, "-" would pass the len>0 check; and end up as "0"
The `*str` check was redundant, the switch/case already ensures the object at the given stack index is a string

--- src/openssl.c
+++ src/openssl.c
@@ -1686,7 +1686,7 @@
 	BIGNUM **bn;
 	const char *str;
 	size_t len, i;
-	_Bool neg, hex = 0;
+	_Bool neg, hex;

 	index = lua_absindex(L, index);

@@ -1696,17 +1696,17 @@

 		str = lua_tolstring(L, index, &len);

-		luaL_argcheck(L, len > 0 && *str, index, "invalid big number string");
-
 		neg = (str[0] == '-');
-
-		if (str[neg] == '0' && (str[neg+1] == 'x' || str[neg+1] == 'X')) {
-			hex = 1;
+		hex = (str[neg] == '0' && (str[neg+1] == 'x' || str[neg+1] == 'X'));
+
+		if (hex) {
+			luaL_argcheck(L, len > 2+(size_t)neg, index, "invalid hex string");
 			for (i = 2+neg; i < len; i++) {
 				if (!isxdigit(str[i]))
 					luaL_argerror(L, 1, "invalid hex string");
 			}
 		} else {
+			luaL_argcheck(L, len > neg, index, "invalid decimal string");
 			for (i = neg; i < len; i++) {
 				if (!isdigit(str[i]))
 					luaL_argerror(L, 1, "invalid decimal string");


Fix tag size bug for creating CBC-MAC

Fix tag size bug for creating CBC-MAC

--- src/openssl.c
+++ src/openssl.c
@@ -411,8 +411,6 @@
 	EVP_CIPHER_CTX_init(&ctx);
 	CHECK_CONDITION(EVP_EncryptInit_ex(&ctx, pcipher, NULL, pcose->pbKey, rgbIV), COSE_ERR_CRYPTO_FAIL);

-	TSize /= 8;
-
 	for (i = 0; i < (unsigned int)cbAuthData / 16; i++) {
 		CHECK_CONDITION(EVP_EncryptUpdate(&ctx, rgbOut, &cbOut, pbAuthData + (i * 16), 16), COSE_ERR_CRYPTO_FAIL);
 	}


Remove --xinerama option, the next release will break option BC anyway

--- src/options.c
+++ src/options.c
@@ -400,7 +400,6 @@
       {"bg-seamless", 1, 0, 203},
       {"menu-style", 1, 0, 204},
       {"zoom", 1, 0, 205},
-      {"xinerama", 1, 0, 206},
       {"screen-clip", 1, 0, 207},
       {"menu-border", 1, 0, 208},
       {"caption-path", 1, 0, 209},
@@ -697,10 +696,6 @@
            break;
         case 205:
            opt.default_zoom = atoi(optarg);
-           break;
-        case 206:
-           opt.xinerama = atoi(optarg);
-           weprintf("Option --xinerama is deprecated, use --no-xinerama (or nothing) instead");
            break;
         case 207:
            opt.screen_clip = atoi(optarg);


Return correct entity handler result for Get and Publish requests to
RD server.

Prior to this fix, rdEntityHandler would always return OC_EH_ERROR.

Change-Id: I1099ffe19e200982562cd9de4f7c97e173a71431
Signed-off-by: Todd Malsbary <8856a5d8416dae6d0ae52d024d7a973f628fb21e@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14473
Tested-by: jenkins-iotivity <09cb29e8a2b473a2c978382eec13ee06fa017bda@opendaylight.org>
Reviewed-by: Habib Virji <40be98b50fb6c4d79bd282a617e2cc82e300d47f@samsung.com>

--- resource/csdk/resource-directory/src/rd_server.c
+++ resource/csdk/resource-directory/src/rd_server.c
@@ -103,7 +103,7 @@
         return OC_EH_ERROR;
     }

-    OIC_LOG_V(DEBUG, TAG, "Received OC_REST_PUT from client with query: %s.", ehRequest->query);
+    OIC_LOG_V(DEBUG, TAG, "Received OC_REST_POST from client with query: %s.", ehRequest->query);

     OCRepPayload *payload = (OCRepPayload *)ehRequest->payload;
     OCRepPayload *resPayload = NULL;
@@ -166,10 +166,10 @@
         {
             case OC_REST_GET:
             case OC_REST_DISCOVER:
-                handleGetRequest(ehRequest);
+                ehRet = handleGetRequest(ehRequest);
                 break;
             case OC_REST_POST:
-                handlePublishRequest(ehRequest);
+                ehRet = handlePublishRequest(ehRequest);
                 break;
             case OC_REST_DELETE:
                 ehRet = handleDeleteRequest(ehRequest);


Adding in strncpy test

Adding in strncpy test

Change-Id: I9aec8de9d11f6624e1aea01399040d38a08967cd
Signed-off-by: Dan Kalowsky <53619d3d3576bbac1c2d05ecd99970e469cb3398@intel.com>

--- samples/microkernel/test/test_libs/src/libraries.c
+++ samples/microkernel/test/test_libs/src/libraries.c
@@ -261,19 +261,42 @@
 	return TC_PASS;
 }

+/*******************************************************************************
+ *
+ * strncpy_test - test string N copy function
+ *
+ * RETURNS: TC_PASS or TC_FAIL
+ */
+
+int strncpy_test (void)
+{
+	TC_PRINT ("\tstrncpy ...\t");
+
+	memset (buffer, '\0', BUFSIZE);
+	strncpy(buffer, "This is over 10 characters", BUFSIZE);
+
+	/* Purposely different values */
+	if (strncmp(buffer, "This is over 20 characters", BUFSIZE) != 0) {
+		TC_PRINT ("failed\n");
+		return TC_FAIL;
+	}
+
+	TC_PRINT ("passed\n");
+	return TC_PASS;
+}

 /*******************************************************************************
 *
  * stringTest - test string operations library
- *
- * RETURNS: TC_PASS or TC_FAIL
+ * * RETURNS: TC_PASS or TC_FAIL
  */

 int stringTest(void)
 {
 	TC_PRINT("Testing string.h library ...\n");

-	if (memset_test() || strlen_test() || strcmp_test() || strcpy_test()) {
+	if (memset_test() || strlen_test() || strcmp_test() || strcpy_test() ||
+	    strncpy_test()) {
 		return TC_FAIL;
 	}


Durr forgot to allocate memory.

Durr forgot to allocate memory.

--- src/options.c
+++ src/options.c
@@ -418,6 +418,7 @@
     } else {
         path = ag_strdup(".");
         *paths = ag_malloc(sizeof(char*) * 2);
+        *base_paths = ag_malloc(sizeof(char*) * 2);
         (*paths)[0] = path;
         (*base_paths)[0] = realpath(path, NULL);
         i = 1;


Clearer help text

Clearer help text

--- src/options.c
+++ src/options.c
@@ -73,7 +73,7 @@
                         (.gitigore, .hgignore, .svnignore; still obey .agignore)\n\
 -v --invert-match\n\
 -w --word-regexp        Only match whole words\n\
--z --search-zip         Search contents of zip files\n\
+-z --search-zip         Search contents of compressed (e.g., gzip) files\n\
 \n");
 }


Added option -? to get help.

Added option -? to get help.

--- src/options.c
+++ src/options.c
@@ -319,6 +319,7 @@
         { "group", no_argument, &group, 1 },
         { "heading", no_argument, &opts.print_path, PATH_PRINT_TOP },
         { "help", no_argument, NULL, 'h' },
+        { "help-windows", no_argument, NULL, '?' },
         { "hidden", no_argument, &opts.search_hidden_files, 1 },
         { "ignore", required_argument, NULL, 0 },
         { "ignore-case", no_argument, NULL, 'i' },
@@ -431,7 +432,7 @@
     }

     char *file_search_regex = NULL;
-    while ((ch = getopt_long(argc, argv, "A:aB:C:cDG:g:FfHhiLlm:nop:QRrSsvVtuUwW:z0", longopts, &opt_index)) != -1) {
+    while ((ch = getopt_long(argc, argv, "A:aB:C:cDG:g:FfHhiLlm:nop:QRrSsvVtuUwW:z0?", longopts, &opt_index)) != -1) {
         switch (ch) {
             case 'A':
                 if (optarg) {
@@ -503,6 +504,7 @@
                 opts.print_path = PATH_PRINT_TOP;
                 break;
             case 'h':
+            case '?':
                 help = 1;
                 break;
             case 'i':


doc: Add ECDSA keys to docs, make key docs consistent

Signed-off-by: Alan Dunn <90d3ad16cd4565f91305ac667132a38a0361079b@gmail.com>
Reviewed-by: Andreas Schneider <5be00ddc76278cf6077f5047ca3384a88460c671@cryptomilk.org>

--- src/options.c
+++ src/options.c
@@ -1360,10 +1360,13 @@
  *                        (string).
  *
  *                      SSH_BIND_OPTIONS_DSAKEY:
- *                        Set the path to the dsa ssh host key (string).
+ *                        Set the path to the ssh host dsa key (string).
  *
  *                      SSH_BIND_OPTIONS_RSAKEY:
  *                        Set the path to the ssh host rsa key (string).
+ *
+ *                      SSH_BIND_OPTIONS_ECDSAKEY:
+ *                        Set the path to the ssh host ecdsa key (string).
  *
  *                      SSH_BIND_OPTIONS_BANNER:
  *                        Set the server banner sent to clients (string).


add more help

add more help

--- src/options.c
+++ src/options.c
@@ -28,8 +28,10 @@
     printf("  --ackmate\n");
     printf("  --after LINES\n");
     printf("  --before LINES\n");
+    printf("  --column\n");
     printf("  --context\n");
     printf("  --[no]color\n");
+    printf("  --[no]group\n");
     printf("\n");
 }


update yystate.c

update yystate.c

--- compiler/parser/yystate.c
+++ compiler/parser/yystate.c
@@ -497,7 +497,7 @@
  * Move the epsilon items from the closure_items set to the kernel of the
  * current state. If epsilon items already exist in the current state,just
  * merge the lookaheads. Note that,because the closure items were sorted
- * ot partition them, the epsilon productions in the closure_items set
+ * to partition them, the epsilon productions in the closure_items set
  * will be in the same order as those already in the kernel. Return the
  * number of items that were moved.
  */
@@ -783,7 +783,7 @@
      * (1) closure -> adds normal closure items to closure_items array.
      * (2) kclosure -> adds to that set all items in the kernel that have
      *     outgoing transitions(ie. whose dots aren't at the far right.)
-     * (3) sort    -> sorts the closure items by the symbol to the right
+     * (3) sort -> sorts the closure items by the symbol to the right
      *     of the dot. Epsilon transitions will sort to the head of the
      *     list, followed by transitions on nonterminals, followed by
      *     transitions on terminals.


Mention required params in --help

Mention required params in --help

--- src/options.c
+++ src/options.c
@@ -14,7 +14,7 @@

 static void usage() {
-    printf("Usage: diffshipper [OPTIONS] PATH\n\
+    printf("Usage: diffshipper -r ROOM_NAME -o ROOM_OWNER -u USERNAME -s API_SECRET [OPTIONS] PATH\n\
 \n\
     --api-url URL       Defaults to floobits.com. This is only needed for debugging/development.\n\
     --create-room       Create a room and add PATH\n\


Added --db-path to the CLI options.

Added --db-path to the CLI options.

--- src/options.c
+++ src/options.c
@@ -248,6 +248,7 @@
   "  --anonymize-level=<1|2|3>       - Anonymization levels: 1 => default, 2 => strong, 3 => pedantic.\n"
   "  --crawlers-only                 - Parse and display only crawlers.\n"
   "  --date-spec=<date|hr|min>       - Date specificity. Possible values: `date` (default), `hr` or `min`.\n"
+  "  --db-path=<path>                - Persist data to disk on exit to the given path or /tmp as default.\n"
   "  --double-decode                 - Decode double-encoded values.\n"
   "  --enable-panel=<PANEL>          - Enable parsing/displaying the given panel.\n"
   "  --fname-as-vhost=<regex>        - Use log filename(s) as virtual host(s). POSIX regex is passed\n"


Revert "kernel: arch interface for memory domain"

This reverts commit 9bbe7bd61eea140c8fb2f09ac318df544fccab46.

--- kernel/include/nano_internal.h
+++ kernel/include/nano_internal.h
@@ -95,30 +95,6 @@
  * @return Max number of free regions, or -1 if there is no limit
  */
 extern int _arch_mem_domain_max_partitions_get(void);
-
-/**
- * @brief Remove a partition from the memory domain
- *
- * A memory domain contains multiple partitions and this API provides the
- * freedom to remove a particular partition while keeping others intact.
- * This API will handle any arch/HW specific changes that needs to be done.
- *
- * @param domain The memory domain structure
- * @param partition_id The partition that needs to be deleted
- */
-extern void _arch_mem_domain_remove_partition(struct k_mem_domain *domain,
-					      u32_t  partition_id);
-
-/**
- * @brief Remove the memory domain
- *
- * A memory domain contains multiple partitions and this API will traverse
- * all these to reset them back to default setting.
- * This API will handle any arch/HW specific changes that needs to be done.
- *
- * @param domain The memory domain structure which needs to be deleted.
- */
-extern void _arch_mem_domain_destroy(struct k_mem_domain *domain);
 #endif

 #ifdef CONFIG_USERSPACE


- fix a copy/paste error in logging the setting of the "multiple_ccaches" option

--- src/options.c
+++ src/options.c
@@ -690,10 +690,10 @@
 					     service,
 					     DEFAULT_MULTIPLE_CCACHES, "",
 					     "multiple_ccaches", 0);
-	if (options->debug && (options->external == 1)) {
+	if (options->debug && (options->multiple_ccaches == 1)) {
 		debug("flag: multiple_ccaches");
 	}
-	if (options->debug && (options->external == 0)) {
+	if (options->debug && (options->multiple_ccaches == 0)) {
 		debug("flag: no multiple_ccaches");
 	}