aboutsummaryrefslogtreecommitdiff
path: root/mpio_tool
diff options
context:
space:
mode:
Diffstat (limited to 'mpio_tool')
-rw-r--r--mpio_tool/Makefile.in76
-rw-r--r--mpio_tool/mpiosh.c101
-rw-r--r--mpio_tool/mpiosh.h3
3 files changed, 137 insertions, 43 deletions
diff --git a/mpio_tool/Makefile.in b/mpio_tool/Makefile.in
index 2586bc4..e291f08 100644
--- a/mpio_tool/Makefile.in
+++ b/mpio_tool/Makefile.in
@@ -120,6 +120,7 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
+DEP_FILES = .deps/mpio_tool.P .deps/mpiosh.P
SOURCES = $(mpio_tool_SOURCES) $(mpiosh_SOURCES)
OBJECTS = $(mpio_tool_OBJECTS) $(mpiosh_OBJECTS)
@@ -127,9 +128,9 @@ all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .obj .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps mpio_tool/Makefile
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu mpio_tool/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
@@ -159,9 +160,6 @@ uninstall-binPROGRAMS:
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
-.c.o:
- $(COMPILE) -c $<
-
# FIXME: We should only use cygpath when building on Windows,
# and only if it is available.
.c.obj:
@@ -184,9 +182,6 @@ distclean-compile:
maintainer-clean-compile:
-.c.lo:
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
@@ -245,6 +240,11 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = mpio_tool
distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu mpio_tool/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
@@ -255,11 +255,38 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
-mpio_tool.o: mpio_tool.c ../libmpio/mpio.h ../libmpio/defs.h \
- ../libmpio/debug.h
-mpiosh.o: mpiosh.c ../libmpio/debug.h ../libmpio/mpio.h \
- ../libmpio/defs.h mpiosh.h
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
@@ -297,26 +324,27 @@ distclean-generic:
maintainer-clean-generic:
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
- mostlyclean-libtool mostlyclean-tags \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \
- clean-generic mostlyclean-am
+ clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \
- distclean-tags distclean-generic clean-am
+ distclean-tags distclean-depend distclean-generic \
+ clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-libtool \
- maintainer-clean-tags maintainer-clean-generic \
- distclean-am
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
@@ -327,12 +355,14 @@ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs \
-mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/mpio_tool/mpiosh.c b/mpio_tool/mpiosh.c
index 7e94818..f424509 100644
--- a/mpio_tool/mpiosh.c
+++ b/mpio_tool/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.2 2002/09/01 16:07:10 crunchy Exp $
+ * $Id: mpiosh.c,v 1.3 2002/09/01 18:27:49 crunchy Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -26,9 +26,13 @@
* */
#include <dirent.h>
+#include <grp.h>
+#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
@@ -60,6 +64,7 @@ static mpiosh_cmd_t commands[] = {
{ "switch", mpiosh_cmd_switch, YES },
{ "ldir", mpiosh_cmd_ldir, YES },
{ "lcd", mpiosh_cmd_lcd, YES },
+ { "lmkdir", mpiosh_cmd_lmkdir, YES },
{ NULL, NULL, NO }
};
@@ -101,7 +106,7 @@ mpiosh_readline_completion(const char *text, int start, int end)
UNUSED(end);
if (start == 0)
- matches = completion_matches(text, mpiosh_readline_comp_cmd);
+ matches = rl_completion_matches(text, mpiosh_readline_comp_cmd);
else {
}
@@ -284,7 +289,7 @@ mpiosh_cmd_help(char *args[])
" open connect to MPIO player\n");
printf("close\n"
" close connect to MPIO player\n");
- printf("dev [i|e]\n"
+ printf("mem [i|e]\n"
" set current memory card. 'i' selects the internal and 'e'\n"
" selects the external memory card (smart media card)\n");
printf("dir\n"
@@ -301,6 +306,14 @@ mpiosh_cmd_help(char *args[])
" read <filename> from memory card\n");
printf("del <filename>\n"
" deletes <filename> from memory card\n");
+ printf("exit, quit\n"
+ " exit mpiosh and close the device\n");
+ printf("lcd\n"
+ " change the current working directory\n");
+ printf("ldir\n"
+ " list local directory\n");
+ printf("lmkdir\n"
+ " create a local directory\n");
}
void
@@ -520,7 +533,7 @@ mpiosh_cmd_dump(char *args[])
{
BYTE *p;
BYTE month, day, hour, minute;
- BYTE fname[100];
+ BYTE fname[256];
char *arg[2];
WORD year;
DWORD fsize;
@@ -532,19 +545,20 @@ mpiosh_cmd_dump(char *args[])
UNUSED(args);
- args[0] = fname;
- args[1] = NULL;
+ arg[0] = fname;
+ arg[1] = NULL;
p = mpio_directory_open(mpiosh.dev, mpiosh.card);
while (p != NULL) {
- memset(fname, '\0', 100);
+ memset(fname, '\0', 256);
mpio_dentry_get(mpiosh.dev, p,
- fname, 100,
+ fname, 256,
&year, &month, &day,
&hour, &minute, &fsize);
- printf("getting '%s' ... ", arg[0]);
+
+ printf("getting '%s' ... \n", arg[0]);
mpiosh_cmd_get(arg);
p = mpio_dentry_next(mpiosh.dev, p);
@@ -616,25 +630,74 @@ mpiosh_cmd_switch(char *args[])
void
mpiosh_cmd_ldir(char *args[])
{
- char dir_buf[NAME_MAX];
- DIR * dir;
- dirent ** dentry;
-
- getcwd(dir_buf, NAME_MAX);
- dir = opendir(dir_buf);
+ char dir_buf[NAME_MAX];
+ struct dirent ** dentry, **run;
+ int count;
- if (dir) {
- int count = scandir(dir, &dentry, alphasort, NULL);
-
+ getcwd(dir_buf, NAME_MAX);
+ if (dir_buf != '\0') {
+ if ((count = scandir(dir_buf, &dentry, NULL, alphasort)) != -1) {
+ int j, i, len = 0;
+ struct stat st;
+ struct passwd * pwd;
+ struct group * grp;
+ char time[12];
+ char rights[11];
+
+ run = dentry;
+ rights[10] = '\0';
+ for (i = 0; i < count; i++, run++) {
+ stat((*run)->d_name, &st);
+
+ rights[0] = *("?pc?dnb?-?l?s???" + (st.st_mode >> 12 & 0xf));
+ for (j = 0; j < 9; j++) {
+ if (st.st_mode & 1 << (8 - j))
+ rights[j + 1] = "rwxrwxrwx"[j];
+ else
+ rights[j + 1] = '-';
+ }
+
+ pwd = getpwuid(st.st_uid);
+ grp = getgrgid(st.st_gid);
+ strftime(time, 12, "%b %2d", localtime(&(st.st_mtime)));
+ printf("%s %08s %08s %8d %10s %s\n",
+ rights, pwd->pw_name, grp->gr_name, st.st_size,
+ time,
+ (*run)->d_name);
+ free(*run);
+ }
+ free(dentry);
+ }
}
-
}
void
mpiosh_cmd_lcd(char *args[])
{
+ if (args[0] == NULL) {
+ fprintf(stderr, "error: no argument given\n");
+ return;
+ }
+
+ if (chdir(args[0])) {
+ perror ("error");
+ }
+}
+
+void
+mpiosh_cmd_lmkdir(char *args[])
+{
+ if (args[0] == NULL) {
+ fprintf(stderr, "error: no argument given\n");
+ return;
+ }
+
+ if (mkdir(args[0], 0777)) {
+ perror("error");
+ }
}
+
int
main(int argc, char *argv[]) {
char * line;
diff --git a/mpio_tool/mpiosh.h b/mpio_tool/mpiosh.h
index 96ec8a9..c3d550a 100644
--- a/mpio_tool/mpiosh.h
+++ b/mpio_tool/mpiosh.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: mpiosh.h,v 1.2 2002/09/01 16:07:10 crunchy Exp $
+ * $Id: mpiosh.h,v 1.3 2002/09/01 18:27:49 crunchy Exp $
*
* Copyright (C) 2002 Andreas Büsching <crunchy@tzi.de>
*
@@ -81,6 +81,7 @@ void mpiosh_cmd_switch(char *args[]);
void mpiosh_cmd_ldir(char *args[]);
void mpiosh_cmd_lcd(char *args[]);
+void mpiosh_cmd_lmkdir(char *args[]);
/* progress callbacks */
BYTE mpiosh_callback_get(int read, int total);