view finch/libgnt/test/wm.c @ 31401:27c56e6b5fa6

Our certificate code is generally designed around no two CA certificates having the same DN. Unfortunately this breaks when have multiple distinct intermediate certificates with the same DN, such as when we want to validate against MSN intermediate CAs. This change allows us to verify against any one of multiple CA certificates with the same DN, instead of relying on a) luck from reading from disk in the "right" order or b) black magic from NSS reconstructing a valid chain on connection attempts after CA pool initialization is complete.
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 23 Nov 2010 01:56:12 +0000
parents 0e3a8505ebbe
children a8cc50c2279f
line wrap: on
line source

#include <gmodule.h>

#include <gnt.h>
#include <gntbox.h>
#include <gntentry.h>
#include <gntlabel.h>

static gboolean
key_pressed(GntEntry *entry, const char *text, gpointer null)
{
	if (*text != '\r')
		return FALSE;

	{
		const char *cmd;
		void *handle;
		void (*func)();

		cmd = gnt_entry_get_text(entry);
		handle = g_module_open(cmd, G_MODULE_BIND_LOCAL);
		if (handle && g_module_symbol(handle, "main", (gpointer)&func))
		{
			char *argv[] = {cmd, NULL};
			gnt_entry_clear(entry);
			func(1, argv);
		}
		else
		{
			GntWidget *widget = gnt_vbox_new(FALSE);
			gnt_box_set_toplevel(GNT_BOX(widget), TRUE);
			gnt_box_set_title(GNT_BOX(widget), "Error");
			gnt_box_add_widget(GNT_BOX(widget), gnt_label_new("Could not execute."));
			gnt_box_add_widget(GNT_BOX(widget), gnt_label_new(g_module_error()));

			gnt_widget_show(widget);
		}
	}
	
	return TRUE;
}

int main()
{
	GntWidget *window, *entry;

	freopen(".error", "w", stderr);

	gnt_init();

	window = gnt_hbox_new(FALSE);

	gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Command"));

	entry = gnt_entry_new(NULL);
	g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), NULL);
	gnt_box_add_widget(GNT_BOX(window), entry);

	gnt_widget_set_position(window, 0, getmaxy(stdscr) - 2);
	gnt_widget_show(window);

	gnt_main();

	gnt_quit();
	
	return 0;
}