You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (uc.item.type != CWP_ITEM_MAP || uc.item.as.map.size != 2) ERROR;
44
51
45
-
if (cw_unpack_next(&uc)) ERROR;
52
+
cw_unpack_next(&uc);
46
53
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 7)) ERROR;
47
54
if (strncmp("compact", uc.item.as.str.start, 7)) ERROR;
48
55
49
-
if (cw_unpack_next(&uc)) ERROR;
56
+
cw_unpack_next(&uc);
50
57
if (uc.item.type != CWP_ITEM_BOOLEAN || uc.item.as.boolean != true) ERROR;
51
58
52
-
if (cw_unpack_next(&uc)) ERROR;
59
+
cw_unpack_next(&uc);
53
60
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 6)) ERROR;
54
61
if (strncmp("schema", uc.item.as.str.start, 6)) ERROR;
55
62
56
-
if (cw_unpack_next(&uc)) ERROR;
63
+
cw_unpack_next(&uc);
57
64
if (uc.item.type != CWP_ITEM_POSITIVE_INTEGER || uc.item.as.u64 != 0) ERROR;
58
65
59
-
if (cw_unpack_next(&uc) != CWP_RC_END_OF_INPUT) ERROR;
66
+
cw_unpack_next(&uc);
67
+
if (uc.return_code != CWP_RC_END_OF_INPUT) ERROR;
60
68
}
61
69
```
62
70
71
+
In the examples folder there are more examples.
72
+
73
+
## Backward compatibility
74
+
75
+
CWPack may be run in compatibility mode. It affects only packing; EXTs are considered illegal, BINs is transformed to STRs and generation of STR8 is supressed.
76
+
63
77
## Error handling
64
78
65
79
CWPack does not check for illegal values (e.g. in STRs for illegal unicode characters).
66
80
67
-
When an error is detected in a context, that context is stopped and all calls are returned
68
-
with the stopped error code.
81
+
When an error is detected in a context, that context is stopped and all future calls to that context are immediatly returned without any actions.
69
82
70
83
## Build
71
84
72
-
CWPack consists of a single src file with corresponding header file. It is written
73
-
in C and the files are together ~ 1K lines. No build is neccesary, just include the
85
+
CWPack consists of a single src file and two header files. It is written
86
+
in strict ansi C and the files are together ~ 1.1K lines. No separate build is neccesary, just include the
74
87
files in your own build.
75
88
76
89
CWPack has no dependencies to other libraries.
77
90
78
-
## Module test
91
+
## Test
79
92
80
-
Included in the test folder in the repository is a simple module test and a shell script to run it.
93
+
Included in the test folder are a module test and a performance test and shell scripts to run them.
-**Dynamic Memory Pack Context** is used when you want to pack to a malloc´d memory buffer. At buffer overflow the context handler tries to reallocate the buffer to a larger size.
7
+
8
+
-**File Pack Context** is used when you pack to a file. At buffer overflow the context handler writes the buffer out and then reuses it. If an item is larger than the buffer, the handler tries to reallocate the buffer so the item would fit.
9
+
10
+
-**File Unpack Context** is used when you unpack from a file. As with File Pack Context, the handler asserts that an items will always fit in the buffer.
0 commit comments