예제 #1
0
파일: main.cpp 프로젝트: omegaonline/oocore
int main(int argc, char* argv[])
{
	// Declare a local stack allocator
	OOBase::StackAllocator<1024> allocator;

	// Set up the command line args
	OOBase::CmdArgs cmd_args(allocator);
	cmd_args.add_option("help",'h');
	cmd_args.add_option("version",'v');

	// Parse command line
	OOBase::CmdArgs::results_t args(allocator);
	int err = cmd_args.parse(argc,argv,args);
	if (err	!= 0)
	{
		OOBase::LocalString strErr(allocator);
		if (args.find("missing",strErr))
		{
			OOBase::stderr_write("Missing value for option ");
			OOBase::stderr_write(strErr.c_str());
		}
		else if (args.find("unknown",strErr))
		{
			OOBase::stderr_write("Unknown option ");
			OOBase::stderr_write(strErr.c_str());
		}
		else
		{
			OOBase::stderr_write("Failed to parse comand line: ");
			OOBase::stderr_write(OOBase::system_error_text(err));
		}
		return EXIT_FAILURE;
	}

	if (args.exists("help"))
		return help();

	if (args.exists("version"))
		return version();

	OOBase::stdout_write(Omega::guid_t::Create().ToString().c_str());
	OOBase::stdout_write("\n");

	return EXIT_SUCCESS;
}
예제 #2
0
파일: shell.c 프로젝트: wjrsonic/openwrt
int
main(int argc, const char *argv[])
{
    char cmd_str[CMDSTR_BUF_SIZE];

    cmd_init();

    if(argc > 1)
    {
        memset(cmd_str, 0, sizeof(cmd_str));
        cmd_args(cmd_str, argc, argv);
        cmd_exit();
        return 0;
    }

    cmd_welcome();

    /*main loop*/
    while (1)
    {
        memset(cmd_str, 0, sizeof(cmd_str));

        if(next_cmd(cmd_str) == 0)/*loop through if '\n'*/
            continue;

        if (cmd_is_exit(cmd_str))
            break;

        if(cmd_is_batch(cmd_str))
        {
            if(cmd_run_batch(cmd_str)!= SW_OK)
                cmd_batch_help();
        }
        else
        {
            cmd_run_one(cmd_str);
        }
    }

    cmd_exit();
    return 0;
}
 */


//QString qemuVm_qprocess::command="./qemu_dummy";
QString qemuVm_qprocess::command="qemu-system-i386";
//QString qemuVm_qprocess::command="taskset";

QStringList cmd_args(){
  QStringList args;
  //  args << "-c"<< "19-24"<<"qemu-system-i386";
  args << "-hda" << "../microMachines_experimental_clean/microMachine.hda";
  args << "--nographic";
  return args;
}

QStringList qemuVm_qprocess::args=cmd_args();

/*
  Construct / Destruct
*/
qemuVm_qprocess::qemuVm_qprocess(QObject *parent) :
    microMachine(),proc(this),boot_char('!'),timer(0)
{
    connect(&proc,SIGNAL(readyRead()),this,SLOT(firstByteRecieved()));

}

/*
qemuVm::qemuVm(QString n) :
  microMachine(n){}
*/
예제 #4
0
int main(int argc, char* argv[])
{
    // Start the logger - use OOServer again...
    OOBase::Logger::open("OOServer",__FILE__);

    // Set critical failure handler
    OOBase::SetCriticalFailure(&CriticalFailure);

    // Declare a local stack allocator
    OOBase::StackAllocator<1024> allocator;

    // Set up the command line args
    OOBase::CmdArgs cmd_args(allocator);
    cmd_args.add_option("help",'h');
    cmd_args.add_option("version",'v');
    cmd_args.add_option("debug");
    cmd_args.add_option("surrogate");
    cmd_args.add_option("service");

#if defined(_WIN32)
    cmd_args.add_option("shellex");
#endif

    // Parse command line
    OOBase::CmdArgs::results_t args(allocator);
    int err = cmd_args.parse(argc,argv,args);
    if (err	!= 0)
    {
        OOBase::LocalString strErr(allocator);
        if (args.find("missing",strErr))
            OOBase::Logger::log(OOBase::Logger::Error,APPNAME " - Missing value for option %s",strErr.c_str());
        else if (args.find("unknown",strErr))
            OOBase::Logger::log(OOBase::Logger::Error,APPNAME " - Unknown option %s",strErr.c_str());
        else
            OOBase::Logger::log(OOBase::Logger::Error,APPNAME " - Failed to parse command line: %s",OOBase::system_error_text(err));

        return EXIT_FAILURE;
    }

    s_is_debug = args.exists("debug");

    if (args.exists("help"))
        return Help();

    if (args.exists("version"))
        return Version();

#if defined(HAVE_UNISTD_H) && 0

    if (s_is_debug)
    {
        printf("Attach a debugger to " APPNAME " process %u, and hit ENTER...\n",getpid());
        char buf[256];
        read(STDIN_FILENO,buf,sizeof(buf));
    }

#endif

    if (args.exists("surrogate"))
        return Host::Surrogate();
    else if (args.exists("service"))
        return Host::ServiceStart();
#if defined(_WIN32)
    else if (args.exists("shellex"))
        return Host::ShellEx(args);
#endif

    // Oops...
    OOBase::Logger::log(OOBase::Logger::Error,APPNAME " - Invalid or missing arguments.");
    return EXIT_FAILURE;
}
예제 #5
0
파일: cmd.c 프로젝트: hettoo/chatsow
static void cmd_execute_real(int c, int caller, char *name, int type) {
    cmd_stack_push();
    s->caller = caller;
    parse_cmd(name, -1);

    cmd_t *cmd = NULL;
    int cmds = 0;
    while ((cmd = cmd_find(cmd, c, type, qfalse)) != NULL) {
        cmds++;

        int start = c;
        int end = c;
        qboolean switch_screen = qfalse;
        int old_type = type;
        if (cmd_type_compatible(cmd->type, type))
            type = cmd->type;
        if ((type == CT_BROADCAST || type == CT_CVAR) && c < 0) {
            start = 0;
            end = CLIENTS - 1;
        } else if (type == CT_BROADCAST_ALL) {
            start = -1;
            end = CLIENTS - 1;
        } else if (type == CT_FIND_FREE && c < 0) {
            int i;
            qboolean found = qfalse;
            for (i = 0; i < CLIENTS && !found; i++) {
                if (!client_active(i)) {
                    start = i;
                    end = i;
                    found = qtrue;
                    switch_screen = qtrue;
                    break;
                }
            }
            if (!found) {
                ui_output(c, "No free client found.\n");
                cmd_stack_pop();
                return;
            }
        }
        for (s->client = start; s->client <= end; s->client++) {
            if (type == CT_SERVER)
                client_command(s->client, "%s", cmd_args(0));
            else
                cmd->f();
            if (switch_screen)
                set_screen(s->client + 1);
        }
        type = old_type;
    }
    if (cmds == 0) {
        if (cmd_type_compatible(type, CT_PUBLIC)) {
            if (cmd_argv(0)[0])
                client_say(c, "Unknown command: \"%s\"", cmd_argv(0));
        } else if (!cmd_type_compatible(type, CT_EVENT)) {
            ui_output(c, "Unknown command: \"%s\"\n", cmd_argv(0));
        }
        cmd_stack_pop();
        return;
    }
    cmd_stack_pop();
}