Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    if ((argc < 3) || (strcmp(argv[1], "--help") == 0))
        help();

    f = open("/dev/rtnet", O_RDWR);

    if (f < 0) {
        perror("/dev/rtnet");
        exit(1);
    }

    memset(&cmd, 0, sizeof(cmd));
    strncpy(cmd.head.if_name, argv[1], IFNAMSIZ);

    if (strcmp(argv[2], "server") == 0)
        cmd_server(argc, argv);
    if (strcmp(argv[2], "add") == 0)
        cmd_add(argc, argv);
    if (strcmp(argv[2], "del") == 0)
        cmd_del(argc, argv);
    if (strcmp(argv[2], "wait") == 0)
        cmd_wait(argc, argv);

    if (strcmp(argv[2], "client") == 0)
        cmd_client(argc, argv);
    if (strcmp(argv[2], "announce") == 0)
        cmd_announce(argc, argv);
    if (strcmp(argv[2], "ready") == 0)
        cmd_ready(argc, argv);

    if (strcmp(argv[2], "detach") == 0)
        cmd_detach(argc, argv);

    help();

    return 0;
}
Ejemplo n.º 2
0
/*
	execute command
*/
EXPORT	INT	exec_cmd(B *cmd)
{
	INT	ac;
	B	*av[N_ARGS];

	ac = setup_param(cmd, av);
	if (ac < 1) return 0;

	if (strcmp(av[0], "date") == 0) {
		cmd_date(ac, av);
	} else if (strcmp(av[0], "attach") == 0) {
		cmd_attach(ac, av);
	} else if (strcmp(av[0], "detach") == 0) {
		cmd_detach(ac, av);
	} else if (strcmp(av[0], "mkdir") == 0) {
		cmd_mkdir(ac, av);
	} else if (strcmp(av[0], "rmdir") == 0) {
		cmd_rmdir(ac, av);
	} else if (strcmp(av[0], "pwd") == 0) {
		cmd_pwd(ac, av);
	} else if (strcmp(av[0], "cd") == 0) {
		cmd_cd(ac, av);
	} else if (strcmp(av[0], "rm") == 0) {
		cmd_rm(ac, av);
	} else if (strcmp(av[0], "mv") == 0) {
		cmd_mv(ac, av);
	} else if (strcmp(av[0], "ls") == 0) {
		cmd_ls(ac, av);
	} else if (strcmp(av[0], "tp") == 0 || strcmp(av[0], "tpx") == 0) {
		cmd_tp(ac, av);
	} else if (strcmp(av[0], "cp") == 0) {
		cmd_cp(ac, av);
	} else if (strcmp(av[0], "trunc") == 0) {
		cmd_trunc(ac, av);
	} else if (strcmp(av[0], "df") == 0) {
		cmd_df(ac, av);
	} else if (strcmp(av[0], "sync") == 0) {
		cmd_sync(ac, av);
	} else if (strcmp(av[0], "chmod") == 0) {
		cmd_chmod(ac, av);
	} else if (strcmp(av[0], "ref") == 0) {
		cmd_ref(ac, av);
	} else if (strcmp(av[0], "load") == 0) {
		cmd_load(ac, av);
	} else if (strcmp(av[0], "loadspg") == 0) {
		cmd_loadspg(ac, av);
	} else if (strcmp(av[0], "unload") == 0) {
		cmd_unload(ac, av);
	} else if (strcmp(av[0], "call") == 0) {
		cmd_call(ac, av);
	} else if (strncmp(av[0], "?", 1) == 0) {
		P("date     [y m d [h m s]]\n");
		P("attach   devnm connm\n");
		P("detach   connm\n");
		P("cd       dir\n");
		P("pwd      \n");
		P("ls       [-t][-l][dir]\n");
		P("mkdir    dir [mode]\n");
		P("rmdir    dir\n");
		P("rm       path\n");
		P("mv       o-path n-path\n");
		P("trunc    path len\n");
		P("df       path\n");
		P("sync     [path [d]]\n");
		P("chmod    path mode\n");
		P("tp       path [ofs len]\n");
		P("tpx      path [ofs len]\n");
		P("cp       s-path d-path/dir [wofs [wlen]]\n");
		P("ref      [item]\n");
		P("call     addr [p1 p2 p3]\n");
		P("load     path\n");
		P("loadspg  path [arg ...]\n");
		P("unload   progid\n");
#ifdef	NET_SAMPLE
		P("net      execute network sample\n");

	} else if (strcmp(av[0], "net") == 0) {
IMPORT	void	net_test(void);
		net_test();
#endif
	} else {
		return 0;
	}
	return 1;
}