changeset 132:d991944aa5f3

fc-simtool: local cd command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 22:23:03 +0000
parents 7305f2e63d66
children ede661d78730
files libcommon/Makefile libcommon/localcd.c simtool/dispatch.c
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/Makefile	Sat Feb 20 22:13:54 2021 +0000
+++ b/libcommon/Makefile	Sat Feb 20 22:23:03 2021 +0000
@@ -3,8 +3,9 @@
 OBJS=	alpha_decode.o alpha_fromfile.o alpha_valid.o apdu.o apducmd.o atr.o \
 	cardconnect.o chkblank.o decimal_str.o dumpdirfunc.o exit.o \
 	filesearch.o globalopts.o gsm7_decode.o gsm7_encode.o \
-	gsm7_encode_table.o gsm7_unpack.o hexdump.o hexread.o hexstr.o names.o \
-	number_decode.o number_encode.o pinentry.o plmncodes.o revnibbles.o
+	gsm7_encode_table.o gsm7_unpack.o hexdump.o hexread.o hexstr.o \
+	localcd.o names.o number_decode.o number_encode.o pinentry.o \
+	plmncodes.o revnibbles.o
 LIB=	libcommon.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcommon/localcd.c	Sat Feb 20 22:23:03 2021 +0000
@@ -0,0 +1,18 @@
+/*
+ * This module implements the local cd command.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+cmd_cd(argc, argv)
+	char **argv;
+{
+	int rc;
+
+	rc = chdir(argv[1]);
+	if (rc < 0)
+		perror(argv[1]);
+	return rc;
+}
--- a/simtool/dispatch.c	Sat Feb 20 22:13:54 2021 +0000
+++ b/simtool/dispatch.c	Sat Feb 20 22:23:03 2021 +0000
@@ -10,6 +10,7 @@
 
 extern int cmd_a38();
 extern int cmd_apdu();
+extern int cmd_cd();
 extern int cmd_change_chv();
 extern int cmd_disable_chv();
 extern int cmd_enable_chv();
@@ -103,6 +104,7 @@
 	{"a38", 1, 1, 1, cmd_a38},
 	{"apdu", 1, 1, 0, cmd_apdu},
 	{"atr", 0, 0, 0, retrieve_atr},
+	{"cd", 1, 1, 0, cmd_cd},
 	{"change-chv1", 2, 2, 0, cmd_change_chv},
 	{"change-chv2", 2, 2, 0, cmd_change_chv},
 	{"change-pin1", 2, 2, 0, cmd_change_chv},