diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-05 09:04:00 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-05 09:04:00 +0200 |
| commit | 3e7bb9b87ef9b47d8f643dbcae19a64ddbc81dbb (patch) | |
| tree | 122faba06273ae0450a2994e22bad42202f11da7 /src/solvers/coord/checkdata.h | |
| parent | f6efc882a279cddb624fe2f2470797561a6997b8 (diff) | |
| download | nissy-core-3e7bb9b87ef9b47d8f643dbcae19a64ddbc81dbb.tar.gz nissy-core-3e7bb9b87ef9b47d8f643dbcae19a64ddbc81dbb.zip | |
Added DRFIN solver
Diffstat (limited to '')
| -rw-r--r-- | src/solvers/coord/checkdata.h | 75 |
1 files changed, 66 insertions, 9 deletions
diff --git a/src/solvers/coord/checkdata.h b/src/solvers/coord/checkdata.h index e448e8f..51265a8 100644 --- a/src/solvers/coord/checkdata.h +++ b/src/solvers/coord/checkdata.h | |||
| @@ -1,14 +1,39 @@ | |||
| 1 | STATIC long long checkdata_coord( | 1 | STATIC long long checkdata_coord_dispatch( |
| 2 | const char *, unsigned long long, const unsigned char *); | 2 | const char *, unsigned long long, const unsigned char *); |
| 3 | STATIC long long checkdata_coord( | ||
| 4 | const coord_t *, unsigned long long, const unsigned char *); | ||
| 5 | STATIC long long checkdata_multicoord( | ||
| 6 | const multicoord_t *, unsigned long long, const unsigned char *); | ||
| 3 | 7 | ||
| 4 | STATIC long long | 8 | STATIC long long |
| 5 | checkdata_coord( | 9 | checkdata_coord_dispatch( |
| 6 | const char *solver, | 10 | const char *solver, |
| 7 | unsigned long long data_size, | 11 | unsigned long long data_size, |
| 8 | const unsigned char *data | 12 | const unsigned char *data |
| 9 | ) | 13 | ) |
| 10 | { | 14 | { |
| 11 | coord_t *coord; | 15 | coord_t *c; |
| 16 | multicoord_t *mc; | ||
| 17 | |||
| 18 | parse_coord_and_trans(solver, &c, &mc, NULL); | ||
| 19 | |||
| 20 | if (c != NULL) | ||
| 21 | return checkdata_coord(c, data_size, data); | ||
| 22 | |||
| 23 | if (mc != NULL) | ||
| 24 | return checkdata_multicoord(mc, data_size, data); | ||
| 25 | |||
| 26 | LOG("[cehckdata] Unknown coordinate solver '%s'\n", solver); | ||
| 27 | return NISSY_ERROR_DATA; | ||
| 28 | } | ||
| 29 | |||
| 30 | STATIC long long | ||
| 31 | checkdata_coord( | ||
| 32 | const coord_t *coord, | ||
| 33 | unsigned long long data_size, | ||
| 34 | const unsigned char *data | ||
| 35 | ) | ||
| 36 | { | ||
| 12 | const unsigned char *table; | 37 | const unsigned char *table; |
| 13 | tableinfo_t info; | 38 | tableinfo_t info; |
| 14 | int64_t err; | 39 | int64_t err; |
| @@ -19,12 +44,6 @@ checkdata_coord( | |||
| 19 | return NISSY_ERROR_DATA; | 44 | return NISSY_ERROR_DATA; |
| 20 | } | 45 | } |
| 21 | 46 | ||
| 22 | parse_coord_and_trans(solver, &coord, NULL); | ||
| 23 | if (coord == NULL) { | ||
| 24 | LOG("[cehckdata] Unknown coordinate solver '%s'\n", solver); | ||
| 25 | return NISSY_ERROR_DATA; | ||
| 26 | } | ||
| 27 | |||
| 28 | table = data + INFOSIZE; | 47 | table = data + INFOSIZE; |
| 29 | err = readtableinfo(data_size, data, &info); | 48 | err = readtableinfo(data_size, data, &info); |
| 30 | if (err != NISSY_OK) { | 49 | if (err != NISSY_OK) { |
| @@ -63,3 +82,41 @@ checkdata_coord( | |||
| 63 | 82 | ||
| 64 | return NISSY_OK; | 83 | return NISSY_OK; |
| 65 | } | 84 | } |
| 85 | |||
| 86 | STATIC long long | ||
| 87 | checkdata_multicoord( | ||
| 88 | const multicoord_t *mcoord, | ||
| 89 | unsigned long long data_size, | ||
| 90 | const unsigned char *data | ||
| 91 | ) | ||
| 92 | { | ||
| 93 | long long r; | ||
| 94 | size_t i, of, s; | ||
| 95 | |||
| 96 | for (of = INFOSIZE, i = 0; mcoord->coordinates[i] != NULL; i++) { | ||
| 97 | LOG("[checkdata] %s: checking data for %s\n", mcoord->name, | ||
| 98 | mcoord->coordinates[i]->name); | ||
| 99 | s = gendata_coord(mcoord->coordinates[i], NULL); | ||
| 100 | if (s > data_size-of) | ||
| 101 | return NISSY_ERROR_DATA; | ||
| 102 | |||
| 103 | r = checkdata_coord(mcoord->coordinates[i], s, data + of); | ||
| 104 | if (r != NISSY_OK) | ||
| 105 | return r; | ||
| 106 | |||
| 107 | LOG("[checkdata] Ok\n"); | ||
| 108 | |||
| 109 | of += s; | ||
| 110 | |||
| 111 | /* Skip padding */ | ||
| 112 | while (of % 8 != 0) { | ||
| 113 | if (data[of] != 0) | ||
| 114 | LOG("[checkdata] Warning: some unused bytes " | ||
| 115 | "are not set to zero. Please report this " | ||
| 116 | "bug.\n"); | ||
| 117 | of++; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | return NISSY_OK; | ||
| 122 | } | ||
