+static void set_be_option(const char *arg)
+{
+ int res = firm_be_option(arg);
+ (void) res;
+ assert(res);
+}
+
+static void set_option(const char *arg)
+{
+ int res = firm_option(arg);
+ (void) res;
+ assert(res);
+}
+
+static void copy_file(FILE *dest, FILE *input)
+{
+ char buf[16384];
+
+ while (!feof(input) && !ferror(dest)) {
+ size_t read = fread(buf, 1, sizeof(buf), input);
+ if(fwrite(buf, 1, read, dest) != read) {
+ perror("couldn't write output");
+ }
+ }
+}
+
+static inline bool streq(char const* a, char const* b)
+{
+ return strcmp(a, b) == 0;
+}
+
+static inline bool strstart(char const* str, char const* start)
+{
+ do {
+ if (*start == '\0')
+ return true;
+ } while (*str++ == *start++);
+ return false;
+}
+
+static FILE *open_file(const char *filename)
+{
+ if (streq(filename, "-")) {
+ return stdin;
+ }
+
+ FILE *in = fopen(filename, "r");
+ if(in == NULL) {
+ fprintf(stderr, "Couldn't open '%s': %s\n", filename,
+ strerror(errno));
+ exit(1);
+ }
+
+ return in;
+}
+
+static filetype_t get_filetype_from_string(const char *string)
+{
+ if (streq(string, "c") || streq(string, "c-header"))
+ return FILETYPE_C;
+ if (streq(string, "c++") || streq(string, "c++-header"))
+ return FILETYPE_CXX;
+ if (streq(string, "assembler"))
+ return FILETYPE_PREPROCESSED_ASSEMBLER;
+ if (streq(string, "assembler-with-cpp"))
+ return FILETYPE_ASSEMBLER;
+ if (streq(string, "none"))
+ return FILETYPE_AUTODETECT;
+
+ return FILETYPE_UNKNOWN;
+}
+
+typedef enum lang_standard_t {
+ STANDARD_DEFAULT, /* gnu99 (for C, GCC does gnu89) or gnu++98 (for C++) */
+ STANDARD_ANSI, /* c89 (for C) or c++98 (for C++) */
+ STANDARD_C89, /* ISO C90 (sic) */
+ STANDARD_C90, /* ISO C90 as modified in amendment 1 */
+ STANDARD_C99, /* ISO C99 */
+ STANDARD_GNU89, /* ISO C90 plus GNU extensions (including some C99) */
+ STANDARD_GNU99, /* ISO C99 plus GNU extensions */
+ STANDARD_CXX98, /* ISO C++ 1998 plus amendments */
+ STANDARD_GNUXX98 /* ISO C++ 1998 plus amendments and GNU extensions */
+} lang_standard_t;
+