+/**************************************************
+ * Helpers
+ **************************************************/
+
+static FILE *oseama_open(const char *pathname, const char *mode) {
+ if (strcmp(pathname, "-"))
+ return fopen(pathname, mode);
+
+ if (isatty(fileno(stdin))) {
+ fprintf(stderr, "Reading from TTY stdin is unsupported\n");
+ return NULL;
+ }
+
+ return stdin;
+}
+
+static int oseama_skip(FILE *fp, size_t length)
+{
+ if (fseek(fp, length, SEEK_CUR)) {
+ uint8_t buf[1024];
+ size_t bytes;
+
+ do {
+ bytes = fread(buf, 1, oseama_min(sizeof(buf), length), fp);
+ if (bytes <= 0)
+ return -EIO;
+ length -= bytes;
+ } while (length);
+ }
+
+ return 0;
+}
+
+static void oseama_close(FILE *fp) {
+ if (fp != stdin)
+ fclose(fp);
+}
+