changeset 19:f3671d3ad953

lcdtest: added cd command to avoid typing long pathnames for show
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 10 Apr 2018 23:37:19 +0000
parents 326a21ad56be
children 2e4f27ea7067
files lcdtest/dispatch.c lcdtest/showppm.c
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lcdtest/dispatch.c	Sat Apr 07 23:13:55 2018 +0000
+++ b/lcdtest/dispatch.c	Tue Apr 10 23:37:19 2018 +0000
@@ -4,6 +4,7 @@
 #include <strings.h>
 #include <stdlib.h>
 
+extern int cmd_cd();
 extern int cmd_fc();
 extern int cmd_fr();
 extern int cmd_rd();
@@ -26,6 +27,7 @@
 	int maxargs;
 	int (*func)();
 } cmdtab[] = {
+	{"cd", 1, 1, cmd_cd},
 	{"exit", 0, 0, cmd_exit},
 	{"fc", 1, 16, cmd_fc},
 	{"fr", 1, 1, cmd_fr},
--- a/lcdtest/showppm.c	Sat Apr 07 23:13:55 2018 +0000
+++ b/lcdtest/showppm.c	Tue Apr 10 23:37:19 2018 +0000
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 char *ppm_filename;
 FILE *ppmfile;
@@ -166,3 +167,13 @@
 	fclose(ppmfile);
 	return(0);
 }
+
+cmd_cd(argc, argv)
+	char **argv;
+{
+	if (chdir(argv[1]) < 0) {
+		perror(argv[1]);
+		return(-1);
+	}
+	return(0);
+}