static DisplayType select_display(const char *p)

{

    Error *err = NULL;

    const char *opts;

    DisplayType display = DT_DEFAULT;



    if (strstart(p, "sdl", &opts)) {

#ifdef CONFIG_SDL

        display = DT_SDL;

        while (*opts) {

            const char *nextopt;



            if (strstart(opts, ",frame=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    no_frame = 0;

                } else if (strstart(opts, "off", &nextopt)) {

                    no_frame = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",alt_grab=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    alt_grab = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    alt_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",ctrl_grab=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    ctrl_grab = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    ctrl_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",window_close=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    no_quit = 0;

                } else if (strstart(opts, "off", &nextopt)) {

                    no_quit = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",gl=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else {

            invalid_sdl_args:

                fprintf(stderr, "Invalid SDL option string: %s\n", p);

                exit(1);

            }

            opts = nextopt;

        }

#else

        fprintf(stderr, "SDL support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "vnc", &opts)) {

#ifdef CONFIG_VNC

        if (*opts == '=') {

            if (vnc_parse(opts + 1, &err) == NULL) {

                error_report_err(err);

                exit(1);

            }

        } else {

            fprintf(stderr, "VNC requires a display argument vnc=<display>\n");

            exit(1);

        }

#else

        fprintf(stderr, "VNC support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "curses", &opts)) {

#ifdef CONFIG_CURSES

        display = DT_CURSES;

#else

        fprintf(stderr, "Curses support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "gtk", &opts)) {

#ifdef CONFIG_GTK

        display = DT_GTK;

        while (*opts) {

            const char *nextopt;



            if (strstart(opts, ",grab_on_hover=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    grab_on_hover = true;

                } else if (strstart(opts, "off", &nextopt)) {

                    grab_on_hover = false;

                } else {

                    goto invalid_gtk_args;

                }

            } else if (strstart(opts, ",gl=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_gtk_args;

                }

            } else {

            invalid_gtk_args:

                fprintf(stderr, "Invalid GTK option string: %s\n", p);

                exit(1);

            }

            opts = nextopt;

        }

#else

        fprintf(stderr, "GTK support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "none", &opts)) {

        display = DT_NONE;

    } else {

        fprintf(stderr, "Unknown display type: %s\n", p);

        exit(1);

    }



    return display;

}

static DisplayType select_display(const char *p)

{

    Error *err = NULL;

    const char *opts;

    DisplayType display = DT_DEFAULT;



    if (strstart(p, "sdl", &opts)) {

#ifdef CONFIG_SDL

        display = DT_SDL;

        while (*opts) {

            const char *nextopt;



            if (strstart(opts, ",frame=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    no_frame = 0;

                } else if (strstart(opts, "off", &nextopt)) {

                    no_frame = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",alt_grab=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    alt_grab = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    alt_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",ctrl_grab=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    ctrl_grab = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    ctrl_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",window_close=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    no_quit = 0;

                } else if (strstart(opts, "off", &nextopt)) {

                    no_quit = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(opts, ",gl=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else {

            invalid_sdl_args:

                fprintf(stderr, "Invalid SDL option string: %s\n", p);

                exit(1);

            }

            opts = nextopt;

        }

#else

        fprintf(stderr, "SDL support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "vnc", &opts)) {

#ifdef CONFIG_VNC

        if (*opts == '=') {

            if (vnc_parse(opts + 1, &err) == NULL) {

                error_report_err(err);

                exit(1);

            }

        } else {

            fprintf(stderr, "VNC requires a display argument vnc=<display>\n");

            exit(1);

        }

#else

        fprintf(stderr, "VNC support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "curses", &opts)) {

#ifdef CONFIG_CURSES

        display = DT_CURSES;

#else

        fprintf(stderr, "Curses support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "gtk", &opts)) {

#ifdef CONFIG_GTK

        display = DT_GTK;

        while (*opts) {

            const char *nextopt;



            if (strstart(opts, ",grab_on_hover=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    grab_on_hover = true;

                } else if (strstart(opts, "off", &nextopt)) {

                    grab_on_hover = false;

                } else {

                    goto invalid_gtk_args;

                }

            } else if (strstart(opts, ",gl=", &nextopt)) {

                opts = nextopt;

                if (strstart(opts, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(opts, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_gtk_args;

                }

            } else {

            invalid_gtk_args:

                fprintf(stderr, "Invalid GTK option string: %s\n", p);

                exit(1);

            }

            opts = nextopt;

        }

#else

        fprintf(stderr, "GTK support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "none", &opts)) {

        display = DT_NONE;

    } else {

        fprintf(stderr, "Unknown display type: %s\n", p);

        exit(1);

    }



    return display;

}

static DisplayType FUNC_0(const char *p)

{

    Error *err = NULL;

    const char *VAR_0;

    DisplayType display = DT_DEFAULT;



    if (strstart(p, "sdl", &VAR_0)) {

#ifdef CONFIG_SDL

        display = DT_SDL;

        while (*VAR_0) {

            const char *nextopt;



            if (strstart(VAR_0, ",frame=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    no_frame = 0;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    no_frame = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(VAR_0, ",alt_grab=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    alt_grab = 1;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    alt_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(VAR_0, ",ctrl_grab=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    ctrl_grab = 1;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    ctrl_grab = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(VAR_0, ",window_close=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    no_quit = 0;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    no_quit = 1;

                } else {

                    goto invalid_sdl_args;

                }

            } else if (strstart(VAR_0, ",gl=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_sdl_args;

                }

            } else {

            invalid_sdl_args:

                fprintf(stderr, "Invalid SDL option string: %s\n", p);

                exit(1);

            }

            VAR_0 = nextopt;

        }

#else

        fprintf(stderr, "SDL support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "vnc", &VAR_0)) {

#ifdef CONFIG_VNC

        if (*VAR_0 == '=') {

            if (vnc_parse(VAR_0 + 1, &err) == NULL) {

                error_report_err(err);

                exit(1);

            }

        } else {

            fprintf(stderr, "VNC requires a display argument vnc=<display>\n");

            exit(1);

        }

#else

        fprintf(stderr, "VNC support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "curses", &VAR_0)) {

#ifdef CONFIG_CURSES

        display = DT_CURSES;

#else

        fprintf(stderr, "Curses support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "gtk", &VAR_0)) {

#ifdef CONFIG_GTK

        display = DT_GTK;

        while (*VAR_0) {

            const char *nextopt;



            if (strstart(VAR_0, ",grab_on_hover=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    grab_on_hover = true;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    grab_on_hover = false;

                } else {

                    goto invalid_gtk_args;

                }

            } else if (strstart(VAR_0, ",gl=", &nextopt)) {

                VAR_0 = nextopt;

                if (strstart(VAR_0, "on", &nextopt)) {

                    request_opengl = 1;

                } else if (strstart(VAR_0, "off", &nextopt)) {

                    request_opengl = 0;

                } else {

                    goto invalid_gtk_args;

                }

            } else {

            invalid_gtk_args:

                fprintf(stderr, "Invalid GTK option string: %s\n", p);

                exit(1);

            }

            VAR_0 = nextopt;

        }

#else

        fprintf(stderr, "GTK support is disabled\n");

        exit(1);

#endif

    } else if (strstart(p, "none", &VAR_0)) {

        display = DT_NONE;

    } else {

        fprintf(stderr, "Unknown display type: %s\n", p);

        exit(1);

    }



    return display;

}

static DisplayType FUNC_0(const char *p)
{ Error *err = NULL; const char *VAR_0; DisplayType display = DT_DEFAULT; if (strstart(p, "sdl", &VAR_0)) { #ifdef CONFIG_SDL
display = DT_SDL; while (*VAR_0) { const char *nextopt; if (strstart(VAR_0, ",frame=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { no_frame = 0; } else if (strstart(VAR_0, "off", &nextopt)) { no_frame = 1; } else { goto invalid_sdl_args; } } else if (strstart(VAR_0, ",alt_grab=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { alt_grab = 1; } else if (strstart(VAR_0, "off", &nextopt)) { alt_grab = 0; } else { goto invalid_sdl_args; } } else if (strstart(VAR_0, ",ctrl_grab=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { ctrl_grab = 1; } else if (strstart(VAR_0, "off", &nextopt)) { ctrl_grab = 0; } else { goto invalid_sdl_args; } } else if (strstart(VAR_0, ",window_close=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { no_quit = 0; } else if (strstart(VAR_0, "off", &nextopt)) { no_quit = 1; } else { goto invalid_sdl_args; } } else if (strstart(VAR_0, ",gl=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { request_opengl = 1; } else if (strstart(VAR_0, "off", &nextopt)) { request_opengl = 0; } else { goto invalid_sdl_args; } } else { invalid_sdl_args:
fprintf(stderr, "Invalid SDL option string: %s\n", p); exit(1); } VAR_0 = nextopt; } #else
fprintf(stderr, "SDL support is disabled\n"); exit(1); #endif
} else if (strstart(p, "vnc", &VAR_0)) { #ifdef CONFIG_VNC
if (*VAR_0 == '=') { if (vnc_parse(VAR_0 + 1, &err) == NULL) { error_report_err(err); exit(1); } } else { fprintf(stderr, "VNC requires a display argument vnc=<display>\n"); exit(1); } #else
fprintf(stderr, "VNC support is disabled\n"); exit(1); #endif
} else if (strstart(p, "curses", &VAR_0)) { #ifdef CONFIG_CURSES
display = DT_CURSES; #else
fprintf(stderr, "Curses support is disabled\n"); exit(1); #endif
} else if (strstart(p, "gtk", &VAR_0)) { #ifdef CONFIG_GTK
display = DT_GTK; while (*VAR_0) { const char *nextopt; if (strstart(VAR_0, ",grab_on_hover=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { grab_on_hover = true; } else if (strstart(VAR_0, "off", &nextopt)) { grab_on_hover = false; } else { goto invalid_gtk_args; } } else if (strstart(VAR_0, ",gl=", &nextopt)) { VAR_0 = nextopt; if (strstart(VAR_0, "on", &nextopt)) { request_opengl = 1; } else if (strstart(VAR_0, "off", &nextopt)) { request_opengl = 0; } else { goto invalid_gtk_args; } } else { invalid_gtk_args:
fprintf(stderr, "Invalid GTK option string: %s\n", p); exit(1); } VAR_0 = nextopt; } #else
fprintf(stderr, "GTK support is disabled\n"); exit(1); #endif
} else if (strstart(p, "none", &VAR_0)) { display = DT_NONE; } else { fprintf(stderr, "Unknown display type: %s\n", p); exit(1); } return display; }