diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-20 19:01:40 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-20 19:01:40 +0300 |
commit | 2052acf054291c2915ace9da9cc1a395c3abf832 (patch) | |
tree | 646d57659ffea2e9e143cf35928fea0a14446487 /src/gmcerts.c | |
parent | 33190c949f5249e211810cb57dced95eb3dfb39d (diff) |
Added timestamps to serialized responses
A new version of the binary serialization format that includes timestamps for GmResponse.
Diffstat (limited to 'src/gmcerts.c')
-rw-r--r-- | src/gmcerts.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gmcerts.c b/src/gmcerts.c index c358573c..b5b7b371 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c | |||
@@ -21,6 +21,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | 21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ |
22 | 22 | ||
23 | #include "gmcerts.h" | 23 | #include "gmcerts.h" |
24 | #include "defs.h" | ||
24 | 25 | ||
25 | #include <the_Foundation/file.h> | 26 | #include <the_Foundation/file.h> |
26 | #include <the_Foundation/fileinfo.h> | 27 | #include <the_Foundation/fileinfo.h> |
@@ -202,7 +203,7 @@ static void saveIdentities_GmCerts_(const iGmCerts *d) { | |||
202 | iFile *f = new_File(collect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_))); | 203 | iFile *f = new_File(collect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_))); |
203 | if (open_File(f, writeOnly_FileMode)) { | 204 | if (open_File(f, writeOnly_FileMode)) { |
204 | writeData_File(f, magicIdMeta_GmCerts_, 4); | 205 | writeData_File(f, magicIdMeta_GmCerts_, 4); |
205 | writeU32_File(f, 0); /* version */ | 206 | writeU32_File(f, latest_FileVersion); /* version */ |
206 | iConstForEach(PtrArray, i, &d->idents) { | 207 | iConstForEach(PtrArray, i, &d->idents) { |
207 | const iGmIdentity *ident = i.ptr; | 208 | const iGmIdentity *ident = i.ptr; |
208 | if (~ident->flags & temporary_GmIdentityFlag) { | 209 | if (~ident->flags & temporary_GmIdentityFlag) { |
@@ -245,7 +246,12 @@ static void loadIdentities_GmCerts_(iGmCerts *d) { | |||
245 | printf("%s: format not recognized\n", cstr_String(path_File(f))); | 246 | printf("%s: format not recognized\n", cstr_String(path_File(f))); |
246 | return; | 247 | return; |
247 | } | 248 | } |
248 | setVersion_Stream(stream_File(f), readU32_File(f)); | 249 | const uint32_t version = readU32_File(f); |
250 | if (version > latest_FileVersion) { | ||
251 | printf("%s: unsupported version\n", cstr_String(path_File(f))); | ||
252 | return; | ||
253 | } | ||
254 | setVersion_Stream(stream_File(f), version); | ||
249 | while (!atEnd_File(f)) { | 255 | while (!atEnd_File(f)) { |
250 | readData_File(f, sizeof(magic), magic); | 256 | readData_File(f, sizeof(magic), magic); |
251 | if (!memcmp(magic, magicIdentity_GmCerts_, sizeof(magic))) { | 257 | if (!memcmp(magic, magicIdentity_GmCerts_, sizeof(magic))) { |