#include <orbit/orbit.h>

int
main(int argc, char **argv)
{
    CORBA_Environment ev;
    CORBA_ORB orb;
    CORBA_sequence_CORBA_TypeCode *types;
    CORBA_TypeCode tc;
    gint i;

    CORBA_exception_init(&ev);
    orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
    if (ev._major != CORBA_NO_EXCEPTION) {
	g_warning("could not initialise ORB");
	return 1;
    }
    g_message("created ORB");

    if (!ORBit_small_load_typelib("Everything")) {
	g_warning("could not load typelib 'Everything'");
	return 1;
    }
    g_message("loaded typelib");

    tc = CORBA_OBJECT_NIL;
    types = ORBit_small_get_types("Everything");
    for (i = 0; i < types->_length; i++) {
	if (!strcmp(types->_buffer[i]->repo_id, "IDL:orbit/test/StrSeq:1.0")) {
	    tc = types->_buffer[i];
	    break;
	}
    }
    CORBA_free(types);
    if (tc == CORBA_OBJECT_NIL) {
	g_warning("could not find typecode 'IDL:orbit/test/StrSeq:1.0'");
	return 1;
    }
    g_message("tc->repo_id == %s", tc->repo_id);
    g_message("(tc->kind == tk_alias) == %d", tc->kind == CORBA_tk_alias);
    g_message("tc->subtypes[0]->repo_id == %s", tc->subtypes[0]->repo_id);
    g_message("tc->subtypes[0]->kind == %d", tc->subtypes[0]->kind);
    
    return 0;
}
