aboutsummaryrefslogtreecommitdiffstats
path: root/text.py
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-08-11 16:48:53 +0000
committerbloodstalker <thabogre@gmail.com>2018-08-11 16:48:53 +0000
commit1eb3f6790388c1e5b990408bb57604aad3f03f03 (patch)
tree11d30e59f2c7e65ff848d19ddfc92c51de47b308 /text.py
parentupdate (diff)
downloadfaultreiber-1eb3f6790388c1e5b990408bb57604aad3f03f03.tar.gz
faultreiber-1eb3f6790388c1e5b990408bb57604aad3f03f03.zip
update
Diffstat (limited to 'text.py')
-rw-r--r--text.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/text.py b/text.py
index 2562311..d70cb09 100644
--- a/text.py
+++ b/text.py
@@ -69,8 +69,23 @@ int64_t read_leb_128_s(int _fd, int max_size) {
if ((last_byte & 0x40) != 0) result |= -(1 << shift);
return result;
}"""
+
+ c_read_until_delimiter = """
+int32_t read_until_delimiter(int _fd, uint8_t delimiter) {
+ uint8_t dummy = 0;
+ int32_t pos = 0;
+ while(1) {
+ read(_fd, &dummy, 1);
+ pos++;
+ if (dummy == delimiter) {
+ lseek(_fd, -pos, SEEK_CUR);
+ return pos;
+ }}
+}"""
c_read_leb_128_s_sig = "int64_t read_leb_128_s(int _fd, int max_size);\n"
c_read_leb_128_u_sig = "uint64_t read_leb_128_u(int _fd, int max_size);\n"
+ c_read_until_delimiter_sig = "int32_t read_until_delimiter(int _fd, uint8_t delimiter);\n"
+ c_read_until_delimiter_proto = "read_until_delimiter(_fd, XXX)"
c_read_leb_macro_defs = """
#define READ_VAR_UINT_1(FD) read_leb128_u(FD, 1)