vtysh源码,一个类似于zebra的本地shell

上传者: sinat_36544290 | 上传时间: 2021-11-03 17:54:52 | 文件大小: 38KB | 文件类型: -
/* VTY shell main routine. */ int main (int argc, char **argv, char **env) { char *line; int opt; int eval_flag = 0; int boot_flag = 0; char *eval_line = NULL; char *config_file = CONFIG_DIR "/" CONFIG_FILE; if(getenv("VTYSH_CONFIG")) config_file = getenv("VTYSH_CONFIG"); while (1) { opt = getopt_long (argc, argv, "be:c:hv", longopts, 0); if (opt == EOF) break; switch (opt) { case 0: break; case 'b': boot_flag = 1; break; case 'e': eval_flag = 1; eval_line = optarg; break; case 'h': usage (argv[0], 0); break; case 'c': config_file = optarg; break; case 'v': printf("Ver:%s %s\n", __DATE__, __TIME__); exit(0); default: usage (argv[0], 1); break; } } /* Signal and others. */ signal_init (); /* Init config. */ config_init(); /* Init the cmd */ cmd_init(); /* Init the vtysh */ vtysh_init_vty (); /* Install command and node view */ cmd_parse_init(); //TODO load the dynamic so /* sort the node */ cmd_sort_node(); /* If eval mode */ if (eval_flag) { vtysh_execute("enable"); vtysh_execute("config terminal"); exit(vtysh_execute(eval_line)); } /* Boot startup configuration file. */ if (boot_flag) exit(vtysh_boot_config (config_file)); in_show_welcome(); host.config = config_file; vtysh_load_config(config_file); /* Main command loop. */ while ((line = vtysh_readline()) != NULL) vtysh_execute (line); printf ("\n"); exit (0); }

文件下载

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明