aboutsummaryrefslogtreecommitdiff
path: root/mpiosh
diff options
context:
space:
mode:
Diffstat (limited to 'mpiosh')
-rw-r--r--mpiosh/callback.c7
-rw-r--r--mpiosh/config.c36
-rw-r--r--mpiosh/global.c4
-rw-r--r--mpiosh/mpiosh.c7
4 files changed, 42 insertions, 12 deletions
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index dfd8474..b43d0c4 100644
--- a/mpiosh/callback.c
+++ b/mpiosh/callback.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.c,v 1.30 2002/10/29 20:03:34 crunchy Exp $
+ * $Id: callback.c,v 1.31 2002/11/04 16:25:17 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -237,6 +237,11 @@ mpiosh_cmd_quit(char *args[])
UNUSED(args);
+ if (mpiosh.config) {
+ mpiosh_config_write(mpiosh.config);
+ mpiosh_config_free(mpiosh.config);
+ }
+
exit(0);
}
diff --git a/mpiosh/config.c b/mpiosh/config.c
index 330bfea..dfe0e29 100644
--- a/mpiosh/config.c
+++ b/mpiosh/config.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Buesching <crunchy@tzi.de>
*
- * $Id: config.c,v 1.1 2002/10/29 20:03:35 crunchy Exp $
+ * $Id: config.c,v 1.2 2002/11/04 16:25:17 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -32,8 +32,7 @@ struct mpiosh_config_t *
mpiosh_config_new(void)
{
struct mpiosh_config_t * cfg = malloc(sizeof(struct mpiosh_config_t));
- char *filename;
- char *tmp;
+ char *filename, *tmp;
struct stat st;
cfg->prompt_int = cfg->prompt_ext = NULL;
@@ -48,6 +47,8 @@ mpiosh_config_new(void)
if (stat(tmp, &st) != -1)
cfg->handle_global =
cfg_handle_new_with_filename(tmp, 1);
+ else
+ cfg->handle_global = 0;
free(tmp), free(filename);
filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_FILE) + 1);
@@ -65,6 +66,18 @@ mpiosh_config_new(void)
free(tmp), free(filename);
+ /* initialise history */
+ using_history();
+
+ filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1);
+ filename[0] = '\0';
+ strcat(filename, CONFIG_USER);
+ strcat(filename, CONFIG_HISTORY);
+ tmp = cfg_resolve_path(filename);
+
+ read_history(tmp);
+ free(tmp), free(filename);
+
return cfg;
}
@@ -87,7 +100,9 @@ mpiosh_config_read_key(struct mpiosh_config_t *config, const char *group,
void
mpiosh_config_free(struct mpiosh_config_t *config)
{
- cfg_close(config->handle_global);
+ if (config->handle_global)
+ cfg_close(config->handle_global);
+
cfg_close(config->handle_user);
free(config->prompt_int);
free(config->prompt_ext);
@@ -141,6 +156,8 @@ mpiosh_config_write(struct mpiosh_config_t *config)
free(path);
if (config->handle_user) {
+ char *tmp, *filename;
+
cfg_key_set_value(config->handle_user,
"mpiosh", "prompt_int", config->prompt_int);
cfg_key_set_value(config->handle_user,
@@ -153,6 +170,17 @@ mpiosh_config_write(struct mpiosh_config_t *config)
"mpiosh", "default_mem", "internal");
cfg_save(config->handle_user, 0);
+
+ /* save history */
+ filename = malloc(strlen(CONFIG_USER) + strlen(CONFIG_HISTORY) + 1);
+ filename[0] = '\0';
+ strcat(filename, CONFIG_USER);
+ strcat(filename, CONFIG_HISTORY);
+ tmp = cfg_resolve_path(filename);
+
+ printf("writing history to file %s\n", filename);
+ write_history(tmp);
+ free(tmp), free(filename);
}
return 1;
diff --git a/mpiosh/global.c b/mpiosh/global.c
index 554652e..a6459bd 100644
--- a/mpiosh/global.c
+++ b/mpiosh/global.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Buesching <crunchy@tzi.de>
*
- * $Id: global.c,v 1.5 2002/10/29 20:03:35 crunchy Exp $
+ * $Id: global.c,v 1.6 2002/11/04 16:25:17 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -37,7 +37,7 @@ int mpiosh_cancel_ack = 0;
const char *CONFIG_GLOBAL = SYSCONFDIR "/mpio/";
const char *CONFIG_USER = "~/.mpio/";
const char *CONFIG_FILE = "mpioshrc";
-const char *CONFIG_HISTORY = "~/.mpio/mpiosh_history";
+const char *CONFIG_HISTORY = "history";
/* prompt strings */
const char *PROMPT_INT = "\033[;1mmpio <i>\033[m ";
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c
index 5ed1faa..5d76f42 100644
--- a/mpiosh/mpiosh.c
+++ b/mpiosh/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.21 2002/10/29 20:03:35 crunchy Exp $
+ * $Id: mpiosh.c,v 1.22 2002/11/04 16:25:17 crunchy Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -94,10 +94,7 @@ main(int argc, char *argv[]) {
/* init readline and history */
mpiosh_readline_init();
- using_history();
-
- debug_init();
-
+ debug_init();
mpiosh_init();
if (!isatty(fileno(stdin))) {