summaryrefslogtreecommitdiff
path: root/src/init/shell.c
diff options
context:
space:
mode:
authordzwdz2022-07-11 17:29:31 +0200
committerdzwdz2022-07-11 17:29:31 +0200
commit5c4fb3b3c58a2d850031e9449b5d65887e42f1c7 (patch)
treea0ddb2000f4de00e56a6c1d90147ec1316fb3915 /src/init/shell.c
parent8da0f7c04d3005f50d13d799a395d0ed8bad95ec (diff)
init/stdlib: a more posix-y file api
Diffstat (limited to 'src/init/shell.c')
-rw-r--r--src/init/shell.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/init/shell.c b/src/init/shell.c
index 17cfffc..a4e96f9 100644
--- a/src/init/shell.c
+++ b/src/init/shell.c
@@ -18,7 +18,7 @@ static char *split(char *base) {
static int readline(char *buf, size_t max) {
char c;
size_t pos = 0;
- while (file_read(&__stdin, &c, 1)) {
+ while (file_read(stdin, &c, 1)) {
switch (c) {
case '\b':
case 0x7f:
@@ -45,7 +45,7 @@ static int readline(char *buf, size_t max) {
}
static void cmd_cat_ls(const char *args, bool ls) {
- libc_file file;
+ libc_file *file;
static char buf[512];
int len; // first used for strlen(args), then length of buffer
@@ -63,22 +63,23 @@ static void cmd_cat_ls(const char *args, bool ls) {
}
}
- if (file_open(&file, buf, 0) < 0) {
+ file = file_open(buf, 0);
+ if (!file) {
printf("couldn't open.\n");
return;
}
- while (!file.eof) {
- int len = file_read(&file, buf, sizeof buf);
+ while (!file->eof) {
+ int len = file_read(file, buf, sizeof buf);
if (len <= 0) break;
if (ls) {
for (int i = 0; i < len; i++)
if (buf[i] == '\0') buf[i] = '\n';
}
- file_write(&__stdout, buf, len);
+ file_write(stdout, buf, len);
}
- file_close(&file);
+ file_close(file);
}
static void cmd_hexdump(const char *args) {