~brightbox/bird/debian-packaging

« back to all changes in this revision

Viewing changes to filter/trie.c

  • Committer: Ondřej Surý
  • Date: 2013-11-25 14:59:24 UTC
  • Revision ID: git-v1:a3c058b8752bd98df2231ac88d94931fdb4e0c65
New upstream version 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
}
266
266
 
267
267
static void
268
 
trie_node_print(struct f_trie_node *t, char **sep)
 
268
trie_node_format(struct f_trie_node *t, buffer *buf)
269
269
{
270
270
  if (t == NULL)
271
271
    return;
272
272
 
273
273
  if (ipa_nonzero(t->accept))
274
 
    {
275
 
      logn("%s%I/%d{%I}", *sep, t->addr, t->plen, t->accept);
276
 
      *sep = ", ";
277
 
    }
 
274
    buffer_print(buf, "%I/%d{%I}, ", t->addr, t->plen, t->accept);
278
275
 
279
 
  trie_node_print(t->c[0], sep);
280
 
  trie_node_print(t->c[1], sep);
 
276
  trie_node_format(t->c[0], buf);
 
277
  trie_node_format(t->c[1], buf);
281
278
}
282
279
 
283
280
/**
284
 
 * trie_print
285
 
 * @t: trie to be printed
 
281
 * trie_format
 
282
 * @t: trie to be formatted
 
283
 * @buf: destination buffer
286
284
 *
287
 
 * Prints the trie to the log buffer.
 
285
 * Prints the trie to the supplied buffer.
288
286
 */
289
287
void
290
 
trie_print(struct f_trie *t)
 
288
trie_format(struct f_trie *t, buffer *buf)
291
289
{
292
 
  char *sep = "";
293
 
  logn("[");
 
290
  buffer_puts(buf, "[");
 
291
 
294
292
  if (t->zero)
295
 
    {
296
 
      logn("%I/%d", IPA_NONE, 0);
297
 
      sep = ", ";
298
 
    }
299
 
  trie_node_print(&t->root, &sep);
300
 
  logn("]");
 
293
    buffer_print(buf, "%I/%d", IPA_NONE, 0);
 
294
  trie_node_format(&t->root, buf);
 
295
 
 
296
  /* Undo last separator */
 
297
  if (buf->pos[-1] != '[')
 
298
    buf->pos -= 2;
 
299
 
 
300
  buffer_puts(buf, "]");
301
301
}