+static int
+load_episode (struct Experiment *e, struct Episode *cur,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct Operation *o;
+ char *sec_name;
+ char *op_name;
+ char *op;
+ int ep_counter = 0;
+ fprintf (stderr, "Parsing episode %u\n",cur->id);
+ GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
+
+ while (1)
+ {
+
+ GNUNET_asprintf(&op_name, "op-%u-operation", ep_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
+ sec_name, op_name, &op))
+ {
+ break;
+ }
+ o = GNUNET_new (struct Operation);
+ /* operations = set_rate, start_send, stop_send, set_preference */
+ if (0 == strcmp (op, "start_send"))
+ {
+ o->type = START_SEND;
+ }
+ else if (0 == strcmp (op, "stop_send"))
+ {
+ o->type = STOP_SEND;
+ }
+ else if (0 == strcmp (op, "set_rate"))
+ {
+ o->type = SET_RATE;
+ }
+ else if (0 == strcmp (op, "set_preference"))
+ {
+ o->type = SET_PREFERENCE;
+ }
+ else
+ {
+ fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
+ ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+
+ GNUNET_free (op_name);
+ GNUNET_asprintf(&op_name, "op-%u-src", ep_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+ sec_name, op_name, &o->src_id))
+ {
+ fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
+ ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+ if (o->src_id > e->num_masters)
+ {
+ fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
+ o->src_id, ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+
+ GNUNET_free (op_name);
+ GNUNET_asprintf(&op_name, "op-%u-dest", ep_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+ sec_name, op_name, &o->dest_id))
+ {
+ fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
+ ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+ if (o->dest_id > e->num_slaves)
+ {
+ fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
+ o->dest_id, ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+
+
+ GNUNET_free (op_name);
+ GNUNET_asprintf(&op_name, "op-%u-value", ep_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+ sec_name, op_name, &o->value))
+ {
+ fprintf (stderr, "Missing value in operation %u `%s' in episode %u\n",
+ ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+ if (o->dest_id > e->num_slaves)
+ {
+ fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
+ o->dest_id, ep_counter, op, cur->id);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+
+ fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %llu\n",
+ ep_counter, cur->id, print_op (o->type), o->src_id, o->dest_id, o->value);
+
+ GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
+ GNUNET_free (op_name);
+ ep_counter++;
+ }
+ GNUNET_free (sec_name);
+
+ return GNUNET_OK;
+}
+