Recognize a matching check if it's an INVALID message (error with no error-code)
[sipe-libnice.git] / stun / debug.c
blob24a37321f63fa6b46ea0f110e37112779efc6b33
1 /*
2 * This file is part of the Nice GLib ICE library.
4 * (C) 2008-2009 Collabora Ltd.
5 * Contact: Youness Alaoui
6 * (C) 2007 Nokia Corporation. All rights reserved.
8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS" basis,
14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15 * for the specific language governing rights and limitations under the
16 * License.
18 * The Original Code is the Nice GLib ICE library.
20 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
21 * Corporation. All Rights Reserved.
23 * Contributors:
24 * Youness Alaoui, Collabora Ltd.
26 * Alternatively, the contents of this file may be used under the terms of the
27 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
28 * case the provisions of LGPL are applicable instead of those above. If you
29 * wish to allow use of your version of this file only under the terms of the
30 * LGPL and not to allow others to use your version of this file under the
31 * MPL, indicate your decision by deleting the provisions above and replace
32 * them with the notice and other provisions required by the LGPL. If you do
33 * not delete the provisions above, a recipient may use your version of this
34 * file under either the MPL or the LGPL.
37 #ifdef HAVE_CONFIG_H
38 # include <config.h>
39 #endif
41 #include <string.h>
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <stdarg.h>
46 #include "debug.h"
49 static int debug_enabled = 1;
51 void stun_debug_enable (void) {
52 debug_enabled = 1;
54 void stun_debug_disable (void) {
55 debug_enabled = 0;
58 void stun_debug (const char *fmt, ...)
60 va_list ap;
61 if (debug_enabled) {
62 va_start (ap, fmt);
63 vfprintf (stderr, fmt, ap);
64 va_end (ap);
68 void stun_debug_bytes (const void *data, size_t len)
70 size_t i;
72 stun_debug ("0x");
73 for (i = 0; i < len; i++)
74 stun_debug ("%02x", ((const unsigned char *)data)[i]);