[syslinux:master] rosh: show environment
syslinux-bot for Gene Cumm
gene.cumm at gmail.com
Fri Oct 8 13:57:16 PDT 2010
Commit-ID: 8f7fa195f59d5d042affed4218924ae98abcc4b2
Gitweb: http://syslinux.zytor.com/commit/8f7fa195f59d5d042affed4218924ae98abcc4b2
Author: Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Tue, 6 Jul 2010 11:13:42 -0400
Committer: Gene Cumm <gene.cumm at gmail.com>
CommitDate: Wed, 7 Jul 2010 10:03:53 -0400
rosh: show environment
---
com32/rosh/rosh.c | 17 ++++++++++++-----
com32/rosh/rosh.h | 23 +++++++++++++++++++++++
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 801fbf5..9efa35e 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -40,9 +40,16 @@
#define APP_YEAR "2010"
#define APP_VER "beta-b068"
-void rosh_version(void)
+void rosh_version(int vtype)
{
+ char env[256];
+ env[0] = 0;
printf("%s v %s; (c) %s %s.\n\tFrom Syslinux %s, %s\n", APP_LONGNAME, APP_VER, APP_YEAR, APP_AUTHOR, VERSION_STR, DATE);
+ switch (vtype) {
+ case 1:
+ rosh_get_env_ver(env, 256);
+ printf("\tRunning on %s\n", env);
+ }
}
void print_beta(void)
@@ -124,7 +131,7 @@ void rosh_help(int type, const char *cmdstr)
case 2:
istr += rosh_search_nonsp(cmdstr, rosh_search_sp(cmdstr, 0));
if ((cmdstr == NULL) || (strcmp(istr, "") == 0)) {
- rosh_version();
+ rosh_version(0);
puts(rosh_help_str2);
} else {
switch (istr[0]) {
@@ -138,7 +145,7 @@ void rosh_help(int type, const char *cmdstr)
break;
case 1:
default:
- rosh_version();
+ rosh_version(0);
puts(rosh_help_str1);
}
}
@@ -1125,7 +1132,7 @@ char rosh_command(const char *cmdstr, const char *ipwdstr)
case 'v':
case 'V':
if (strncasecmp("version", tstr, tlen) == 0)
- rosh_version();
+ rosh_version(1);
else
rosh_help(1, NULL);
break;
@@ -1184,7 +1191,7 @@ int main(int argc, char *argv[])
if (argc != 1) {
rv = rosh_argcat(cmdstr, argc, argv, 1);
} else {
- rosh_version();
+ rosh_version(0);
print_beta();
cmdstr[0] = '\0';
}
diff --git a/com32/rosh/rosh.h b/com32/rosh/rosh.h
index 135087b..b016e2f 100644
--- a/com32/rosh/rosh.h
+++ b/com32/rosh/rosh.h
@@ -90,9 +90,17 @@ int stat(const char *pathname, struct stat *buf)
return ret;
}
+int rosh_get_env_ver(char *dest, size_t n)
+{
+ const struct syslinux_version *slv = syslinux_version();
+ strncpy(dest, slv->version_string, n);
+ return 0;
+}
+
#else
# include <termios.h>
# include <sys/ioctl.h>
+# include <sys/utsname.h>
# define ROSH_IS_COM32 0
static inline char *syslinux_config_file(void)
@@ -100,6 +108,21 @@ static inline char *syslinux_config_file(void)
return "";
}
+int rosh_get_env_ver(char *dest, size_t n)
+{
+ int ret, len;
+ struct utsname env;
+ ret= uname(&env);
+ if (ret >= 0) {
+ strncpy(dest, env.sysname, n);
+ len = strlen(dest);
+ strncpy(dest + len, " ", (n - len));
+ len = strlen(dest);
+ strncpy(dest + len, env.release, (n - len));
+ }
+ return ret;
+}
+
static inline int getscreensize(int fd, int *rows, int *cols)
{
char *str;
More information about the Syslinux-commits
mailing list