su_tag_io.c 1.73 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/**@SU_TAG
 * 
 * @CFILE su_tag_io.c
 * @brief Printing tag lists.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * 
 * @date Created: Wed Feb 21 12:12:27 2001 ppessi
 */

#include "config.h"

#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>

42 43 44 45
#include <sofia-sip/su_tag.h>
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/su_tag_io.h>
#include <sofia-sip/su_tag_inline.h>
Pekka Pessi's avatar
Pekka Pessi committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

/** Print tags */
void tl_print(FILE *f, char const *title, tagi_t const lst[])
{
  fputs(title, f);

  for (; lst; lst = t_next(lst)) {
    char buffer[4096];
    char const *fmt = "   %s\n";
    int n;

    buffer[0] = '\0';

    n = t_snprintf(lst, buffer, sizeof(buffer));

61
    if (n + 1 < (int)sizeof(buffer)) {
Pekka Pessi's avatar
Pekka Pessi committed
62 63 64 65 66 67 68 69
      if (n > 0 && buffer[n - 1] == '\n')
	fmt = "   %s";
    }
    else 
      buffer[sizeof(buffer) - 1] = '\0';
    fprintf(f, fmt, buffer);
  }
}