aboutsummaryrefslogtreecommitdiff
path: root/read_dword.h
diff options
context:
space:
mode:
Diffstat (limited to 'read_dword.h')
-rw-r--r--read_dword.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/read_dword.h b/read_dword.h
index e7150c0..499fd1d 100644
--- a/read_dword.h
+++ b/read_dword.h
@@ -18,24 +18,40 @@
* along with Mtools. If not, see <http://www.gnu.org/licenses/>.
*/
-static Dword read_dword(int handle)
+static Dword read_dword(int handle)
{
Byte val[4];
-
+
if(read(handle, (char *)val, 4) < 4)
return (Dword) -1;
return byte2dword(val);
}
-UNUSED(static Qword read_qword(int handle) )
+UNUSED(static int32_t read_sdword(int handle))
+{
+ Byte val[4];
+
+ if(read(handle, (char *)val, 4) < 4)
+ return (int32_t) -1;
+
+ return byte2sdword(val);
+}
+
+
+struct SQwordRet { int64_t v; int err; };
+UNUSED(static struct SQwordRet read_sqword(int handle) )
{
Byte val[8];
-
- if(read(handle, (char *)val, 8) < 8)
- return -1;
+ struct SQwordRet ret;
- return byte2qword(val);
+ if(read(handle, (char *)val, 8) < 8) {
+ ret.err=-1;
+ } else {
+ ret.v = (int64_t) byte2qword(val);
+ ret.err = 0;
+ }
+ return ret;
}
#endif