From 7341d268521a1697f801eec11d4e7fec6d3b3c1e Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Tue, 9 Jul 2024 12:56:10 -0700 Subject: [PATCH] Created read method on MString to read from sockets. --- MString.cpp | 9 +++++++++ MString.h | 6 ++++++ compile | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/MString.cpp b/MString.cpp index 1d9ec32..23b82d8 100644 --- a/MString.cpp +++ b/MString.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include namespace coreutils { @@ -247,6 +249,13 @@ namespace coreutils { } length = size; } + + MString &MString::read(int fd) { + char ch; + while(::read(fd, &ch, 1)) + write(ch); + return *this; + } int MString::offset() { return cursor - data; diff --git a/MString.h b/MString.h index e44fa55..d7617bb 100644 --- a/MString.h +++ b/MString.h @@ -213,6 +213,12 @@ namespace coreutils { /// MString &write(ZString &value); + + /// + /// Read data from a socket and store in MString. + /// + + MString &read(int fd); int offset(); diff --git a/compile b/compile index 12ab0a6..a49fc36 100755 --- a/compile +++ b/compile @@ -5,7 +5,7 @@ do filename="${file%.*}" list="$list $filename.o" echo -n "Compiling $filename..." - g++ -g -c $file -std=c++20 & + g++ -g -c $file -std=c++23 & if [ $? = '0' ] then echo "OK"