[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1064 - in GNUnet/src: conf include util
From: |
durner |
Subject: |
[GNUnet-SVN] r1064 - in GNUnet/src: conf include util |
Date: |
Sun, 26 Jun 2005 07:47:58 -0700 (PDT) |
Author: durner
Date: 2005-06-26 07:47:50 -0700 (Sun, 26 Jun 2005)
New Revision: 1064
Added:
GNUnet/src/conf/recreate.c
Modified:
GNUnet/src/conf/Makefile.am
GNUnet/src/conf/gnunet-setup.c
GNUnet/src/include/gnunet_util.h
GNUnet/src/util/daemon.c
Log:
module to recreate config files
Modified: GNUnet/src/conf/Makefile.am
===================================================================
--- GNUnet/src/conf/Makefile.am 2005-06-26 14:40:10 UTC (rev 1063)
+++ GNUnet/src/conf/Makefile.am 2005-06-26 14:47:50 UTC (rev 1064)
@@ -78,6 +78,7 @@
expr.h \
lkc.h \
menu.c \
+ recreate.c \
symbol.c \
zconf.tab.h \
zconf_tab.c \
Modified: GNUnet/src/conf/gnunet-setup.c
===================================================================
--- GNUnet/src/conf/gnunet-setup.c 2005-06-26 14:40:10 UTC (rev 1063)
+++ GNUnet/src/conf/gnunet-setup.c 2005-06-26 14:47:50 UTC (rev 1064)
@@ -32,6 +32,7 @@
static void help() {
puts(_("USAGE: gnunet-setup MODULE\n\n"
"MODULE\n"
+ " recreate\t\recreate configuration files\n"
" config\t\ttext-based configuration\n"
" menuconfig\ttext-based menu\n"
" gconfig\tGTK configuration\n"
@@ -50,6 +51,7 @@
#endif
int conf_main(int ac, char **av);
+int recreate_main(int ac, char **av);
int main(int argc,
char *argv[]) {
@@ -89,7 +91,11 @@
#else
puts("Gconfig is not available\n");
#endif
- } else {
+ }
+ else if (strncmp(argv[1], "recreate", 7) == 0) {
+ recreate_main(argc - 1, &argv[1]);
+ }
+ else {
puts("Unknown configurator\n\n");
help();
}
Added: GNUnet/src/conf/recreate.c
===================================================================
--- GNUnet/src/conf/recreate.c 2005-06-26 14:40:10 UTC (rev 1063)
+++ GNUnet/src/conf/recreate.c 2005-06-26 14:47:50 UTC (rev 1064)
@@ -0,0 +1,68 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005 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 conf/silent.c
+ * @brief create .conf files from the .in templates
+ * @author Nils Durner
+ */
+
+#include "gnunet_util.h"
+
+#define LKC_DIRECT_LINK
+#include "lkc.h"
+
+
+int recreate_main(int ac, char **av) {
+ struct symbol *sym;
+
+ conf_parse(DATADIR"/config.in");
+
+ /* we are setting advanced/rare settings below */
+ sym = sym_find("EXPERIMENTAL", "Meta");
+ sym_set_tristate_value(sym, yes);
+ sym = sym_find("ADVANCED", "Meta");
+ sym_set_tristate_value(sym, yes);
+ sym = sym_find("RARE", "Meta");
+ sym_set_tristate_value(sym, yes);
+
+ /* save new config files to DATADIR */
+ sym = sym_find("config-daemon.in_CONF_DEF_DIR", "Meta");
+ sym_set_string_value(sym, DATADIR"/");
+
+ sym = sym_find("config-daemon.in_CONF_DEF_FILE", "Meta");
+ sym_set_string_value(sym, "gnunet.root");
+
+ sym = sym_find("config-client.in_CONF_DEF_DIR", "Meta");
+ sym_set_string_value(sym, DATADIR"/");
+
+ sym = sym_find("config-client.in_CONF_DEF_FILE", "Meta");
+ sym_set_string_value(sym, "gnunet.user");
+
+ /* Write defaults */
+ if (!conf_write()) {
+ printf(_("Unable to save configuration files to %s.\n"),
DATADIR);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+/* end of silent.c */
Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h 2005-06-26 14:40:10 UTC (rev 1063)
+++ GNUnet/src/include/gnunet_util.h 2005-06-26 14:47:50 UTC (rev 1064)
@@ -2401,6 +2401,11 @@
*/
int waitForGNUnetDaemonTermination(int pid);
+/**
+ * @brief Terminate a process
+ * @return YES on success, NO otherwise
+ */
+int termProcess(int pid);
/* ifndef GNUNET_UTIL_H */
#endif
Modified: GNUnet/src/util/daemon.c
===================================================================
--- GNUnet/src/util/daemon.c 2005-06-26 14:40:10 UTC (rev 1063)
+++ GNUnet/src/util/daemon.c 2005-06-26 14:47:50 UTC (rev 1064)
@@ -314,4 +314,29 @@
return NO;
}
+int termProcess(int pid) {
+#ifndef MINGW
+ return kill(daemon1, SIGTERM) == 0;
+#else
+ int ret;
+ DWORD dwExitCode = 0;
+
+ HANDLE hProc = OpenProcess(1, 0, pid);
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid);
+
+ WaitForSingleObject(hProc, 3000);
+
+ GetExitCodeProcess(hProc, &dwExitCode);
+ if(dwExitCode == STILL_ACTIVE) {
+ ret = TerminateProcess(hProc, 0);
+ }
+ else
+ ret = 1;
+
+ CloseHandle(hProc);
+
+ return ret;
+#endif
+}
+
/* end of daemon.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1064 - in GNUnet/src: conf include util,
durner <=