libnetfilter_conntrack  1.0.6
expect/snprintf.c
1 /*
2  * (C) 2005-2011 by Pablo Neira Ayuso <pablo@netfilter.org>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  */
9 
10 #include "internal/internal.h"
11 
12 int __snprintf_expect(char *buf,
13  unsigned int len,
14  const struct nf_expect *exp,
15  unsigned int type,
16  unsigned int msg_output,
17  unsigned int flags)
18 {
19  int size;
20 
21  switch(msg_output) {
22  case NFCT_O_DEFAULT:
23  size = __snprintf_expect_default(buf, len, exp, type, flags);
24  break;
25  case NFCT_O_XML:
26  size = __snprintf_expect_xml(buf, len, exp, type, flags);
27  break;
28  default:
29  errno = ENOENT;
30  return -1;
31  }
32 
33  /* NULL terminated string */
34  buf[size+1 > len ? len-1 : size] = '\0';
35 
36  return size;
37 }