4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
39 #define COMPAT_LAYER "Apple Bonjour"
42 static pthread_mutex_t linkage_mutex = PTHREAD_MUTEX_INITIALIZER;
43 static int linkage_warning = 0;
45 static void get_exe_name(char *t, size_t l) {
49 /* Yes, I know, this is not portable. But who cares? It's
50 * for cosmetics only, anyway. */
52 snprintf(fn, sizeof(fn), "/proc/%lu/exe", (unsigned long) getpid());
54 if ((k = readlink(fn, t, l-1)) < 0)
55 snprintf(t, l, "(unknown)");
59 assert((size_t) k <= l-1);
62 if ((slash = strrchr(t, '/')))
63 memmove(t, slash+1, strlen(slash)+1);
67 static void warning(const char *ident, const char *fmt, ...) {
76 vfprintf(stderr, fmt, ap);
79 openlog(ident, LOG_PID, LOG_USER);
80 vsyslog(LOG_WARNING, fmt, ap2);
85 void avahi_warn_linkage(void) {
88 pthread_mutex_lock(&linkage_mutex);
91 pthread_mutex_unlock(&linkage_mutex);
93 if (!w && !getenv("AVAHI_COMPAT_NOWARN")) {
96 get_exe_name(exename, sizeof(exename));
98 warning(exename, "*** WARNING: The application '%s' uses the "COMPAT_LAYER" compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename);
102 void avahi_warn_unsupported(const char *function) {
104 get_exe_name(exename, sizeof(exename));
106 warning(exename, "*** WARNING: The application '%s' called '%s()' which is not supported (or only supported partially) in the "COMPAT_LAYER" compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename, function);