varbyterw.h (1435B)
1 /* 2 Variable-Byte Data Reader/Writer header file 3 varbyterw.h 4 M. Yamanaka 5 email: myamanaka@live.com 6 website: http://www.csmyamanaka.com 7 License: MIT (See included "LICENSE" file for details) 8 */ 9 10 #pragma once 11 12 #include <stdlib.h> 13 14 /* 15 Write Data to Char Array 16 "char" is a stand-in for byte because C doesn't have a byte type at least on the compiler that I am using at this time (GCC 9.3.0). 17 Therefore, this function writes the byte representation of a given input data onto a char (byte) array. 18 This can be done in either endian format controlled by the last argument of this function. 19 The arguments from left to right are: 20 void* ... input data 21 char* ... destination char array 22 int ... number of bytes 23 int ... endian-ness, 0 for little-endian, 1 for big-endian 24 The return value is 0 but eventually, I would like to implement error codes. 25 */ 26 int wDataToChar(void*, char*, int, int); 27 28 /* 29 Read Data from Char Array 30 Again, "char" is just byte. 31 This function reads a series of bytes in either endian form and extracts the data and interprets it as a given variable.. 32 The arguments from left to right are: 33 char* ... byte data 34 void* ... destination variable 35 int ... number of bytes to interpret 36 int ... endian-ness, 0 for little, 1 for big 37 A return value is also tentatively 0 but likewise with the aforementioned plan. 38 */ 39 int rDataFromChar(char*, void*, int, int); 40