Example #1
0
static int test_uph(apr_pool_t *p)
{
    int i;
    apr_status_t rv;
    apr_uri_t info;
    struct uph_test *t;
    const char *failed;
    int rc = 0;

    for (i = 0; i < sizeof(uph_tests) / sizeof(uph_tests[0]); i++) {
        memset(&info, 0, sizeof(info));
        t = &uph_tests[i];
        rv = apr_uri_parse_hostinfo(p, t->hostinfo, &info);
        failed = (rv != t->rv) ? "bad rc" : NULL;
        if (!failed && t->rv == APR_SUCCESS) {
            if (!same_str(info.hostname, t->hostname))
                failed = "bad hostname";
            if (!same_str(info.port_str, t->port_str))
                failed = "bad port_str";
            if (info.port != t->port)
                failed = "bad port";
        }
        if (failed) {
            ++rc;
            fprintf(stderr, "failure for testcase %d/hostinfo %s: %s\n", i,
                    t->hostinfo, failed);
            show_info(rv, t->rv, &info);
        }
    }

    return rc;
}
Example #2
0
static int test_aup(apr_pool_t *p)
{
    int i;
    apr_status_t rv;
    apr_uri_t info;
    struct aup_test *t;
    const char *failed;
    int rc = 0;

    for (i = 0; i < sizeof(aup_tests) / sizeof(aup_tests[0]); i++) {
        memset(&info, 0, sizeof(info));
        t = &aup_tests[i];
        rv = apr_uri_parse(p, t->uri, &info);
        failed = (rv != t->rv) ? "bad rc" : NULL;
        if (!failed && t->rv == APR_SUCCESS) {
            if (!same_str(info.scheme, t->scheme))
                failed = "bad scheme";
            if (!same_str(info.hostinfo, t->hostinfo))
                failed = "bad hostinfo";
            if (!same_str(info.user, t->user))
                failed = "bad user";
            if (!same_str(info.password, t->password))
                failed = "bad password";
            if (!same_str(info.hostname, t->hostname))
                failed = "bad hostname";
            if (!same_str(info.port_str, t->port_str))
                failed = "bad port_str";
            if (!same_str(info.path, t->path))
                failed = "bad path";
            if (!same_str(info.query, t->query))
                failed = "bad query";
            if (!same_str(info.fragment, t->fragment))
                failed = "bad fragment";
            if (info.port != t->port)
                failed = "bad port";
        }
        if (failed) {
            ++rc;
            fprintf(stderr, "failure for testcase %d/uri %s: %s\n", i,
                    t->uri, failed);
            show_info(rv, t->rv, &info);
        }
        else if (t->rv == APR_SUCCESS) {
            const char *s = apr_uri_unparse(p, &info,
                                            APR_URI_UNP_REVEALPASSWORD);

            if (strcmp(s, t->uri)) {
                fprintf(stderr, "apr_uri_unparsed failed for testcase %d\n", i);
                fprintf(stderr, "  got %s, expected %s\n", s, t->uri);
            }
        }
    }

    return rc;
}
Example #3
0
static Tree_Node_T match_single_str(Single_Str_T single_str, Char_T const **pos_p, bool *pat_end_p)
{
#if PROFILING
  fun_calls[MATCH_SINGLE_STR].num++;
#endif

  if (!same_str(single_str->str, *pos_p, single_str->str_len))
    return NULL;

  *pat_end_p = true; /* 肯定是模式终止节点 */
  *pos_p += single_str->str_len;

  return &single_str->child;
}
Example #4
0
void
gdbui_env_dlg(const GdbEnvironInfo * env)
{
	GtkWidget *dlg = gtk_dialog_new_with_buttons(_("Environment settings"),
						     GTK_WINDOW(gdbui_setup.main_window),
						     GTK_DIALOG_MODAL |
						     GTK_DIALOG_DESTROY_WITH_PARENT,
						     GTK_STOCK_OK, GTK_RESPONSE_OK,
						     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);

	GtkBox *vbox = GTK_BOX(GTK_DIALOG(dlg)->vbox);
	GtkWidget *cwd_box = gtk_entry_new();
	GtkWidget *path_box = gtk_entry_new();
	GtkWidget *args_box = gtk_entry_new();
	GtkWidget *dirs_box = gtk_entry_new();

	gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(gdbui_setup.main_window));
	gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
	gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK);

	gtk_entry_set_text(GTK_ENTRY(cwd_box), env->cwd ? env->cwd : "");
	gtk_entry_set_text(GTK_ENTRY(path_box), env->path ? env->path : "");
	gtk_entry_set_text(GTK_ENTRY(args_box), env->args ? env->args : "");
	gtk_entry_set_text(GTK_ENTRY(dirs_box), env->dirs ? env->dirs : "");

	label(args_box, _("\n Command-line arguments passed to target program:"));
	label(dirs_box, _("\n Search path for source files:"));
	label(cwd_box, _("\n Working directory for target program:"));
	label(path_box, _("\n Search path for executables:"));

	gtk_widget_show_all(dlg);
	gtk_widget_set_usize(dlg, (gdk_screen_get_width(gdk_screen_get_default()) / 2) * 1, 0);
	if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK)
	{
		const gchar *cwd = gtk_entry_get_text(GTK_ENTRY(cwd_box));
		const gchar *path = gtk_entry_get_text(GTK_ENTRY(path_box));
		const gchar *args = gtk_entry_get_text(GTK_ENTRY(args_box));
		const gchar *dirs = gtk_entry_get_text(GTK_ENTRY(dirs_box));
		if (!same_str(cwd, env->cwd))
		{
			gdbio_send_cmd("-environment-cd %s\n", cwd);
		}
		if (!same_str(path, env->path))
		{
			gchar *fixed = fixup_path(path);
			gdbio_send_cmd("-environment-path -r %s\n", fixed);
			g_free(fixed);
		}
		if (!same_str(args, env->args))
		{
			gdbio_send_cmd("-exec-arguments %s\n", args);
		}
		if (!same_str(dirs, env->dirs))
		{
			gchar *fixed = fixup_path(dirs);
			gdbio_send_cmd("-environment-directory -r %s\n", fixed);
			g_free(fixed);
		}
	}
	gtk_widget_destroy(dlg);
}