1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 /**@SU_TAG
26  *
27  * @CFILE su_tag_io.c
28  * @brief Printing tag lists.
29  *
30  * @author Pekka Pessi <Pekka.Pessi@nokia.com>
31  *
32  * @date Created: Wed Feb 21 12:12:27 2001 ppessi
33  */
34 
35 #include "config.h"
36 
37 #include <string.h>
38 #include <assert.h>
39 #include <stdarg.h>
40 #include <stdio.h>
41 
42 #include <sofia-sip/su_tag.h>
43 #include <sofia-sip/su_tag_class.h>
44 #include <sofia-sip/su_tag_io.h>
45 #include <sofia-sip/su_tag_inline.h>
46 
47 /** Print tags */
tl_print(FILE * f,char const * title,tagi_t const lst[])48 void tl_print(FILE *f, char const *title, tagi_t const lst[])
49 {
50   fputs(title, f);
51 
52   for (; lst; lst = t_next(lst)) {
53     char buffer[4096];
54     char const *fmt = "   %s\n";
55     int n;
56 
57     buffer[0] = '\0';
58 
59     n = t_snprintf(lst, buffer, sizeof(buffer));
60 
61     if (n + 1 < (int)sizeof(buffer)) {
62       if (n > 0 && buffer[n - 1] == '\n')
63 	fmt = "   %s";
64     }
65     else
66       buffer[sizeof(buffer) - 1] = '\0';
67     fprintf(f, fmt, buffer);
68   }
69 }
70