- while ((evt = action_get_action(argv[0]))) {
- msg_action_fun function =
- xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
- (*function) (evt);
- xbt_dynar_free(&evt);
- }
+ while ((evt = action_get_action(argv[0]))) {
+ msg_action_fun function =
+ xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
+ (*function) (evt);
+ xbt_dynar_free(&evt);
+ }
+ } else { // Should have got my trace file in argument
+ xbt_assert0(argc>=2,
+ "No simulation-wide trace file provided to MSG_action_trace_run(), "
+ "and no process-wide trace file provided in deployment file. Aborting."
+ );
+
+ char *line = NULL;
+ size_t line_len = 0;
+ FILE *fp = fopen(argv[1], "r");
+ xbt_assert2(fp != NULL, "Cannot open %s: %s", argv[1], strerror(errno));
+
+ ssize_t read;
+ // Read lines and execute them until I reach the end of file
+ while ((read = getline(&line, &line_len, fp)) != -1) {
+ // cleanup and split the string I just read
+ char *comment = strchr(line, '#');
+ if (comment != NULL)
+ *comment = '\0';
+ xbt_str_trim(line, NULL);
+ if (line[0] == '\0')
+ continue;
+ evt = xbt_str_split_quoted(line);