gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3595 - in GNUnet/src: include util/os


From: durner
Subject: [GNUnet-SVN] r3595 - in GNUnet/src: include util/os
Date: Wed, 1 Nov 2006 03:53:17 -0800 (PST)

Author: durner
Date: 2006-11-01 03:53:11 -0800 (Wed, 01 Nov 2006)
New Revision: 3595

Modified:
   GNUnet/src/include/gnunet_util_os.h
   GNUnet/src/util/os/osconfig.c
Log:
fix return codes

Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2006-11-01 11:27:31 UTC (rev 3594)
+++ GNUnet/src/include/gnunet_util_os.h 2006-11-01 11:53:11 UTC (rev 3595)
@@ -188,7 +188,16 @@
  *        application, NO to disable it
  * @param username name of the user account to use
  * @param groupname name of the group to use
- * @return OK on success, SYSERR on error
+ * @returns YES on success, NO if unsupported, SYSERR on failure or one of
+ *          these error codes:
+ *  Windows
+ *    2 SCM could not be opened
+ *    3 service could not be created/deleted
+ *    4 permissions could not be granted
+ *    5 registry could not be accessed
+ *    6 service could not be accessed
+ *  Unix
+ *    2 startup script could not be opened
  */
 int os_modify_autostart(struct GE_Context * ectx,
                        int testCapability,

Modified: GNUnet/src/util/os/osconfig.c
===================================================================
--- GNUnet/src/util/os/osconfig.c       2006-11-01 11:27:31 UTC (rev 3594)
+++ GNUnet/src/util/os/osconfig.c       2006-11-01 11:53:11 UTC (rev 3595)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -24,6 +24,7 @@
  * @brief functions to read or change the OS configuration
  * @author Nils Durner
  */
+
 #include "platform.h"
 #include "gnunet_util_os.h"
 #include "gnunet_util_string.h"
@@ -94,7 +95,7 @@
 
 /**
  * @brief Checks if we can start GNUnet automatically
- * @return 1 if yes, 0 otherwise
+ * @return YES if yes, NO otherwise
  */
 static int isOSAutostartCapable()
 {
@@ -103,18 +104,48 @@
   {
     /* Debian */
     if(ACCESS("/etc/init.d/", W_OK) == 0)
-      return 1;
+      return YES;
   }
-  return 0;
+  return NO;
 #else
 #ifdef WINDOWS
-  return IsWinNT();
+  return IsWinNT() ? YES : NO;
 #else
-  return 0;
+  return NO;
 #endif
 #endif
 }
 
+/**
+ * @brief Make "application" start automatically
+ *
+ * @param testCapability YES to merely probe if the OS has this
+ *        functionality (in that case, no actual operation is
+ *        performed).  SYSERR is returned if
+ *        a) autostart is not supported,
+ *        b) the application does not seem to exist
+ *        c) the user or group do not exist
+ *        d) the user has insufficient permissions for
+ *           changing autostart
+ *        e) doAutoStart is NO, but autostart is already
+ *           disabled
+ *        f) doAutoStart is YES, but autostart is already
+ *           enabled
+ * @param doAutoStart YES to enable autostart of the
+ *        application, NO to disable it
+ * @param username name of the user account to use
+ * @param groupname name of the group to use
+ * @returns YES on success, NO if unsupported, SYSERR on failure or one of
+ *          these error codes:
+ *  Windows
+ *    2 SCM could not be opened
+ *    3 service could not be created/deleted
+ *    4 permissions could not be granted
+ *    5 registry could not be accessed
+ *    6 service could not be accessed
+ *  Unix
+ *    2 startup script could not be opened
+ */
 int os_modify_autostart(struct GE_Context *ectx,
                         int testCapability,
                         int doAutoStart,
@@ -142,15 +173,16 @@
       switch (InstallAsService(username))
       {
         case 0:
+          break;
         case 1:
-          break;
+          return NO;
         case 2:
+            return 2;
+        case 3:
           if(GetLastError() != ERROR_SERVICE_EXISTS)
-            return 1;
-        case 3:
-          return 2;
+            return 3;
         default:
-          return -1;
+          return SYSERR;
       }
 
       /* Grant permissions to the GNUnet directory */
@@ -161,7 +193,7 @@
         plibc_conv_to_win_path("/", szHome);
 
         if(!AddPathAccessRights(szHome, username, GENERIC_ALL))
-          return 3;
+          return 4;
       }
     }
     else
@@ -178,12 +210,12 @@
         if(RegSetValueEx(hKey,
                          "GNUnet",
                          0, REG_SZ, szPath, strlen(szPath)) != ERROR_SUCCESS)
-          return 4;
+          return 5;
 
         RegCloseKey(hKey);
       }
       else
-        return 4;
+        return 5;
     }
   }
   else
@@ -193,16 +225,17 @@
       switch (UninstallService())
       {
         case 0:
+          break;
         case 1:
-          break;
+          return NO;
         case 2:
-          return 1;
+          return 2;
         case 3:
-          return 5;
+          return 6;
         case 4:
-          return 6;
+          return 3;
         default:
-          return -1;
+          return SYSERR;
       }
     }
     else
@@ -216,8 +249,12 @@
         RegDeleteValue(hKey, "GNUnet");
         RegCloseKey(hKey);
       }
+      else
+        return 5;
     }
   }
+  
+  return YES;
 #else
   struct stat buf;
 
@@ -248,7 +285,7 @@
         GE_LOG_STRERROR_FILE(ectx,
                              GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                              "fopen", "/etc/init.d/gnunetd");
-        return 1;
+        return 2;
       }
 
       fprintf(f,
@@ -301,7 +338,7 @@
                            "system", "/usr/sbin/update-rc.d");
       return SYSERR;
     }
-    return OK;
+    return YES;
   }
   else
   {                             /* REMOVE autostart */
@@ -320,7 +357,7 @@
                            "system", "/usr/sbin/update-rc.d");
       return SYSERR;
     }
-    return OK;
+    return YES;
   }
 #endif
   return SYSERR;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]