A bunch of portability fixes, derived from Steve Lhomme's MSVC

Original commit message from CVS:
A bunch of portability fixes, derived from Steve Lhomme's MSVC
patch (bug #141317):
* gst/gst-i18n-lib.h: Allow disabling gettext.
* gst/gstatomic_impl.h: disable warning when it's dumb.
* gst/gstclock.c: fix include
* gst/gstcompat.h: fix variadic macro
* gst/gstinfo.c: fix include
* gst/gstmacros.h: add defines for inlines on MSVC
* gst/gstplugin.c: fix includes
* gst/gstregistry.c: fix includes
* gst/gstregistry.h: use S_IREAD, etc., if S_IRUSR isn't defined
* gst/gstsystemclock.c: fix include
* gst/gsttrace.c: (gst_trace_new), (gst_trace_text_flush): use
S_IREAD if S_IRUSR isn't defined.  fix use of non-portable functions
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_parse_element_factory): fix use of non-portable
functions
* libs/gst/control/dparam.h: Remove trailing comma in enum definition
* libs/gst/control/dparammanager.h: same
diff --git a/gst/gst-i18n-lib.h b/gst/gst-i18n-lib.h
index f5db797..a68d505 100644
--- a/gst/gst-i18n-lib.h
+++ b/gst/gst-i18n-lib.h
@@ -23,15 +23,25 @@
 #ifndef __GST_I18N_LIB_H__
 #define __GST_I18N_LIB_H__
 
-#include "gettext.h" /* included with gettext distribution and copied */
-
-#ifndef GETTEXT_PACKAGE
-#error You must define GETTEXT_PACKAGE before including this header.
+#ifndef GST_VERSION
+#error You must include config.h before including this header.
 #endif
 
+#ifdef ENABLE_NLS
+
+#include "gettext.h" /* included with gettext distribution and copied */
+
 /* we want to use shorthand _() for translating and N_() for marking */
 #define _(String) dgettext (GETTEXT_PACKAGE, String)
 #define N_(String) gettext_noop (String)
 /* FIXME: if we need it, we can add Q_ as well, like in glib */
 
+#else
+
+#define GETTEXT_PACKAGE NULL
+#define _(String) String
+#define N_(String) String
+
+#endif
+
 #endif /* __GST_I18N_LIB_H__ */
diff --git a/gst/gstatomic_impl.h b/gst/gstatomic_impl.h
index 8228d7b..2fd577d 100644
--- a/gst/gstatomic_impl.h
+++ b/gst/gstatomic_impl.h
@@ -423,7 +423,11 @@
 }
 
 #else 
+
+/* no need warning about this if we can't do inline assembly */
+#ifdef __GNUC__
 #warning consider putting your architecture specific atomic implementations here
+#endif
 
 /*
  * generic implementation
diff --git a/gst/gstclock.c b/gst/gstclock.c
index 2c604f4..1552d66 100644
--- a/gst/gstclock.c
+++ b/gst/gstclock.c
@@ -20,7 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <sys/time.h>
+#include <time.h>
 
 #include "gst_private.h"
 
diff --git a/gst/gstcompat.h b/gst/gstcompat.h
index 5ec3458..ff6b0b8 100644
--- a/gst/gstcompat.h
+++ b/gst/gstcompat.h
@@ -36,9 +36,11 @@
 					gst_element_link_pads(a,b,c,d)
 #ifdef G_HAVE_ISO_VARARGS
 #define	gst_element_connect_many(a,...)	gst_element_link_many(a,__VA_ARGS__)
-#else
+#elif defined(G_HAVE_GNUC_VARARGS)
 #define gst_element_connect_many(a,args...) \
 					gst_element_link_many(a, ## args)
+#else
+/* FIXME: need an inline function */
 #endif
 #define	gst_element_connect_filtered(a,b,c) \
 					gst_element_link_filtered(a,b,c)
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 3dc2a1c..f27e8b2 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -34,7 +34,9 @@
 #include <printf.h>
 #endif
 #include <stdio.h>              /* fprintf */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <string.h>             /* G_VA_COPY */
 #include "gstinfo.h"
 #include "gstlog.h"
diff --git a/gst/gstmacros.h b/gst/gstmacros.h
index 537d90f..6f20ac8 100644
--- a/gst/gstmacros.h
+++ b/gst/gstmacros.h
@@ -32,6 +32,9 @@
 #if defined (__GNUC__) && !defined (GST_IMPLEMENT_INLINES)
 # define GST_INLINE_FUNC extern __inline__
 # define GST_CAN_INLINE 1
+#elif defined(_MSC_VER)
+# define GST_INLINE_FUNC extern __inline
+# define GST_CAN_INLINE 1
 #else
 # define GST_INLINE_FUNC extern 
 # undef GST_CAN_INLINE
diff --git a/gst/gstplugin.c b/gst/gstplugin.c
index d89a762..67af719 100644
--- a/gst/gstplugin.c
+++ b/gst/gstplugin.c
@@ -20,10 +20,17 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_DIRENT_H
 #include <dirent.h>
+#endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <signal.h>
 
 #include "gst_private.h"
@@ -32,7 +39,6 @@
 #include "gstversion.h"
 #include "gstregistrypool.h"
 #include "gstinfo.h"
-#include "config.h"
 #include "gstfilter.h"
 
 
diff --git a/gst/gstregistry.c b/gst/gstregistry.c
index 06de568..dddedcf 100644
--- a/gst/gstregistry.c
+++ b/gst/gstregistry.c
@@ -20,10 +20,15 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <glib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/gst/gstregistry.h b/gst/gstregistry.h
index ed10727..e1ac8ee 100644
--- a/gst/gstregistry.h
+++ b/gst/gstregistry.h
@@ -34,6 +34,8 @@
 #define LOCAL_REGISTRY_FILE      LOCAL_REGISTRY_DIR"/registry.xml"
 #define LOCAL_REGISTRY_FILE_TMP  LOCAL_REGISTRY_DIR"/.registry.xml.tmp"
 
+/* compatibility for pre-POSIX defines */
+#ifdef S_IRUSR
 #define REGISTRY_DIR_PERMS (S_ISGID | \
                             S_IRUSR | S_IWUSR | S_IXUSR | \
 		            S_IRGRP | S_IXGRP | \
@@ -42,6 +44,12 @@
 #define REGISTRY_FILE_PERMS (S_IRUSR | S_IWUSR | \
                              S_IRGRP | S_IWGRP | \
 			     S_IROTH | S_IWOTH)
+#else
+#define REGISTRY_DIR_PERMS (S_ISGID | \
+                            S_IREAD | S_IWRITE | S_IEXEC)
+#define REGISTRY_TMPFILE_PERMS (S_IREAD | S_IWRITE)
+#define REGISTRY_FILE_PERMS (S_IREAD | S_IWRITE)
+#endif
 
 G_BEGIN_DECLS
 
diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c
index 9966a58..e5dba1a 100644
--- a/gst/gstsystemclock.c
+++ b/gst/gstsystemclock.c
@@ -20,7 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <sys/time.h>
+#include <time.h>
 
 #include "gst_private.h"
 #include "gstinfo.h"
diff --git a/gst/gsttrace.c b/gst/gsttrace.c
index 68633a6..b45dc92 100644
--- a/gst/gsttrace.c
+++ b/gst/gsttrace.c
@@ -21,9 +21,13 @@
  */
 
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#include <sys/types.h>
+#endif
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
@@ -67,6 +71,12 @@
   g_return_val_if_fail (trace != NULL, NULL);
   trace->filename = g_strdup (filename);
   g_print ("opening '%s'\n", trace->filename);
+#ifndef S_IWUSR
+#define S_IWUSR S_IWRITE
+#endif
+#ifndef S_IRUSR
+#define S_IDUSR S_IREAD
+#endif
   trace->fd =
       open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
   perror ("opening trace file");
@@ -120,7 +130,7 @@
   }
 
   for (i = 0; i < trace->bufoffset; i++) {
-    snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n",
+    g_snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n",
         trace->buf[i].timestamp,
         trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message);
     write (trace->fd, str, strlen (str));
diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c
index d08bc4e..fe3c32f 100644
--- a/gst/registries/gstxmlregistry.c
+++ b/gst/registries/gstxmlregistry.c
@@ -29,7 +29,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <fcntl.h>
 #include <utime.h>
 
@@ -757,9 +759,9 @@
       gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
     }
   } else if (!strcmp (tag, "uri_type")) {
-    if (strncasecmp (text, "sink", 4) == 0) {
+    if (g_ascii_strncasecmp (text, "sink", 4) == 0) {
       factory->uri_type = GST_URI_SINK;
-    } else if (strncasecmp (text, "source", 5) == 0) {
+    } else if (g_ascii_strncasecmp (text, "source", 5) == 0) {
       factory->uri_type = GST_URI_SRC;
     }
   } else if (!strcmp (tag, "uri_protocol")) {