OrionUserland
Barry Using POSIX names in structs 2e11092 (2 years, 4 months ago)diff --git a/sh/main.c b/sh/main.c index d1319ad..f4c93d2 100644 --- a/sh/main.c +++ b/sh/main.c @@ -14,7 +14,7 @@ #define PS1 "\033[1;31m%s\033[0m@\033[1m%s\033[0m:\033[1;32m%s\033[0m$> " -int argparser(char *str, char **res); +int argparser(char sep, char *str, char **res); /* Get the nice current working directory */ static void @@ -35,7 +35,6 @@ main(int argc, char *argv[]) { int fd, sz, i; char *buf; - struct stat statbuf; struct dirent *de; /* Get username */ @@ -44,8 +43,8 @@ main(int argc, char *argv[]) username = malloc(33); homedir = malloc(PATH_MAX); Passwd *pwd = getpwuid(uid); - strcpy(username, pwd->username); - strcpy(homedir, pwd->homedir); + strcpy(username, pwd->pw_name); + strcpy(homedir, pwd->pw_dir); /* Get hostname */ hostname = malloc(HOST_NAME_MAX + 1); @@ -72,7 +71,7 @@ main(int argc, char *argv[]) if (sz < 1) continue; - count = argparser(line, v); + count = argparser(' ', line, v); /* Change directory (built-in) */ if (!strcmp(v[0], "cd")) { diff --git a/sh/parser.c b/sh/parser.c index 6c0af04..d3111ca 100644 --- a/sh/parser.c +++ b/sh/parser.c @@ -2,17 +2,17 @@ /* Split a string into separate strings */ int -argparser(char *str, char **res) +argparser(char sep, char *str, char **res) { int count = 0; char *finder; memset(res, 0, 1024); finder = str; - while (*finder == ' ') finder++; + while (*finder == sep) finder++; res[count++] = finder; while (*finder) { - if (*finder == ' ') { + if (*finder == sep) { res[count++] = finder + 1; *finder = '\0'; }