@@ -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);
@@ -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)
The 'sim_cmd_file' function only called by 'do_cmd' function in the sim_cmd.c file. Signed-off-by: Honggang Li <honli@redhat.com> --- ibsim/ibsim.c | 38 -------------------------------------- ibsim/sim_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-)