[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3132 - in GNUnet/src: include util util/crypto util/getopt
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3132 - in GNUnet/src: include util util/crypto util/getopt util/loggers util/os util/string |
Date: |
Tue, 25 Jul 2006 00:09:35 -0700 (PDT) |
Author: grothoff
Date: 2006-07-25 00:09:30 -0700 (Tue, 25 Jul 2006)
New Revision: 3132
Added:
GNUnet/src/include/gnunet_directories.h
GNUnet/src/util/os/priority.c
Modified:
GNUnet/src/include/Makefile.am
GNUnet/src/include/gnunet_util.h
GNUnet/src/include/gnunet_util_error.h
GNUnet/src/include/gnunet_util_os.h
GNUnet/src/util/crypto/hashing.c
GNUnet/src/util/getopt/Makefile
GNUnet/src/util/initialize.c
GNUnet/src/util/loggers/file.c
GNUnet/src/util/os/Makefile.am
GNUnet/src/util/string/Makefile
Log:
fixing util
Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/include/Makefile.am 2006-07-25 07:09:30 UTC (rev 3132)
@@ -20,6 +20,7 @@
gnunet_dht_datastore_memory.h \
gnunet_dht_lib.h \
gnunet_dht_service.h \
+ gnunet_directories.h \
gnunet_ecrs_lib.h \
gnunet_fragmentation_service.h \
gnunet_fs_lib.h \
Added: GNUnet/src/include/gnunet_directories.h
===================================================================
--- GNUnet/src/include/gnunet_directories.h 2006-07-25 06:43:45 UTC (rev
3131)
+++ GNUnet/src/include/gnunet_directories.h 2006-07-25 07:09:30 UTC (rev
3132)
@@ -0,0 +1,40 @@
+/*
+ This file is part of GNUnet.
+ (C) 2001, 2002, 2003, 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
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file include/gnunet_directories.h
+ * @brief directories and files in GNUnet (default locations)
+ *
+ * @author Christian Grothoff
+ */
+
+#ifndef GNUNET_DIRECTORIES
+#define GNUNET_DIRECTORIES
+
+#define DEFAULT_CLIENT_CONFIG_FILE "~/.gnunet/gnunet.conf"
+#define DEFAULT_DAEMON_DIR "/etc"
+#define DEFAULT_DAEMON_CONFIG_FILE DEFAULT_DAEMON_DIR"/gnunetd.conf"
+#define VAR_DIRECTORY "/var/lib"
+#define VAR_DAEMON_DIRECTORY VAR_DIRECTORY"/gnunet"
+#define VAR_DAEMON_CONFIG_FILE VAR_DAEMON_DIRECTORY"/gnunetd.conf"
+#define GNUNET_HOME_DIRECTORY "~/.gnunet"
+#define HOME_DAEMON_CONFIG_FILE GNUNET_HOME_DIRECTORY"/gnunetd.conf"
+
+#endif
Property changes on: GNUnet/src/include/gnunet_directories.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/include/gnunet_util.h 2006-07-25 07:09:30 UTC (rev 3132)
@@ -86,29 +86,6 @@
*/
#define GNUNET_UTIL_VERSION 0x00070100
-/* CHRISTIAN: move this to gnunet_core.h or _protocols.h ? */
-
-/* FIXME: these functions need to be replaced with
- functions that are appropriate for bootstrapping
- the new gnunetutil library (i.e. setup error,
- parse command line, setup configuration, etc.) */
-
-/**
- * Initialize the util module.
- * @param argc the number of arguments
- * @param argv the command line arguments
- * @param parser parser to call at the right moment
- * @return OK on success, SYSERR if we should abort
- */
-int initUtil(int argc,
- char * argv[]);
-
-
-/**
- * Shutdown the util services in proper order.
- */
-void doneUtil(void);
-
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: GNUnet/src/include/gnunet_util_error.h
===================================================================
--- GNUnet/src/include/gnunet_util_error.h 2006-07-25 06:43:45 UTC (rev
3131)
+++ GNUnet/src/include/gnunet_util_error.h 2006-07-25 07:09:30 UTC (rev
3132)
@@ -39,9 +39,6 @@
#include "gnunet_util_common.h"
-
-
-
/**
* Context required to log messages.
*/
Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/include/gnunet_util_os.h 2006-07-25 07:09:30 UTC (rev 3132)
@@ -154,6 +154,13 @@
void * cls);
/**
+ * Set our process priority
+ * @return OK on success, SYSERR on error
+ */
+int os_set_process_priority(struct GE_Context * ectx,
+ const char * str);
+
+/**
* @brief Make "application" start automatically
*
* @param testCapability YES to merely probe if the OS has this
Modified: GNUnet/src/util/crypto/hashing.c
===================================================================
--- GNUnet/src/util/crypto/hashing.c 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/crypto/hashing.c 2006-07-25 07:09:30 UTC (rev 3132)
@@ -330,13 +330,17 @@
int fh;
struct sha512_ctx ctx;
- if (OK != getFileSize(ectx,
- filename,
- &len))
+ if (OK != disk_file_test(ectx,
+ filename))
return SYSERR;
- fh = fileopen(ectx,
- filename,
- O_RDONLY | O_LARGEFILE);
+ if (OK != disk_file_size(ectx,
+ filename,
+ &len,
+ NO))
+ return SYSERR;
+ fh = disk_file_open(ectx,
+ filename,
+ O_RDONLY | O_LARGEFILE);
if (fh == -1) {
GE_LOG_STRERROR_FILE(ectx,
GE_ERROR | GE_USER | GE_ADMIN | GE_REQUEST,
@@ -566,7 +570,8 @@
int getHashCodeBit(const HashCode512 * code,
unsigned int bit) {
if (bit >= 8 * sizeof(HashCode512)) {
- BREAK();
+ GE_ASSERT(NULL,
+ 0);
return -1; /* error */
}
return (((unsigned char*)code)[bit >> 3] & (1 << bit & 7)) > 0;
Modified: GNUnet/src/util/getopt/Makefile
===================================================================
--- GNUnet/src/util/getopt/Makefile 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/getopt/Makefile 2006-07-25 07:09:30 UTC (rev 3132)
@@ -124,7 +124,7 @@
FFLAGS = -g -O2
GMSGFMT = /usr/bin/msgfmt
GNUNETGTK_CFLAGS = -I/usr/include/libglade-2.0 -I/usr/include/gtk-2.0
-I/usr/include/libxml2 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-GNUNETGTK_LIBS = -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lz -lgdk-x11-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama
-lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0
-lgmodule-2.0 -ldl -lglib-2.0
+GNUNETGTK_LIBS = -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama
-lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0
-lgmodule-2.0 -ldl -lglib-2.0
GREP = /bin/grep
GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
GTK_LIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm
-lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr
-lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl
-lglib-2.0
Modified: GNUnet/src/util/initialize.c
===================================================================
--- GNUnet/src/util/initialize.c 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/initialize.c 2006-07-25 07:09:30 UTC (rev 3132)
@@ -28,86 +28,10 @@
#include "gnunet_util.h"
/**
- * Set our process priority
+ * Initialize the util library.
*/
-static void setProcessPrio(const char * str) {
- int prio = 0;
-
- if (str) {
- /* We support four levels (NORMAL, ABOVE NORMAL, BELOW NORMAL, HIGH and
IDLE)
- * and the usual numeric nice() increments */
- if (strcmp(str, "NORMAL") == 0)
+int __attribute__ ((constructor)) gnunet_util_init() {
#ifdef MINGW
- prio = NORMAL_PRIORITY_CLASS;
-#else
- prio = 0;
-#endif
- else if (strcmp(str, "ABOVE NORMAL") == 0)
-#ifdef MINGW
- prio = ABOVE_NORMAL_PRIORITY_CLASS;
-#else
- prio = -5;
-#endif
- else if (strcmp(str, "BELOW NORMAL") == 0)
-#ifdef MINGW
- prio = BELOW_NORMAL_PRIORITY_CLASS;
-#else
- prio = 10;
-#endif
- else if (strcmp(str, "HIGH") == 0)
-#ifdef MINGW
- prio = HIGH_PRIORITY_CLASS;
-#else
- prio = -10;
-#endif
- else if (strcmp(str, "IDLE") == 0)
-#ifdef MINGW
- prio = IDLE_PRIORITY_CLASS;
-#else
- prio = 19;
-#endif
- else {
- prio = atoi(str);
-
-#ifdef MINGW
- /* Convert the nice increment to a priority class */
- if (prio == 0)
- prio = NORMAL_PRIORITY_CLASS;
- else if (prio > 0 && prio <= 10)
- prio = BELOW_NORMAL_PRIORITY_CLASS;
- else if (prio > 0)
- prio = IDLE_PRIORITY_CLASS;
- else if (prio < 0 && prio >= -10)
- prio = ABOVE_NORMAL_PRIORITY_CLASS;
- else if (prio < 0)
- prio = HIGH_PRIORITY_CLASS;
-#endif
- }
-
- /* Set process priority */
-#ifdef MINGW
- SetPriorityClass(GetCurrentProcess(), prio);
-#else
- errno = 0;
- nice(prio);
- if (errno != 0)
- GE_LOG_STRERROR(NULL,
- GE_WARNING | GE_ADMIN | GE_BULK,
- "nice");
-#endif
- }
-}
-
-/**
- * Initialize the util library. Use argc, argv and the given parser
- * for processing command-line options <strong>after</strong> the
- * configuration module was initialized, but <strong>before</strong> logging
- * and other configuration-dependent features are started.
- */
-int initUtil(int argc,
- char * argv[]) {
-
-#ifdef MINGW
if (InitWinEnv() != ERROR_SUCCESS)
return SYSERR;
#endif
@@ -116,19 +40,13 @@
BINDTEXTDOMAIN("GNUnet", LOCALEDIR);
textdomain("GNUnet");
#endif
- /* if (argc > 0)
- setConfigurationString("MAIN",
- "ARGV[0]",
- argv[0]);*/
- // setProcessPrio();
return OK;
}
-void doneUtil() {
+void __attribute__ ((destructor)) gnunet_util_fini() {
#ifdef MINGW
ShutdownWinEnv();
#endif
}
-
/* end of initialize.c */
Modified: GNUnet/src/util/loggers/file.c
===================================================================
--- GNUnet/src/util/loggers/file.c 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/loggers/file.c 2006-07-25 07:09:30 UTC (rev 3132)
@@ -24,11 +24,11 @@
*
* @author Christian Grothoff
*/
+#define _XOPEN_SOURCE /* glibc2 needs this */
#include "gnunet_util_error_loggers.h"
#include "gnunet_util_string.h"
#include "gnunet_util.h"
#include "platform.h"
-#define _XOPEN_SOURCE /* glibc2 needs this */
#include <time.h>
/**
Modified: GNUnet/src/util/os/Makefile.am
===================================================================
--- GNUnet/src/util/os/Makefile.am 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/os/Makefile.am 2006-07-25 07:09:30 UTC (rev 3132)
@@ -10,6 +10,7 @@
daemon.c \
dso.c \
osconfig.c \
+ priority.c \
semaphore.c \
statuscalls.c \
time.c \
Added: GNUnet/src/util/os/priority.c
===================================================================
--- GNUnet/src/util/os/priority.c 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/os/priority.c 2006-07-25 07:09:30 UTC (rev 3132)
@@ -0,0 +1,113 @@
+/*
+ This file is part of GNUnet
+ (C) 2002, 2003, 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
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file util/os/priority.c
+ * @brief Methods to set process priority
+ * @author Nils Durner
+ */
+
+#include "platform.h"
+#include "gnunet_util_error.h"
+#include "gnunet_util_os.h"
+
+/**
+ * Set our process priority
+ */
+int os_set_process_priority(struct GE_Context * ectx,
+ const char * str) {
+ int prio = 0;
+
+ GE_ASSERT(ectx,
+ str != NULL);
+ /* We support four levels (NORMAL, ABOVE NORMAL, BELOW NORMAL, HIGH and IDLE)
+ * and the usual numeric nice() increments */
+ if (strcmp(str, "NORMAL") == 0)
+#ifdef MINGW
+ prio = NORMAL_PRIORITY_CLASS;
+#else
+ prio = 0;
+#endif
+ else if (strcmp(str, "ABOVE NORMAL") == 0)
+#ifdef MINGW
+ prio = ABOVE_NORMAL_PRIORITY_CLASS;
+#else
+ prio = -5;
+#endif
+ else if (strcmp(str, "BELOW NORMAL") == 0)
+#ifdef MINGW
+ prio = BELOW_NORMAL_PRIORITY_CLASS;
+#else
+ prio = 10;
+#endif
+ else if (strcmp(str, "HIGH") == 0)
+#ifdef MINGW
+ prio = HIGH_PRIORITY_CLASS;
+#else
+ prio = -10;
+#endif
+ else if (strcmp(str, "IDLE") == 0)
+#ifdef MINGW
+ prio = IDLE_PRIORITY_CLASS;
+#else
+ prio = 19;
+#endif
+ else {
+ if (1 != sscanf(str,
+ "%d",
+ &prio)) {
+ GE_LOG(ectx,
+ GE_USER | GE_BULK | GE_ERROR,
+ _("Invalid process priority `%s'\n"),
+ str);
+ return SYSERR;
+ }
+
+#ifdef MINGW
+ /* Convert the nice increment to a priority class */
+ if (prio == 0)
+ prio = NORMAL_PRIORITY_CLASS;
+ else if (prio > 0 && prio <= 10)
+ prio = BELOW_NORMAL_PRIORITY_CLASS;
+ else if (prio > 0)
+ prio = IDLE_PRIORITY_CLASS;
+ else if (prio < 0 && prio >= -10)
+ prio = ABOVE_NORMAL_PRIORITY_CLASS;
+ else if (prio < 0)
+ prio = HIGH_PRIORITY_CLASS;
+#endif
+ }
+
+ /* Set process priority */
+#ifdef MINGW
+ SetPriorityClass(GetCurrentProcess(), prio);
+#else
+ errno = 0;
+ nice(prio);
+ if (errno != 0) {
+ GE_LOG_STRERROR(ectx,
+ GE_WARNING | GE_ADMIN | GE_BULK,
+ "nice");
+ return SYSERR;
+ }
+#endif
+ return OK;
+}
+
Property changes on: GNUnet/src/util/os/priority.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: GNUnet/src/util/string/Makefile
===================================================================
--- GNUnet/src/util/string/Makefile 2006-07-25 06:43:45 UTC (rev 3131)
+++ GNUnet/src/util/string/Makefile 2006-07-25 07:09:30 UTC (rev 3132)
@@ -126,7 +126,7 @@
FFLAGS = -g -O2
GMSGFMT = /usr/bin/msgfmt
GNUNETGTK_CFLAGS = -I/usr/include/libglade-2.0 -I/usr/include/gtk-2.0
-I/usr/include/libxml2 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include
-GNUNETGTK_LIBS = -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lz -lgdk-x11-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama
-lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0
-lgmodule-2.0 -ldl -lglib-2.0
+GNUNETGTK_LIBS = -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama
-lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0
-lgmodule-2.0 -ldl -lglib-2.0
GREP = /bin/grep
GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
GTK_LIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm
-lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr
-lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl
-lglib-2.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3132 - in GNUnet/src: include util util/crypto util/getopt util/loggers util/os util/string,
grothoff <=