diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-07-06 14:30:09 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-07-06 14:30:09 +0000 |
commit | be0a1c9f96833554598b89a2feffe3f5a84dabc0 (patch) | |
tree | 8de4940fb566c4ea0df4e2838f2e9f1b200cd7d6 /src/regex/regex_graph.c | |
parent | 75346f09320827a82d926d00ec6feb148aa83f69 (diff) | |
download | gnunet-be0a1c9f96833554598b89a2feffe3f5a84dabc0.tar.gz gnunet-be0a1c9f96833554598b89a2feffe3f5a84dabc0.zip |
regex: iterating over the initial states
Diffstat (limited to 'src/regex/regex_graph.c')
-rw-r--r-- | src/regex/regex_graph.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/regex/regex_graph.c b/src/regex/regex_graph.c index 5adecab62..b8eda8ec9 100644 --- a/src/regex/regex_graph.c +++ b/src/regex/regex_graph.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "gnunet_regex_lib.h" | 26 | #include "gnunet_regex_lib.h" |
27 | #include "regex_internal.h" | 27 | #include "regex_internal.h" |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Context for graph creation. Passed as the cls to | 30 | * Context for graph creation. Passed as the cls to |
31 | * GNUNET_REGEX_automaton_save_graph_step. | 31 | * GNUNET_REGEX_automaton_save_graph_step. |
32 | */ | 32 | */ |
@@ -77,7 +77,7 @@ scc_tarjan_strongconnect (unsigned int *scc_counter, | |||
77 | 77 | ||
78 | if (NULL == w) | 78 | if (NULL == w) |
79 | continue; | 79 | continue; |
80 | 80 | ||
81 | if (w->index < 0) | 81 | if (w->index < 0) |
82 | { | 82 | { |
83 | scc_tarjan_strongconnect (scc_counter, w, index, stack, stack_size); | 83 | scc_tarjan_strongconnect (scc_counter, w, index, stack, stack_size); |
@@ -160,9 +160,10 @@ GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | |||
160 | char *s_tran = NULL; | 160 | char *s_tran = NULL; |
161 | char *name; | 161 | char *name; |
162 | char *to_name; | 162 | char *to_name; |
163 | 163 | ||
164 | if (GNUNET_YES == ctx->verbose) | 164 | if (GNUNET_YES == ctx->verbose) |
165 | GNUNET_asprintf (&name, "%i (%s)", s->proof_id, s->name); | 165 | GNUNET_asprintf (&name, "%i (%s) (%s) (%s)", s->proof_id, s->name, s->proof, |
166 | GNUNET_h2s (&s->hash)); | ||
166 | else | 167 | else |
167 | GNUNET_asprintf (&name, "%i", s->proof_id); | 168 | GNUNET_asprintf (&name, "%i", s->proof_id); |
168 | 169 | ||
@@ -174,7 +175,8 @@ GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | |||
174 | } | 175 | } |
175 | else | 176 | else |
176 | { | 177 | { |
177 | GNUNET_asprintf (&s_acc, "\"%s\" [color=\"0.%i 0.8 0.95\"];\n", name, s->scc_id); | 178 | GNUNET_asprintf (&s_acc, "\"%s\" [color=\"0.%i 0.8 0.95\"];\n", name, |
179 | s->scc_id); | ||
178 | } | 180 | } |
179 | 181 | ||
180 | if (NULL == s_acc) | 182 | if (NULL == s_acc) |
@@ -197,10 +199,14 @@ GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | |||
197 | } | 199 | } |
198 | 200 | ||
199 | if (GNUNET_YES == ctx->verbose) | 201 | if (GNUNET_YES == ctx->verbose) |
200 | GNUNET_asprintf (&to_name, "%i (%s)", ctran->to_state->proof_id, ctran->to_state->name); | 202 | { |
203 | GNUNET_asprintf (&to_name, "%i (%s) (%s) (%s)", ctran->to_state->proof_id, | ||
204 | ctran->to_state->name, ctran->to_state->proof, | ||
205 | GNUNET_h2s (&ctran->to_state->hash)); | ||
206 | } | ||
201 | else | 207 | else |
202 | GNUNET_asprintf (&to_name, "%i", ctran->to_state->proof_id); | 208 | GNUNET_asprintf (&to_name, "%i", ctran->to_state->proof_id); |
203 | 209 | ||
204 | if (ctran->label == 0) | 210 | if (ctran->label == 0) |
205 | { | 211 | { |
206 | GNUNET_asprintf (&s_tran, | 212 | GNUNET_asprintf (&s_tran, |
@@ -243,13 +249,12 @@ GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | |||
243 | */ | 249 | */ |
244 | void | 250 | void |
245 | GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | 251 | GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, |
246 | const char *filename, | 252 | const char *filename, int verbose) |
247 | int verbose) | ||
248 | { | 253 | { |
249 | char *start; | 254 | char *start; |
250 | char *end; | 255 | char *end; |
251 | struct GNUNET_REGEX_Graph_Context ctx; | 256 | struct GNUNET_REGEX_Graph_Context ctx; |
252 | 257 | ||
253 | if (NULL == a) | 258 | if (NULL == a) |
254 | { | 259 | { |
255 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not print NFA, was NULL!"); | 260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not print NFA, was NULL!"); |
@@ -263,6 +268,7 @@ GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | |||
263 | } | 268 | } |
264 | 269 | ||
265 | ctx.filep = fopen (filename, "w"); | 270 | ctx.filep = fopen (filename, "w"); |
271 | ctx.verbose = verbose; | ||
266 | 272 | ||
267 | if (NULL == ctx.filep) | 273 | if (NULL == ctx.filep) |
268 | { | 274 | { |