THRIFT-302. ruby: Native extension fails to build

A piece of code needed for compilation on Linux was missing; this patch replaces it. Also, there were some compiler warnings and declarations that were missing that are now fixed.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@740366 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index 0e7aa1a..b882344 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -1,7 +1,28 @@
-
 #include <struct.h>
 #include <constants.h>
 
+#ifndef HAVE_STRLCPY
+
+static
+size_t
+strlcpy (char *dst, const char *src, size_t dst_sz)
+{
+    size_t n;
+
+    for (n = 0; n < dst_sz; n++) {
+      if ((*dst++ = *src++) == '\0')
+        break;
+    }
+
+    if (n < dst_sz)
+      return n;
+    if (n > 0)
+      *(dst - 1) = '\0';
+    return n + strlen (src);
+}
+
+#endif
+
 static native_proto_method_table *mt;
 
 #define IS_CONTAINER(ttype) ((ttype) == TTYPE_MAP || (ttype) == TTYPE_LIST || (ttype) == TTYPE_SET)