[syslinux:master] rosh: change rosh_cd() to use argc/argv

syslinux-bot for Gene Cumm gene.cumm at gmail.com
Sun Nov 14 12:54:33 PST 2010


Commit-ID:  2e16477b7971de5459fa82d6739d7008911717c8
Gitweb:     http://syslinux.zytor.com/commit/2e16477b7971de5459fa82d6739d7008911717c8
Author:     Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Thu, 30 Sep 2010 23:03:35 -0400
Committer:  Gene Cumm <gene.cumm at gmail.com>
CommitDate: Sat, 9 Oct 2010 07:33:07 -0400

rosh: change rosh_cd() to use argc/argv



---
 com32/rosh/rosh.c |   34 ++++++++++++++++------------------
 com32/rosh/rosh.h |    6 ++++++
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 97be4fc..0d51f22 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -41,7 +41,7 @@
 #define APP_NAME	"rosh"
 #define APP_AUTHOR	"Gene Cumm"
 #define APP_YEAR	"2010"
-#define APP_VER		"beta-b071"
+#define APP_VER		"beta-b072"
 
 void rosh_version(int vtype)
 {
@@ -221,6 +221,9 @@ void rosh_help(int type, const char *cmdstr)
 	    puts(rosh_help_str2);
 	} else {
 	    switch (istr[0]) {
+	    case 'c':
+		puts(rosh_help_cd_str);
+		break;
 	    case 'l':
 		puts(rosh_help_ls_str);
 		break;
@@ -407,26 +410,21 @@ void rosh_cat(const char *cmdstr)
 }				/* rosh_cat */
 
 /* Change PWD (Present Working Directory)
- *	cmdstr	command string to process
+ *	argc	Argument count
+ *	argv	Argument values
  *	ipwdstr	Initial PWD
  */
-void rosh_cd(const char *cmdstr, const char *ipwdstr)
+void rosh_cd(int argc, char *argv[], const char *ipwdstr)
 {
-    int rv;
-    char filestr[ROSH_PATH_SZ];
-    int cmdpos;
-    ROSH_DEBUG("CMD: '%s'\n", cmdstr);
-    /* Initialization */
-    filestr[0] = 0;
-    cmdpos = 0;
-    rv = 0;
-    /* skip the first word */
-    cmdpos = rosh_parse_sp_1(filestr, cmdstr, cmdpos);
-    cmdpos = rosh_parse_sp_1(filestr, cmdstr, cmdpos);
-    if (strlen(filestr) != 0)
-	rv = chdir(filestr);
-    else
+    int rv = 0;
+    ROSH_DEBUG("CMD: \n");
+    ROSH_DEBUG_ARGV(argc, argv);
+    if (argc == 2)
+	rv = chdir(argv[1]);
+    else if (argc == 1)
 	rv = chdir(ipwdstr);
+    else
+	rosh_help(2, argv[0]);
     if (rv != 0) {
 	rosh_error(errno, "cd", filestr);
 	errno = 0;
@@ -1147,7 +1145,7 @@ char rosh_command(const char *cmdstr, const char *ipwdstr)
 	case 'd':
 	case 'D':
 	    if (strncasecmp("cd", argv[0], tlen) == 0)
-		rosh_cd(cmdstr, ipwdstr);
+		rosh_cd(argc, argv, ipwdstr);
 	    else
 		rosh_help(1, NULL);
 	    break;
diff --git a/com32/rosh/rosh.h b/com32/rosh/rosh.h
index 118c531..907df1e 100644
--- a/com32/rosh/rosh.h
+++ b/com32/rosh/rosh.h
@@ -46,6 +46,7 @@
 
 #ifdef DO_DEBUG
 # define ROSH_DEBUG	printf
+# define ROSH_DEBUG_ARGV	rosh_pr_argv
 /* define ROSH_DEBUG(f, ...)	printf (f, ## __VA_ARGS__) */
 # ifdef DO_DEBUG2
 #  define ROSH_DEBUG2	printf
@@ -55,6 +56,7 @@
 # endif	/* DO_DEBUG2 */
 #else /* DO_DEBUG */
 # define ROSH_DEBUG(f, ...)	((void)0)
+# define ROSH_DEBUG_ARGV(int argc, char *argv[])	((void)0)
 # define ROSH_DEBUG2(f, ...)	((void)0)
 #endif /* DO_DEBUG */
 
@@ -235,6 +237,10 @@ const char rosh_beta_str[] =
 const char rosh_cd_norun_str[] =
     " -- cd (Change Directory) not implemented for use with run and exit.\n";
 
+const char rosh_help_cd_str[] = "cd    Change directory\n\
+   with no argument, return to original directory from entry to rosh\n\
+   with one argument, change to that directory";
+
 const char rosh_help_ls_str[] = "ls    List contents of current directory\n\
   -l  Long format\n\
   -i  Inode; print Inode of file\n\



More information about the Syslinux-commits mailing list