aboutsummaryrefslogtreecommitdiffstats
path: root/com32/rosh/rosh.c
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2010-10-16 08:07:02 -0400
committerGene Cumm <gene.cumm@gmail.com>2010-10-16 08:07:02 -0400
commite3993dc6158ad8833cbf1330329470c50fd782d3 (patch)
tree65312da44b243b00c6b59405643b5eddb2bc078b /com32/rosh/rosh.c
parentb2dd6a4f613701b2a7561342180e4e435c54045a (diff)
downloadsyslinux-e3993dc6158ad8833cbf1330329470c50fd782d3.tar.gz
syslinux-e3993dc6158ad8833cbf1330329470c50fd782d3.tar.xz
syslinux-e3993dc6158ad8833cbf1330329470c50fd782d3.zip
rosh: rosh_argcat now has length. if DO_DEBUG, show startup command
Diffstat (limited to 'com32/rosh/rosh.c')
-rw-r--r--com32/rosh/rosh.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 25ecb72d..12e09995 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -43,7 +43,7 @@
#define APP_NAME "rosh"
#define APP_AUTHOR "Gene Cumm"
#define APP_YEAR "2010"
-#define APP_VER "beta-b088"
+#define APP_VER "beta-b089"
/* Print version information to stdout
*/
@@ -327,11 +327,13 @@ void rosh_error(const int ierrno, const char *cmdstr, const char *filestr)
/* Concatenate command line arguments into one string
* cmdstr Output command string
+ * cmdlen Length of cmdstr
* argc Argument Count
* argv Argument Values
* barg Beginning Argument
*/
-int rosh_argcat(char *cmdstr, const int argc, char *argv[], const int barg)
+int rosh_argcat(char *cmdstr, const int cmdlen, const int argc, char *argv[],
+ const int barg)
{
int i, arglen, curpos; /* index, argument length, current position
in cmdstr */
@@ -340,15 +342,15 @@ int rosh_argcat(char *cmdstr, const int argc, char *argv[], const int barg)
for (i = barg; i < argc; i++) {
arglen = strlen(argv[i]);
/* Theoretically, this should never be met in SYSLINUX */
- if ((curpos + arglen) > (ROSH_CMD_SZ - 1))
- arglen = (ROSH_CMD_SZ - 1) - curpos;
+ if ((curpos + arglen) > (cmdlen - 1))
+ arglen = (cmdlen - 1) - curpos;
memcpy(cmdstr + curpos, argv[i], arglen);
curpos += arglen;
- if (curpos >= (ROSH_CMD_SZ - 1)) {
+ if (curpos >= (cmdlen - 1)) {
/* Hopefully, curpos should not be greater than
- (ROSH_CMD_SZ - 1) */
+ (cmdlen - 1) */
/* Still need a '\0' at the last character */
- cmdstr[(ROSH_CMD_SZ - 1)] = 0;
+ cmdstr[(cmdlen - 1)] = 0;
break; /* Escape out of the for() loop;
We can no longer process anything more */
} else {
@@ -1117,7 +1119,7 @@ void rosh_run(int argc, char *argv[])
char cmdstr[ROSH_CMD_SZ];
int len;
- len = rosh_argcat(cmdstr, argc, argv, 0);
+ len = rosh_argcat(cmdstr, ROSH_CMD_SZ, argc, argv, 0);
if (len) {
printf("--run: '%s'\n", cmdstr);
syslinux_run_command(cmdstr);
@@ -1342,6 +1344,12 @@ int main(int argc, char *argv[])
if (argc == 1) {
rosh_version(0);
print_beta();
+ } else {
+#ifdef DO_DEBUG
+ char cmdstr[ROSH_CMD_SZ];
+ rosh_argcat(cmdstr, ROSH_CMD_SZ, argc, argv, 1);
+ ROSH_DEBUG("arg='%s'\n", cmdstr);
+#endif
}
rv = rosh_prompt(argc, argv);
printf("--Exiting '" APP_NAME "'\n");