Beispiel #1
0
int console_receive(MasterIpcThread* ipcThread, Master* M, ChildProcess* proc, int sourceId, IpcPacket* packet)
{
    ExceptionScope exScope;
    Console* volatile console   = NULL;
    int volatile ret            = false;
    int ex;
    
    exception_begin_try(B(ipcThread), &exScope);
    
    switch ((ex = exception_try(B(ipcThread))))
    {
    case Try:
        ret = console_do_receive(ipcThread, M, proc, sourceId, packet, &console);
        break;
    
    default:
        if (console)
            console_destroy(console);
        
        log_format(B(ipcThread), LogError, "[console_receive] Error (%i): %s", ex, string_data(exception_message(B(ipcThread))));
        
        exception_handled(B(ipcThread));
        break;
    }
    
    exception_end_try(B(ipcThread));
    
    return ret;
}
int main()
{
	console_t con;

	assert(console_init(&con) == 0);
	assert(console_bind(&con, "set_ok", cmd_set_ok) == 0);
	assert(console_bind(&con, "err", cmd_return_error) == 0);
	assert(console_bind(&con, "param", cmd_param_ok) == 0);

	// verify that cmd_set_ok is called
	assert(console_exec(&con, "set_ok") == 0);
	assert(g_ok == 1);
	
	// verify that cmd_return_error is called
	// should return -1 since cmdfunc would fail
	assert(console_exec(&con, "err") == -1);

	// calling nonexisted command returns -1
	assert(console_exec(&con, "nonexist") == -1);

	// verify that parameter is parsed correctly
	assert(console_exec(&con, "param hello") == 0);

	console_destroy(&con);

	printf("passed\n");

	return 0;
}
Beispiel #3
0
void run_app() {
	/*  
	 * Builder for the application
	 */
	Repository* repo = repository_init("Files/cheltuieli.txt");
	Validator* valid = validator_init();
	Controller* ctr = controller_init(repo, valid);
	Console* cons = console_init(ctr);
	
	console_run(cons);

	console_destroy(cons);
	controller_destroy(ctr);
	validator_destroy(valid);
	repository_destroy(repo);
}
Beispiel #4
0
void console_finish(Console* console)
{
    console_write(console, NULL, 0, ServerOp_ConsoleFinish);
    console_destroy(console);
}
Beispiel #5
0
void dbg_console_destroy()
{
	thread_destroy(_dbg_console_thread);
	console_destroy(_dbg_console);
}
Beispiel #6
0
int csmng_stop()
{
	console_destroy(instance);
	console_unhook(NULL, NULL, csmng_monitor);
	return ERR_NOERROR;
}