Index: trunk/src/slib.c
===================================================================
--- trunk/src/slib.c	(revision 476)
+++ trunk/src/slib.c	(revision 481)
@@ -587,4 +587,14 @@
 
 
+#if !defined (VA_COPY)
+#if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
+#define VA_COPY(ap1, ap2)     (*(ap1) = *(ap2))
+#elif defined (VA_COPY_AS_ARRAY)
+#define VA_COPY(ap1, ap2)     memmove ((ap1), (ap2), sizeof (va_list))
+#else /* va_list is a pointer */
+#define VA_COPY(ap1, ap2)     ((ap1) = (ap2))
+#endif
+#endif 
+
 #if !defined(HAVE_VSNPRINTF) || defined(HAVE_BROKEN_VSNPRINTF)
 static
@@ -774,5 +784,5 @@
   str[n-1] = '\0';
 #else
-  va_copy(vl2, vl);                      /* save the argument list           */
+  VA_COPY (vl2, vl);                     /* save the argument list           */
   total = sl_printf_count (format, vl);
   len = (int) total;
@@ -820,5 +830,5 @@
   str[n-1] = '\0';
 #else
-  va_copy(vl2, vl);                    /* save the argument list           */
+  VA_COPY (vl2, vl);                   /* save the argument list           */
   total = sl_printf_count (format, vl);
   if (total < n) 
@@ -1141,6 +1151,6 @@
 static   gid_t   rgid_orig;
 
-static   int     uids_are_stored = SL_FALSE;
-static   int     suid_is_set     = SL_TRUE;
+static   int     uids_are_stored = S_FALSE;
+static   int     suid_is_set     = S_TRUE;
 
 #ifdef HAVE_SETRESUID
@@ -1156,5 +1166,5 @@
 int sl_is_suid()
 {
-  if (uids_are_stored == SL_FALSE)
+  if (uids_are_stored == S_FALSE)
     {
       if (getuid() == geteuid() && getgid() == getegid())
@@ -1179,6 +1189,6 @@
 {
   SL_ENTER(_("sl_get_euid"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = euid;
   else
@@ -1189,6 +1199,6 @@
 uid_t sl_ret_euid()
 {
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     return (euid);
   else
@@ -1203,6 +1213,6 @@
 {
   SL_ENTER(_("sl_get_egid"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = egid;
   else
@@ -1218,6 +1228,6 @@
 {
   SL_ENTER(_("sl_get_ruid"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = ruid;
   else
@@ -1233,6 +1243,6 @@
 {
   SL_ENTER(_("sl_get_rgid"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = rgid;
   else
@@ -1248,6 +1258,6 @@
 {
   SL_ENTER(_("sl_get_ruid_orig"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = ruid_orig;
   else
@@ -1263,6 +1273,6 @@
 {
   SL_ENTER(_("sl_get_rgid_orig"));
-  /* SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));*/
-  if (uids_are_stored == SL_TRUE)
+  /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/
+  if (uids_are_stored == S_TRUE)
     *ret = rgid_orig;
   else
@@ -1289,17 +1299,17 @@
   SL_ENTER(_("sl_set_suid"));
 
-  if (uids_are_stored == SL_FALSE)
+  if (uids_are_stored == S_FALSE)
     {
       SL_IRETURN(SL_ENONE, _("sl_set_suid"));
     }
 
-  SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));  
+  SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));  
 
   if (ruid == euid && rgid == egid) 
     {
-      suid_is_set = SL_TRUE;
+      suid_is_set = S_TRUE;
       SL_IRETURN(SL_ENONE, _("sl_set_suid"));
     }  
-  SL_REQUIRE(suid_is_set     == SL_FALSE, _("suid_is_set == SL_FALSE"));  
+  SL_REQUIRE(suid_is_set     == S_FALSE, _("suid_is_set == S_FALSE"));  
 
 #if defined(HAVE_SETRESUID)
@@ -1330,5 +1340,5 @@
 
   SL_REQUIRE(retval == 0, _("retval == 0"));
-  suid_is_set = SL_TRUE;
+  suid_is_set = S_TRUE;
   SL_IRETURN(SL_ENONE, _("sl_set_suid"));
 }
@@ -1344,17 +1354,17 @@
   SL_ENTER(_("sl_unset_suid"));
 
-  if (uids_are_stored == SL_FALSE)
+  if (uids_are_stored == S_FALSE)
     {
       SL_IRETURN(SL_ENONE, _("sl_unset_suid"));
     }
 
-  SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));
+  SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));
 
   if (ruid == euid && rgid == egid)
     {
-      suid_is_set = SL_FALSE;
+      suid_is_set = S_FALSE;
       SL_IRETURN(SL_ENONE, _("sl_unset_suid"));
     }  
-  SL_REQUIRE(suid_is_set     == SL_TRUE, _("suid_is_set == SL_TRUE"));  
+  SL_REQUIRE(suid_is_set     == S_TRUE, _("suid_is_set == S_TRUE"));  
 
 #if defined(HAVE_SETRESUID)
@@ -1384,5 +1394,5 @@
 
   SL_REQUIRE(retval == 0, _("retval == 0"));
-  suid_is_set = SL_FALSE;
+  suid_is_set = S_FALSE;
   SL_IRETURN(SL_ENONE, _("sl_unset_suid"));
 }
@@ -1395,5 +1405,5 @@
 {
   SL_ENTER(_("sl_save_uids"));
-  if (uids_are_stored == SL_TRUE) 
+  if (uids_are_stored == S_TRUE) 
     SL_IRETURN(SL_EREPEAT, _("sl_save_uids"));
 
@@ -1404,5 +1414,5 @@
   ruid = ruid_orig;
   rgid = rgid_orig;
-  uids_are_stored = SL_TRUE;
+  uids_are_stored = S_TRUE;
 
   SL_IRETURN(SL_ENONE, _("sl_save_uids"));
@@ -1417,5 +1427,5 @@
 {
   SL_ENTER(_("sl_drop_privileges"));
-  SL_REQUIRE(uids_are_stored == SL_TRUE, _("uids_are_stored == SL_TRUE"));
+  SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));
 
   SL_REQUIRE(setgid(rgid_orig) == 0, _("setgid(rgid_orig) == 0"));
@@ -1442,5 +1452,5 @@
 {
   SL_ENTER(_("sl_policy_get_root"));
-  SL_REQUIRE(uids_are_stored == SL_FALSE, _("uids_are_stored == SL_FALSE"));
+  SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE"));
 
   SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE"));
@@ -1455,5 +1465,5 @@
       rgid = egid;
     }
-  suid_is_set = SL_TRUE;
+  suid_is_set = S_TRUE;
   if (euid == 0)
     {
@@ -1474,5 +1484,5 @@
 {
   SL_ENTER(_("sl_policy_get_real"));
-  SL_REQUIRE(uids_are_stored == SL_FALSE, _("uids_are_stored == SL_FALSE"));
+  SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE"));
   SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE"));
 
@@ -1507,5 +1517,5 @@
 	      _("sl_drop_privileges() == SL_ENONE"));
 
-  suid_is_set = SL_TRUE;
+  suid_is_set = S_TRUE;
   SL_IRETURN(SL_ENONE, _("sl_policy_get_real"));
 }
@@ -1522,5 +1532,5 @@
 
   SL_REQUIRE(user != NULL, _("user != NULL"));
-  SL_REQUIRE(uids_are_stored == SL_FALSE, _("uids_are_stored == SL_FALSE"));
+  SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE"));
   SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE"));
 
@@ -1778,5 +1788,5 @@
   ofiles[fd]->content = NULL;
   ofiles[fd]->stream  = stream;
-  ofiles[fd]->flush   = SL_FALSE;
+  ofiles[fd]->flush   = S_FALSE;
 
   sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE);
@@ -2058,5 +2068,5 @@
   ofiles[fd]->content = NULL;
   ofiles[fd]->stream  = NULL;
-  ofiles[fd]->flush   = SL_FALSE;
+  ofiles[fd]->flush   = S_FALSE;
 
   sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE);
@@ -2182,5 +2192,5 @@
 #endif
 
-static int sl_drop_cache = SL_FALSE;
+static int sl_drop_cache = S_FALSE;
 
 int sl_set_drop_cache(const char * str)
@@ -2203,5 +2213,5 @@
 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED)
 
-  if (SL_FALSE != sl_drop_cache && !SL_ISERROR(status))
+  if (S_FALSE != sl_drop_cache && !SL_ISERROR(status))
     {
       int fd = get_the_fd(status);
@@ -2209,5 +2219,5 @@
 	{
 	  if (0 == sl_check_mincore(fd))
-	    ofiles[fd]->flush = SL_TRUE;
+	    ofiles[fd]->flush = S_TRUE;
 	}
     }
@@ -2345,5 +2355,5 @@
     {
 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED)
-      if (ofiles[fd]->flush == SL_TRUE)
+      if (ofiles[fd]->flush == S_TRUE)
 	{
 	  posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
@@ -2569,5 +2579,5 @@
   extern volatile int sig_termfast;
  
-  if (is_nonblocking == SL_FALSE)
+  if (is_nonblocking == S_FALSE)
     {
       /* set to non-blocking mode 
@@ -2620,5 +2630,5 @@
 		{
 		  error = errno;
-		  if (is_nonblocking == SL_FALSE)
+		  if (is_nonblocking == S_FALSE)
 		      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
 		  TPT(( 0, FIL__, __LINE__, _("msg=<read error>")));
@@ -2637,5 +2647,5 @@
       else if (retval == 0)
 	{
-	  if (is_nonblocking == SL_FALSE)
+	  if (is_nonblocking == S_FALSE)
 	      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
 	  TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
@@ -2648,5 +2658,5 @@
 	{
 	  error = errno;
-	  if (is_nonblocking == SL_FALSE)
+	  if (is_nonblocking == S_FALSE)
 	      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
 	  TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
@@ -2657,5 +2667,5 @@
       if (sig_termfast == 1) 
 	{
-	  if (is_nonblocking == SL_FALSE)
+	  if (is_nonblocking == S_FALSE)
 	      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
 	  TPT(( 0, FIL__, __LINE__, _("msg=<terminated>")));
@@ -2669,5 +2679,5 @@
       if (tdiff > timeout)
 	{
-	  if (is_nonblocking == SL_FALSE)
+	  if (is_nonblocking == S_FALSE)
 	      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
 	  TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
@@ -2679,5 +2689,5 @@
     }
 
-  if (is_nonblocking == SL_FALSE)
+  if (is_nonblocking == S_FALSE)
     retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
   return ((int) bytes);
@@ -2888,6 +2898,6 @@
 
 extern uid_t rootonly[];
-extern int   EUIDSLOT;
-extern int   ORIG_EUIDSLOT;
+extern unsigned int   EUIDSLOT;
+extern unsigned int   ORIG_EUIDSLOT;
 
 extern char  tf_path[MAXFILENAME];	/* Error path for trust function. */
@@ -2998,5 +3008,5 @@
 int  sl_trust_purge_user (void)
 {
-  int i;
+  unsigned int i;
 
   EUIDSLOT = ORIG_EUIDSLOT;
@@ -3074,6 +3084,6 @@
 {
   long          status;
-  static time_t old = 0;
-  static time_t now;
+  static size_t old = 0;
+  static size_t now;
 
   SL_ENTER(_("sl_trustfile_euid"));
@@ -3084,4 +3094,5 @@
 
   now = time(NULL);
+
   if (now < (old + 300))
     {
@@ -3119,6 +3130,6 @@
 {
   if ((b == 0) || (a >= (INT_MIN / b) && a <= (INT_MAX / b)))
-    return SL_TRUE; /* no overflow */
-  return SL_FALSE;
+    return S_TRUE; /* no overflow */
+  return S_FALSE;
 }
 
@@ -3126,6 +3137,6 @@
 {
   if ((b == 0) || (a <= (SIZE_MAX / b)))
-    return SL_TRUE; /* no overflow */
-  return SL_FALSE;
+    return S_TRUE; /* no overflow */
+  return S_FALSE;
 }
 
@@ -3134,6 +3145,6 @@
   (void) a;
   if (b != 0)
-    return SL_TRUE; /* no overflow */
-  return SL_FALSE;
+    return S_TRUE; /* no overflow */
+  return S_FALSE;
 }
 
@@ -3143,16 +3154,16 @@
     {
       if (a <= (INT_MAX - b))
-	return SL_TRUE; /* no overflow */
+	return S_TRUE; /* no overflow */
       else
-	return SL_FALSE;
+	return S_FALSE;
     }
   else if (a < 0 && b < 0)
     {
       if (a >= (INT_MIN - b))
-	return SL_TRUE; /* no overflow */
+	return S_TRUE; /* no overflow */
       else
-	return SL_FALSE;
-    }
-  return SL_TRUE;
+	return S_FALSE;
+    }
+  return S_TRUE;
 }
 
@@ -3160,7 +3171,7 @@
 {
   if (a <= (SIZE_MAX - b))
-    return SL_TRUE; /* no overflow */
+    return S_TRUE; /* no overflow */
   else
-    return SL_FALSE;
+    return S_FALSE;
 }
 
@@ -3170,15 +3181,15 @@
     {
       if (a <= (INT_MAX + b))
-	return SL_TRUE; /* no overflow */
+	return S_TRUE; /* no overflow */
       else
-	return SL_FALSE;
+	return S_FALSE;
     }
   else if (a < 0 && b >= 0)
     {
       if (a >= (INT_MIN + b))
-	return SL_TRUE; /* no overflow */
+	return S_TRUE; /* no overflow */
       else
-	return SL_FALSE;
-    }
-  return SL_TRUE;
-}
+	return S_FALSE;
+    }
+  return S_TRUE;
+}
