As a research project, we are writing an abstraction layer on top of the standard C file processing library (BINARY) (stdio), providing several additional functions for processing files with transactions.
The workflow is as follows:
- the user opens a file with our API (or standard
fopen). Both return FILE*. File opened in BINARY mode! - the user writes data to a file using standard library commands (for example,
fwrite) - the user opens an open file transaction using our API:
TRANSACTION a = trans_start(FILE* ) - the user sets the data validators for the object
TRANSACTION(set_validator(TRANSACTION, int(*)(char*)) - the user "writes" data to a file using our own API (
int trans_write_string(TRANSACTION*, char*, length)- in fact, this "record" puts its data in memory for the validators defined above, which could perform operations on the data and set some flags somewhere ... not related to the question.
- The user uses
trans_commit(TRANSACTION)to actually write data to a file. Now, depending on the flags set by the validators, it CANNOT write data to a file, but report an error to the user (which can be resolved programmatically ... not so important for the question). - the user closes the file using the standard API
fclose.
API (trans_write_string), . , , ..... , ..... fwrite (, C, ++ ).
(... ) API, (16 , 32 , 64 ), ... , C API stdio . , , , N ( ), 2 16- , M , 8 64- , 2 16- ..
" , , //os/endianness".
char (char* addr = &my_16bit_int) *(addr) *(addr + 1) (.. N ) , , , endiannes ? , "" - 16- ? 64- , ?
?
EDIT: , (XML), (: N 8- , 1 16- , ..) ( ). "" - "", 16- , .., - XML- "".
EDIT2: , , 20- :)
EDIT3: , !