+/* Quote characters that will confuse the shell when we run the preprocessor. */
+
+static const char *
+quot (const char *string)
+{
+ static char *buf = 0;
+ static int buflen = 0;
+ int slen = strlen (string);
+ const char *src;
+ char *dest;
+
+ if ((buflen < slen * 2 + 2) || ! buf)
+ {
+ buflen = slen * 2 + 2;
+ free (buf);
+ buf = (char *) xmalloc (buflen);
+ }
+
+ for (src=string, dest=buf; *src; src++, dest++)
+ {
+ if (*src == '(' || *src == ')' || *src == ' ')
+ *dest++ = '\\';
+ *dest = *src;
+ }
+ *dest = 0;
+ return buf;
+}
+
+/* Long options. */
+
+enum option_values
+{
+ /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
+ OPTION_PREPROCESSOR = 150,
+ OPTION_USE_TEMP_FILE,
+ OPTION_NO_USE_TEMP_FILE,
+ OPTION_YYDEBUG,
+ OPTION_INCLUDE_DIR,
+ OPTION_PREPROCESSOR_ARG
+};
+
+static const struct option long_options[] =
+{
+ {"input", required_argument, 0, 'i'},
+ {"output", required_argument, 0, 'o'},
+ {"input-format", required_argument, 0, 'J'},
+ {"output-format", required_argument, 0, 'O'},
+ {"target", required_argument, 0, 'F'},
+ {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
+ {"preprocessor-arg", required_argument, 0, OPTION_PREPROCESSOR_ARG},
+ {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
+ {"define", required_argument, 0, 'D'},
+ {"undefine", required_argument, 0, 'U'},
+ {"verbose", no_argument, 0, 'v'},
+ {"codepage", required_argument, 0, 'c'},
+ {"language", required_argument, 0, 'l'},
+ {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE},
+ {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE},
+ {"yydebug", no_argument, 0, OPTION_YYDEBUG},
+ {"version", no_argument, 0, 'V'},
+ {"help", no_argument, 0, 'h'},
+ {0, no_argument, 0, 0}
+};
+
+void
+windres_add_include_dir (const char *p)
+{
+ struct include_dir *n, **pp;
+
+ /* Computing paths is often complicated and error prone.
+ The easiest way to check for mistakes is at the time
+ we add them to include_dirs. */
+ assert (p != NULL);
+ assert (*p != '\0');
+
+ n = xmalloc (sizeof *n);
+ n->next = NULL;
+ n->dir = (char * ) p;
+
+ for (pp = &include_dirs; *pp != NULL; pp = &(*pp)->next)
+ ;
+ *pp = n;
+}
+
+/* This keeps gcc happy when using -Wmissing-prototypes -Wstrict-prototypes. */
+int main (int, char **);
+