aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--TODO7
-rw-r--r--mpiosh/callback.c69
-rw-r--r--mpiosh/callback.h3
-rw-r--r--mpiosh/mpiosh.c34
-rw-r--r--mpiosh/mpiosh.h8
6 files changed, 111 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 02d0392..c6317fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-09-13 Andreas Buesching <crunchy@tzi.de>
+
+ * mpiosh/callback.c (mpiosh_callback_get, mpiosh_callback_put)
+ (mpiosh_callback_del): using mpiosh_cancel to abort operation
+
+ * mpiosh/mpiosh.c: changed handling of SIGINT. The global variable
+ mpiosh_cancel indicates the interrupt.
+
+ * mpiosh/callback.c (mpiosh_cmd_help): add support for
+ arguments. just prints help about specified commands.
+
+ * mpiosh/mpiosh.c: add new command lpwd
+
2002-09-13 Markus Germeier <mager@informatik.uni-bremen.de>
* mpiosh/callback.c (mpiosh_cmd_put, mpiosh_cmd_del)
diff --git a/TODO b/TODO
index 2c39ea3..3a2241b 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.12 2002/09/12 18:49:34 crunchy Exp $
+$Id: TODO,v 1.13 2002/09/13 15:20:24 crunchy Exp $
* Kernel Module
- the MPIO can no multitasking, so:
@@ -32,7 +32,12 @@ $Id: TODO,v 1.12 2002/09/12 18:49:34 crunchy Exp $
- more completion functions
+ command completion [DONE]
+ correct completion of filenames (quoting)
+ + command option completion
- handle regexps in command arguments [DONE]
- use indices for files as possible arguments for put/get
- use shell-like regular expressions
- command separator like ';' [DONE]
+ - using stdin for reading command sequences
+ - fill: uses current local directory to fill the current memory card
+ + options: random, best(?)
+
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index b84dea1..020b03f 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.2 2002/09/13 13:07:06 germeier Exp $
+ * $Id: callback.c,v 1.3 2002/09/13 15:20:25 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -76,19 +76,34 @@ void
mpiosh_cmd_help(char *args[])
{
mpiosh_cmd_t *cmd = commands;
+ int ignore;
- UNUSED(args);
-
while (cmd->cmd) {
- printf("%s", cmd->cmd);
- if (cmd->args)
- printf(" %s\n", cmd->args);
- else
- printf("\n");
- if (cmd->info)
- printf(" %s\n", cmd->info);
- else
- printf("\n");
+ if (args[0] != NULL) {
+ char ** walk = args;
+ ignore = 1;
+
+ while(*walk) {
+ if (!strcmp(*walk, cmd->cmd)) {
+ ignore = 0;
+ break;
+ }
+ walk++;
+ }
+ } else
+ ignore = 0;
+
+ if (!ignore) {
+ printf("%s", cmd->cmd);
+ if (cmd->args)
+ printf(" %s\n", cmd->args);
+ else
+ printf("\n");
+ if (cmd->info)
+ printf(" %s\n", cmd->info);
+ else
+ printf("\n");
+ }
cmd++;
}
}
@@ -206,6 +221,12 @@ mpiosh_callback_get(int read, int total)
{
printf("\rretrieved %.2f %%", ((double) read / total) * 100.0 );
fflush(stdout);
+
+ if (mpiosh_cancel) {
+ mpiosh_cancel = 0;
+ return 1;
+ }
+
return 0; // continue
}
@@ -271,6 +292,12 @@ mpiosh_callback_put(int read, int total)
{
printf("\rwrote %.2f %%", ((double) read / total) * 100.0 );
fflush(stdout);
+
+ if (mpiosh_cancel) {
+ mpiosh_cancel = 0;
+ return 1;
+ }
+
return 0; // continue
}
@@ -339,6 +366,12 @@ mpiosh_callback_del(int read, int total)
{
printf("\rdeleted %.2f %%", ((double) read / total) * 100.0 );
fflush(stdout);
+
+ if (mpiosh_cancel) {
+ mpiosh_cancel = 0;
+ return 1;
+ }
+
return 0; // continue
}
@@ -540,6 +573,18 @@ mpiosh_cmd_ldir(char *args[])
}
void
+mpiosh_cmd_lpwd(char *args[])
+{
+ char dir_buf[NAME_MAX];
+
+ UNUSED(args);
+
+ getcwd(dir_buf, NAME_MAX);
+
+ printf("%s\n", dir_buf);
+}
+
+void
mpiosh_cmd_lcd(char *args[])
{
MPIOSH_CHECK_ARG;
diff --git a/mpiosh/callback.h b/mpiosh/callback.h
index 4a0f79e..622ab00 100644
--- a/mpiosh/callback.h
+++ b/mpiosh/callback.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.h,v 1.1 2002/09/13 06:59:38 crunchy Exp $
+ * $Id: callback.h,v 1.2 2002/09/13 15:20:25 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -49,6 +49,7 @@ void mpiosh_cmd_switch(char *args[]);
/* local command callbacks */
void mpiosh_cmd_ldir(char *args[]);
+void mpiosh_cmd_lpwd(char *args[]);
void mpiosh_cmd_lcd(char *args[]);
void mpiosh_cmd_lmkdir(char *args[]);
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c
index 3b725d0..2db4e16 100644
--- a/mpiosh/mpiosh.c
+++ b/mpiosh/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.2 2002/09/13 07:00:46 crunchy Exp $
+ * $Id: mpiosh.c,v 1.3 2002/09/13 15:20:25 crunchy Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -39,8 +39,13 @@
#include "callback.h"
#include "mpiosh.h"
+/* structure containing current state */
mpiosh_t mpiosh;
+/* flag indicating a user-interrupt of the current command */
+int mpiosh_cancel = 0;
+
+/* prompt strings */
const char *PROMPT_INT = "\033[;1mmpio <i>\033[m ";
const char *PROMPT_EXT = "\033[;1mmpio <e>\033[m ";
@@ -51,8 +56,8 @@ mpiosh_cmd_t commands[] = {
{ "ver", NULL,
"version of mpio package",
mpiosh_cmd_version },
- { "help", NULL,
- "show known commands",
+ { "help", "[<command>]",
+ "show information about known commands or just about <command>",
mpiosh_cmd_help },
{ "dir", NULL,
"list content of current memory card",
@@ -110,6 +115,9 @@ mpiosh_cmd_t commands[] = {
{ "ldir", NULL,
"list local directory",
mpiosh_cmd_ldir },
+ { "lpwd", NULL,
+ "print current working directory",
+ mpiosh_cmd_lpwd },
{ "lcd", NULL,
"change the current working directory",
mpiosh_cmd_lcd },
@@ -325,12 +333,19 @@ mpiosh_command_free_args(char **args)
free(args);
}
+void
+mpiosh_signal_handler(int signal)
+{
+ debug("user abort!\n");
+ mpiosh_cancel = 1;
+}
int
main(int argc, char *argv[]) {
- char * line;
- char ** cmds, **walk;
- mpiosh_cmd_t *cmd;
+ char * line;
+ char ** cmds, **walk;
+ mpiosh_cmd_t * cmd;
+ struct sigaction sigc;
UNUSED(argc);
UNUSED(argv);
@@ -339,7 +354,12 @@ main(int argc, char *argv[]) {
setenv("mpio_color", "", 0);
/* no unwanted interruption anymore */
- signal(SIGINT, SIG_IGN);
+ sigc.sa_handler = mpiosh_signal_handler;
+ sigc.sa_flags = SA_NOMASK;
+
+ sigaction(SIGINT, &sigc, NULL);
+
+/* signal(SIGINT, SIG_IGN); */
/* init readline and history */
rl_readline_name = "mpio";
diff --git a/mpiosh/mpiosh.h b/mpiosh/mpiosh.h
index a26c911..c6e8755 100644
--- a/mpiosh/mpiosh.h
+++ b/mpiosh/mpiosh.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: mpiosh.h,v 1.2 2002/09/13 07:00:46 crunchy Exp $
+ * $Id: mpiosh.h,v 1.3 2002/09/13 15:20:25 crunchy Exp $
*
* Copyright (C) 2002 Andreas Büsching <crunchy@tzi.de>
*
@@ -39,6 +39,9 @@ typedef struct {
cmd_callback func;
} mpiosh_cmd_t;
+/* signal handler */
+void mpiosh_signal_handler(int signal);
+
/* readline extensions */
void mpiosh_readline_init(void);
char **mpiosh_readline_completion(const char *text, int start, int end);
@@ -51,9 +54,10 @@ char **mpiosh_command_split(char *line);
char **mpiosh_command_get_args(char *line);
void mpiosh_command_free_args(char **args);
-/* global structure for device information */
+/* global structures */
extern mpiosh_t mpiosh;
extern mpiosh_cmd_t commands[];
+extern int mpiosh_cancel;
extern const char *PROMPT_INT;
extern const char *PROMPT_EXT;