gnunet-svn
[Top][All Lists]
Advanced

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

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


From: moon
Subject: [GNUnet-SVN] r3069 - in GNUnet: . src/include src/util/os
Date: Tue, 27 Jun 2006 07:21:12 -0700 (PDT)

Author: moon
Date: 2006-06-27 07:21:05 -0700 (Tue, 27 Jun 2006)
New Revision: 3069

Modified:
   GNUnet/configure.ac
   GNUnet/src/include/gnunet_util_os.h
   GNUnet/src/util/os/Makefile.am
   GNUnet/src/util/os/installpath.c
Log:
added installpath.c to build (compiles, but maybe not works right)
removed uneeded AC_DEFINE_DIR from Makefile.am



Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2006-06-26 20:49:53 UTC (rev 3068)
+++ GNUnet/configure.ac 2006-06-27 14:21:05 UTC (rev 3069)
@@ -138,8 +138,9 @@
 # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do
 # not contain the actual GNUnet installation. GNUnet usually lives in
 # "C:\Program Files\GNU\GNUnet\bin".
-AC_DEFINE_DIR([DATADIR], [datadir/GNUnet/], [The directory for installing 
read-only architecture-independent data])
-AC_DEFINE_DIR([LOCALEDIR], [datadir/locale/], [gettext catalogs])
+#AC_DEFINE_DIR([DATADIR], [datadir/GNUnet/], [The directory for 
+#installing read-only architecture-independent data])
+#AC_DEFINE_DIR([LOCALEDIR], [datadir/locale/], [gettext catalogs])
 
 
 CHECK_PTHREAD

Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2006-06-26 20:49:53 UTC (rev 3068)
+++ GNUnet/src/include/gnunet_util_os.h 2006-06-27 14:21:05 UTC (rev 3069)
@@ -241,6 +241,28 @@
 int os_daemon_stop(struct GE_Context * ectx,
                   int pid);
 
+/**
+ * List of install paths
+ */
+enum InstallPathKind {
+  PREFIX,
+  BINDIR,
+  LIBDIR,
+  DATADIR,
+  PACKAGEDATADIR,
+  LOCALEDIR };
+
+/**
+ * @brief get the path to a specific app dir
+ * @author Milan
+ * @param ectx the context to report the errors to
+ * @param cfg the context to get configuration values from
+ * @return a pointer to the dir path (to be freed by the caller)
+ */
+char * os_get_installation_path(struct GE_Context * ectx,
+                                struct GC_Configuration * cfg,
+                                enum InstallPathKind dirkind);
+
 #if 0 /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: GNUnet/src/util/os/Makefile.am
===================================================================
--- GNUnet/src/util/os/Makefile.am      2006-06-26 20:49:53 UTC (rev 3068)
+++ GNUnet/src/util/os/Makefile.am      2006-06-27 14:21:05 UTC (rev 3069)
@@ -12,7 +12,8 @@
  osconfig.c \
  semaphore.c \
  statuscalls.c \
- time.c
+ time.c \
+ installpath.c
 
 check_PROGRAMS = \
  daemontest \

Modified: GNUnet/src/util/os/installpath.c
===================================================================
--- GNUnet/src/util/os/installpath.c    2006-06-26 20:49:53 UTC (rev 3068)
+++ GNUnet/src/util/os/installpath.c    2006-06-27 14:21:05 UTC (rev 3069)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/util/os/prefix.c
+ * @file src/util/os/installpath.c
  * @brief get paths used by the program
  * @author Milan
  */
@@ -32,32 +32,26 @@
 #endif
 
 #include <sys/stat.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+
+#include "platform.h"
+#include "gnunet_util_string.h"
 #include "gnunet_util_config.h"
+#include "gnunet_util_os.h"
 
+/* assumed math size for a path
+ * used to try allocating less memory than PATH_MAX */
 #define PATH_TRY 96
 
-/*
- * List of app dirs
- * Used to find paths
- */
-enum InstallPathKind {
-  PREFIX,
-  BINDIR,
-  LIBDIR,
-  DATADIR,
-  PACKAGEDATADIR,
-  LOCALEDIR };
 
 /*
  * @brief get the path to the executable, including the binary itself
  * @author Milan
  * @param ectx the context to report the errors to
  * @param cfg the context to get configuration values from
- * @returns a pointer to the executable path, owned by the function (don't 
free it)
+ * @return a pointer to the executable path, owned by the function (don't free 
it)
  */
 static char *os_get_exec_path(struct GE_Context * ectx,
                               struct GC_Configuration * cfg) {
@@ -116,7 +110,7 @@
     tmp = MALLOC(PATH_TRY); /* let's try with a little buffer */
     if( !getcwd(tmp, PATH_TRY-1) ) { /* buffer too small */
       tmp = REALLOC(tmp, path_max);
-      size = getcwd(tmp, path_max-1); }
+      getcwd(tmp, path_max-1); }
 
     execpath = MALLOC(strlen(tmp)+strlen(path1)+2);
     sprintf(execpath, "%s/%s", tmp, path1);
@@ -133,13 +127,13 @@
 
     while(strchr(tmp, ':')) {
       path2 = (strrchr(tmp, ':')+1);
-      size2 = strlen(path2)+size+2);
+      size2 = strlen(path2)+size+2;
       if(size2 > size1) {
         path3 = REALLOC(path3, size2); /* not nice, but best to do: */
         size1 = size2; }               /* malloc PATH_MAX bytes is too much */
 
       sprintf(path3, "%s/%s", path2, path1);
-      if(STAT(path3, &dummy_stat) == 0) {
+      if(stat(path3, &dummy_stat) == 0) {
         found = 1;
         break; }
        *(path2-1) = '\0';
@@ -161,19 +155,18 @@
   if(found) {
       return execpath; }
   else { /* we can do nothing to run normally */
-    GE_LOG(NULL, /* This error should not occur on standard Unices */
+    GE_LOG(ectx, /* This error should not occur on standard Unices */
           GE_ERROR | GE_USER | GE_ADMIN | GE_DEVELOPER | GE_IMMEDIATE,
           _("Cannot determine the path to the executable, your system may be 
broken or not supported.\n"));
      return NULL; }
 }
 
-
 /*
  * @brief get the path to a specific app dir
  * @author Milan
  * @param ectx the context to report the errors to
  * @param cfg the context to get configuration values from
- * @returns a pointer to the dir path (to be freed by the caller)
+ * @return a pointer to the dir path (to be freed by the caller)
  */
 char * os_get_installation_path(struct GE_Context * ectx,
                                 struct GC_Configuration * cfg,
@@ -243,7 +236,7 @@
   final_dir = STRDUP(tmp);
 
   FREE(tmp);
-  FREENONULL(dirname);
+  FREENONNULL(dirname);
   return final_dir;
 }
 
@@ -253,4 +246,4 @@
 #ifdef __cplusplus
 }
 #endif
-/* end of prefix.c */
+/* end of installpath.c */





reply via email to

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