1.1 --- a/test_files/programs/cat.c Thu Apr 18 17:13:40 2024 +0200
1.2 +++ b/test_files/programs/cat.c Thu Apr 18 17:14:13 2024 +0200
1.3 @@ -1,8 +1,5 @@
1.4 /*
1.5 - * Show concatenated filesystem object contents using the client library.
1.6 - *
1.7 - * This should eventually use C library functions instead of client library
1.8 - * functions.
1.9 + * Show concatenated filesystem object contents.
1.10 *
1.11 * Copyright (C) 2024 Paul Boddie <paul@boddie.org.uk>
1.12 *
1.13 @@ -26,16 +23,6 @@
1.14
1.15
1.16
1.17 -/* NOTE: For inclusion in the C library: stream acquisition and access. */
1.18 -
1.19 -#include <fsclient/client.h>
1.20 -#include <systypes/env.h>
1.21 -#include <systypes/fcntl.h>
1.22 -
1.23 -file_t *output;
1.24 -
1.25 -
1.26 -
1.27 /* Transfer size for communication. */
1.28
1.29 static const offset_t TO_TRANSFER = 1024;
1.30 @@ -47,19 +34,19 @@
1.31 static int show_object(const char *path)
1.32 {
1.33 char *buffer[TO_TRANSFER];
1.34 - file_t *file = client_open(path, O_RDONLY);
1.35 - offset_t nread;
1.36 + FILE *file = fopen(path, "r");
1.37 + size_t nread;
1.38
1.39 - if (!client_opened(file))
1.40 + if (file == NULL)
1.41 return 1;
1.42
1.43 - while ((nread = client_read(file, buffer, TO_TRANSFER)))
1.44 + while ((nread = fread(buffer, sizeof(char), TO_TRANSFER, file)))
1.45 {
1.46 - if (!client_write(output, buffer, nread))
1.47 + if (!fwrite(buffer, sizeof(char), nread, stdout))
1.48 break;
1.49 }
1.50
1.51 - client_close(file);
1.52 + fclose(file);
1.53
1.54 return 0;
1.55 }
1.56 @@ -70,10 +57,6 @@
1.57 {
1.58 int i;
1.59
1.60 - /* NOTE: For inclusion in the C library: stream acquisition and access. */
1.61 -
1.62 - output = client_get_stream(ENV_OUTPUT_STREAM_NAME, O_WRONLY);
1.63 -
1.64 /* Show all specified objects. */
1.65
1.66 for (i = 1; i < argc; i++)
1.67 @@ -82,10 +65,6 @@
1.68 return 1;
1.69 }
1.70
1.71 - /* NOTE: For inclusion in the C library: stream acquisition and access. */
1.72 -
1.73 - client_flush(output);
1.74 -
1.75 return 0;
1.76 }
1.77