aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrunchy <crunchy>2002-11-04 16:25:17 +0000
committercrunchy <crunchy>2002-11-04 16:25:17 +0000
commit4b1237e6d4fc6ca2e5ffe10946c92fe2e5484be0 (patch)
tree02b254fe8d7c71242703281947612d22ff28ef6d
parent49cea7b628458fdaca794f2b01cf1b5901d8fb92 (diff)
downloadmpiosh-4b1237e6d4fc6ca2e5ffe10946c92fe2e5484be0.tar.gz
mpiosh-4b1237e6d4fc6ca2e5ffe10946c92fe2e5484be0.tar.bz2
mpiosh-4b1237e6d4fc6ca2e5ffe10946c92fe2e5484be0.zip
saving command history
-rw-r--r--ChangeLog11
-rw-r--r--TODO4
-rw-r--r--mpiosh/callback.c7
-rw-r--r--mpiosh/config.c36
-rw-r--r--mpiosh/global.c4
-rw-r--r--mpiosh/mpiosh.c7
6 files changed, 55 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index c0c5733..d47f1a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-11-04 Andreas Buesching <crunchy@tzi.de>
+
+ * mpiosh/callback.c (mpiosh_cmd_quit): writing configuration
+ including history und freeing config reader
+
+ * mpiosh/global.c: modified filename for history
+ "~/.mpio/history"
+
+ * mpiosh/config.c (mpiosh_config_new): reading history file
+ (mpiosh_config_write): saving current history
+
2002-11-02 Yuji Touya <salmoon@users.sourceforge.net>
* tools/logotool.c: add a tool to extract/change logo animation
diff --git a/TODO b/TODO
index c09d77e..dee1965 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.17 2002/10/29 20:03:34 crunchy Exp $
+$Id: TODO,v 1.18 2002/11/04 16:25:17 crunchy Exp $
* Kernel Module
- the MPIO can no multitasking, so:
@@ -40,5 +40,5 @@ $Id: TODO,v 1.17 2002/10/29 20:03:34 crunchy Exp $
- fill: uses current local directory to fill the current memory card
+ options: random, best(?)
- configuration files [almost DONE]
- - save command history
+ - save command history [DONE]
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))) {