The 'sim_cmd_file' function only called by 'do_cmd' function in the sim_cmd.c file. Signed-off-by: Honggang Li <honli@xxxxxxxxxx> --- ibsim/ibsim.c | 38 -------------------------------------- ibsim/sim_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index debf591fea92..40e605c75429 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -517,44 +517,6 @@ static int sim_read_pkt(int fd, int client) return -1; // never reached } -int sim_cmd_file(FILE * f, char *s) -{ - char line[4096]; - FILE *cmd_file; - char *p; - - s++; - while (isspace(*s)) - s++; - - if (!s || !*s) { - fprintf(f, "do_cmd_from_file: no file name - skip\n"); - return -1; - } - - p = s + strlen(s) - 1; - while (isspace(*p)) { - *p = '\0'; - p--; - } - - cmd_file = fopen(s, "r"); - if (!cmd_file) { - fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", - s, strerror(errno)); - return -1; - } - - while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { - if((p = strchr(line, '\n')) != NULL) - *p = '\0'; - do_cmd(line, f); - } - - fclose(cmd_file); - return 0; -} - static int sim_init_net(char *netconf, FILE * out) { DEBUG("reading %s", netconf); diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4b8fb62e0906..4345731e5081 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1143,6 +1143,44 @@ format_error: return -1; } +int sim_cmd_file(FILE * f, char *s) +{ + char line[4096]; + FILE *cmd_file; + char *p; + + s++; + while (isspace(*s)) + s++; + + if (!s || !*s) { + fprintf(f, "do_cmd_from_file: no file name - skip\n"); + return -1; + } + + p = s + strlen(s) - 1; + while (isspace(*p)) { + *p = '\0'; + p--; + } + + cmd_file = fopen(s, "r"); + if (!cmd_file) { + fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", + s, strerror(errno)); + return -1; + } + + while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { + if((p = strchr(line, '\n')) != NULL) + *p = '\0'; + do_cmd(line, f); + } + + fclose(cmd_file); + return 0; +} + int netstarted; int do_cmd(char *buf, FILE *f) -- 2.15.0-rc1