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
36 static pthread_mutex_t linkage_mutex = PTHREAD_MUTEX_INITIALIZER;
37 static int linkage_warning = 0;
39 static void get_exe_name(char *t, size_t l) {
43 /* Yes, I know, this is not portable. But who cares? It's
44 * for cosmetics only, anyway. */
46 snprintf(fn, sizeof(fn), "/proc/%lu/exe", (unsigned long) getpid());
48 if ((k = readlink(fn, t, l-1)) < 0)
49 snprintf(t, l, "(unknown)");
53 assert((size_t) k <= l-1);
56 if ((slash = strrchr(t, '/')))
57 memmove(t, slash+1, strlen(slash)+1);
61 void avahi_warn_linkage(void) {
64 pthread_mutex_lock(&linkage_mutex);
67 pthread_mutex_unlock(&linkage_mutex);
69 if (!w && !getenv("AVAHI_BONJOUR_NOWARN")) {
71 get_exe_name(exename, sizeof(exename));
73 fprintf(stderr, "*** WARNING: The application '%s' uses the Bonjour compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename);
77 void avahi_warn_unsupported(const char *function) {
79 get_exe_name(exename, sizeof(exename));
81 fprintf(stderr, "*** WARNING: The application '%s' called '%s()' which is not supported in the Bonjour compatiblity layer of Avahi. Please fix it to use the native API! ***\n", exename, function);