summaryrefslogtreecommitdiffstats
path: root/xref.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-08-13 18:06:45 +0200
committerMattias Andrée <maandree@kth.se>2021-08-13 18:06:45 +0200
commitfcffe4810f59de6a4f39596a37242022b68e7bc5 (patch)
treed91ef754fe3b24ecfea8270ef4ef0c070de8c359 /xref.c
downloadlibparsesfnt-fcffe4810f59de6a4f39596a37242022b68e7bc5.tar.gz
libparsesfnt-fcffe4810f59de6a4f39596a37242022b68e7bc5.tar.bz2
libparsesfnt-fcffe4810f59de6a4f39596a37242022b68e7bc5.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'xref.c')
-rw-r--r--xref.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/xref.c b/xref.c
new file mode 100644
index 0000000..edec384
--- /dev/null
+++ b/xref.c
@@ -0,0 +1,48 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+int
+libparsesfnt_parse_xref(
+ const char *data, size_t size,
+ struct libparsesfnt_xref *infop,
+ const struct libparsesfnt_tabdir_entry *tag)
+{
+ return PARSE(LIBPARSESFNT_XREF__, tag->offset, 0, 0, 0, 1, tag);
+}
+
+
+int
+libparsesfnt_parse_xref_entries(
+ const char *data, size_t size,
+ struct libparsesfnt_xref_entry *infop,
+ const struct libparsesfnt_tabdir_entry *tag,
+ size_t first, size_t count)
+{
+ return PARSE(LIBPARSESFNT_XREF_ENTRY__, tag->offset, 16, 0, first, count, tag);
+}
+
+
+int
+libparsesfnt_get_xref_offset(
+ size_t size,
+ size_t *offsetp,
+ const struct libparsesfnt_tabdir_entry *tag, const struct libparsesfnt_xref *xref,
+ const struct libparsesfnt_xref_entry *entry)
+{
+ size_t offset = (size_t)tag->offset;
+ if ((size_t)xref->string_offset > size - offset)
+ goto ebfont;
+ offset += (size_t)xref->string_offset;
+ if ((size_t)entry->string_offset > size - offset)
+ goto ebfont;
+ offset += (size_t)entry->string_offset;
+ if ((size_t)entry->string_length > size - offset)
+ goto ebfont;
+ *offsetp = offset;
+ return 0;
+
+ebfont:
+ errno = EBFONT;
+ return -1;
+}