ucarp-1.5.2+git20192404.1a9aaf7/0000755000175000017500000000000013460025251015260 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/.travis.yml0000644000175000017500000000025613460025251017374 0ustar gxaviergxavierlanguage: c compiler: - clang - gcc before_script: - sudo apt-get install libpcap-dev - ./autogen.sh - ./configure --disable-dependency-tracking script: make check ucarp-1.5.2+git20192404.1a9aaf7/AUTHORS0000644000175000017500000000145413460025251016334 0ustar gxaviergxavier* Frank DENIS * Eric Evans - maintainer of Debian packages. * David H - maintainer of Fink packages. * Richard Bellamy - helped a lot with Solaris portability. * Russell Mosemann - neutral mode and bug fixes. * Dean Gaudet - EINTR handling, log exec errors, --passfile. * Steve Kehlet and Marcus Goller - fixed the bogus code that issued poisonous gratuitous ARP, and improved the behavior when multiple nodes are started with the same interval and skew. Steve helped a lot on many things. * Tim Niemeyer - Ensure remastering works when the preferred master has its network connection flap. * Serve Sireskin - --ignoreifstate option. ucarp-1.5.2+git20192404.1a9aaf7/NEWS0000644000175000017500000000307713460025251015766 0ustar gxaviergxavier* Version 1.5.2: - Avoid adverts that might be twice what they should be on some Linux systems (Steve Kehlet). * Version 1.5.1: - A new option has been added to try using broadcast advertisements instead of multicast ones. * Version 1.5: - Breakage introducted with version 1.4 should finally be fixed, thanks to Petr Kohts, Greg Walton and Steve Kehlet. - A new option has been added to ignore unplugged network cable detection, useful when nodes are connected with a crossover cable, not with a switch. * Version 1.4: - This version should finally fix every issue people had with gratuitous ARP announcements. - Nodes configured with the same intervals shouln't flip-flop any more. * Version 1.3: - Gratuitous ARP packets should now properly be sent, regardless of the architecture. - New option: -m (-xparam=...) in order to add arbitrary arguments to up/down scripts. - New option: -o (--passfile=...) in order to read the secret key from a file. - A delayed ARP request is sent after the first one when switching to MASTER, in order to deal with some layer-3 switches. - Bug fixes. * Version 1.2: - Neutral mode (--neutral). - NetBSD compatibility. - Minor bug fixes. * Version 1.1: - The non-preemptive mode should work flawlessly. - Syslog facilities can now be changed. - Self-sent packets are now filtered out. - Portability has been improved. * Version 1.0: - I18n support has been added. - Syslog support has been implemented. - Code cleanups and documentation updates. - A mailing-list is now available. - Daemonization (--daemonize / -B) has been added. ucarp-1.5.2+git20192404.1a9aaf7/Makefile.am0000644000175000017500000000013513460025251017313 0ustar gxaviergxavierSUBDIRS = \ m4 \ po \ src \ examples ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = config.rpath ucarp-1.5.2+git20192404.1a9aaf7/COPYING0000644000175000017500000000262613460025251016321 0ustar gxaviergxavier UCARP is covered by the following license : /* * Copyright (c) 2004-2015 Frank Denis with the help of * all contributors. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ ------------------------------------------ Some code has been imported from the Pure-FTPd project. ------------------------------------------ The bsd-getopt_long.c and bsd-getopt_long.h source code is based upon the OpenBSD and NetBSD projects and it is covered by the BSD license. The carp.c and ip_carp.h files are derived from OpenBSD source code. The original license is enclosed at the beginning of the related files. ucarp-1.5.2+git20192404.1a9aaf7/README0000644000175000017500000002473313460025251016151 0ustar gxaviergxavier .:. UCARP .:. Documentation for version 1.5.2 ------------------------ BLURB ------------------------ UCARP allows a couple of hosts to share common virtual IP addresses in order to provide automatic failover. It is a portable userland implementation of the secure and patent-free Common Address Redundancy Protocol (CARP, OpenBSD's alternative to the patents-bloated VRRP). Strong points of the CARP protocol are: very low overhead, cryptographically signed messages, interoperability between different operating systems and no need for any dedicated extra network link between redundant hosts. ------------------------ COMPILATION ------------------------ libpcap (http://www.tcpdump.org/) must be installed on your system, with development files (headers). Then, follow the boring traditional procedure: ./configure make install-strip For details, have a look at the INSTALL file. The software has been successfully tested on Linux 2.4, Linux 2.6, MacOS X, OpenBSD, MirBSD and NetBSD. ------------------------ REQUIREMENTS ------------------------ A couple of virtual hosts must be given: - A shared virtual IP, which will be dynamically answered by one alive host. Services that need high availability need to be assigned to that virtual IP. - A real IP address for each host. - A shared identifier for the virtual IP address, which is a number between 1 and 255. - For each host : an advertisement interval, comprised of a base and skew value, which is the frequency the host will tell the other one that it's still alive. By default, base is 1 and skew is 0, which basically means one advertisement a second. The protocol is very light, a tiny packet every second won't have any noticeable impact on your network. - A shared password (that will never go plaintext to the network). - A script to bring the virtual address up when a host becomes the master. - Another script to bring the virtual address down when a host is no more the master. ------------------------ USAGE ------------------------ The server will usually be installed as : /usr/local/sbin/ucarp Everything is driven through command-line options. In order to see the list of available options, try : /usr/local/sbin/ucarp -h Better than a long technical discussion, here's a real-life setup example. Your company has an internal mail relay whose IP address is 10.1.1.252. Every user has configured his mail client with that host or IP address and the service must always be up and running without having to reconfigure every user's mail client in case of a failure. Instead of assigning 10.1.1.252 to a particular mail server, you decide to use ucarp to allow two hosts to share this IP address. Of course, only one server can answer for this address at a time, while the other sits idle. However the other server will automatically become active in case the first one fails. Thus you're providing a simple but powerful IP failover solution. So you set up two mail servers hosts with an identical configuration. Their real IP addresses are 10.1.1.1 and 10.1.1.2. First, we will create a script that brings the virtual IP address up. Let's save that file as /etc/vip-up.sh : #! /bin/sh /sbin/ip addr add 10.1.1.252/24 dev eth0 Now another script to bring it down, /etc/vip-down.sh : #! /bin/sh /sbin/ip addr del 10.1.1.252/24 dev eth0 Of course, anything can go in these scripts. For instance, you may want to add routes, to add something to log files or to send mail. And last, but not least, you can use a script that will connect to your switches and flush their ARP cache. Some users reported that transitions were way faster when also switching MAC addresses. The called scripts are passed arguments, in this order: For instance, as the is passed as the first argument to the called scripts, feel free to replace "eth0" with "$1" and 10.1.1.252 by "$2" in the previous examples. Don't forget to make those files executable : chmod +x /etc/vip-up.sh /etc/vip-down.sh Right. What we need now is an identifier for the virtual IP. Let's take "42". And we also need a password. Let's take "love". Now, on the first host (whoose real IP is 10.1.1.1), run : /usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.1 & On the second host, whose real IP is 10.1.1.2, run : /usr/local/sbin/ucarp -v 42 -p love -a 10.1.1.252 -s 10.1.1.2 & You should see that one of those hosts quickly becomes the master, and the other one the backup. Related scripts are spawned on change. Now unplug the master. After a few seconds, the other host becomes the new master. ------------------------ MULTICAST IP SELECTION ------------------------- The '--vhid' virtual IP identifier field only is only eight bits, providing up to 255 different virtual IPs on the same multicast group IP. For larger deployments, and more flexibility in allocation, ucarp can optionally use a different multicast IP. By default, ucarp will send/listen on 224.0.0.18, which is the assigned IP for VRRP. If you want to use a different address, use the '--mcast' option. Consult the available multicast addresses before deciding which to use. http://www.iana.org/assignments/multicast-addresses/multicast-addresses.xml http://tools.ietf.org/html/rfc5771 http://tools.ietf.org/html/rfc2365 Addresses within 239.192.0.0/14 should be most appropriate. If ucarp isn't working on a different IP, check that your networking gear is set up to handle it. tcpdump on each host can be handy for diagnosis: tcpdump -n 'net 224.0.0.0/4' ------------------------ MASTER ELECTION PROCESS ------------------------ When ucarp first runs, it starts as a backup and listens to the network to determine if it should become the master. If at any time more than three times the node's advertising interval (defined as the advertising base (seconds) plus a fudge factor, the advertising skew) passes without hearing a peer's CARP advertisement, the node will transition itself to being a master. Transitioning from backup to master means: 1. running the specified up script to assign the vip to the local system 2. sending a gratuitous arp to the network to claim the vip 3. continuously sending CARP advertisements to the network every interval. Transitioning from master to backup means: 1. running the specified down script to remove the vip from the local system To understand how ucarp works, it's important to note that the advertisement interval is not only used as the time in between which each CARP advertisement is sent by the master, but also as a priority mechanism where shorter (i.e. more frequent) is better. The interval base and skew values are stored in the CARP advertisement and are used by other nodes to make certain decisions. By default, once a node becomes the master, it will continue on indefinitely as the master. If you like/want/need this behavior, or don't have a preferred master, then choose the same interval on all hosts. If for whatever reason you were to choose different intervals on the hosts, then over time the one with the shortest interval would tend to become the master as machines are rebooted, after failures, etc. Also of note is a conflict resolution algorithm that in case a master hears another, equal (in terms of its advertised interval) master, the one with the lower IP address will remain master and the other will immediately demote itself. This is simply to eliminate flapping and quickly determine who should remain master. This situation should not happen very often but it can. If you want a "preferred" master to always be the master (even if another host is already the master), add the preempt switch (--preempt or -P) and assign a shorter interval via the advertisement base (--advbase or -b) and skew (--advskew or -k). This will cause the preferred node to ignore a master who is advertising a longer interval and promote itself to master. The old master will quickly hear the preferred node advertising a shorter interval and immediately demote itself. In summary, a backup will become master if: - no one else advertises for 3 times its own advertisement interval - you specified --preempt and it hears a master with a longer interval and a master will become backup if: - another master advertises a shorter interval - another master advertises the same interval, and has a lower IP address ------------------------ OTHER NOTES ------------------------ Specify the --neutral (-n) switch for ucarp to not run the downscript at startup. --shutdown (-z) will run the downscript at exit, unless ucarp is already in the backup state. The "dead ratio" (--deadratio=...) knob basically changes how long a backup server will wait for an unresponsive master before considering it as dead, and becoming the new master. In the original protocol, the ratio is 3. This is also the default when this command-line switch is missing. Notices are sent both to stderr/stdout and to the syslog daemon (with the "daemon" facility) by default. stderr/stdout are bypassed if the daemon is started in background (--daemonize). Facilities can be changed with the --syslog switch. Use --syslog=none to disable syslog logging, for instance if prefer using something like multilog. You can send the ucarp process a SIGUSR1 to have it log a status line to syslog, like: Jan 7 17:38:22 localhost ucarp[6103]: [INFO] BACKUP on eth0 id 198 You can send the ucarp process a SIGUSR2 to have it demote itself from master to backup, pause 3 seconds, then proceed as usual to listen for other masters and promote itself if necessary. This could be useful if you wish another node to take over master. --ignoreifstate (-S) option tells ucarp to ignore unplugged network cable. It is useful when you connect ucarp nodes with a crossover patch cord (not via a hub or a switch). Without this option the node in MASTER state will switch to BACKUP state when the other node is powered down, because network interface shows that cable is unplugged (NO-CARRIER). Some network interface drivers don't support NO-CARRIER feature, and this option is not needed for these network cards. The card that definitely supports this feature is Realtek 8139. ------------------------ TRANSLATIONS ------------------------ UCARP can speak your native language through gettext / libintl. If you want to translate the software, have a look at the po/ directory. Copy the ucarp.pot file to .po and use software like Kbabel or Emacs to update the file. Better use use your local charset than UTF-8. ucarp-1.5.2+git20192404.1a9aaf7/m4/0000755000175000017500000000000013460025251015600 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/m4/wint_t.m40000644000175000017500000000170713460025251017353 0ustar gxaviergxavier# wint_t.m4 serial 2 (gettext-0.17) dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Test whether has the 'wint_t' type. dnl Prerequisite: AC_PROG_CC AC_DEFUN([gt_TYPE_WINT_T], [ AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, [AC_TRY_COMPILE([ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include wint_t foo = (wchar_t)'\0';], , gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) if test $gt_cv_c_wint_t = yes; then AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/intmax.m40000644000175000017500000000201113460025251017334 0ustar gxaviergxavier# intmax.m4 serial 3 (gettext-0.16) dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Test whether the system has the 'intmax_t' type, but don't attempt to dnl find a replacement if it is lacking. AC_DEFUN([gt_TYPE_INTMAX_T], [ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gl_AC_HEADER_STDINT_H]) AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, [AC_TRY_COMPILE([ #include #include #if HAVE_STDINT_H_WITH_UINTMAX #include #endif #if HAVE_INTTYPES_H_WITH_UINTMAX #include #endif ], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) if test $gt_cv_c_intmax_t = yes; then AC_DEFINE(HAVE_INTMAX_T, 1, [Define if you have the 'intmax_t' type in or .]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/nls.m40000644000175000017500000000226613460025251016644 0ustar gxaviergxavier# nls.m4 serial 3 (gettext-0.15) dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ(2.50) AC_DEFUN([AM_NLS], [ AC_MSG_CHECKING([whether NLS is requested]) dnl Default is enabled NLS AC_ARG_ENABLE(nls, [ --disable-nls do not use Native Language Support], USE_NLS=$enableval, USE_NLS=yes) AC_MSG_RESULT($USE_NLS) AC_SUBST(USE_NLS) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/intldir.m40000644000175000017500000000161613460025251017513 0ustar gxaviergxavier# intldir.m4 serial 1 (gettext-0.16) dnl Copyright (C) 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. AC_PREREQ(2.52) dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) ucarp-1.5.2+git20192404.1a9aaf7/m4/lock.m40000644000175000017500000003022313460025251016772 0ustar gxaviergxavier# lock.m4 serial 7 (gettext-0.17) dnl Copyright (C) 2005-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Tests for a multithreading library to be used. dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, dnl USE_PTH_THREADS, USE_WIN32_THREADS dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with dnl libtool). dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for dnl programs that really need multithread functionality. The difference dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for dnl multithread-safe programs. AC_DEFUN([gl_LOCK_EARLY], [ AC_REQUIRE([gl_LOCK_EARLY_BODY]) ]) dnl The guts of gl_LOCK_EARLY. Needs to be expanded only once. AC_DEFUN([gl_LOCK_EARLY_BODY], [ dnl Ordering constraints: This macro modifies CPPFLAGS in a way that dnl influences the result of the autoconf tests that test for *_unlocked dnl declarations, on AIX 5 at least. Therefore it must come early. AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl AC_BEFORE([$0], [gl_ARGP])dnl AC_REQUIRE([AC_CANONICAL_HOST]) dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes dnl AC_GNU_SOURCE. m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], [AC_REQUIRE([AC_GNU_SOURCE])]) dnl Check for multithreading. AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) AC_HELP_STRING([--disable-threads], [build without multithread safety]), [gl_use_threads=$enableval], [case "$host_os" in dnl Disable multithreading by default on OSF/1, because it interferes dnl with fork()/exec(): When msgexec is linked with -lpthread, its child dnl process gets an endless segmentation fault inside execvp(). osf*) gl_use_threads=no ;; *) gl_use_threads=yes ;; esac ]) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then # For using : case "$host_os" in osf*) # On OSF/1, the compiler needs the flag -D_REENTRANT so that it # groks . cc also understands the flag -pthread, but # we don't use it because 1. gcc-2.95 doesn't understand -pthread, # 2. putting a flag into CPPFLAGS that has an effect on the linker # causes the AC_TRY_LINK test below to succeed unexpectedly, # leading to wrong values of LIBTHREAD and LTLIBTHREAD. CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; esac # Some systems optimize for single-threaded programs by default, and # need special flags to disable these optimizations. For example, the # definition of 'errno' in . case "$host_os" in aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; esac fi ]) dnl The guts of gl_LOCK. Needs to be expanded only once. AC_DEFUN([gl_LOCK_BODY], [ AC_REQUIRE([gl_LOCK_EARLY_BODY]) gl_threads_api=none LIBTHREAD= LTLIBTHREAD= LIBMULTITHREAD= LTLIBMULTITHREAD= if test "$gl_use_threads" != no; then dnl Check whether the compiler and linker support weak declarations. AC_MSG_CHECKING([whether imported symbols can be declared weak]) gl_have_weak=no AC_TRY_LINK([extern void xyzzy (); #pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) AC_MSG_RESULT([$gl_have_weak]) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that # it groks . It's added above, in gl_LOCK_EARLY_BODY. AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no) if test "$gl_have_pthread_h" = yes; then # Other possible tests: # -lpthreads (FSU threads, PCthreads) # -lgthreads gl_have_pthread= # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist # in libc. IRIX 6.5 has the first one in both libc and libpthread, but # the second one only in libpthread, and lock.c needs it. AC_TRY_LINK([#include ], [pthread_mutex_lock((pthread_mutex_t*)0); pthread_mutexattr_init((pthread_mutexattr_t*)0);], [gl_have_pthread=yes]) # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) if test -n "$gl_have_pthread"; then # The program links fine without libpthread. But it may actually # need to link with libpthread in order to create multiple threads. AC_CHECK_LIB(pthread, pthread_kill, [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread # On Solaris and HP-UX, most pthread functions exist also in libc. # Therefore pthread_in_use() needs to actually try to create a # thread: pthread_create from libc will fail, whereas # pthread_create will actually create a thread. case "$host_os" in solaris* | hpux*) AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1, [Define if the pthread_in_use() detection is hard.]) esac ]) else # Some library is needed. Try libpthread and libc_r. AC_CHECK_LIB(pthread, pthread_kill, [gl_have_pthread=yes LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) if test -z "$gl_have_pthread"; then # For FreeBSD 4. AC_CHECK_LIB(c_r, pthread_kill, [gl_have_pthread=yes LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) fi fi if test -n "$gl_have_pthread"; then gl_threads_api=posix AC_DEFINE([USE_POSIX_THREADS], 1, [Define if the POSIX multithreading library can be used.]) if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then if test $gl_have_weak = yes; then AC_DEFINE([USE_POSIX_THREADS_WEAK], 1, [Define if references to the POSIX multithreading library should be made weak.]) LIBTHREAD= LTLIBTHREAD= fi fi # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the # pthread_rwlock_* functions. AC_CHECK_TYPE([pthread_rwlock_t], [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1, [Define if the POSIX multithreading library has read/write locks.])], [], [#include ]) # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. AC_TRY_COMPILE([#include ], [#if __FreeBSD__ == 4 error "No, in FreeBSD 4.0 recursive mutexes actually don't work." #else int x = (int)PTHREAD_MUTEX_RECURSIVE; return !x; #endif], [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1, [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) fi fi fi if test -z "$gl_have_pthread"; then if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then gl_have_solaristhread= gl_save_LIBS="$LIBS" LIBS="$LIBS -lthread" AC_TRY_LINK([#include #include ], [thr_self();], [gl_have_solaristhread=yes]) LIBS="$gl_save_LIBS" if test -n "$gl_have_solaristhread"; then gl_threads_api=solaris LIBTHREAD=-lthread LTLIBTHREAD=-lthread LIBMULTITHREAD="$LIBTHREAD" LTLIBMULTITHREAD="$LTLIBTHREAD" AC_DEFINE([USE_SOLARIS_THREADS], 1, [Define if the old Solaris multithreading library can be used.]) if test $gl_have_weak = yes; then AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1, [Define if references to the old Solaris multithreading library should be made weak.]) LIBTHREAD= LTLIBTHREAD= fi fi fi fi if test "$gl_use_threads" = pth; then gl_save_CPPFLAGS="$CPPFLAGS" AC_LIB_LINKFLAGS(pth) gl_have_pth= gl_save_LIBS="$LIBS" LIBS="$LIBS -lpth" AC_TRY_LINK([#include ], [pth_self();], gl_have_pth=yes) LIBS="$gl_save_LIBS" if test -n "$gl_have_pth"; then gl_threads_api=pth LIBTHREAD="$LIBPTH" LTLIBTHREAD="$LTLIBPTH" LIBMULTITHREAD="$LIBTHREAD" LTLIBMULTITHREAD="$LTLIBTHREAD" AC_DEFINE([USE_PTH_THREADS], 1, [Define if the GNU Pth multithreading library can be used.]) if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then if test $gl_have_weak = yes; then AC_DEFINE([USE_PTH_THREADS_WEAK], 1, [Define if references to the GNU Pth multithreading library should be made weak.]) LIBTHREAD= LTLIBTHREAD= fi fi else CPPFLAGS="$gl_save_CPPFLAGS" fi fi if test -z "$gl_have_pthread"; then if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then if { case "$host_os" in mingw*) true;; *) false;; esac }; then gl_threads_api=win32 AC_DEFINE([USE_WIN32_THREADS], 1, [Define if the Win32 multithreading API can be used.]) fi fi fi fi AC_MSG_CHECKING([for multithread API to use]) AC_MSG_RESULT([$gl_threads_api]) AC_SUBST(LIBTHREAD) AC_SUBST(LTLIBTHREAD) AC_SUBST(LIBMULTITHREAD) AC_SUBST(LTLIBMULTITHREAD) ]) AC_DEFUN([gl_LOCK], [ AC_REQUIRE([gl_LOCK_EARLY]) AC_REQUIRE([gl_LOCK_BODY]) gl_PREREQ_LOCK ]) # Prerequisites of lib/lock.c. AC_DEFUN([gl_PREREQ_LOCK], [ AC_REQUIRE([AC_C_INLINE]) ]) dnl Survey of platforms: dnl dnl Platform Available Compiler Supports test-lock dnl flavours option weak result dnl --------------- --------- --------- -------- --------- dnl Linux 2.4/glibc posix -lpthread Y OK dnl dnl GNU Hurd/glibc posix dnl dnl FreeBSD 5.3 posix -lc_r Y dnl posix -lkse ? Y dnl posix -lpthread ? Y dnl posix -lthr Y dnl dnl FreeBSD 5.2 posix -lc_r Y dnl posix -lkse Y dnl posix -lthr Y dnl dnl FreeBSD 4.0,4.10 posix -lc_r Y OK dnl dnl NetBSD 1.6 -- dnl dnl OpenBSD 3.4 posix -lpthread Y OK dnl dnl MacOS X 10.[123] posix -lpthread Y OK dnl dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK dnl dnl HP-UX 11 posix -lpthread N (cc) OK dnl Y (gcc) dnl dnl IRIX 6.5 posix -lpthread Y 0.5 dnl dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK dnl dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK dnl -lpthread (gcc) Y dnl dnl Cygwin posix -lpthread Y OK dnl dnl Any of the above pth -lpth 0.0 dnl dnl Mingw win32 N OK dnl dnl BeOS 5 -- dnl dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is dnl turned off: dnl OK if all three tests terminate OK, dnl 0.5 if the first test terminates OK but the second one loops endlessly, dnl 0.0 if the first test already loops endlessly. ucarp-1.5.2+git20192404.1a9aaf7/m4/Makefile.am0000644000175000017500000000015613460025251017636 0ustar gxaviergxavierEXTRA_DIST = \ gettext.m4 \ iconv.m4 \ lib-ld.m4 \ lib-link.m4 \ lib-prefix.m4 \ nls.m4 \ po.m4 \ progtest.m4 ucarp-1.5.2+git20192404.1a9aaf7/m4/size_max.m40000644000175000017500000000513313460025251017663 0ustar gxaviergxavier# size_max.m4 serial 6 dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([gl_SIZE_MAX], [ AC_CHECK_HEADERS(stdint.h) dnl First test whether the system already has SIZE_MAX. AC_MSG_CHECKING([for SIZE_MAX]) AC_CACHE_VAL([gl_cv_size_max], [ gl_cv_size_max= AC_EGREP_CPP([Found it], [ #include #if HAVE_STDINT_H #include #endif #ifdef SIZE_MAX Found it #endif ], gl_cv_size_max=yes) if test -z "$gl_cv_size_max"; then dnl Define it ourselves. Here we assume that the type 'size_t' is not wider dnl than the type 'unsigned long'. Try hard to find a definition that can dnl be used in a preprocessor #if, i.e. doesn't contain a cast. AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1], [#include #include ], size_t_bits_minus_1=) AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)], [#include ], fits_in_uint=) if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then if test $fits_in_uint = 1; then dnl Even though SIZE_MAX fits in an unsigned int, it must be of type dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. AC_TRY_COMPILE([#include extern size_t foo; extern unsigned long foo; ], [], fits_in_uint=0) fi dnl We cannot use 'expr' to simplify this expression, because 'expr' dnl works only with 'long' integers in the host environment, while we dnl might be cross-compiling from a 32-bit platform to a 64-bit platform. if test $fits_in_uint = 1; then gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" else gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" fi else dnl Shouldn't happen, but who knows... gl_cv_size_max='((size_t)~(size_t)0)' fi fi ]) AC_MSG_RESULT([$gl_cv_size_max]) if test "$gl_cv_size_max" != yes; then AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max], [Define as the maximum value of type 'size_t', if the system doesn't define it.]) fi ]) dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. dnl Remove this when we can assume autoconf >= 2.61. m4_ifdef([AC_COMPUTE_INT], [], [ AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/codeset.m40000644000175000017500000000136613460025251017476 0ustar gxaviergxavier# codeset.m4 serial 2 (gettext-0.16) dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([AM_LANGINFO_CODESET], [ AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, [AC_TRY_LINK([#include ], [char* cs = nl_langinfo(CODESET); return !cs;], am_cv_langinfo_codeset=yes, am_cv_langinfo_codeset=no) ]) if test $am_cv_langinfo_codeset = yes; then AC_DEFINE(HAVE_LANGINFO_CODESET, 1, [Define if you have and nl_langinfo(CODESET).]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/lcmessage.m40000644000175000017500000000240413460025251020005 0ustar gxaviergxavier# lcmessage.m4 serial 4 (gettext-0.14.2) dnl Copyright (C) 1995-2002, 2004-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995. # Check whether LC_MESSAGES is available in . AC_DEFUN([gt_LC_MESSAGES], [ AC_CACHE_CHECK([for LC_MESSAGES], gt_cv_val_LC_MESSAGES, [AC_TRY_LINK([#include ], [return LC_MESSAGES], gt_cv_val_LC_MESSAGES=yes, gt_cv_val_LC_MESSAGES=no)]) if test $gt_cv_val_LC_MESSAGES = yes; then AC_DEFINE(HAVE_LC_MESSAGES, 1, [Define if your file defines LC_MESSAGES.]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/longlong.m40000644000175000017500000001005413460025251017661 0ustar gxaviergxavier# longlong.m4 serial 13 dnl Copyright (C) 1999-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. # Define HAVE_LONG_LONG_INT if 'long long int' works. # This fixes a bug in Autoconf 2.61, but can be removed once we # assume 2.62 everywhere. # Note: If the type 'long long int' exists but is only 32 bits large # (as on some very old compilers), HAVE_LONG_LONG_INT will not be # defined. In this case you can treat 'long long int' like 'long int'. AC_DEFUN([AC_TYPE_LONG_LONG_INT], [ AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], [AC_LINK_IFELSE( [_AC_TYPE_LONG_LONG_SNIPPET], [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. dnl If cross compiling, assume the bug isn't important, since dnl nobody cross compiles for this platform as far as we know. AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[@%:@include @%:@ifndef LLONG_MAX @%:@ define HALF \ (1LL << (sizeof (long long int) * CHAR_BIT - 2)) @%:@ define LLONG_MAX (HALF - 1 + HALF) @%:@endif]], [[long long int n = 1; int i; for (i = 0; ; i++) { long long int m = n << i; if (m >> i != n) return 1; if (LLONG_MAX / 2 < m) break; } return 0;]])], [ac_cv_type_long_long_int=yes], [ac_cv_type_long_long_int=no], [ac_cv_type_long_long_int=yes])], [ac_cv_type_long_long_int=no])]) if test $ac_cv_type_long_long_int = yes; then AC_DEFINE([HAVE_LONG_LONG_INT], 1, [Define to 1 if the system has the type `long long int'.]) fi ]) # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. # This fixes a bug in Autoconf 2.61, but can be removed once we # assume 2.62 everywhere. # Note: If the type 'unsigned long long int' exists but is only 32 bits # large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT # will not be defined. In this case you can treat 'unsigned long long int' # like 'unsigned long int'. AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], [ AC_CACHE_CHECK([for unsigned long long int], [ac_cv_type_unsigned_long_long_int], [AC_LINK_IFELSE( [_AC_TYPE_LONG_LONG_SNIPPET], [ac_cv_type_unsigned_long_long_int=yes], [ac_cv_type_unsigned_long_long_int=no])]) if test $ac_cv_type_unsigned_long_long_int = yes; then AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1, [Define to 1 if the system has the type `unsigned long long int'.]) fi ]) # Expands to a C program that can be used to test for simultaneous support # of 'long long' and 'unsigned long long'. We don't want to say that # 'long long' is available if 'unsigned long long' is not, or vice versa, # because too many programs rely on the symmetry between signed and unsigned # integer types (excluding 'bool'). AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], [ AC_LANG_PROGRAM( [[/* Test preprocessor. */ #if ! (-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) error in preprocessor; #endif #if ! (18446744073709551615ULL <= -1ull) error in preprocessor; #endif /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 ? 1 : -1)]; int i = 63;]], [[/* Test availability of runtime routines for shift and division. */ long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) | (llmax / ll) | (llmax % ll) | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) | (ullmax / ull) | (ullmax % ull));]]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/lib-ld.m40000644000175000017500000000653113460025251017212 0ustar gxaviergxavier# lib-ld.m4 serial 3 (gettext-0.13) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/xsize.m40000644000175000017500000000064513460025251017211 0ustar gxaviergxavier# xsize.m4 serial 3 dnl Copyright (C) 2003-2004 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_XSIZE], [ dnl Prerequisites of lib/xsize.h. AC_REQUIRE([gl_SIZE_MAX]) AC_REQUIRE([AC_C_INLINE]) AC_CHECK_HEADERS(stdint.h) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/po.m40000644000175000017500000004460613460025251016472 0ustar gxaviergxavier# po.m4 serial 15 (gettext-0.17) dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ(2.50) dnl Checks for all prerequisites of the po subdirectory. AC_DEFUN([AM_PO_SUBDIRS], [ AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake AC_REQUIRE([AM_NLS])dnl dnl Release version of the gettext macros. This is used to ensure that dnl the gettext macros and po/Makefile.in.in are in sync. AC_SUBST([GETTEXT_MACRO_VERSION], [0.17]) dnl Perform the following tests also if --disable-nls has been given, dnl because they are needed for "make dist" to work. dnl Search for GNU msgfmt in the PATH. dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. dnl The second test excludes FreeBSD msgfmt. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) dnl Test whether it is GNU msgfmt >= 0.15. changequote(,)dnl case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; *) MSGFMT_015=$MSGFMT ;; esac changequote([,])dnl AC_SUBST([MSGFMT_015]) changequote(,)dnl case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac changequote([,])dnl AC_SUBST([GMSGFMT_015]) dnl Search for GNU xgettext 0.12 or newer in the PATH. dnl The first test excludes Solaris xgettext and early GNU xgettext versions. dnl The second test excludes FreeBSD xgettext. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) dnl Remove leftover from FreeBSD xgettext call. rm -f messages.po dnl Test whether it is GNU xgettext >= 0.15. changequote(,)dnl case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; *) XGETTEXT_015=$XGETTEXT ;; esac changequote([,])dnl AC_SUBST([XGETTEXT_015]) dnl Search for GNU msgmerge 0.11 or newer in the PATH. AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) dnl Installation directories. dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we dnl have to define it here, so that it can be used in po/Makefile. test -n "$localedir" || localedir='${datadir}/locale' AC_SUBST([localedir]) dnl Support for AM_XGETTEXT_OPTION. test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) AC_CONFIG_COMMANDS([po-directories], [[ for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" case "$ac_file" in *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; esac # PO directories have a Makefile.in generated from Makefile.in.in. case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Treat a directory as a PO directory if and only if it has a # POTFILES.in file. This allows packages to have multiple PO # directories under different names or in different locations. if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration # parameters. if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then # The LINGUAS file contains the set of available languages. if test -n "$OBSOLETE_ALL_LINGUAS"; then test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) # Compute UPDATEPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) # Compute DUMMYPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) # Compute GMOFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) case "$ac_given_srcdir" in .) srcdirpre= ;; *) srcdirpre='$(srcdir)/' ;; esac POFILES= UPDATEPOFILES= DUMMYPOFILES= GMOFILES= for lang in $ALL_LINGUAS; do POFILES="$POFILES $srcdirpre$lang.po" UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" DUMMYPOFILES="$DUMMYPOFILES $lang.nop" GMOFILES="$GMOFILES $srcdirpre$lang.gmo" done # CATALOGS depends on both $ac_dir and the user's LINGUAS # environment variable. INST_LINGUAS= if test -n "$ALL_LINGUAS"; then for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "$LINGUAS"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then INST_LINGUAS="$INST_LINGUAS $presentlang" fi done fi CATALOGS= if test -n "$INST_LINGUAS"; then for lang in $INST_LINGUAS; do CATALOGS="$CATALOGS $lang.gmo" done fi test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do if test -f "$f"; then case "$f" in *.orig | *.bak | *~) ;; *) cat "$f" >> "$ac_dir/Makefile" ;; esac fi done fi ;; esac done]], [# Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it # from automake < 1.5. eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" ]) ]) dnl Postprocesses a Makefile in a directory containing PO files. AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], [ # When this code is run, in config.status, two variables have already been # set: # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, # - LINGUAS is the value of the environment variable LINGUAS at configure # time. changequote(,)dnl # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Find a way to echo strings without interpreting backslash. if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then gt_echo='echo' else if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then gt_echo='printf %s\n' else echo_func () { cat < "$ac_file.tmp" if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` cat >> "$ac_file.tmp" < /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` cat >> "$ac_file.tmp" <> "$ac_file.tmp" </dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/iconv.m40000644000175000017500000001375313460025251017171 0ustar gxaviergxavier# iconv.m4 serial AM6 (gettext-0.17) dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_func_iconv=yes) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_lib_iconv=yes am_cv_func_iconv=yes) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [ dnl This tests against bugs in AIX 5.1 and HP-UX 11.11. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi AC_TRY_RUN([ #include #include int main () { /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static const char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) return 1; } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) return 1; return 0; }], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], [case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac]) LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST(LIBICONV) AC_SUBST(LTLIBICONV) ]) AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL(am_cv_proto_iconv, [ AC_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([$]{ac_t:- }[$]am_cv_proto_iconv) AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/printf-posix.m40000644000175000017500000000271113460025251020505 0ustar gxaviergxavier# printf-posix.m4 serial 3 (gettext-0.17) dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Test whether the printf() function supports POSIX/XSI format strings with dnl positions. AC_DEFUN([gt_PRINTF_POSIX], [ AC_REQUIRE([AC_PROG_CC]) AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], gt_cv_func_printf_posix, [ AC_TRY_RUN([ #include #include /* The string "%2$d %1$d", with dollar characters protected from the shell's dollar expansion (possibly an autoconf bug). */ static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; static char buf[100]; int main () { sprintf (buf, format, 33, 55); return (strcmp (buf, "55 33") != 0); }], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, [ AC_EGREP_CPP(notposix, [ #if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ notposix #endif ], gt_cv_func_printf_posix="guessing no", gt_cv_func_printf_posix="guessing yes") ]) ]) case $gt_cv_func_printf_posix in *yes) AC_DEFINE(HAVE_POSIX_PRINTF, 1, [Define if your printf() function supports format strings with positions.]) ;; esac ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/gettext.m40000644000175000017500000003457013460025251017537 0ustar gxaviergxavier# gettext.m4 serial 60 (gettext-0.17) dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2006. dnl Macro to add for using GNU gettext. dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The dnl default (if it is not specified or empty) is 'no-libtool'. dnl INTLSYMBOL should be 'external' for packages with no intl directory, dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. dnl If INTLSYMBOL is 'use-libtool', then a libtool library dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, dnl depending on --{enable,disable}-{shared,static} and on the presence of dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library dnl $(top_builddir)/intl/libintl.a will be created. dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext dnl implementations (in libc or libintl) without the ngettext() function dnl will be ignored. If NEEDSYMBOL is specified and is dnl 'need-formatstring-macros', then GNU gettext implementations that don't dnl support the ISO C 99 formatstring macros will be ignored. dnl INTLDIR is used to find the intl libraries. If empty, dnl the value `$(top_builddir)/intl/' is used. dnl dnl The result of the configuration is one of three cases: dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled dnl and used. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 2) GNU gettext has been found in the system's C library. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 3) No internationalization, always use English msgid. dnl Catalog format: none dnl Catalog extension: none dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. dnl The use of .gmo is historical (it was needed to avoid overwriting the dnl GNU format catalogs when building on a platform with an X/Open gettext), dnl but we keep it in order not to force irrelevant filename changes on the dnl maintainers. dnl AC_DEFUN([AM_GNU_GETTEXT], [ dnl Argument checking. ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT ])])])])]) ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT ])])])]) define([gt_included_intl], ifelse([$1], [external], ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), [yes])) define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) gt_NEEDS_INIT AM_GNU_GETTEXT_NEED([$2]) AC_REQUIRE([AM_PO_SUBDIRS])dnl ifelse(gt_included_intl, yes, [ AC_REQUIRE([AM_INTL_SUBDIR])dnl ]) dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Sometimes libintl requires libiconv, so first search for libiconv. dnl Ideally we would do this search only after the dnl if test "$USE_NLS" = "yes"; then dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT dnl the configure script would need to contain the same shell code dnl again, outside any 'if'. There are two solutions: dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not dnl documented, we avoid it. ifelse(gt_included_intl, yes, , [ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ]) dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. gt_INTL_MACOSX dnl Set USE_NLS. AC_REQUIRE([AM_NLS]) ifelse(gt_included_intl, yes, [ BUILD_INCLUDED_LIBINTL=no USE_INCLUDED_LIBINTL=no ]) LIBINTL= LTLIBINTL= POSUB= dnl Add a version number to the cache macros. case " $gt_needs " in *" need-formatstring-macros "*) gt_api_version=3 ;; *" need-ngettext "*) gt_api_version=2 ;; *) gt_api_version=1 ;; esac gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" dnl If we use NLS figure out what method if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no ifelse(gt_included_intl, yes, [ AC_MSG_CHECKING([whether included gettext is requested]) AC_ARG_WITH(included-gettext, [ --with-included-gettext use the GNU gettext library included here], nls_cv_force_use_gnu_gettext=$withval, nls_cv_force_use_gnu_gettext=no) AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" if test "$nls_cv_force_use_gnu_gettext" != "yes"; then ]) dnl User does not insist on using GNU NLS library. Figure out what dnl to use. If GNU gettext is available we use this. Else we have dnl to fall back to GNU NLS library. if test $gt_api_version -ge 3; then gt_revision_test_code=' #ifndef __GNU_GETTEXT_SUPPORTED_REVISION #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) #endif changequote(,)dnl typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; changequote([,])dnl ' else gt_revision_test_code= fi if test $gt_api_version -ge 2; then gt_expression_test_code=' + * ngettext ("", "", 0)' else gt_expression_test_code= fi AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], [AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern int *_nl_domain_bindings;], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], [eval "$gt_func_gnugettext_libc=yes"], [eval "$gt_func_gnugettext_libc=no"])]) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl Sometimes libintl requires libiconv, so first search for libiconv. ifelse(gt_included_intl, yes, , [ AM_ICONV_LINK ]) dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) dnl because that would add "-liconv" to LIBINTL and LTLIBINTL dnl even if libiconv doesn't exist. AC_LIB_LINKFLAGS_BODY([intl]) AC_CACHE_CHECK([for GNU gettext in libintl], [$gt_func_gnugettext_libintl], [gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" dnl Now see whether libintl exists and does not depend on libiconv. AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *);], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], [eval "$gt_func_gnugettext_libintl=yes"], [eval "$gt_func_gnugettext_libintl=no"]) dnl Now see whether libintl exists and depends on libiconv. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *);], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], [LIBINTL="$LIBINTL $LIBICONV" LTLIBINTL="$LTLIBINTL $LTLIBICONV" eval "$gt_func_gnugettext_libintl=yes" ]) fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) fi dnl If an already present or preinstalled GNU gettext() is found, dnl use it. But if this macro is used in GNU gettext, and GNU dnl gettext is already preinstalled in libintl, we update this dnl libintl. (Cf. the install rule in intl/Makefile.in.) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ && test "$PACKAGE" != gettext-runtime \ && test "$PACKAGE" != gettext-tools; }; then gt_use_preinstalled_gnugettext=yes else dnl Reset the values set by searching for libintl. LIBINTL= LTLIBINTL= INCINTL= fi ifelse(gt_included_intl, yes, [ if test "$gt_use_preinstalled_gnugettext" != "yes"; then dnl GNU gettext is not found in the C library. dnl Fall back on included GNU gettext library. nls_cv_use_gnu_gettext=yes fi fi if test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions used to generate GNU NLS library. BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi CATOBJEXT= if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions to use GNU gettext tools. CATOBJEXT=.gmo fi ]) if test -n "$INTL_MACOSX_LIBS"; then if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Some extra flags are needed during linking. LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" fi fi if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.]) else USE_NLS=no fi fi AC_MSG_CHECKING([whether to use NLS]) AC_MSG_RESULT([$USE_NLS]) if test "$USE_NLS" = "yes"; then AC_MSG_CHECKING([where the gettext function comes from]) if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then gt_source="external libintl" else gt_source="libc" fi else gt_source="included intl directory" fi AC_MSG_RESULT([$gt_source]) fi if test "$USE_NLS" = "yes"; then if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then AC_MSG_CHECKING([how to link with libintl]) AC_MSG_RESULT([$LIBINTL]) AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) fi dnl For backward compatibility. Some packages may be using this. AC_DEFINE(HAVE_GETTEXT, 1, [Define if the GNU gettext() function is already present or preinstalled.]) AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if the GNU dcgettext() function is already present or preinstalled.]) fi dnl We need to process the po/ directory. POSUB=po fi ifelse(gt_included_intl, yes, [ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL dnl to 'yes' because some of the testsuite requires it. if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then BUILD_INCLUDED_LIBINTL=yes fi dnl Make all variables we use known to autoconf. AC_SUBST(BUILD_INCLUDED_LIBINTL) AC_SUBST(USE_INCLUDED_LIBINTL) AC_SUBST(CATOBJEXT) dnl For backward compatibility. Some configure.ins may be using this. nls_cv_header_intl= nls_cv_header_libgt= dnl For backward compatibility. Some Makefiles may be using this. DATADIRNAME=share AC_SUBST(DATADIRNAME) dnl For backward compatibility. Some Makefiles may be using this. INSTOBJEXT=.mo AC_SUBST(INSTOBJEXT) dnl For backward compatibility. Some Makefiles may be using this. GENCAT=gencat AC_SUBST(GENCAT) dnl For backward compatibility. Some Makefiles may be using this. INTLOBJS= if test "$USE_INCLUDED_LIBINTL" = yes; then INTLOBJS="\$(GETTOBJS)" fi AC_SUBST(INTLOBJS) dnl Enable libtool support if the surrounding package wishes it. INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) ]) dnl For backward compatibility. Some Makefiles may be using this. INTLLIBS="$LIBINTL" AC_SUBST(INTLLIBS) dnl Make all documented variables known to autoconf. AC_SUBST(LIBINTL) AC_SUBST(LTLIBINTL) AC_SUBST(POSUB) ]) dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. m4_define([gt_NEEDS_INIT], [ m4_divert_text([DEFAULTS], [gt_needs=]) m4_define([gt_NEEDS_INIT], []) ]) dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) AC_DEFUN([AM_GNU_GETTEXT_NEED], [ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) ]) dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) ucarp-1.5.2+git20192404.1a9aaf7/m4/progtest.m40000644000175000017500000000555013460025251017716 0ustar gxaviergxavier# progtest.m4 serial 4 (gettext-0.14.2) dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1996. AC_PREREQ(2.50) # Search path for a program which passes the given test. dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) AC_DEFUN([AM_PATH_PROG_WITH_TEST], [ # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) AC_CACHE_VAL(ac_cv_path_$1, [case "[$]$1" in [[\\/]]* | ?:[[\\/]]*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in ifelse([$5], , $PATH, [$5]); do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD if [$3]; then ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) fi AC_SUBST($1)dnl ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/stdint_h.m40000644000175000017500000000161413460025251017660 0ustar gxaviergxavier# stdint_h.m4 serial 6 dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. # Define HAVE_STDINT_H_WITH_UINTMAX if exists, # doesn't clash with , and declares uintmax_t. AC_DEFUN([gl_AC_HEADER_STDINT_H], [ AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, [AC_TRY_COMPILE( [#include #include ], [uintmax_t i = (uintmax_t) -1; return !i;], gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)]) if test $gl_cv_header_stdint_h = yes; then AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, [Define if exists, doesn't clash with , and declares uintmax_t. ]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/intlmacosx.m40000644000175000017500000000456513460025251020235 0ustar gxaviergxavier# intlmacosx.m4 serial 1 (gettext-0.17) dnl Copyright (C) 2004-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Checks for special options needed on MacOS X. dnl Defines INTL_MACOSX_LIBS. AC_DEFUN([gt_INTL_MACOSX], [ dnl Check for API introduced in MacOS X 10.2. AC_CACHE_CHECK([for CFPreferencesCopyAppValue], gt_cv_func_CFPreferencesCopyAppValue, [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" AC_TRY_LINK([#include ], [CFPreferencesCopyAppValue(NULL, NULL)], [gt_cv_func_CFPreferencesCopyAppValue=yes], [gt_cv_func_CFPreferencesCopyAppValue=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) fi dnl Check for API introduced in MacOS X 10.3. AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], [gt_cv_func_CFLocaleCopyCurrent=yes], [gt_cv_func_CFLocaleCopyCurrent=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFLocaleCopyCurrent = yes; then AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi AC_SUBST([INTL_MACOSX_LIBS]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/inttypes-pri.m40000644000175000017500000000215213460025251020511 0ustar gxaviergxavier# inttypes-pri.m4 serial 4 (gettext-0.16) dnl Copyright (C) 1997-2002, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_PREREQ(2.52) # Define PRI_MACROS_BROKEN if exists and defines the PRI* # macros to non-string values. This is the case on AIX 4.3.3. AC_DEFUN([gt_INTTYPES_PRI], [ AC_CHECK_HEADERS([inttypes.h]) if test $ac_cv_header_inttypes_h = yes; then AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], gt_cv_inttypes_pri_broken, [ AC_TRY_COMPILE([#include #ifdef PRId32 char *p = PRId32; #endif ], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) ]) fi if test "$gt_cv_inttypes_pri_broken" = yes; then AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, [Define if exists and defines unusable PRI* macros.]) PRI_MACROS_BROKEN=1 else PRI_MACROS_BROKEN=0 fi AC_SUBST([PRI_MACROS_BROKEN]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/intl.m40000644000175000017500000002525013460025251017014 0ustar gxaviergxavier# intl.m4 serial 8 (gettext-0.17) dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2006. AC_PREREQ(2.52) dnl Checks for all prerequisites of the intl subdirectory, dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. AC_DEFUN([AM_INTL_SUBDIR], [ AC_REQUIRE([AC_PROG_INSTALL])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([gt_GLIBC2])dnl AC_REQUIRE([AC_PROG_RANLIB])dnl AC_REQUIRE([gl_VISIBILITY])dnl AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl AC_REQUIRE([gt_TYPE_WCHAR_T])dnl AC_REQUIRE([gt_TYPE_WINT_T])dnl AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gt_TYPE_INTMAX_T]) AC_REQUIRE([gt_PRINTF_POSIX]) AC_REQUIRE([gl_GLIBC21])dnl AC_REQUIRE([gl_XSIZE])dnl AC_REQUIRE([gt_INTL_MACOSX])dnl AC_CHECK_TYPE([ptrdiff_t], , [AC_DEFINE([ptrdiff_t], [long], [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) ]) AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) AC_CHECK_FUNCS([asprintf fwprintf putenv setenv setlocale snprintf wcslen]) dnl Use the _snprintf function only if it is declared (because on NetBSD it dnl is defined as a weak alias of snprintf; we prefer to use the latter). gt_CHECK_DECL(_snprintf, [#include ]) gt_CHECK_DECL(_snwprintf, [#include ]) dnl Use the *_unlocked functions only if they are declared. dnl (because some of them were defined without being declared in Solaris dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built dnl on Solaris 2.5.1 to run on Solaris 2.6). dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. gt_CHECK_DECL(getc_unlocked, [#include ]) case $gt_cv_func_printf_posix in *yes) HAVE_POSIX_PRINTF=1 ;; *) HAVE_POSIX_PRINTF=0 ;; esac AC_SUBST([HAVE_POSIX_PRINTF]) if test "$ac_cv_func_asprintf" = yes; then HAVE_ASPRINTF=1 else HAVE_ASPRINTF=0 fi AC_SUBST([HAVE_ASPRINTF]) if test "$ac_cv_func_snprintf" = yes; then HAVE_SNPRINTF=1 else HAVE_SNPRINTF=0 fi AC_SUBST([HAVE_SNPRINTF]) if test "$ac_cv_func_wprintf" = yes; then HAVE_WPRINTF=1 else HAVE_WPRINTF=0 fi AC_SUBST([HAVE_WPRINTF]) AM_LANGINFO_CODESET gt_LC_MESSAGES dnl Compilation on mingw and Cygwin needs special Makefile rules, because dnl 1. when we install a shared library, we must arrange to export dnl auxiliary pointer variables for every exported variable, dnl 2. when we install a shared library and a static library simultaneously, dnl the include file specifies __declspec(dllimport) and therefore we dnl must arrange to define the auxiliary pointer variables for the dnl exported variables _also_ in the static library. if test "$enable_shared" = yes; then case "$host_os" in mingw* | cygwin*) is_woe32dll=yes ;; *) is_woe32dll=no ;; esac else is_woe32dll=no fi WOE32DLL=$is_woe32dll AC_SUBST([WOE32DLL]) dnl On mingw and Cygwin, we can activate special Makefile rules which add dnl version information to the shared libraries and executables. case "$host_os" in mingw* | cygwin*) is_woe32=yes ;; *) is_woe32=no ;; esac WOE32=$is_woe32 AC_SUBST([WOE32]) if test $WOE32 = yes; then dnl Check for a program that compiles Windows resource files. AC_CHECK_TOOL([WINDRES], [windres]) fi dnl Determine whether when creating a library, "-lc" should be passed to dnl libtool or not. On many platforms, it is required for the libtool option dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool dnl in the *.la files - makes it impossible to create multithreaded programs, dnl because libtool also reorders the -lc to come before the -pthread, and dnl this disables pthread_create() . case "$host_os" in hpux*) LTLIBC="" ;; *) LTLIBC="-lc" ;; esac AC_SUBST([LTLIBC]) dnl Rename some macros and functions used for locking. AH_BOTTOM([ #define __libc_lock_t gl_lock_t #define __libc_lock_define gl_lock_define #define __libc_lock_define_initialized gl_lock_define_initialized #define __libc_lock_init gl_lock_init #define __libc_lock_lock gl_lock_lock #define __libc_lock_unlock gl_lock_unlock #define __libc_lock_recursive_t gl_recursive_lock_t #define __libc_lock_define_recursive gl_recursive_lock_define #define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized #define __libc_lock_init_recursive gl_recursive_lock_init #define __libc_lock_lock_recursive gl_recursive_lock_lock #define __libc_lock_unlock_recursive gl_recursive_lock_unlock #define glthread_in_use libintl_thread_in_use #define glthread_lock_init libintl_lock_init #define glthread_lock_lock libintl_lock_lock #define glthread_lock_unlock libintl_lock_unlock #define glthread_lock_destroy libintl_lock_destroy #define glthread_rwlock_init libintl_rwlock_init #define glthread_rwlock_rdlock libintl_rwlock_rdlock #define glthread_rwlock_wrlock libintl_rwlock_wrlock #define glthread_rwlock_unlock libintl_rwlock_unlock #define glthread_rwlock_destroy libintl_rwlock_destroy #define glthread_recursive_lock_init libintl_recursive_lock_init #define glthread_recursive_lock_lock libintl_recursive_lock_lock #define glthread_recursive_lock_unlock libintl_recursive_lock_unlock #define glthread_recursive_lock_destroy libintl_recursive_lock_destroy #define glthread_once libintl_once #define glthread_once_call libintl_once_call #define glthread_once_singlethreaded libintl_once_singlethreaded ]) ]) dnl Checks for the core files of the intl subdirectory: dnl dcigettext.c dnl eval-plural.h dnl explodename.c dnl finddomain.c dnl gettextP.h dnl gmo.h dnl hash-string.h hash-string.c dnl l10nflist.c dnl libgnuintl.h.in (except the *printf stuff) dnl loadinfo.h dnl loadmsgcat.c dnl localealias.c dnl log.c dnl plural-exp.h plural-exp.c dnl plural.y dnl Used by libglocale. AC_DEFUN([gt_INTL_SUBDIR_CORE], [ AC_REQUIRE([AC_C_INLINE])dnl AC_REQUIRE([AC_TYPE_SIZE_T])dnl AC_REQUIRE([gl_AC_HEADER_STDINT_H]) AC_REQUIRE([AC_FUNC_ALLOCA])dnl AC_REQUIRE([AC_FUNC_MMAP])dnl AC_REQUIRE([gt_INTDIV0])dnl AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl AC_REQUIRE([gt_INTTYPES_PRI])dnl AC_REQUIRE([gl_LOCK])dnl AC_TRY_LINK( [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], [], [AC_DEFINE([HAVE_BUILTIN_EXPECT], 1, [Define to 1 if the compiler understands __builtin_expect.])]) AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \ argz_next __fsetlocking]) dnl Use the *_unlocked functions only if they are declared. dnl (because some of them were defined without being declared in Solaris dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built dnl on Solaris 2.5.1 to run on Solaris 2.6). dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. gt_CHECK_DECL(feof_unlocked, [#include ]) gt_CHECK_DECL(fgets_unlocked, [#include ]) AM_ICONV dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOURCE is defined, dnl and a _NL_LOCALE_NAME macro always. AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name, [AC_TRY_LINK([#include #include ], [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES)); return !cs; ], gt_cv_nl_locale_name=yes, gt_cv_nl_locale_name=no) ]) if test $gt_cv_nl_locale_name = yes; then AC_DEFINE(HAVE_NL_LOCALE_NAME, 1, [Define if you have and it defines the NL_LOCALE_NAME macro if _GNU_SOURCE is defined.]) fi dnl intl/plural.c is generated from intl/plural.y. It requires bison, dnl because plural.y uses bison specific features. It requires at least dnl bison-1.26 because earlier versions generate a plural.c that doesn't dnl compile. dnl bison is only needed for the maintainer (who touches plural.y). But in dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put dnl the rule in general Makefile. Now, some people carelessly touch the dnl files or have a broken "make" program, hence the plural.c rule will dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not dnl present or too old. AC_CHECK_PROGS([INTLBISON], [bison]) if test -z "$INTLBISON"; then ac_verc_fail=yes else dnl Found it, now check the version. AC_MSG_CHECKING([version of bison]) changequote(<<,>>)dnl ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` case $ac_prog_version in '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) changequote([,])dnl ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; esac AC_MSG_RESULT([$ac_prog_version]) fi if test $ac_verc_fail = yes; then INTLBISON=: fi ]) dnl gt_CHECK_DECL(FUNC, INCLUDES) dnl Check whether a function is declared. AC_DEFUN([gt_CHECK_DECL], [ AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, [AC_TRY_COMPILE([$2], [ #ifndef $1 char *p = (char *) $1; #endif ], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) if test $ac_cv_have_decl_$1 = yes; then gt_value=1 else gt_value=0 fi AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/glibc2.m40000644000175000017500000000135413460025251017207 0ustar gxaviergxavier# glibc2.m4 serial 1 dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. # Test for the GNU C Library, version 2.0 or newer. # From Bruno Haible. AC_DEFUN([gt_GLIBC2], [ AC_CACHE_CHECK(whether we are using the GNU C Library 2 or newer, ac_cv_gnu_library_2, [AC_EGREP_CPP([Lucky GNU user], [ #include #ifdef __GNU_LIBRARY__ #if (__GLIBC__ >= 2) Lucky GNU user #endif #endif ], ac_cv_gnu_library_2=yes, ac_cv_gnu_library_2=no) ] ) AC_SUBST(GLIBC2) GLIBC2="$ac_cv_gnu_library_2" ] ) ucarp-1.5.2+git20192404.1a9aaf7/m4/uintmax_t.m40000644000175000017500000000211213460025251020046 0ustar gxaviergxavier# uintmax_t.m4 serial 10 dnl Copyright (C) 1997-2004, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. AC_PREREQ(2.13) # Define uintmax_t to 'unsigned long' or 'unsigned long long' # if it is not already defined in or . AC_DEFUN([gl_AC_TYPE_UINTMAX_T], [ AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gl_AC_HEADER_STDINT_H]) if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) test $ac_cv_type_unsigned_long_long_int = yes \ && ac_type='unsigned long long' \ || ac_type='unsigned long' AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, [Define to unsigned long or unsigned long long if and don't define.]) else AC_DEFINE(HAVE_UINTMAX_T, 1, [Define if you have the 'uintmax_t' type in or .]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/lib-link.m40000644000175000017500000007205513460025251017554 0ustar gxaviergxavier# lib-link.m4 serial 13 (gettext-0.17) dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_PREREQ(2.54) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes undefine([Name]) undefine([NAME]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. If found, it dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" LIBS="$LIBS $LIB[]NAME" AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= LIB[]NAME[]_PREFIX= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) undefine([Name]) undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl acl_libext, dnl acl_shlibext, dnl acl_hardcode_libdir_flag_spec, dnl acl_hardcode_libdir_separator, dnl acl_hardcode_direct, dnl acl_hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE(rpath, [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Autoconf >= 2.61 supports dots in --with options. define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix], [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` LIB[]NAME[]_PREFIX="$basedir" additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/intdiv0.m40000644000175000017500000000443113460025251017421 0ustar gxaviergxavier# intdiv0.m4 serial 2 (gettext-0.17) dnl Copyright (C) 2002, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([gt_INTDIV0], [ AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], gt_cv_int_divbyzero_sigfpe, [ gt_cv_int_divbyzero_sigfpe= changequote(,)dnl case "$host_os" in macos* | darwin[6-9]* | darwin[1-9][0-9]*) # On MacOS X 10.2 or newer, just assume the same as when cross- # compiling. If we were to perform the real test, 1 Crash Report # dialog window would pop up. case "$host_cpu" in i[34567]86 | x86_64) gt_cv_int_divbyzero_sigfpe="guessing yes" ;; esac ;; esac changequote([,])dnl if test -z "$gt_cv_int_divbyzero_sigfpe"; then AC_TRY_RUN([ #include #include static void sigfpe_handler (int sig) { /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ exit (sig != SIGFPE); } int x = 1; int y = 0; int z; int nan; int main () { signal (SIGFPE, sigfpe_handler); /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) signal (SIGTRAP, sigfpe_handler); #endif /* Linux/SPARC yields signal SIGILL. */ #if defined (__sparc__) && defined (__linux__) signal (SIGILL, sigfpe_handler); #endif z = x / y; nan = y / y; exit (1); } ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, [ # Guess based on the CPU. changequote(,)dnl case "$host_cpu" in alpha* | i[34567]86 | x86_64 | m68k | s390*) gt_cv_int_divbyzero_sigfpe="guessing yes";; *) gt_cv_int_divbyzero_sigfpe="guessing no";; esac changequote([,])dnl ]) fi ]) case "$gt_cv_int_divbyzero_sigfpe" in *yes) value=1;; *) value=0;; esac AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, [Define if integer division by zero raises signal SIGFPE.]) ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/inttypes_h.m40000644000175000017500000000164413460025251020235 0ustar gxaviergxavier# inttypes_h.m4 serial 7 dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. # Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, # doesn't clash with , and declares uintmax_t. AC_DEFUN([gl_AC_HEADER_INTTYPES_H], [ AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, [AC_TRY_COMPILE( [#include #include ], [uintmax_t i = (uintmax_t) -1; return !i;], gl_cv_header_inttypes_h=yes, gl_cv_header_inttypes_h=no)]) if test $gl_cv_header_inttypes_h = yes; then AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, [Define if exists, doesn't clash with , and declares uintmax_t. ]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/m4/glibc21.m40000644000175000017500000000144513460025251017271 0ustar gxaviergxavier# glibc21.m4 serial 3 dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. # Test for the GNU C Library, version 2.1 or newer. # From Bruno Haible. AC_DEFUN([gl_GLIBC21], [ AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, ac_cv_gnu_library_2_1, [AC_EGREP_CPP([Lucky GNU user], [ #include #ifdef __GNU_LIBRARY__ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) Lucky GNU user #endif #endif ], ac_cv_gnu_library_2_1=yes, ac_cv_gnu_library_2_1=no) ] ) AC_SUBST(GLIBC21) GLIBC21="$ac_cv_gnu_library_2_1" ] ) ucarp-1.5.2+git20192404.1a9aaf7/m4/wchar_t.m40000644000175000017500000000132613460025251017473 0ustar gxaviergxavier# wchar_t.m4 serial 1 (gettext-0.12) dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Test whether has the 'wchar_t' type. dnl Prerequisite: AC_PROG_CC AC_DEFUN([gt_TYPE_WCHAR_T], [ AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, [AC_TRY_COMPILE([#include wchar_t foo = (wchar_t)'\0';], , gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) if test $gt_cv_c_wchar_t = yes; then AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) fi ]) ucarp-1.5.2+git20192404.1a9aaf7/src/0000755000175000017500000000000013460025251016047 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/src/spawn.h0000644000175000017500000000017013460025251017346 0ustar gxaviergxavier#ifndef __SPAWN_H__ #define __SPAWN_H__ 1 int spawn_handler(const int dev_desc_fd, const char * const script); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/fakesnprintf.h0000644000175000017500000000113513460025251020712 0ustar gxaviergxavier#ifndef __FAKESNPRINTF_H__ #define __FAKESNPRINTF_H__ 1 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) int fakesnprintf_vsnprintf(char * const str_, const size_t size_, const char *format, va_list va); int fakesnprintf_snprintf(char * const str, const size_t size, const char * const format, ...); # define snprintf fakesnprintf_snprintf # define vsnprintf fakesnprintf_vsnprintf # ifdef CONF_SNPRINTF_TYPE # undef CONF_SNPRINTF_TYPE # endif # define CONF_SNPRINTF_TYPE 4 #endif #endif /* FAKESNPRINTF_H */ ucarp-1.5.2+git20192404.1a9aaf7/src/bsd-getopt_long.c0000644000175000017500000004451213460025251021310 0ustar gxaviergxavier/* $OpenBSD: getopt_long.c,v 1.20 2005/10/25 15:49:37 jmc Exp $ */ /* * Copyright (c) 2002 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #define IN_GETOPT_LONG_C 1 #include #include "ucarp.h" #ifndef HAVE_GETOPT_LONG # include "bsd-getopt_long.h" # ifdef WITH_DMALLOC # include # endif int pure_opterr = 1; /* if error message should be printed */ int pure_optind = 1; /* index into parent argv vector */ int pure_optopt = '?'; /* character checked for validity */ int pure_optreset; /* reset getopt */ const char *pure_optarg; /* argument associated with option */ # define PRINT_ERROR ((pure_opterr) && (*options != ':')) # define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ # define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ # define FLAG_LONGONLY 0x04 /* operate as pure_getopt_long_only */ /* return values */ # define BADCH (int)'?' # define BADARG ((*options == ':') ? (int)':' : (int)'?') # define INORDER (int)1 # define EMSG "" static int pure_getopt_internal(int, char * const *, const char *, const struct pure_option *, int *, int); static int pure_parse_long_options(char * const *, const char *, const struct pure_option *, int *, int); static int pure_gcd(int, int); static void pure_permute_args(int, int, int, char * const *); static const char *pure_place = EMSG; /* option letter processing */ /* XXX: set pure_optreset to 1 rather than these two */ static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_end = -1; /* first option after non options (for permute) */ /* Error messages */ static const char *recargchar = "option requires an argument -- %c\n"; static const char *recargstring = "option requires an argument -- %s\n"; static const char *ambig = "ambiguous option -- %.*s\n"; static const char *noarg = "option doesn't take an argument -- %.*s\n"; static const char *illoptchar = "unknown option -- %c\n"; static const char *illoptstring = "unknown option -- %s\n"; /* * Compute the greatest common divisor of a and b. */ static int pure_gcd(int a, int b) { int c; c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return b; } /* * Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). */ static void pure_permute_args(int panonopt_start, int panonopt_end, int opt_end, char * const *nargv) { int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; char *swap; /* * compute lengths of blocks and number and size of cycles */ nnonopts = panonopt_end - panonopt_start; nopts = opt_end - panonopt_end; ncycle = pure_gcd(nnonopts, nopts); cyclelen = (opt_end - panonopt_start) / ncycle; for (i = 0; i < ncycle; i++) { cstart = panonopt_end+i; pos = cstart; for (j = 0; j < cyclelen; j++) { if (pos >= panonopt_end) pos -= nnonopts; else pos += nopts; swap = nargv[pos]; /* LINTED const cast */ ((char **) nargv)[pos] = nargv[cstart]; /* LINTED const cast */ ((char **)nargv)[cstart] = swap; } } } /* * pure_parse_long_options -- * Parse long options in argc/argv argument vector. * Returns -1 if short_too is set and the option does not match long_options. */ static int pure_parse_long_options(char * const *nargv, const char *options, const struct pure_option *long_options, int *idx, int short_too) { const char *current_argv, *has_equal; size_t current_argv_len; int i, match; current_argv = pure_place; match = -1; pure_optind++; if ((has_equal = strchr(current_argv, '=')) != NULL) { /* argument found (--option=arg) */ current_argv_len = has_equal - current_argv; has_equal++; } else current_argv_len = strlen(current_argv); for (i = 0; long_options[i].name; i++) { /* find matching long option */ if (strncmp(current_argv, long_options[i].name, current_argv_len)) continue; if (strlen(long_options[i].name) == current_argv_len) { /* exact match */ match = i; break; } /* * If this is a known short option, don't allow * a partial match of a single character. */ if (short_too && current_argv_len == 1) continue; if (match == -1) /* partial match */ match = i; else { /* ambiguous abbreviation */ if (PRINT_ERROR) fprintf(stderr, ambig, (int)current_argv_len, current_argv); pure_optopt = 0; return BADCH; } } if (match != -1) { /* option found */ if (long_options[match].has_arg == no_argument && has_equal) { if (PRINT_ERROR) fprintf(stderr, noarg, (int)current_argv_len, current_argv); /* * XXX: GNU sets pure_optopt to val regardless of flag */ if (long_options[match].flag == NULL) pure_optopt = long_options[match].val; else pure_optopt = 0; return BADARG; } if (long_options[match].has_arg == required_argument || long_options[match].has_arg == optional_argument) { if (has_equal) pure_optarg = has_equal; else if (long_options[match].has_arg == required_argument) { /* * optional argument doesn't use next nargv */ pure_optarg = nargv[pure_optind++]; } } if ((long_options[match].has_arg == required_argument) && (pure_optarg == NULL)) { /* * Missing argument; leading ':' indicates no error * should be generated. */ if (PRINT_ERROR) fprintf(stderr, recargstring, current_argv); /* * XXX: GNU sets pure_optopt to val regardless of flag */ if (long_options[match].flag == NULL) pure_optopt = long_options[match].val; else pure_optopt = 0; --pure_optind; return BADARG; } } else { /* unknown option */ if (short_too) { --pure_optind; return -1; } if (PRINT_ERROR) fprintf(stderr, illoptstring, current_argv); pure_optopt = 0; return BADCH; } if (idx) *idx = match; if (long_options[match].flag) { *long_options[match].flag = long_options[match].val; return 0; } else return long_options[match].val; } /* * getopt_internal -- * Parse argc/argv argument vector. Called by user level routines. */ static int pure_getopt_internal(int nargc, char * const *nargv, const char *options, const struct pure_option *long_options, int *idx, int flags) { char *oli; /* option letter list index */ int optchar, short_too; static int posixly_correct = -1; if (options == NULL) return -1; /* * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. */ if (posixly_correct == -1) posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); if (posixly_correct || *options == '+') flags &= ~FLAG_PERMUTE; else if (*options == '-') flags |= FLAG_ALLARGS; if (*options == '+' || *options == '-') options++; /* * XXX Some GNU programs (like cvs) set pure_optind to 0 instead of * XXX using pure_optreset. Work around this braindamage. */ if (pure_optind == 0) pure_optind = pure_optreset = 1; pure_optarg = NULL; if (pure_optreset) nonopt_start = nonopt_end = -1; start: if (pure_optreset || !*pure_place) { /* update scanning pointer */ pure_optreset = 0; if (pure_optind >= nargc) { /* end of argument vector */ pure_place = EMSG; if (nonopt_end != -1) { /* do permutation, if we have to */ pure_permute_args(nonopt_start, nonopt_end, pure_optind, nargv); pure_optind -= nonopt_end - nonopt_start; } else if (nonopt_start != -1) { /* * If we skipped non-options, set pure_optind * to the first of them. */ pure_optind = nonopt_start; } nonopt_start = nonopt_end = -1; return -1; } if (*(pure_place = nargv[pure_optind]) != '-' || (pure_place[1] == '\0' && strchr(options, '-') == NULL)) { pure_place = EMSG; /* found non-option */ if (flags & FLAG_ALLARGS) { /* * GNU extension: * return non-option as argument to option 1 */ pure_optarg = nargv[pure_optind++]; return INORDER; } if (!(flags & FLAG_PERMUTE)) { /* * If no permutation wanted, stop parsing * at first non-option. */ return -1; } /* do permutation */ if (nonopt_start == -1) nonopt_start = pure_optind; else if (nonopt_end != -1) { pure_permute_args(nonopt_start, nonopt_end, pure_optind, nargv); nonopt_start = pure_optind - (nonopt_end - nonopt_start); nonopt_end = -1; } pure_optind++; /* process next argument */ goto start; } if (nonopt_start != -1 && nonopt_end == -1) nonopt_end = pure_optind; /* * Check for "--" or "--foo" with no long options * but if pure_place is simply "-" leave it unmolested. */ if (pure_place[1] != '\0' && *++pure_place == '-' && (pure_place[1] == '\0' || long_options == NULL)) { pure_optind++; pure_place = EMSG; /* * We found an option (--), so if we skipped * non-options, we have to permute. */ if (nonopt_end != -1) { pure_permute_args(nonopt_start, nonopt_end, pure_optind, nargv); pure_optind -= nonopt_end - nonopt_start; } nonopt_start = nonopt_end = -1; return -1; } } /* * Check long options if: * 1) we were passed some * 2) the arg is not just "-" * 3) either the arg starts with -- we are pure_getopt_long_only() */ if (long_options != NULL && pure_place != nargv[pure_optind] && (*pure_place == '-' || (flags & FLAG_LONGONLY))) { short_too = 0; if (*pure_place == '-') pure_place++; /* --foo long option */ else if (*pure_place != ':' && strchr(options, *pure_place) != NULL) short_too = 1; /* could be short option too */ optchar = pure_parse_long_options(nargv, options, long_options, idx, short_too); if (optchar != -1) { pure_place = EMSG; return optchar; } } if ((optchar = (int) *pure_place++) == ':' || optchar == '-' && *pure_place != '\0' || (oli = strchr(options, optchar)) == NULL) { /* * If the user didn't specify '-' as an option, * assume it means -1 as POSIX specifies. */ if (optchar == '-') return -1; /* option letter unknown or ':' */ if (!*pure_place) ++pure_optind; if (PRINT_ERROR) fprintf(stderr, illoptchar, optchar); pure_optopt = optchar; return BADCH; } if (long_options != NULL && optchar == 'W' && oli[1] == ';') { /* -W long-option */ if (*pure_place) /* no space */ /* NOTHING */; else if (++pure_optind >= nargc) { /* no arg */ pure_place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); pure_optopt = optchar; return BADARG; } else /* white space */ pure_place = nargv[pure_optind]; optchar = pure_parse_long_options(nargv, options, long_options, idx, 0); pure_place = EMSG; return optchar; } if (*++oli != ':') { /* doesn't take argument */ if (!*pure_place) ++pure_optind; } else { /* takes (optional) argument */ pure_optarg = NULL; if (*pure_place) { /* no white space */ pure_optarg = pure_place; /* XXX: disable test for :: if PC? (GNU doesn't) */ } else if (oli[1] != ':') { /* arg not optional */ if (++pure_optind >= nargc) { /* no arg */ pure_place = EMSG; if (PRINT_ERROR) fprintf(stderr, recargchar, optchar); pure_optopt = optchar; return BADARG; } else { pure_optarg = nargv[pure_optind]; } } else if (!(flags & FLAG_PERMUTE)) { /* * If permutation is disabled, we can accept an * optional arg separated by whitespace so long * as it does not start with a dash (-). */ if (pure_optind + 1 < nargc && *nargv[pure_optind + 1] != '-') { pure_optarg = nargv[++pure_optind]; } } pure_place = EMSG; ++pure_optind; } /* dump back option letter */ return optchar; } /* * getopt -- * Parse argc/argv argument vector. */ int pure_getopt(int nargc, char * const *nargv, const char *options) { /* * We don't pass FLAG_PERMUTE to pure_getopt_internal() since * the BSD getopt(3) (unlike GNU) has never done this. * * Furthermore, since many privileged programs call getopt() * before dropping privileges it makes sense to keep things * as simple (and bug-free) as possible. */ return pure_getopt_internal(nargc, nargv, options, NULL, NULL, 0); } /* * pure_getopt_long -- * Parse argc/argv argument vector. */ int pure_getopt_long(int nargc, char * const *nargv, const char *options, const struct pure_option *long_options, int *idx) { return pure_getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE); } /* * pure_getopt_long_only -- * Parse argc/argv argument vector. */ int pure_getopt_long_only(int nargc, char * const *nargv, const char *options, const struct pure_option *long_options, int *idx) { return pure_getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE|FLAG_LONGONLY); } #endif ucarp-1.5.2+git20192404.1a9aaf7/src/Makefile.am0000644000175000017500000000102313460025251020077 0ustar gxaviergxavierlocaledir = $(datadir)/locale INCLUDES = -DLOCALEDIR=\"$(localedir)\" sbin_PROGRAMS = \ ucarp ucarp_SOURCES = \ gettext.h \ ucarp.c \ ucarp.h \ carp.c \ carp_p.h \ ucarp_p.h \ ip_carp.h \ crypto-sha1.c \ crypto.h \ crypto-sha1.h \ globals.h \ fillmac.c \ fillmac.h \ bsd-getopt_long.h \ bsd-getopt_long.c \ garp.c \ garp.h \ spawn.c \ spawn.h \ fakesnprintf.c \ fakesnprintf.h \ mysnprintf.c \ mysnprintf.h \ log.c \ log.h \ daemonize.c \ daemonize.h \ syslognames.h ucarp_LDADD = \ $(LTLIBINTL) ucarp-1.5.2+git20192404.1a9aaf7/src/globals.h0000644000175000017500000000172713460025251017652 0ustar gxaviergxavier#ifndef __GLOBALS_H__ #define __GLOBALS_H__ 1 #ifdef DEFINE_GLOBALS # define GLOBAL0(A) A # define GLOBAL(A, B) A = B #else # define GLOBAL0(A) extern A # define GLOBAL(A, B) extern A #endif GLOBAL0(char *interface); GLOBAL0(struct in_addr srcip); GLOBAL0(struct in_addr mcastip); GLOBAL0(unsigned char vhid); GLOBAL0(char *pass); GLOBAL0(struct in_addr vaddr); GLOBAL(unsigned char advbase, DEFAULT_ADVBASE); GLOBAL(unsigned int dead_ratio, DEFAULT_DEAD_RATIO); GLOBAL0(unsigned char advskew); GLOBAL0(char *upscript); GLOBAL0(char *downscript); GLOBAL0(signed char debug); GLOBAL0(signed char preempt); GLOBAL0(signed char neutral); GLOBAL0(signed char shutdown_at_exit); GLOBAL0(unsigned char hwaddr[6]); GLOBAL0(signed char no_syslog); GLOBAL0(signed char daemonize); GLOBAL0(signed char ignoreifstate); GLOBAL0(signed char no_mcast); GLOBAL(int syslog_facility, DEFAULT_FACILITY); GLOBAL0(char *vaddr_arg); GLOBAL0(char *xparam); GLOBAL0(sig_atomic_t received_signal); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/ucarp_p.h0000644000175000017500000000163413460025251017655 0ustar gxaviergxavier#ifndef __CARP_P_H__ #define __CARP_P_H__ 1 static const char *GETOPT_OPTIONS = "i:s:v:p:Pa:hb:k:x:nu:d:Dr:zf:Bo:SM"; static struct option long_options[] = { { "interface", 1, NULL, 'i' }, { "srcip", 1, NULL, 's' }, { "mcastip", 1, NULL, 'm' }, { "vhid", 1, NULL, 'v' }, { "pass", 1, NULL, 'p' }, { "preempt", 0, NULL, 'P' }, { "neutral", 0, NULL, 'n' }, { "addr", 1, NULL, 'a' }, { "help", 0, NULL, 'h' }, { "advbase", 1, NULL, 'b' }, { "advskew", 1, NULL, 'k' }, { "upscript", 1, NULL, 'u' }, { "downscript", 1, NULL, 'd' }, { "deadratio", 1, NULL, 'r' }, { "debug", 0, NULL, 'D' }, { "shutdown", 0, NULL, 'z' }, { "facility", 1, NULL, 'f' }, { "daemonize", 0, NULL, 'B' }, { "ignoreifstate", 0, NULL, 'S' }, { "nomcast", 0, NULL, 'M' }, { "passfile", 1, NULL, 'o' }, { "xparam", 1, NULL, 'x' }, { NULL, 0, NULL, 0 } }; #endif ucarp-1.5.2+git20192404.1a9aaf7/src/spawn.c0000644000175000017500000000272613460025251017352 0ustar gxaviergxavier#include #include "ucarp.h" #include "spawn.h" #ifdef HAVE_SYS_WAIT_H # include #endif #include "log.h" #ifdef WITH_DMALLOC # include #endif int spawn_handler(const int dev_desc_fd, const char * const script) { pid_t pid; if (script == NULL || *script == 0) { return 0; } pid = fork(); if (pid == (pid_t) 0) { (void) close(dev_desc_fd); execl(script, script, interface, vaddr_arg, xparam, (char *) NULL); logfile(LOG_ERR, _("Unable to exec %s %s %s%s%s: %s"), script, interface, vaddr_arg, (xparam ? " " : ""), (xparam ? xparam : ""), strerror(errno)); _exit(EXIT_FAILURE); } else if (pid != (pid_t) -1) { logfile(LOG_WARNING, _("Spawning [%s %s %s%s%s]"), script, interface, vaddr_arg, (xparam ? " " : ""), (xparam ? xparam : "")); #ifdef HAVE_WAITPID { while (waitpid(pid, NULL, 0) == (pid_t) -1 && errno == EINTR); } #else { pid_t foundpid; do { foundpid = wait3(NULL, 0, NULL); if (foundpid == (pid_t) -1 && errno == EINTR) { continue; } } while (foundpid != (pid_t) -1 && foundpid != pid); } #endif } else { logfile(LOG_ERR, _("Unable to spawn the script: %s"), strerror(errno)); return -1; } return 0; } ucarp-1.5.2+git20192404.1a9aaf7/src/crypto-sha1.h0000644000175000017500000000072413460025251020375 0ustar gxaviergxavier/* * SHA-1 in C * By Steve Reid * 100% Public Domain */ #ifndef __SHA1_H__ #define __SHA1_H__ 1 #include "crypto.h" typedef struct { crypto_uint4 state[5]; crypto_uint4 count[2]; unsigned char buffer[64]; } SHA1_CTX; void SHA1Init(SHA1_CTX * context); void SHA1Update(SHA1_CTX * context, const unsigned char * data, unsigned int len); void SHA1Final(unsigned char digest[20], SHA1_CTX * context); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/syslognames.h0000644000175000017500000000313613460025251020567 0ustar gxaviergxavier#ifndef __SYSLOGNAMES_H__ #define __SYSLOGNAMES_H__ 1 #ifdef SYSLOG_NAMES struct { const char *c_name; int c_val; } facilitynames[] = { # ifdef LOG_AUTH { "auth", LOG_AUTH }, # endif # ifdef LOG_AUTHPRIV { "authpriv", LOG_AUTHPRIV }, # endif # ifdef LOG_CRON { "cron", LOG_CRON }, # endif # ifdef LOG_DAEMON { "daemon", LOG_DAEMON }, # endif # ifdef LOG_FTP { "ftp", LOG_FTP }, # endif # ifdef LOG_KERN { "kern", LOG_KERN }, # endif # ifdef LOG_LPR { "lpr", LOG_LPR }, # endif # ifdef LOG_MAIL { "mail", LOG_MAIL }, # endif # ifdef INTERNAL_MARK { "mark", INTERNAL_MARK }, /* INTERNAL */ # endif # ifdef LOG_NEWS { "news", LOG_NEWS }, # endif # ifdef LOG_AUTH { "security", LOG_AUTH }, /* DEPRECATED */ # endif # ifdef LOG_SYSLOG { "syslog", LOG_SYSLOG }, # endif # ifdef LOG_USER { "user", LOG_USER }, # endif # ifdef LOG_UUCP { "uucp", LOG_UUCP }, # endif # ifdef LOG_LOCAL0 { "local0", LOG_LOCAL0 }, # endif # ifdef LOG_LOCAL1 { "local1", LOG_LOCAL1 }, # endif # ifdef LOG_LOCAL2 { "local2", LOG_LOCAL2 }, # endif # ifdef LOG_LOCAL3 { "local3", LOG_LOCAL3 }, # endif # ifdef LOG_LOCAL4 { "local4", LOG_LOCAL4 }, # endif # ifdef LOG_LOCAL5 { "local5", LOG_LOCAL5 }, # endif # ifdef LOG_LOCAL6 { "local6", LOG_LOCAL6 }, # endif # ifdef LOG_LOCAL7 { "local7", LOG_LOCAL7 }, # endif # ifdef LOG_LOCAL8 { "local8", LOG_LOCAL8 }, # endif # ifdef LOG_LOCAL9 { "local9", LOG_LOCAL9 }, # endif { NULL, -1 } }; #else extern struct { const char *c_name; int c_val; } facilitynames[]; #endif #endif ucarp-1.5.2+git20192404.1a9aaf7/src/log.c0000644000175000017500000000335413460025251017001 0ustar gxaviergxavier#include #include #include "log.h" #include "ucarp.h" #ifdef WITH_DMALLOC # include #endif void logfile(const int crit, const char *format, ...) { const char *urgency; va_list va; char line[MAX_SYSLOG_LINE]; if (crit == LOG_DEBUG && ! debug) return; va_start(va, format); vsnprintf(line, sizeof line, format, va); switch (crit) { case LOG_INFO: urgency = "[INFO] "; break; case LOG_WARNING: urgency = "[WARNING] "; break; case LOG_ERR: urgency = "[ERROR] "; break; case LOG_NOTICE: urgency = "[NOTICE] "; break; case LOG_DEBUG: urgency = "[DEBUG] "; break; default: urgency = ""; } if (no_syslog == 0) { #ifdef SAVE_DESCRIPTORS openlog("ucarp", LOG_PID, syslog_facility); #endif syslog(crit, "%s%s", urgency, line); #ifdef SAVE_DESCRIPTORS closelog(); #endif } if (daemonize == 0) { char timestr[200]; struct timeval tv; struct tm *tmp; if (gettimeofday(&tv, NULL)) { perror("gettimeofday"); return; } if (!(tmp = localtime(&tv.tv_sec))) { perror("localtime"); return; } if (strftime(timestr, sizeof(timestr), "%Y-%m-%dT%H:%M:%S", tmp) == 0) { fprintf(stderr, "strftime returned 0"); return; } switch (crit) { case LOG_WARNING: case LOG_ERR: fprintf(stderr, "%s.%06ld: %s%s\n", timestr, tv.tv_usec, urgency, line); break; default: printf("%s.%06ld: %s%s\n", timestr, tv.tv_usec, urgency, line); } } va_end(va); } ucarp-1.5.2+git20192404.1a9aaf7/src/daemonize.c0000644000175000017500000000432213460025251020167 0ustar gxaviergxavier#include #include "daemonize.h" #include "ucarp.h" #include "log.h" #ifdef WITH_DMALLOC # include #endif static unsigned int open_max(void) { long z; if ((z = (long) sysconf(_SC_OPEN_MAX)) < 0L) { logfile(LOG_ERR, "_SC_OPEN_MAX"); _exit(EXIT_FAILURE); } return (unsigned int) z; } static int closedesc_all(const int closestdin) { int fodder; if (closestdin != 0) { (void) close(0); if ((fodder = open("/dev/null", O_RDONLY)) == -1) { return -1; } (void) dup2(fodder, 0); if (fodder > 0) { (void) close(fodder); } } if ((fodder = open("/dev/null", O_WRONLY)) == -1) { return -1; } (void) dup2(fodder, 1); (void) dup2(1, 2); if (fodder > 2) { (void) close(fodder); } return 0; } void dodaemonize(void) { pid_t child; unsigned int i; /* Contributed by Jason Lunz - also based on APUI code, see open_max() */ if (daemonize != 0) { if ((child = fork()) == (pid_t) -1) { logfile(LOG_ERR, _("Unable to get in background: [fork: %s]"), strerror(errno)); return; } else if (child != (pid_t) 0) { _exit(EXIT_SUCCESS); /* parent exits */ } if (setsid() == (pid_t) -1) { logfile(LOG_WARNING, _("Unable to detach from the current session: %s"), strerror(errno)); /* continue anyway */ } /* Fork again so we're not a session leader */ if ((child = fork()) == (pid_t) -1) { logfile(LOG_ERR, _("Unable to background: [fork: %s] #2"), strerror(errno)); return; } else if ( child != (pid_t) 0) { _exit(EXIT_SUCCESS); /* parent exits */ } chdir("/"); i = open_max(); do { if (isatty((int) i)) { (void) close((int) i); } i--; } while (i > 2U); if (closedesc_all(1) != 0) { logfile(LOG_ERR, _("Unable to detach: /dev/null can't be duplicated")); _exit(EXIT_FAILURE); } } } ucarp-1.5.2+git20192404.1a9aaf7/src/mysnprintf.c0000644000175000017500000000130413460025251020422 0ustar gxaviergxavier#include #include #ifdef STDC_HEADERS # include # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include "mysnprintf.h" #ifdef WITH_DMALLOC # include #endif #ifdef SNPRINTF_IS_BOGUS int workaround_snprintf(char *str, size_t size, const char *format, ...) { int v; int r = 0; va_list va; va_start(va, format); v = vsnprintf(str, size, format, va); if (v < 0 || (ssize_t) v >= (ssize_t) size) { r--; } va_end(va); return r; } #endif ucarp-1.5.2+git20192404.1a9aaf7/src/gettext.h0000644000175000017500000000657013460025251017714 0ustar gxaviergxavier/* Convenience header for conditional use of GNU . Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 /* NLS can be disabled through the configure --disable-nls option. */ #if ENABLE_NLS /* Get declarations of GNU message catalog functions. */ # include #else /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. We don't include as well because people using "gettext.h" will not include , and also including would fail on SunOS 4, whereas is OK. */ #if defined(__sun) # include #endif /* Many header files from the libstdc++ coming with g++ 3.3 or newer include , which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. */ #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) # include # if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H # include # endif #endif /* Disabled NLS. The casts to 'const char *' serve the purpose of producing warnings for invalid uses of the value returned from these functions. On pre-ANSI systems without 'const', the config.h file is supposed to contain "#define const". */ # define gettext(Msgid) ((const char *) (Msgid)) # define dgettext(Domainname, Msgid) ((const char *) (Msgid)) # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) # define ngettext(Msgid1, Msgid2, N) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define dngettext(Domainname, Msgid1, Msgid2, N) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) # define textdomain(Domainname) ((const char *) (Domainname)) # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) #endif /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time translation is done at a different place in the code. The argument, String, should be a literal string. Concatenated strings and other string expressions won't work. The macro's expansion is not parenthesized, so that it is suitable as initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String #endif /* _LIBGETTEXT_H */ ucarp-1.5.2+git20192404.1a9aaf7/src/carp_p.h0000644000175000017500000000037313460025251017467 0ustar gxaviergxavier#ifndef __CARP_P_H__ #define __CARP_P_H__ 1 static struct carp_softc sc; static struct timeval now; static pcap_t *dev_desc; static int dev_desc_fd = -1; static int carp_suppress_preempt; static void carp_send_ad_all(struct carp_softc *sc); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/garp.c0000644000175000017500000000432013460025251017143 0ustar gxaviergxavier#include #include "ucarp.h" #include "garp.h" #include "log.h" #ifdef WITH_DMALLOC # include #endif int gratuitous_arp(const int dev_desc_fd) { struct ether_header eh; static unsigned char arp[28] = { 0x00, 0x01, /* MAC address type */ 0x08, 0x00, /* Protocol address type */ 0x06, 0x04, /* MAC address size, protocol address size */ 0x00, 0x01, /* OP (1=request, 2=reply) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Sender MAC */ 0x00, 0x00, 0x00, 0x00, /* Sender IP */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* Target MAC */ 0xff, 0xff, 0xff, 0xff /* Target IP */ }; unsigned char *pkt; int rc; if (ETHER_ADDR_LEN > 6) { abort(); } /* * - Gratuitous ARPs should use requests for the highest interoperability. * - Target MAC and IP should match sender * http://www1.ietf.org/mail-archive/web/dhcwg/current/msg03797.html * http://en.wikipedia.org/wiki/Address_Resolution_Protocol * http://ettercap.sourceforge.net/forum/viewtopic.php?t=2392 * http://wiki.ethereal.com/Gratuitous_ARP */ arp[7] = 0x01; /* request op */ memcpy(&arp[8], hwaddr, sizeof hwaddr); /* Sender MAC */ memcpy(&arp[14], &vaddr.s_addr, (size_t) 4U); /* Sender IP */ memcpy(&arp[18], hwaddr, sizeof hwaddr); /* Target MAC */ memcpy(&arp[24], &vaddr.s_addr, (size_t) 4U); /* Target IP */ memset(&eh, 0, sizeof eh); memcpy(&eh.ether_shost, hwaddr, sizeof hwaddr); memset(&eh.ether_dhost, 0xff, ETHER_ADDR_LEN); eh.ether_type = htons(ETHERTYPE_ARP); if ((pkt = ALLOCA(sizeof eh + sizeof arp)) == NULL) { logfile(LOG_ERR, _("out of memory to send gratuitous ARP")); return -1; } memcpy(pkt, &eh, sizeof eh); memcpy(pkt + sizeof eh, arp, sizeof arp); do { rc = write(dev_desc_fd, pkt, sizeof eh + sizeof arp); } while (rc < 0 && errno == EINTR); if (rc < 0) { logfile(LOG_ERR, _("write() in garp: %s"), strerror(errno)); ALLOCA_FREE(pkt); return -1; } ALLOCA_FREE(pkt); return 0; } ucarp-1.5.2+git20192404.1a9aaf7/src/crypto-sha1.c0000644000175000017500000001531113460025251020366 0ustar gxaviergxavier/* * SHA-1 in C * By Steve Reid * 100% Public Domain * * Test Vectors (from FIPS PUB 180-1) * "abc" * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 * A million repetitions of "a" * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ #include #ifndef USE_SYSTEM_CRYPT_SHA1 #include "ucarp.h" #include "crypto.h" #include "crypto-sha1.h" #ifdef WITH_DMALLOC # include #endif /* #define SHA1HANDSOFF * Copies data before messing with it. */ #define SHA1HANDSOFF #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) /* blk0() and blk() perform the initial expand. */ /* I got the idea of expanding during the round function from SSLeay */ #ifndef WORDS_BIGENDIAN # define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ |(rol(block->l[i],8)&0x00FF00FF)) #else # define blk0(i) block->l[i] #endif #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ ^block->l[(i+2)&15]^block->l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); /* Hash a single 512-bit block. This is the core of the algorithm. */ static void SHA1Transform(crypto_uint4 state[5], const unsigned char buffer[64]) { crypto_uint4 a, b, c, d, e; typedef union { unsigned char c[64]; unsigned int l[16]; } CHAR64LONG16; CHAR64LONG16 *block; #ifdef SHA1HANDSOFF static CHAR64LONG16 workspace; block = &workspace; memcpy(block, buffer, 64); #else block = (CHAR64LONG16 *) buffer; #endif /* Copy context->state[] to working vars */ a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; /* 4 rounds of 20 operations each. Loop unrolled. */ R0(a, b, c, d, e, 0); R0(e, a, b, c, d, 1); R0(d, e, a, b, c, 2); R0(c, d, e, a, b, 3); R0(b, c, d, e, a, 4); R0(a, b, c, d, e, 5); R0(e, a, b, c, d, 6); R0(d, e, a, b, c, 7); R0(c, d, e, a, b, 8); R0(b, c, d, e, a, 9); R0(a, b, c, d, e, 10); R0(e, a, b, c, d, 11); R0(d, e, a, b, c, 12); R0(c, d, e, a, b, 13); R0(b, c, d, e, a, 14); R0(a, b, c, d, e, 15); R1(e, a, b, c, d, 16); R1(d, e, a, b, c, 17); R1(c, d, e, a, b, 18); R1(b, c, d, e, a, 19); R2(a, b, c, d, e, 20); R2(e, a, b, c, d, 21); R2(d, e, a, b, c, 22); R2(c, d, e, a, b, 23); R2(b, c, d, e, a, 24); R2(a, b, c, d, e, 25); R2(e, a, b, c, d, 26); R2(d, e, a, b, c, 27); R2(c, d, e, a, b, 28); R2(b, c, d, e, a, 29); R2(a, b, c, d, e, 30); R2(e, a, b, c, d, 31); R2(d, e, a, b, c, 32); R2(c, d, e, a, b, 33); R2(b, c, d, e, a, 34); R2(a, b, c, d, e, 35); R2(e, a, b, c, d, 36); R2(d, e, a, b, c, 37); R2(c, d, e, a, b, 38); R2(b, c, d, e, a, 39); R3(a, b, c, d, e, 40); R3(e, a, b, c, d, 41); R3(d, e, a, b, c, 42); R3(c, d, e, a, b, 43); R3(b, c, d, e, a, 44); R3(a, b, c, d, e, 45); R3(e, a, b, c, d, 46); R3(d, e, a, b, c, 47); R3(c, d, e, a, b, 48); R3(b, c, d, e, a, 49); R3(a, b, c, d, e, 50); R3(e, a, b, c, d, 51); R3(d, e, a, b, c, 52); R3(c, d, e, a, b, 53); R3(b, c, d, e, a, 54); R3(a, b, c, d, e, 55); R3(e, a, b, c, d, 56); R3(d, e, a, b, c, 57); R3(c, d, e, a, b, 58); R3(b, c, d, e, a, 59); R4(a, b, c, d, e, 60); R4(e, a, b, c, d, 61); R4(d, e, a, b, c, 62); R4(c, d, e, a, b, 63); R4(b, c, d, e, a, 64); R4(a, b, c, d, e, 65); R4(e, a, b, c, d, 66); R4(d, e, a, b, c, 67); R4(c, d, e, a, b, 68); R4(b, c, d, e, a, 69); R4(a, b, c, d, e, 70); R4(e, a, b, c, d, 71); R4(d, e, a, b, c, 72); R4(c, d, e, a, b, 73); R4(b, c, d, e, a, 74); R4(a, b, c, d, e, 75); R4(e, a, b, c, d, 76); R4(d, e, a, b, c, 77); R4(c, d, e, a, b, 78); R4(b, c, d, e, a, 79); /* Add the working vars back into context.state[] */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; /* Wipe variables */ a = b = c = d = e = 0; } /* SHA1Init - Initialize new context */ void SHA1Init(SHA1_CTX * context) { /* SHA1 initialization constants */ context->state[0] = 0x67452301; context->state[1] = 0xEFCDAB89; context->state[2] = 0x98BADCFE; context->state[3] = 0x10325476; context->state[4] = 0xC3D2E1F0; context->count[0] = context->count[1] = 0; } /* Run your data through this. */ void SHA1Update(SHA1_CTX * context, const unsigned char *data, unsigned int len) { unsigned int i; unsigned int j; j = context->count[0]; if ((context->count[0] += len << 3) < j) context->count[1] += (len >> 29) + 1; j = (j >> 3) & 63; if ((j + len) > 63) { memcpy(&context->buffer[j], data, (i = 64 - j)); SHA1Transform(context->state, context->buffer); for (; i + 63 < len; i += 64) { SHA1Transform(context->state, &data[i]); } j = 0; } else i = 0; memcpy(&context->buffer[j], &data[i], len - i); } /* Add padding and return the message digest. */ void SHA1Final(unsigned char digest[20], SHA1_CTX * context) { unsigned int i; unsigned char finalcount[8]; for (i = 0; i < 8; i++) { finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */ } SHA1Update(context, (const unsigned char *) "\200", 1); while ((context->count[0] & 504) != 448) { SHA1Update(context, (const unsigned char *) "\0", 1); } SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ if (digest != NULL) { for (i = 0; i < 20; i++) { digest[i] = (unsigned char) ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); } } #if 0 /* Wipe variables */ i = 0; memset(context->buffer, 0, 64); memset(context->state, 0, 20); memset(context->count, 0, 8); memset(&finalcount, 0, 8); # ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ SHA1Transform(context->state, context->buffer); # endif #endif } #else extern char *interface; #endif ucarp-1.5.2+git20192404.1a9aaf7/src/fillmac.h0000644000175000017500000000012313460025251017623 0ustar gxaviergxavier#ifndef __FILLMAC_H__ #define __FILLMAC_H__ 1 int fill_mac_address(void); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/crypto.h0000644000175000017500000000157413460025251017547 0ustar gxaviergxavier#ifndef __CRYPTO_H__ #define __CRYPTO_H__ 1 #if SIZEOF_SHORT == 4 typedef short crypto_int4; typedef unsigned short crypto_uint4; #elif SIZEOF_INT == 4 typedef int crypto_int4; typedef unsigned int crypto_uint4; #elif SIZEOF_LONG == 4 typedef long crypto_int4; typedef unsigned long crypto_uint4; #elif SIZEOF_SHORT > 4 typedef short crypto_int4; typedef unsigned short crypto_uint4; #elif SIZEOF_INT > 4 typedef int crypto_int4; typedef unsigned int crypto_uint4; #elif SIZEOF_LONG > 4 typedef long crypto_int4; typedef unsigned long crypto_uint4; #else # error Please report your architecture and OS type to j at ucarp dot org #endif char *crypto_hash_sha1(const char *string, const int hex); char *crypto_hash_ssha1(const char *string, const char *stored); char *crypto_hash_md5(const char *string, const int hex); char *crypto_hash_smd5(const char *string, const char *stored); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/daemonize.h0000644000175000017500000000012313460025251020167 0ustar gxaviergxavier#ifndef __DAEMONIZE_H__ #define __DAEMONIZE_H__ 1 void dodaemonize(void); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/mysnprintf.h0000644000175000017500000000142313460025251020431 0ustar gxaviergxavier#ifndef __MYSNPRINTF_H__ #define __MYSNPRINTF_H__ 1 int workaround_snprintf(char *str, size_t size, const char *format, ...); #ifndef HAVE_SNPRINTF # include "fakesnprintf.h" #endif #ifdef CONF_SNPRINTF_TYPE # if CONF_SNPRINTF_TYPE == 8 # define SNPRINTF_C99 1 # elif CONF_SNPRINTF_TYPE <= 0 # define SNPRINTF_OLD 1 # define SNPRINTF_IS_BOGUS 1 # else # define SNPRINTF_IS_BOGUS 1 # endif #else # warning Unknown snprintf() type # define SNPRINTF_IS_BOGUS 1 #endif #if CONF_SNPRINTF_TYPE < 0 # define SNCHECK(CALL, SIZE) ((CALL) < 0) #elif defined(SNPRINTF_IS_BOGUS) || !defined(SNPRINTF_C99) || \ CONF_SNPRINTF_TYPE == 4 || CONF_SNPRINTF_TYPE == 8 # define SNCHECK(CALL, SIZE) ((CALL) >= ((int) (SIZE))) #else # define SNCHECK(CALL, SIZE) (workaround_ ## CALL) #endif #endif ucarp-1.5.2+git20192404.1a9aaf7/src/garp.h0000644000175000017500000000013413460025251017147 0ustar gxaviergxavier#ifndef __GARP_H__ #define __GARP_H__ 1 int gratuitous_arp(const int dev_desc_fd); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/fillmac.c0000644000175000017500000001062213460025251017623 0ustar gxaviergxavier#include #include "ucarp.h" #include "fillmac.h" #include #ifdef HAVE_IFADDRS_H # include #endif #ifdef HAVE_NET_IF_DL_H # include #endif #ifdef HAVE_NET_IF_TYPES_H # include #endif #ifdef HAVE_SYS_SOCKIO_H # include #endif #ifndef HAVE_NET_IF_ARP_H # include #endif #include "log.h" #ifdef WITH_DMALLOC # include #endif #ifdef PF_PACKET # define HWINFO_DOMAIN PF_PACKET #else # define HWINFO_DOMAIN PF_INET #endif #ifdef SOCK_PACKET # define HWINFO_TYPE SOCK_PACKET #else # define HWINFO_TYPE SOCK_DGRAM #endif int fill_mac_address(void) { int s; if ((s = socket(HWINFO_DOMAIN, HWINFO_TYPE, 0)) == -1) { logfile(LOG_ERR, _("Unable to open raw device: [%s]"), strerror(errno)); return -1; } #ifdef SIOCGIFHWADDR { struct ifreq ifr; if (strlen(interface) >= sizeof ifr.ifr_name) { logfile(LOG_ERR, _("Interface name too long")); return -1; } strncpy(ifr.ifr_name, interface, sizeof ifr.ifr_name); if (ioctl(s, SIOCGIFHWADDR, &ifr) != 0) { logfile(LOG_ERR, _("Unable to get hardware info about an interface: %s"), strerror(errno)); (void) close(s); return -1; } switch (ifr.ifr_hwaddr.sa_family) { case ARPHRD_ETHER: case ARPHRD_IEEE802: break; default: logfile(LOG_ERR, _("Unknown hardware type [%u]"), (unsigned int) ifr.ifr_hwaddr.sa_family); } memcpy(hwaddr, &ifr.ifr_hwaddr.sa_data, sizeof hwaddr); } #elif defined(HAVE_GETIFADDRS) { struct ifaddrs *ifas; struct ifaddrs *ifa; struct sockaddr_dl *sadl; struct ether_addr *ea; if (getifaddrs(&ifas) != 0) { logfile(LOG_ERR, _("Unable to get interface address: %s"), strerror(errno)); return -1; } ifa = ifas; while (ifa != NULL) { if (strcmp(ifa->ifa_name, interface) == 0 && ifa->ifa_addr->sa_family == AF_LINK) { sadl = (struct sockaddr_dl *) (void *) ifa->ifa_addr; if (sadl == NULL || sadl->sdl_type != IFT_ETHER || sadl->sdl_alen <= 0) { logfile(LOG_ERR, _("Invalid media / hardware address for [%s]"), interface); return -1; } ea = (struct ether_addr *) LLADDR(sadl); memcpy(hwaddr, ea, sizeof hwaddr); return 0; } ifa = ifa->ifa_next; } return -1; } #elif defined(SIOCGLIFNUM) { struct lifconf lifc; struct lifnum lifn; struct lifreq *lifr; caddr_t *lifrspace; struct arpreq arpreq; lifn.lifn_flags = 0; lifn.lifn_family = AF_INET; if (ioctl(s, SIOCGLIFNUM, &lifn) < 0) { logfile(LOG_ERR, _("ioctl SIOCGLIFNUM error")); return -1; } if (lifn.lifn_count <= 0) { logfile(LOG_ERR, _("No interface found")); return -1; } lifc.lifc_family = lifn.lifn_family; lifc.lifc_len = lifn.lifn_count * sizeof *lifr; lifrspace = ALLOCA(lifc.lifc_len); lifc.lifc_buf = (caddr_t) lifrspace; if (ioctl(s, SIOCGLIFCONF, &lifc) < 0) { logfile(LOG_ERR, _("ioctl SIOCGLIFCONF error")); ALLOCA_FREE(lifrspace); return -1; } lifr = lifc.lifc_req; for(;;) { if (lifn.lifn_count <= 0) { logfile(LOG_ERR, _("Interface [%s] not found"), interface); ALLOCA_FREE(lifrspace); return -1; } lifn.lifn_count--; if (strcmp(lifr->lifr_name, interface) == 0) { break; } lifr++; } memcpy(&arpreq.arp_pa, &lifr->lifr_addr, sizeof arpreq.arp_pa); ALLOCA_FREE(lifrspace); if (ioctl(s, SIOCGARP, &arpreq) != 0) { logfile(LOG_ERR, _("Unable to get hardware info about [%s]"), interface); return -1; } memcpy(hwaddr, &arpreq.arp_ha.sa_data, sizeof hwaddr); } #endif (void) close(s); return 0; } ucarp-1.5.2+git20192404.1a9aaf7/src/bsd-getopt_long.h0000644000175000017500000001146213460025251021313 0ustar gxaviergxavier /* $OpenBSD: getopt_long.c,v 1.13 2003/06/03 01:52:40 millert Exp $ */ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /* * Copyright (c) 2002 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __BSD_GETOPT_LONG_H__ #define __BSD_GETOPT_LONG_H__ #ifndef HAVE_GETOPT_LONG /* * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions */ # ifndef no_argument # define no_argument 0 # endif # ifndef required_argument # define required_argument 1 # endif # ifndef optional_argument # define optional_argument 2 # endif struct pure_option { /* name of long option */ const char *name; /* * one of no_argument, required_argument, and optional_argument: * whether option takes an argument */ int has_arg; /* if not NULL, set *flag to val when option found */ int *flag; /* if flag not NULL, value to set *flag to; else return value */ int val; }; int pure_getopt_long(int nargc, char * const *nargv, const char *options, const struct pure_option *long_options, int *idx); int pure_getopt_long_only(int nargc, char * const *nargv, const char *options, const struct pure_option *long_options, int *idx); int pure_getopt(int nargc, char * const *nargv, const char *options); extern const char *pure_optarg; /* getopt(3) external variables */ extern int pure_opterr; extern int pure_optind; extern int pure_optopt; extern int pure_optreset; /* prefix+macros just to avoid clashes with existing getopt() implementations */ # ifndef IN_GETOPT_LONG_C # undef option # define option pure_option # undef getopt_long # define getopt_long(A, B, C, D, E) pure_getopt_long(A, B, C, D, E) # undef getopt_long_only # define getopt_long_only(A, B, C, D, E) pure_getopt_long_only(A, B, C, D, E) # undef getopt # define getopt(A, B, C) pure_getopt(A, B, C) # undef optarg # define optarg pure_optarg # undef opterr # define opterr pure_opterr # undef optind # define optind pure_optind # undef optopt # define optopt pure_optopt # undef optreset # define optreset pure_optreset # endif #endif #endif ucarp-1.5.2+git20192404.1a9aaf7/src/log.h0000644000175000017500000000014613460025251017002 0ustar gxaviergxavier#ifndef __LOG_H__ #define __LOG_H__ 1 void logfile(const int crit, const char *format, ...); #endif ucarp-1.5.2+git20192404.1a9aaf7/src/fakesnprintf.c0000644000175000017500000002450513460025251020713 0ustar gxaviergxavier/* * snprintf() / vsnprintf() re-implementation by Frank Denis * * These functions understand : * - characters ("%c") . * - space padding ("%3d", "%-3s") . * - zero padding ("%04d") . * - explicit '+' ("%+d", "%+3.2f") . * - length restrictions ("%.30s", "%-42.30s", "%.4d") . * - int, long, long long types ("%lld", "%-3ld", "%i") . * - unsigned int, long, long long types ("%llu", "%-3lu", "%u") . * - hex and octal unsigned types ("%llX", "%04x", "%-3o") . * - double and long double types ("%f", "%Lf") . * - floating point frac restrictions ("%.2f") . * - combinations of everything ("%-8.5llo") . * * Nothing more. Return value is if an overflow occured, or the * copied size if no overflow occured (mostly compatible with C99 * snprintf() behavior, except that it doesn't return any value larger * than ). * * These functions are portable, they are twice faster than their BSD and GNU * implementations, and they don't tamper with errno. But they only know * a limited subset of what a full-implementation is supposed to do. * * It's enough for UCARP, though. */ #include #include "ucarp.h" #ifdef WITH_DMALLOC # include #endif #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) /* * add a string to the buffer * \param zero if this is non-zero, we pad with zeroes, else we pad * with a blank. * \param maxlen sets the maximum size of the string to be added */ static void fakesnprintf_addstr(char **str, size_t *size, const char *pnt, size_t maxlen, size_t padlen, unsigned char zero, unsigned char minuspad) { size_t maxlenc; /* prepare to cut off string if longer than maxlen */ maxlenc = strlen(pnt); if (maxlen > 0U && maxlen < maxlenc) { maxlenc = maxlen; } if (padlen > 0U && minuspad == 0U && padlen > maxlenc) { size_t maxlenp = padlen - maxlenc; if (maxlenp > *size) { maxlenp = *size; } if (maxlenp > 0U) { memset(*str, zero != 0 ? '0' : ' ', maxlenp); (*size) -= maxlenp; (*str) += maxlenp; } } if (maxlenc > *size) { maxlenc = *size; } if (maxlenc > 0U) { memcpy(*str, pnt, maxlenc); (*size) -= maxlenc; (*str) += maxlenc; } if (padlen > 0U && minuspad > 0U && padlen > maxlenc) { size_t maxlenp = padlen - maxlenc; if (maxlenp > *size) { maxlenp = *size; } if (maxlenp > 0U) { memset(*str, ' ', maxlenp); (*size) -= maxlenp; (*str) += maxlenp; } } } int fakesnprintf_vsnprintf(char * const str_, const size_t size_, const char *format, va_list va) { char *str; size_t size; size_t maxlen; size_t padlen; unsigned char longs; unsigned char zero; unsigned char minuspad; unsigned char hasmaxlen; unsigned char plussign; str = str_; size = size_; str_[size_ - 1U] = 1; while (size > 0U && *format != 0) { if (*format != '%') { *str++ = *format++; size--; continue; } longs = 0U; zero = 0U; minuspad = 0U; maxlen = 0U; padlen = 0U; hasmaxlen = 0U; plussign = 0U; for (;;) { breakpoint_nextspecial_inc: format++; breakpoint_nextspecial_noinc: switch (*format) { case 0: goto breakpoint_end; case '%': *str++ = '%'; size--; goto breakpoint_next; case 'c': { int val; val = va_arg(va, int); *str++ = (char) val; size--; goto breakpoint_next; } case 'l': case 'L': longs++; goto breakpoint_nextspecial_inc; case '0': zero++; goto breakpoint_nextspecial_inc; case '.': format++; hasmaxlen = 1U; while ((unsigned char) *format >= '0' && (unsigned char) *format <= '9') { maxlen *= 10U; maxlen += (*format - '0'); format++; } goto breakpoint_nextspecial_noinc; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': do { padlen *= 10U; padlen += *format - '0'; format++; } while ((unsigned char) *format >= '0' && (unsigned char) *format <= '9'); goto breakpoint_nextspecial_noinc; case '-': minuspad++; format++; goto breakpoint_nextspecial_noinc; case '+': plussign++; format++; goto breakpoint_nextspecial_noinc; case 's': { const char *pnt; pnt = va_arg(va, const char *); if (pnt == NULL) { pnt = ""; } fakesnprintf_addstr(&str, &size, pnt, maxlen, padlen, zero, minuspad); goto breakpoint_next; } case 'u': case 'o': case 'x': case 'X': { unsigned long long val; char vals[256]; char *valspnt = vals + sizeof vals; const char *basics; unsigned int base; switch (longs) { case 2: val = va_arg(va, unsigned long long); break; case 1: val = (unsigned long long) va_arg(va, unsigned long); break; default: val = (unsigned long long) va_arg(va, unsigned int); } basics = "0123456789abcdef"; switch (*format) { case 'o': base = 8U; break; case 'X': basics = "0123456789ABCDEF"; case 'x': base = 16U; break; default: base = 10U; } *--valspnt = 0; do { *--valspnt = basics[val % base]; val /= base; } while (valspnt != &vals[0] && val > 0ULL); fakesnprintf_addstr(&str, &size, valspnt, maxlen, padlen, zero, minuspad); goto breakpoint_next; } case 'd': case 'i': { long long val; unsigned char minussign = 0U; char vals[256]; char *valspnt = vals + sizeof vals; switch (longs) { case 2: val = va_arg(va, long long); break; case 1: val = (long long) va_arg(va, long); break; default: val = (long long) va_arg(va, int); } if (val < 0LL) { minussign++; val = -val; } *--valspnt = 0; do { *--valspnt = "0123456789"[val % 10LL]; val /= 10LL; } while (valspnt != &vals[1] && val > 0LL); if (minussign != 0) { *--valspnt = '-'; } else if (plussign != 0) { *--valspnt = '+'; } fakesnprintf_addstr(&str, &size, valspnt, maxlen, padlen, zero, minuspad); goto breakpoint_next; } case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': { unsigned int nfrac = 6U; long double val; unsigned long long vali; unsigned char minussign = 0U; char vals[512]; char *valspnt = vals + sizeof vals / 2U; char *valsleft; if (longs != 0) { val = va_arg(va, long double); } else { val = va_arg(va, double); } if (val < 0.0L) { minussign++; val = -val; } vali = (unsigned long long) val; do { *--valspnt = '0' + vali % 10ULL; vali /= 10ULL; } while (valspnt != &vals[1] && vali > 0ULL); if (minussign != 0) { *--valspnt = '-'; } else if (plussign != 0) { *--valspnt = '+'; } valsleft = valspnt; valspnt = vals + sizeof vals / 2U; if (maxlen > (sizeof vals / 2U) - 3U) { nfrac = (sizeof vals / 2U) - 3U; } else if (hasmaxlen != 0U) { nfrac = maxlen; } if (nfrac > 0U) { *valspnt++ = '.'; } while (nfrac > 0U) { nfrac--; val *= 10.0L; *valspnt++ = '0' + (((unsigned long long) val) % 10U); } *valspnt = 0; fakesnprintf_addstr(&str, &size, valsleft, sizeof vals, padlen, zero, minuspad); goto breakpoint_next; } } } breakpoint_next: format++; } breakpoint_end: if (str_[size_ - 1U] != 1) { str_[size_ - 1U] = 0; return (int) size_; } *str = 0; return (int) (size_ - size); } int fakesnprintf_snprintf(char * const str, const size_t size, const char * const format, ...) { int ret; va_list va; va_start(va, format); ret = fakesnprintf_vsnprintf(str, size, format, va); va_end(va); return ret; } #endif /* !HAVE_SNPRINTF */ ucarp-1.5.2+git20192404.1a9aaf7/src/carp.c0000644000175000017500000007362613460025251017156 0ustar gxaviergxavier/* * Copyright (c) 2004-2015 Frank Denis. All rights reserved. * * This crucial part of UCARP is derived from the OpenBSD project. * Original copyright follows. * * Copyright (c) 2002 Michael Shalayeff. All rights reserved. * Copyright (c) 2003 Ryan McBride. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "ucarp.h" #include "crypto.h" #ifndef USE_SYSTEM_CRYPT_SHA1 # include "crypto-sha1.h" #else # include #endif #include "ip_carp.h" #include "fillmac.h" #include "garp.h" #include "spawn.h" #include "log.h" #include "carp_p.h" #ifdef WITH_DMALLOC # include #endif static void carp_set_state(struct carp_softc *sc, int state) { if ((int) sc->sc_state == state) { return; } switch (state) { case INIT: logfile(LOG_INFO, _("Switching to state: INIT")); break; case BACKUP: logfile(LOG_WARNING, _("Switching to state: BACKUP")); if ((sc->sc_state != INIT) || (neutral != 1)) { (void) spawn_handler(dev_desc_fd, downscript); } break; case MASTER: logfile(LOG_WARNING, _("Switching to state: MASTER")); (void) spawn_handler(dev_desc_fd, upscript); gratuitous_arp(dev_desc_fd); break; default: logfile(LOG_ERR, _("Unknown state: [%d]"), (int) state); abort(); } sc->sc_state = state; } static void carp_hmac_prepare(struct carp_softc *sc) { unsigned char version = CARP_VERSION, type = CARP_ADVERTISEMENT; unsigned char vhid = sc->sc_vhid & 0xff; size_t i; #ifdef INET6 struct in6_addr in6; #endif /* INET6 */ /* compute ipad from key */ memset(sc->sc_pad, 0, sizeof sc->sc_pad); memcpy(sc->sc_pad, sc->sc_key, sizeof sc->sc_key); for (i = 0; i < sizeof sc->sc_pad; i++) { sc->sc_pad[i] ^= 0x36; } /* precompute first part of inner hash */ SHA1Init(&sc->sc_sha1); SHA1Update(&sc->sc_sha1, sc->sc_pad, sizeof sc->sc_pad); SHA1Update(&sc->sc_sha1, (void *) &version, sizeof version); SHA1Update(&sc->sc_sha1, (void *) &type, sizeof type); SHA1Update(&sc->sc_sha1, (void *) &vhid, sizeof vhid); SHA1Update(&sc->sc_sha1, (void *) &vaddr.s_addr, sizeof vaddr.s_addr); /* convert ipad to opad */ for (i = 0; i < sizeof sc->sc_pad; i++) { sc->sc_pad[i] ^= 0x36 ^ 0x5c; } } static unsigned short cksum(const void * const buf_, const size_t len) { const unsigned char *buf = (const unsigned char *) buf_; unsigned long sum = 0UL; size_t evenlen = len & ~ (size_t) 1U; size_t i = (size_t) 0U; if (len <= (size_t) 0U) { return 0U; } do { sum += (buf[i] << 8) | buf[i + 1]; if (sum > 0xffff) { sum &= 0xffff; sum++; } i += 2; } while (i < evenlen); if (i != evenlen) { sum += buf[i] << 8; if (sum > 0xffff) { sum &= 0xffff; sum++; } } return (unsigned short) ~sum; } static void carp_hmac_generate(struct carp_softc *sc, u_int32_t counter[2], unsigned char *md) { SHA1_CTX ctx; /* fetch first half of inner hash */ memcpy(&ctx, &sc->sc_sha1, sizeof ctx); SHA1Update(&ctx, (void *) counter, sizeof sc->sc_counter); SHA1Final(md, &ctx); /* outer hash */ SHA1Init(&ctx); SHA1Update(&ctx, sc->sc_pad, sizeof sc->sc_pad); SHA1Update(&ctx, md, 20); SHA1Final(md, &ctx); } static int carp_prepare_ad(struct carp_header *ch, struct carp_softc *sc) { if (sc->sc_init_counter != 0) { /* this could also be seconds since unix epoch */ #ifdef HAVE_ARC4RANDOM sc->sc_counter = arc4random(); #else sc->sc_counter = random(); #endif sc->sc_counter <<= 32; #ifdef HAVE_ARC4RANDOM sc->sc_counter += arc4random(); #else sc->sc_counter += random(); #endif } else if (sc->sc_counter == 0xffffffffffffffffULL) { sc->sc_counter = 0ULL; } else { sc->sc_counter++; } ch->carp_counter[0] = htonl((sc->sc_counter >> 32) & 0xffffffff); ch->carp_counter[1] = htonl(sc->sc_counter & 0xffffffff); carp_hmac_generate(sc, ch->carp_counter, ch->carp_md); return 0; } static void carp_send_ad(struct carp_softc *sc) { struct carp_header ch; struct ether_header eh; struct timeval tv; struct ip ip; unsigned char *ip_ptr; unsigned char *pkt; unsigned short sum; size_t ip_len; size_t eth_len; int advbase; int advskew; int rc; logfile(LOG_DEBUG, "-> carp_send_ad()"); advbase = sc->sc_advbase; if (carp_suppress_preempt == 0 || sc->sc_advskew > CARP_BULK_UPDATE_MIN_DELAY) { advskew = sc->sc_advskew; } else { advskew = CARP_BULK_UPDATE_MIN_DELAY; } tv.tv_sec = advbase; tv.tv_usec = (unsigned int) (advskew * 1000000ULL / 256ULL); ch.carp_version = CARP_VERSION; ch.carp_type = CARP_ADVERTISEMENT; ch.carp_vhid = sc->sc_vhid; ch.carp_advbase = advbase; ch.carp_advskew = advskew; ch.carp_authlen = CARP_AUTHLEN; ch.carp_pad1 = 0; /* must be zero */ ch.carp_cksum = 0; ip_len = sizeof ip + sizeof ch; eth_len = ip_len + sizeof eh; if ((pkt = ALLOCA(eth_len)) == NULL) { logfile(LOG_ERR, _("Out of memory to create packet")); timeradd(&now, &tv, &sc->sc_ad_tmo); return; } ip.ip_v = IPVERSION; ip.ip_hl = (sizeof ip) >> 2; ip.ip_tos = IPTOS_LOWDELAY; ip.ip_len = htons(ip_len); #ifdef HAVE_ARC4RANDOM ip.ip_id = htons(arc4random() & 0xffff); #else ip.ip_id = htons(random() & 0xffff); #endif ip.ip_off = htons(IP_DF); ip.ip_ttl = CARP_DFLTTL; ip.ip_p = IPPROTO_CARP; ip.ip_sum = 0; memcpy(&ip.ip_src, &srcip, sizeof ip.ip_src); memcpy(&ip.ip_dst.s_addr, &mcastip, sizeof ip.ip_dst.s_addr); carp_prepare_ad(&ch, sc); ch.carp_cksum = 0; sum = cksum(&ch, sizeof ch); ch.carp_cksum = htons(sum); eh.ether_shost[0] = 0x00; eh.ether_shost[1] = 0x00; eh.ether_shost[2] = 0x5e; eh.ether_shost[3] = 0x00; eh.ether_shost[4] = 0x00; eh.ether_shost[5] = vhid; if (no_mcast) { eh.ether_dhost[0] = 0xff; eh.ether_dhost[1] = 0xff; eh.ether_dhost[2] = 0xff; eh.ether_dhost[3] = 0xff; eh.ether_dhost[4] = 0xff; eh.ether_dhost[5] = 0xff; } else { unsigned int m = ntohl(mcastip.s_addr); eh.ether_dhost[0] = 0x01; eh.ether_dhost[1] = 0x00; eh.ether_dhost[2] = 0x5e; eh.ether_dhost[3] = m >> 16 & 0x7f; eh.ether_dhost[4] = m >> 8 & 0xff; eh.ether_dhost[5] = m & 0xff; } eh.ether_type = htons(ETHERTYPE_IP); memcpy(pkt, &eh, sizeof eh); memcpy(pkt + sizeof eh, &ip, sizeof ip); memcpy(pkt + sizeof ip + sizeof eh, &ch, sizeof ch); ip_ptr = pkt + sizeof eh; sum = cksum(ip_ptr, ip_len); ip_ptr[offsetof(struct ip, ip_sum)] = (sum >> 8) & 0xff; ip_ptr[offsetof(struct ip, ip_sum) + 1] = sum & 0xff; do { rc = write(dev_desc_fd, pkt, eth_len); } while (rc < 0 && errno == EINTR); if (rc < 0) { logfile(LOG_WARNING, _("write() has failed: %s"), strerror(errno)); if (sc->sc_sendad_errors < INT_MAX) { sc->sc_sendad_errors++; } if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) { logfile(LOG_ERR, _("write() error #%d/%d"), carp_suppress_preempt, CARP_SENDAD_MAX_ERRORS); carp_suppress_preempt++; if (carp_suppress_preempt == 1) { carp_send_ad_all(sc); } } sc->sc_sendad_success = 0; } else { if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS) { if (++sc->sc_sendad_success >= CARP_SENDAD_MIN_SUCCESS) { carp_suppress_preempt--; sc->sc_sendad_errors = 0; } } else { sc->sc_sendad_errors = 0; } } logfile(LOG_DEBUG, _("* advertisement injected *")); ALLOCA_FREE(pkt); if (sc->sc_delayed_arp > 0) sc->sc_delayed_arp--; if (sc->sc_delayed_arp == 0) { if (sc->sc_state == MASTER) { gratuitous_arp(dev_desc_fd); } sc->sc_delayed_arp = -1; } if (advbase != 255 || advskew != 255) { timeradd(&now, &tv, &sc->sc_ad_tmo); /* IPv6 ? */ } } static void carp_send_ad_all(struct carp_softc *sc) { carp_send_ad(sc); } static void carp_setrun(struct carp_softc *sc, sa_family_t af) { struct timeval tv; logfile(LOG_DEBUG, "carp_setrun()"); if (gettimeofday(&now, NULL) != 0) { logfile(LOG_WARNING, _("initializing now to gettimeofday() failed: %s"), strerror(errno)); } switch (sc->sc_state) { case INIT: carp_set_state(sc, BACKUP); carp_setrun(sc, 0); break; case BACKUP: sc->sc_ad_tmo.tv_sec = 0; tv.tv_sec = (unsigned int) sc->sc_advbase * dead_ratio; tv.tv_usec = (unsigned int) (sc->sc_advskew * 1000000ULL / 256ULL); switch (af) { case AF_INET: timeradd(&now, &tv, &sc->sc_md_tmo); break; #ifdef INET6 case AF_INET6: timeradd(&now, &tv, &sc->sc_md6_tmo); break; #endif /* INET6 */ default: timeradd(&now, &tv, &sc->sc_md_tmo); #ifdef INET6 timeradd(&now, &tv, &sc->sc_md6_tmo); #endif break; } break; case MASTER: tv.tv_sec = (unsigned int) sc->sc_advbase; tv.tv_usec = (unsigned int) (sc->sc_advskew * 1000000ULL / 256ULL); timeradd(&now, &tv, &sc->sc_md_tmo); /* No IPv6 scheduling ? */ break; } } static void carp_master_down(struct carp_softc *sc) { logfile(LOG_DEBUG, "carp_master_down()"); switch (sc->sc_state) { case INIT: logfile(LOG_DEBUG, _("master_down event in INIT state")); break; case MASTER: break; case BACKUP: carp_set_state(sc, MASTER); carp_send_ad(sc); /* Schedule a delayed ARP request to deal w/ some L3 switches */ sc->sc_delayed_arp = 2; #ifdef INET6 carp_send_na(sc); #endif /* INET6 */ carp_setrun(sc, 0); break; } } static void packethandler(unsigned char *dummy, const struct pcap_pkthdr *header, const unsigned char *sp) { struct ether_header etherhead; struct ip iphead; unsigned int source; unsigned int dest; unsigned char proto; unsigned int caplen; unsigned int ip_len; (void) dummy; if (header->caplen <= (sizeof etherhead + sizeof iphead)) { return; } memcpy(ðerhead, sp, sizeof etherhead); logfile(LOG_DEBUG, "Ethernet " "[%02x:%02x:%02x:%02x:%02x:%02x]->[%02x:%02x:%02x:%02x:%02x:%02x] " "type [%04x]", (unsigned int) etherhead.ether_shost[0], (unsigned int) etherhead.ether_shost[1], (unsigned int) etherhead.ether_shost[2], (unsigned int) etherhead.ether_shost[3], (unsigned int) etherhead.ether_shost[4], (unsigned int) etherhead.ether_shost[5], (unsigned int) etherhead.ether_dhost[0], (unsigned int) etherhead.ether_dhost[1], (unsigned int) etherhead.ether_dhost[2], (unsigned int) etherhead.ether_dhost[3], (unsigned int) etherhead.ether_dhost[4], (unsigned int) etherhead.ether_dhost[5], (unsigned int) ntohs(etherhead.ether_type)); sp += sizeof etherhead; caplen = header->caplen - sizeof etherhead; memcpy(&iphead, sp, sizeof iphead); if (iphead.ip_src.s_addr == srcip.s_addr) { return; } ip_len = iphead.ip_hl << 2; source = ntohl(iphead.ip_src.s_addr); dest = ntohl(iphead.ip_dst.s_addr); proto = iphead.ip_p; switch (proto) { case IPPROTO_CARP: { struct carp_header ch; unsigned long long tmp_counter; struct timeval sc_tv; struct timeval ch_tv; logfile(LOG_DEBUG, "\n---------------------------\n\n" "carp [%d.%d.%d.%d] -> [%d.%d.%d.%d]", source >> 24 & 0xff, source >> 16 & 0xff, source >> 8 & 0xff, source & 0xff, dest >> 24 & 0xff, dest >> 16 & 0xff, dest >> 8 & 0xff, dest & 0xff); if (caplen < ip_len + sizeof ch) { logfile(LOG_DEBUG, "Bogus size: caplen=[%u], ip_len=[%u] ch_len=[%u]", (unsigned int) caplen, (unsigned int) ip_len, (unsigned int) sizeof ch); return; } memcpy(&ch, sp + ip_len, sizeof ch); #ifdef EXTRA_DEBUG logfile(LOG_DEBUG, "Capture len: [%u] carp_header: [%u] ip_header: [%u]", (unsigned int) caplen, (unsigned int) sizeof ch, (unsigned int) ip_len); logfile(LOG_DEBUG, "CARP type: [%u] version: [%u]", (unsigned) ch.carp_type, (unsigned) ch.carp_version); logfile(LOG_DEBUG, "CARP vhid: [%u] advskew: [%u]", (unsigned) ch.carp_vhid, (unsigned) ch.carp_advskew); logfile(LOG_DEBUG, "CARP advbase: [%u] cksum: [%u]", (unsigned) ch.carp_advbase, (unsigned) ch.carp_cksum); logfile(LOG_DEBUG, "CARP counter: [%lu][%lu]", (unsigned long) ch.carp_counter[0], (unsigned long) ch.carp_counter[1]); #endif if (iphead.ip_ttl != CARP_DFLTTL) { logfile(LOG_WARNING, _("Bad TTL: [%u]"), (unsigned int) iphead.ip_ttl); return; } if (ch.carp_version != CARP_VERSION) { logfile(LOG_WARNING, _("Bad version: [%u]"), (unsigned int) ch.carp_version); return; } if (ch.carp_vhid != vhid) { logfile(LOG_DEBUG, _("Ignoring vhid: [%u]"), (unsigned int) ch.carp_vhid); return; } if (iphead.ip_dst.s_addr != mcastip.s_addr) { logfile(LOG_DEBUG, _("Ignoring different multicast ip: [%s]"), inet_ntoa(iphead.ip_dst)); return; } if (cksum(sp, ip_len + sizeof ch) != 0) { logfile(LOG_WARNING, _("Bad IP checksum")); return; } { SHA1_CTX ctx; unsigned char md2[20]; memcpy(&ctx, &sc.sc_sha1, sizeof ctx); SHA1Update(&ctx, (void *) &ch.carp_counter, sizeof ch.carp_counter); SHA1Final(md2, &ctx); SHA1Init(&ctx); SHA1Update(&ctx, sc.sc_pad, sizeof(sc.sc_pad)); SHA1Update(&ctx, md2, sizeof md2); SHA1Final(md2, &ctx); if (sizeof md2 != sizeof ch.carp_md) { logfile(LOG_ERR, "sizeof md2 != sizeof carp_md !!!"); abort(); } if (memcmp(md2, ch.carp_md, sizeof md2) != 0) { logfile(LOG_WARNING, _("Bad digest - " "md2=[%02x%02x%02x%02x...] md=[%02x%02x%02x%02x...] - " "Check vhid, password and virtual IP address"), (unsigned int) md2[0], (unsigned int) md2[1], (unsigned int) md2[2], (unsigned int) md2[3], (unsigned int) (ch.carp_md)[0], (unsigned int) (ch.carp_md)[1], (unsigned int) (ch.carp_md)[2], (unsigned int) (ch.carp_md)[3]); return; } } tmp_counter = ntohl(ch.carp_counter[0]); tmp_counter = tmp_counter << 32; tmp_counter += ntohl(ch.carp_counter[1]); sc.sc_init_counter = 0; sc.sc_counter = tmp_counter; sc_tv.tv_sec = (unsigned int) sc.sc_advbase; if (carp_suppress_preempt != 0 && sc.sc_advskew < CARP_BULK_UPDATE_MIN_DELAY) { sc_tv.tv_usec = (unsigned int) (CARP_BULK_UPDATE_MIN_DELAY * 1000000ULL / 256ULL); } else { sc_tv.tv_usec = (unsigned int) (sc.sc_advskew * 1000000ULL / 256ULL); } ch_tv.tv_sec = (unsigned int) ch.carp_advbase; ch_tv.tv_usec = (unsigned int) (ch.carp_advskew * 1000000ULL / 256ULL); logfile(LOG_DEBUG, "sc_tv(local) = [%lu] ch_tv(remote) = [%lu]", (unsigned long) sc_tv.tv_sec, (unsigned long) ch_tv.tv_sec); switch (sc.sc_state) { case INIT: break; case MASTER: /* * If we receive an advertisement from a master who's going to * be more frequent than us, or from a master who's advertising * with the same frequency as us but with a lower IP address, * go into BACKUP state. */ if (timercmp(&sc_tv, &ch_tv, >) || (timercmp(&sc_tv, &ch_tv, ==) && iphead.ip_src.s_addr < srcip.s_addr)) { /* To be really sure the new master knows that is * has to reassert control of the VIP */ carp_send_ad(&sc); carp_set_state(&sc, BACKUP); carp_setrun(&sc, 0); logfile(LOG_WARNING, _("Preferred master advertised: " "going back to BACKUP state")); } /* * If we receive an advertisement from a master who's advertising * less frequently than us, or with the same frequency as us but * with a higher IP address, reassert our dominance by issuing * another gratuitous arp. */ if (timercmp(&sc_tv, &ch_tv, <) || (timercmp(&sc_tv, &ch_tv, ==) && iphead.ip_src.s_addr > srcip.s_addr)) { gratuitous_arp(dev_desc_fd); sc.sc_delayed_arp = 2; /* and yet another in 2 ticks */ logfile(LOG_WARNING, _("Non-preferred master advertising: " "reasserting control of VIP with another gratuitous arp")); } break; case BACKUP: /* * If we're pre-empting masters who advertise slower than us, * and this one claims to be slower, treat him as down. */ if (preempt != 0 && timercmp(&sc_tv, &ch_tv, <)) { carp_master_down(&sc); logfile(LOG_WARNING, _("Putting MASTER down - preemption")); break; } /* * If the master is going to advertise at such a low frequency * that he's guaranteed to time out, we'd might as well just * treat him as timed out now. */ sc_tv.tv_sec = (unsigned int) sc.sc_advbase * dead_ratio; if (timercmp(&sc_tv, &ch_tv, <)) { carp_master_down(&sc); logfile(LOG_WARNING, _("Putting MASTER DOWN (going to time out)")); break; } /* * Otherwise, we reset the counter and wait for the next * advertisement. */ carp_setrun(&sc, AF_INET); /* XXX - TODO was af */ break; } break; } default: return; } } static RETSIGTYPE sighandler_exit(const int sig) { received_signal=15; } static RETSIGTYPE sighandler_usr(const int sig) { switch (sig) { case SIGUSR1: received_signal=1; break; case SIGUSR2: received_signal=2; break; } } static char *build_bpf_rule(void) { static char rule[256]; const char *srcip_s; if ((srcip_s = inet_ntoa(srcip)) == NULL) { logfile(LOG_ERR, "inet_ntoa: [%s]", strerror(errno)); return NULL; } snprintf(rule, sizeof rule, "proto %u and src host not %s", (unsigned int) IPPROTO_CARP, srcip_s); logfile(LOG_DEBUG, "BPF rule: [%s]", rule); return rule; } int docarp(void) { char errbuf[PCAP_ERRBUF_SIZE]; struct ip_mreq req_add; struct bpf_program bpfp; struct pollfd pfds[1]; struct ifreq iface; int fd; int nfds; int iface_running = 1; int poll_sleep_time; struct timeval time_until_advert; struct sigaction usr_action; struct sigaction term_action; sc.sc_vhid = vhid; sc.sc_advbase = advbase; sc.sc_advskew = advskew; sc.sc_init_counter = 1; sc.sc_delayed_arp = -1; #ifdef INET6 sc.sc_im6o.im6o_multicast_hlim = CARP_DFLTTL; #endif /* INET6 */ carp_set_state(&sc, INIT); { const size_t passlen = strlen(pass) + (size_t) 1U; if (passlen > sizeof sc.sc_key) { logfile(LOG_ERR, _("Password too long")); return -1; } memcpy(sc.sc_key, pass, passlen); } sc.sc_ad_tmo.tv_sec = 0; sc.sc_ad_tmo.tv_usec = 0; sc.sc_md_tmo.tv_sec = 0; sc.sc_md6_tmo.tv_usec = 0; carp_hmac_prepare(&sc); if (fill_mac_address() != 0) { logfile(LOG_ERR, _("Unable to find MAC address of [%s]"), interface == NULL ? "-" : interface); return -1; } logfile(LOG_INFO, _("Local advertised ethernet address is " "[%02x:%02x:%02x:%02x:%02x:%02x]"), (unsigned int) hwaddr[0], (unsigned int) hwaddr[1], (unsigned int) hwaddr[2], (unsigned int) hwaddr[3], (unsigned int) hwaddr[4], (unsigned int) hwaddr[5]); if ((dev_desc = pcap_open_live(interface, ETHERNET_MTU, 0, CAPTURE_TIMEOUT, errbuf)) == NULL) { logfile(LOG_ERR, _("Unable to open interface [%s]: %s"), interface == NULL ? "-" : interface, errbuf); return -1; } if (pcap_compile(dev_desc, &bpfp, build_bpf_rule(), 1, (bpf_u_int32) 0) != 0) { logfile(LOG_ERR, _("Unable to compile pcap rule: %s [%s]"), errbuf, interface == NULL ? "-" : interface); return -1; } pcap_setfilter(dev_desc, &bpfp); dev_desc_fd = pcap_fileno(dev_desc); pfds[0].fd = dev_desc_fd; pfds[0].events = POLLIN | POLLERR | POLLHUP; if (shutdown_at_exit != 0) { (void) sigemptyset(&term_action.sa_mask); term_action.sa_handler = sighandler_exit; term_action.sa_flags = SA_NODEFER; if (sigaction(SIGINT, &term_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGINT handler: %s", strerror(errno)); return -1; } if (sigaction(SIGQUIT, &term_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGQUIT handler: %s", strerror(errno)); return -1; } if (sigaction(SIGTERM, &term_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGTERM handler: %s", strerror(errno)); return -1; } if (sigaction(SIGHUP, &term_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGHUP handler: %s", strerror(errno)); return -1; } } (void) sigemptyset(&usr_action.sa_mask); usr_action.sa_handler = sighandler_usr; usr_action.sa_flags = SA_NODEFER; if (sigaction(SIGUSR1, &usr_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGUSR1 handler: %s", strerror(errno)); return -1; } if (sigaction(SIGUSR2, &usr_action, NULL) < 0) { logfile(LOG_ERR, "Error when trying register SIGUSR2 handler: %s", strerror(errno)); return -1; } if (gettimeofday(&now, NULL) != 0) { logfile(LOG_WARNING, _("initializing now to gettimeofday() failed: %s"), strerror(errno)); } carp_setrun(&sc, 0); if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { logfile(LOG_ERR, _("Error opening socket for interface [%s]: %s"), interface == NULL ? "-" : interface, strerror(errno)); return -1; } if (!no_mcast) { memset(&req_add, 0, sizeof req_add); req_add.imr_multiaddr.s_addr = mcastip.s_addr; req_add.imr_interface.s_addr = srcip.s_addr; if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &req_add, sizeof req_add) < 0) { logfile(LOG_ERR, "Can't do IP_ADD_MEMBERSHIP errno=%s (%d)", strerror(errno), errno); close(fd); return -1; } } #ifdef SIOCGIFFLAGS if (strlen(interface) >= sizeof iface.ifr_name) { logfile(LOG_ERR, _("Interface name too long")); return -1; } strncpy(iface.ifr_name, interface, sizeof iface.ifr_name); #endif for (;;) { #ifdef SIOCGIFFLAGS if (ioctl(fd, SIOCGIFFLAGS, &iface) != 0) { break; } if ((iface.ifr_flags & IFF_RUNNING) == 0) { if (ignoreifstate == 0) { carp_set_state(&sc, BACKUP); sc.sc_ad_tmo.tv_sec = 0; sc.sc_ad_tmo.tv_usec = 0; sc.sc_md_tmo.tv_sec = 0; sc.sc_md6_tmo.tv_usec = 0; if (iface_running) { iface_running = 0; } sleep(SECONDS_TO_WAIT_AFTER_INTERFACE_IS_DOWN); continue; } } else { if (!iface_running) { iface_running = 1; carp_setrun(&sc, 0); } } #endif if (received_signal != 0) { int flag = received_signal; received_signal = 0; switch (flag) { case 1: logfile(LOG_INFO, "%s on %s id %d", (sc.sc_state == BACKUP ? "BACKUP" : "MASTER"), interface, sc.sc_vhid); break; case 2: logfile(LOG_DEBUG, "Caught signal (USR2) considering going down"); if (sc.sc_state != BACKUP) { carp_set_state(&sc, BACKUP); sleep(3); /* hold up a sec... */ carp_setrun(&sc, 0); /* now listen for 3 heartbeats, as usual */ continue; } break; case 15: logfile(LOG_DEBUG, "sighandler_exit(): Calling [%s] and exiting", downscript); if (sc.sc_state != BACKUP) { (void) spawn_handler(dev_desc_fd, downscript); } _exit(EXIT_SUCCESS); break; } } if (sc.sc_ad_tmo.tv_sec == 0) { unsigned int tmpskew = advskew * 1000 / 256; poll_sleep_time = sc.sc_advbase * 1000 + tmpskew; } else { if (gettimeofday(&now, NULL) != 0) { logfile(LOG_WARNING, _("gettimeofday() failed: %s"), strerror(errno)); continue; } timersub(&sc.sc_ad_tmo, &now, &time_until_advert); poll_sleep_time = (time_until_advert.tv_sec * 1000) + (time_until_advert.tv_usec / 1000); } nfds = poll(pfds, (nfds_t) 1, MAX(1, poll_sleep_time)); if (nfds == -1) { if (errno == EINTR) { continue; } logfile(LOG_ERR, _("exiting: poll() error: %s"), strerror(errno)); } if ((pfds[0].revents & (POLLERR | POLLHUP)) != 0) { logfile(LOG_ERR, _("exiting: pfds[0].revents = %d"), pfds[0].revents); if ((sc.sc_state != BACKUP) && (shutdown_at_exit != 0)) { (void) spawn_handler(dev_desc_fd, downscript); } break; } if (gettimeofday(&now, NULL) != 0) { logfile(LOG_WARNING, _("gettimeofday() failed: %s"), strerror(errno)); continue; } if (nfds == 1) { pcap_dispatch(dev_desc, 1, packethandler, NULL); } if (sc.sc_md_tmo.tv_sec != 0 && timercmp(&now, &sc.sc_md_tmo, >)) { carp_master_down(&sc); } #ifdef INET6 if (sc.sc_md6_tmo.tv_sec != 0 && timercmp(&now, &sc.sc_md6_tmo, >)) { carp_master_down(&sc); } #endif if (sc.sc_ad_tmo.tv_sec != 0) { if (timercmp(&now, &sc.sc_ad_tmo, >)) { carp_send_ad(&sc); } else { timersub(&sc.sc_ad_tmo, &now, &time_until_advert); int diff_ms = (time_until_advert.tv_sec * 1000) + (time_until_advert.tv_usec / 1000); if (abs(diff_ms) <= 1) { carp_send_ad(&sc); } } } } pcap_close(dev_desc); pcap_freecode(&bpfp); return 0; } ucarp-1.5.2+git20192404.1a9aaf7/src/ip_carp.h0000644000175000017500000001422413460025251017640 0ustar gxaviergxavier/* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. * Copyright (c) 2003 Ryan McBride. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ /* * The CARP header layout is as follows: * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |Version| Type | VirtualHostID | AdvSkew | Auth Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Reserved | AdvBase | Checksum | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Counter (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Counter (2) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SHA-1 HMAC (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SHA-1 HMAC (2) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SHA-1 HMAC (3) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SHA-1 HMAC (4) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SHA-1 HMAC (5) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ #ifndef __IP_CARP_H__ #define __IP_CARP_H__ 1 struct carp_header { #ifdef WORDS_BIGENDIAN u_int8_t carp_version:4, carp_type:4; #else u_int8_t carp_type:4, carp_version:4; #endif u_int8_t carp_vhid; /* virtual host id */ u_int8_t carp_advskew; /* advertisement skew */ u_int8_t carp_authlen; /* size of counter+md, 32bit chunks */ u_int8_t carp_pad1; /* reserved */ u_int8_t carp_advbase; /* advertisement interval */ u_int16_t carp_cksum; u_int32_t carp_counter[2]; unsigned char carp_md[20]; /* SHA1 HMAC */ } __packed; #define CARP_DFLTTL 255 /* carp_version */ #define CARP_VERSION 2 /* carp_type */ #define CARP_ADVERTISEMENT 0x01 #define CARP_KEY_LEN 20 /* a sha1 hash of a passphrase */ /* carp_advbase */ #define CARP_DFLTINTV 1 #define CARP_BULK_UPDATE_MIN_DELAY 240 /* * Statistics. */ struct carpstats { u_int64_t carps_ipackets; /* total input packets, IPv4 */ u_int64_t carps_ipackets6; /* total input packets, IPv6 */ u_int64_t carps_badif; /* wrong interface */ u_int64_t carps_badttl; /* TTL is not CARP_DFLTTL */ u_int64_t carps_hdrops; /* packets shorter than header */ u_int64_t carps_badsum; /* bad checksum */ u_int64_t carps_badver; /* bad (incl unsupp) version */ u_int64_t carps_badlen; /* data length does not match */ u_int64_t carps_badauth; /* bad authentication */ u_int64_t carps_badvhid; /* bad VHID */ u_int64_t carps_badaddrs; /* bad address list */ u_int64_t carps_opackets; /* total output packets, IPv4 */ u_int64_t carps_opackets6; /* total output packets, IPv6 */ u_int64_t carps_onomem; /* no memory for an mbuf */ u_int64_t carps_ostates; /* total state updates sent */ u_int64_t carps_preempt; /* if enabled, preemptions */ }; /* * Configuration structure for SIOCSVH SIOCGVH */ struct carpreq { int carpr_state; #define CARP_STATES "INIT", "BACKUP", "MASTER" #define CARP_MAXSTATE 2 int carpr_vhid; int carpr_advskew; int carpr_advbase; unsigned char carpr_key[CARP_KEY_LEN]; }; #define SIOCSVH _IOWR('i', 245, struct ifreq) #define SIOCGVH _IOWR('i', 246, struct ifreq) /* * Names for CARP sysctl objects */ #define CARPCTL_ALLOW 1 /* accept incoming CARP packets */ #define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */ #define CARPCTL_LOG 3 /* log bad packets */ #define CARPCTL_ARPBALANCE 4 /* balance arp responses */ #define CARPCTL_MAXID 5 #define CARPCTL_NAMES { \ { 0, 0 }, \ { "allow", CTLTYPE_INT }, \ { "preempt", CTLTYPE_INT }, \ { "log", CTLTYPE_INT }, \ { "arpbalance", CTLTYPE_INT }, \ } #endif ucarp-1.5.2+git20192404.1a9aaf7/src/ucarp.c0000644000175000017500000002232013460025251017324 0ustar gxaviergxavier #define DEFINE_GLOBALS 1 #include #include "ucarp.h" #ifndef HAVE_GETOPT_LONG # include "bsd-getopt_long.h" #else # include #endif #ifdef HAVE_SETLOCALE # include #endif #include "log.h" #include "daemonize.h" #include "ucarp_p.h" #ifdef WITH_DMALLOC # include #endif static void usage(void) { puts("\n" PACKAGE_STRING " - " __DATE__ "\n"); fputs(_( "--interface= (-i ): bind interface \n" "--srcip= (-s ): source (real) IP address of that host\n" "--mcast= (-m ): multicast group IP address (default 224.0.0.18)\n" "--vhid= (-v ): virtual IP identifier (1-255)\n" "--pass= (-p ): password\n" "--passfile= (-o ): read password from file\n" "--preempt (-P): becomes a master as soon as possible\n" "--neutral (-n): don't run downscript at start if backup\n" "--addr= (-a ): virtual shared IP address\n" "--help (-h): summary of command-line options\n" "--advbase= (-b ): advertisement frequency\n" "--advskew= (-k ): advertisement skew (0-255)\n" "--upscript= (-u ): run to become a master\n" "--downscript= (-d ): run to become a backup\n" "--deadratio= (-r ): ratio to consider a host as dead\n" "--debug (-D): enable debug output\n" "--shutdown (-z): call shutdown script at exit\n" "--daemonize (-B): run in background\n" "--ignoreifstate (-S): ignore interface state (down, no carrier)\n" "--nomcast (-M): use broadcast (instead of multicast) advertisements\n" "--facility= (-f): set syslog facility (default=daemon)\n" "--xparam= (-x): extra parameter to send to up/down scripts\n" "\n" "Sample usage:\n" "\n" "Manage the 10.1.1.252 shared virtual address on interface eth0, with\n" "1 as a virtual address idenfitier, mypassword as a password, and\n" "10.1.1.1 as a real permanent address for this host.\n" "Call /etc/vip-up.sh when the host becomes a master, and\n" "/etc/vip-down.sh when the virtual IP address has to be disabled.\n" "\n" "ucarp --interface=eth0 --srcip=10.1.1.1 --vhid=1 --pass=mypassword \\\n" " --addr=10.1.1.252 \\\n" " --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh\n" "\n\n" "Please report bugs to "), stdout); puts(PACKAGE_BUGREPORT ".\n"); exit(EXIT_SUCCESS); } static void init_rand(void) { struct timeval tv; gettimeofday(&tv, NULL); #ifdef HAVE_SRANDOMDEV srandomdev(); #elif defined(HAVE_RANDOM) srandom((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ (getpid() << 16))); #else srand((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ (getpid() << 16))); #endif } static void die_mem(void) { logfile(LOG_ERR, _("Out of memory")); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { int option_index = 0; int fodder; #ifdef HAVE_SETLOCALE setlocale(LC_ALL, ""); #endif bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); if (argc <= 1) { usage(); } inet_pton(AF_INET, DEFAULT_MCASTIP, &mcastip); while ((fodder = getopt_long(argc, argv, GETOPT_OPTIONS, long_options, &option_index)) != -1) { switch (fodder) { case 'h': { usage(); } case 'i': { free(interface); if ((interface = strdup(optarg)) == NULL) { die_mem(); } break; } case 's': { if (inet_pton(AF_INET, optarg, &srcip) == 0) { logfile(LOG_ERR, _("Invalid address: [%s]"), optarg); return 1; } break; } case 'm': { if (inet_pton(AF_INET, optarg, &mcastip) == 0) { logfile(LOG_ERR, _("Invalid address: [%s]"), optarg); return 1; } break; } case 'v': { if (strtoul(optarg, NULL, 0) > 255 || strtol(optarg, NULL, 0) < 1) { logfile(LOG_ERR, _("vhid must be between 1 and 255.")); return 1; } vhid = (unsigned char) strtoul(optarg, NULL, 0); break; } case 'p': { free(pass); if ((pass = strdup(optarg)) == NULL) { die_mem(); } break; } case 'o': { char buf[512U]; char *p; FILE *pw; if ((pw = fopen(optarg, "r")) == NULL) { logfile(LOG_ERR, _("unable to open passfile %s for reading: %s"), optarg, strerror(errno)); return 1; } if (fgets(buf, sizeof buf, pw) == NULL) { logfile(LOG_ERR, _("error reading passfile %s: %s"), optarg, ferror(pw) ? strerror(errno) : _("unexpected end of file")); fclose(pw); return 1; } fclose(pw); p = strchr(buf, '\n'); if (p != NULL) { *p = 0; } if ((pass = strdup(buf)) == NULL) { die_mem(); } break; } case 'P': { preempt = 1; break; } case 'n': { neutral = 1; break; } case 'a': { free(vaddr_arg); if (inet_pton(AF_INET, optarg, &vaddr) == 0) { logfile(LOG_ERR, _("Invalid address: [%s]"), optarg); return 1; } vaddr_arg = strdup(optarg); break; } case 'b': { advbase = (unsigned char) strtoul(optarg, NULL, 0); break; } case 'k': { advskew = (unsigned char) strtoul(optarg, NULL, 0); break; } case 'd': { free(downscript); if ((downscript = strdup(optarg)) == NULL) { die_mem(); } break; } case 'D': { debug = 1; break; } case 'u': { free(upscript); if ((upscript = strdup(optarg)) == NULL) { die_mem(); } break; } case 'r': { dead_ratio = (unsigned int) strtoul(optarg, NULL, 0); break; } case 'z': { shutdown_at_exit = 1; break; } case 'B': { daemonize = 1; break; } case 'S': { ignoreifstate = 1; break; } case 'f': { int n = 0; if (strcasecmp(optarg, "none") == 0) { no_syslog = 1; break; } while (facilitynames[n].c_name && strcasecmp(facilitynames[n].c_name, optarg) != 0) { n++; } if (facilitynames[n].c_name) { syslog_facility = facilitynames[n].c_val; } else { logfile(LOG_ERR, _("Unknown syslog facility: [%s]"), optarg); } break; } case 'x': { free(xparam); if ((xparam = strdup(optarg)) == NULL) { die_mem(); } break; } case 'M': { no_mcast = 1; break; } default: { usage(); } } } #ifndef SAVE_DESCRIPTORS if (no_syslog == 0) { openlog("ucarp", LOG_PID, syslog_facility); } #endif if (interface == NULL || *interface == 0) { interface = pcap_lookupdev(NULL); if (interface == NULL || *interface == 0) { logfile(LOG_ERR, _("You must supply a network interface")); return 1; } logfile(LOG_INFO, _("Using [%s] as a network interface"), interface); } if (vhid == 0) { logfile(LOG_ERR, _("You must supply a valid virtual host id")); return 1; } if (pass == NULL || *pass == 0) { logfile(LOG_ERR, _("You must supply a password")); return 1; } if (advbase == 0 && advskew == 0) { logfile(LOG_ERR, _("You must supply an advertisement time base")); return 1; } if (srcip.s_addr == 0) { logfile(LOG_ERR, _("You must supply a persistent source address")); return 1; } if (vaddr.s_addr == 0) { logfile(LOG_ERR, _("You must supply a virtual host address")); return 1; } if (upscript == NULL) { logfile(LOG_WARNING, _("Warning: no script called when going up")); } if (downscript == NULL) { logfile(LOG_WARNING, _("Warning: no script called when going down")); } if (dead_ratio <= 0U) { logfile(LOG_ERR, _("Dead ratio can't be zero")); return 1; } dodaemonize(); init_rand(); if (docarp() != 0) { return 2; } #ifndef SAVE_DESCRIPTORS if (no_syslog == 0) { closelog(); } #endif return 0; } ucarp-1.5.2+git20192404.1a9aaf7/src/ucarp.h0000644000175000017500000001074213460025251017336 0ustar gxaviergxavier#ifndef __UCARP_H__ #define __UCARP_H__ 1 #include #ifdef STDC_HEADERS # include # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #else # if HAVE_STRINGS_H # include # endif #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include #include #ifdef HAVE_FCNTL_H # include #elif defined(HAVE_SYS_FCNTL_H) # include #endif #ifdef HAVE_IOCTL_H # include #elif defined(HAVE_SYS_IOCTL_H) # include #endif #include #ifdef HAVE_NETINET_IN_H # include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H # include #endif #include #include #include #include #include #ifdef __sun__ # define u_int8_t uint8_t # define u_int16_t uint16_t # define u_int32_t uint32_t # define u_int64_t uint64_t # define ether_shost ether_shost.ether_addr_octet # define ether_dhost ether_dhost.ether_addr_octet #endif #include "gettext.h" #define _(txt) gettext(txt) #define N_(txt) txt #include "mysnprintf.h" #include "crypto.h" #ifndef USE_SYSTEM_CRYPT_SHA1 # include "crypto-sha1.h" #else # include #endif #include "ip_carp.h" #ifndef errno extern int errno; #endif #ifdef HAVE_ALLOCA # ifdef HAVE_ALLOCA_H # include # endif # define ALLOCA(X) alloca(X) # define ALLOCA_FREE(X) do { } while (0) #else # define ALLOCA(X) malloc(X) # define ALLOCA_FREE(X) free(X) #endif #ifdef DEFINE_GLOBALS # define SYSLOG_NAMES 1 /* for -f */ #endif #include #ifndef HAVE_SYSLOG_NAMES # include "syslognames.h" #endif #ifndef MAX_SYSLOG_LINE # define MAX_SYSLOG_LINE 4096U #endif #ifndef __GNUC__ # define __packed__ #endif #define ETHERNET_MTU 1500 #ifndef ETHER_ADDR_LEN # define ETHER_ADDR_LEN 6 #endif #ifndef IPPROTO_CARP # define IPPROTO_CARP 112 #endif #ifndef timercmp # define timercmp(tvp, uvp, cmp) \ (((tvp)->tv_sec == (uvp)->tv_sec) ? \ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ ((tvp)->tv_sec cmp (uvp)->tv_sec)) #endif #ifndef HAVE_SETEUID # ifdef HAVE_SETREUID # define seteuid(X) setreuid(-1, (X)) # elif defined(HAVE_SETRESUID) # define seteuid(X) setresuid(-1, (X), -1) # else # define seteuid(X) (-1) # endif #endif #ifndef HAVE_SETEGID # ifdef HAVE_SETREGID # define setegid(X) setregid(-1, (X)) # elif defined(HAVE_SETRESGID) # define setegid(X) setresgid(-1, (X), -1) # else # define setegid(X) (-1) # endif #endif #ifndef HAVE_STRTOULL # ifdef HAVE_STRTOQ # define strtoull(X, Y, Z) strtoq(X, Y, Z) # else # define strtoull(X, Y, Z) strtoul(X, Y, Z) # endif #endif #ifndef ULONG_LONG_MAX # define ULONG_LONG_MAX (1ULL << 63) #endif #ifdef WITH_DMALLOC # define _exit(X) exit(X) #endif #define CAPTURE_TIMEOUT 1000 #ifndef MAX #define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif struct carp_softc { int if_flags; /* current flags to treat UP/DOWN */ struct ifnet *sc_ifp; struct in_ifaddr *sc_ia; /* primary iface address */ #ifdef INET6 struct in6_ifaddr *sc_ia6; /* primary iface address v6 */ struct ip6_moptions sc_im6o; #endif /* INET6 */ enum { INIT = 0, BACKUP, MASTER } sc_state; int sc_flags_backup; int sc_suppress; int sc_sendad_errors; #define CARP_SENDAD_MAX_ERRORS 3 int sc_sendad_success; #define CARP_SENDAD_MIN_SUCCESS 3 int sc_vhid; int sc_advskew; int sc_naddrs; int sc_naddrs6; int sc_advbase; /* seconds */ int sc_init_counter; u_int64_t sc_counter; int sc_delayed_arp; /* authentication */ #define CARP_HMAC_PAD 64 unsigned char sc_key[CARP_KEY_LEN]; unsigned char sc_pad[CARP_HMAC_PAD]; SHA1_CTX sc_sha1; struct timeval sc_ad_tmo; /* advertisement timeout */ struct timeval sc_md_tmo; /* master down timeout */ struct timeval sc_md6_tmo; /* master down timeout */ }; #define CARP_AUTHLEN 7 #define DEFAULT_ADVBASE 1U #define DEFAULT_DEAD_RATIO 3U #define DEFAULT_MCASTIP "224.0.0.18" #define SECONDS_TO_WAIT_AFTER_INTERFACE_IS_DOWN 10U #define DEFAULT_FACILITY LOG_DAEMON int docarp(void); #include "globals.h" #endif ucarp-1.5.2+git20192404.1a9aaf7/examples/0000755000175000017500000000000013460025251017076 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/examples/bsd/0000755000175000017500000000000013460025251017646 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/examples/bsd/Makefile.am0000644000175000017500000000005113460025251021676 0ustar gxaviergxavierEXTRA_DIST = \ vip-up.sh \ vip-down.sh ucarp-1.5.2+git20192404.1a9aaf7/examples/bsd/vip-up.sh0000755000175000017500000000012513460025251021423 0ustar gxaviergxavier#! /bin/sh exec 2> /dev/null /sbin/ifconfig "$1" alias "$2" netmask 255.255.255.255 ucarp-1.5.2+git20192404.1a9aaf7/examples/bsd/vip-down.sh0000755000175000017500000000007613460025251021753 0ustar gxaviergxavier#! /bin/sh exec 2> /dev/null /sbin/ifconfig "$1" -alias "$2" ucarp-1.5.2+git20192404.1a9aaf7/examples/Makefile.am0000644000175000017500000000004313460025251021127 0ustar gxaviergxavierSUBDIRS = \ linux \ bsd ucarp-1.5.2+git20192404.1a9aaf7/examples/linux/0000755000175000017500000000000013460025251020235 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/examples/linux/Makefile.am0000644000175000017500000000005113460025251022265 0ustar gxaviergxavierEXTRA_DIST = \ vip-up.sh \ vip-down.sh ucarp-1.5.2+git20192404.1a9aaf7/examples/linux/vip-up.sh0000755000175000017500000000021413460025251022011 0ustar gxaviergxavier#! /bin/sh exec 2> /dev/null /sbin/ip addr add "$2"/24 dev "$1" # or alternatively: # /sbin/ifconfig "$1":254 "$2" netmask 255.255.255.0 ucarp-1.5.2+git20192404.1a9aaf7/examples/linux/vip-down.sh0000755000175000017500000000016513460025251022341 0ustar gxaviergxavier#! /bin/sh exec 2> /dev/null /sbin/ip addr del "$2"/24 dev "$1" # or alternatively: # /sbin/ifconfig "$1":254 down ucarp-1.5.2+git20192404.1a9aaf7/ChangeLog0000644000175000017500000000723113460025251017035 0ustar gxaviergxavier * Version 1.5.2: - Uses arc4random() if available. - Avoids adverts that might be twice as what they should be. By Steve Kehlet. * Version 1.5.1: - New option (--nomcast / -M) to use broadcast advertisements instead of multicast ones. By Steve Kehlet. - autotools update. * Version 1.5: - Have ucarp register for the VRRP multicast group, by Petr Kohts. - Selection of master improved, by Greg Walton. - New option, -S (--ignoreifstate) to ignore unplugged network cable detection, for NICs that don't support that feature, by Serge Sireskin. - -o is now working as an alternative to --passfile, thanks to Eric Evans. - Have a degraded master send a last advertisement because if its network link gets cut and uncut, it doesn't know that the slave has taken the master role. Contributed by Tim Niemeyer. * Version 1.4: - --xparam shortcut is -m, not -x. Thanks fo Fabrice Dulaunoy. - Use multicast destination address for advertisements instead of broadcasts. Required for some switches. Fabrice Dulaunoy. - gettext upgrade. - Host with the lower IP address wit hnow be elected master when multiples nodes are started with the same parameters, in order to avoid flip-flop. By Steve Kehlet. - Improved gratuitous ARP payload for better interoperability, by Steve Kehlet. - Removed bogus gratuitous ARP code. Initial report by Marcus Goller. - Documentation updates, by Steve Kehlet. * Version 1.3: -n option wasn't properly parsed while --neutral was. Reported by Stefan Behte. gratuitous ARP packets should now be properly sent. Thanks to Marcus Rueckert for indirectly pointing out that the code was wrong. New -m option, and the virtual IP address is now passed to up/down scripts as well. By Fabrice Dulaunoy and Dirk Jagdmann who provided different implementations of the same idea. A bogus return statement has been removed, thanks to Alessio Cervellin. All interfaces should now be discovered on Solaris. EINTR is handled, thanks to Dean Gaudet. Log exec errors, Dean Gaudet. --passfile option, Dean Gaudet. Ignore POLLNVAL that looks bogus on some systems, at least OSX, reported by John Sterling. Send a delayed ARP request when switching to MASTER to deal with some L3 switches (adapted from an OpenBSD diff by mpf at openbsd.org). Completly remove transition path INIT -> MASTER (adapted from an OpenBSD diff by mpf at openbsd.org). * Version 1.2: fakesnprintf/bsd-getopt_long updates from pure-ftpd 1.0.21. Avoid processing our own multicasts. Thanks to Gregory McGarry. --neutral mode, by Russell Mosemann. Avoid low prioritized hosts quickly switching to MASTER at bootup if preemption is enabled. * Version 1.1: 'exec' was removed from sample scripts since it confused some people who tried to add commands afterwards :) Workarounds have been added for unaligned pointers. It should fix crashes on Sparc hardware. logfile() properly sends errors to stderr and notices to stdout. The OpenBSD getopt_long() replacement has been fixed. inet_aton() has been replaced by inet_pton(); self-sent packets are now filtered out. The read timeout for pcap_open_live() has been shortened. Captured ethernet frames sometimes have extra bytes after the IP packet. This case is now properly handled. The interface is no more switched in promiscous mode. MAC addresses are fetched on Solaris and other Solaris portability improvements have been made, thanks to Richard Bellamy. Even in non-preemptive mode, we start to poll for a dead master as soon as we leave the INIT state. Syslog facilities can now be changed through the -f / --syslog switch. * Version 1.0: Finally the first 1.x release :) Thanks to everyone for testing every previous snapshot. ucarp-1.5.2+git20192404.1a9aaf7/configure.ac0000644000175000017500000001526313460025251017555 0ustar gxaviergxavierAC_PREREQ(2.59) AC_INIT([ucarp],[1.5.2]) AC_CONFIG_SRCDIR([src/ucarp.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.9 dist-bzip2]) AC_CONFIG_LIBOBJ_DIR(src) AC_SUBST(VERSION) ISODATE=`date +%Y-%m-%d` AC_SUBST(ISODATE) # Checks for programs. AC_PROG_CC AC_PROG_CC_C_O AC_PROG_CPP AC_USE_SYSTEM_EXTENSIONS AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB AC_PROG_LIBTOOL AC_ISC_POSIX AM_GNU_GETTEXT([external]) # Checks for header files. AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([memory.h strings.h unistd.h netinet/in_systm.h]) AC_CHECK_HEADERS([netinet/in.h stdlib.h string.h sys/socket.h sys/time.h]) AC_CHECK_HEADERS([ifaddrs.h net/if_dl.h net/if_types.h]) AC_CHECK_HEADERS([sys/sockio.h net/if_arp.h], [], [], [[ #include #ifdef HAS_SYS_SOCKET_H #include #endif #ifdef HAS_NETINET_IN_H #include #endif ]]) AC_CHECK_HEADERS([fcntl.h sys/fcntl.h ioctl.h sys/ioctl.h]) dnl Check for endianness AC_C_BIGENDIAN dnl Check for types AC_TYPE_SIGNAL AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_CHECK_TYPE(dev_t, , [AC_DEFINE(dev_t, unsigned int, [dev_t type])], [ #ifdef HAVE_UNISTD_H # include #endif #include #include ]) dnl Check for sizes AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) dnl Socket things AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)]) AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)]) AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)]) if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)]) fi if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then AC_MSG_CHECKING([if we can include libnsl + libsocket]) LIBS="-lnsl -lsocket $LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes], [my_ac_link_result=no]) if test "$my_ac_link_result" = "no" ; then AC_MSG_RESULT([failure]) AC_MSG_ERROR([unable to use gethostbyname()]) else AC_MSG_RESULT([success]) fi fi # Checks for libraries. AC_CHECK_LIB([pcap], [pcap_lookupdev]) dnl Types - continued AC_CHECK_TYPE(socklen_t, , [AC_DEFINE(socklen_t, int, [socklen_t type])], [ #ifdef HAVE_UNISTD_H # include #endif #include #include ]) AC_CHECK_TYPE(ssize_t, , [AC_DEFINE(ssize_t, long int, [ssize_t type])], [ #include #ifdef STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_UNISTD_H # include #endif #include ]) AC_CHECK_TYPE(sig_atomic_t, , [AC_DEFINE(sig_atomic_t, signed char, [sig_atomic_t type])], [ #ifdef HAVE_UNISTD_H # include #endif #include #include ]) AC_CHECK_TYPE(nfds_t, , [AC_DEFINE(nfds_t, unsigned long, [nfds_t type])], [ #ifdef HAVE_UNISTD_H # include #endif #include #include ]) dnl Check for typedefs, structures, and compiler characteristics. AC_PROG_GCC_TRADITIONAL AC_C_CONST AC_C_INLINE dnl Options AC_ARG_WITH(debug, [AS_HELP_STRING(--with-debug,For maintainers only - please do not use)], [ if test "x$withval" = "xyes" ; then CFLAGS="$CFLAGS -DDEBUG=1 -g -Wall -W -Wcast-align -Wbad-function-cast -Wstrict-prototypes -Wwrite-strings -Wreturn-type " fi ]) dnl Checks for library functions. AC_FUNC_ALLOCA AC_FUNC_MEMCMP AC_FUNC_STRFTIME AC_FUNC_STAT AC_FUNC_VPRINTF AC_FUNC_FORK AC_FUNC_WAIT3 AC_CHECK_FUNCS(initgroups setrlimit waitpid setproctitle getopt_long) AC_CHECK_FUNCS(seteuid setreuid setresuid setegid setregid setresgid) AC_CHECK_FUNCS(strtoull strtoq) AC_CHECK_FUNCS(memset munmap strdup fileno) AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_ntop inet_pton) AC_CHECK_FUNCS(snprintf vsnprintf vfprintf gethostname) AC_CHECK_FUNCS(setlocale) AC_CHECK_FUNCS(random srandomdev arc4random) AC_CHECK_FUNCS(getifaddrs) if test "x$sysconfdir" = 'xNONE' || test "x$sysconfdir" = 'x'; then CONFDIR='/etc' else if test "x$sysconfdir" = 'x${prefix}/etc'; then if test "x$prefix" = 'xNONE' || test "x$prefix" = 'x/usr'; then CONFDIR='/etc' else CONFDIR="$sysconfdir" fi else CONFDIR="$sysconfdir" fi fi if test -r /dev/arandom; then AC_MSG_NOTICE([You have /dev/arandom - Great]) AC_DEFINE(HAVE_DEV_ARANDOM,,[Define if you have /dev/arandom]) fi if test -r /dev/urandom; then AC_MSG_NOTICE([You have /dev/urandom - Great]) AC_DEFINE(HAVE_DEV_URANDOM,,[Define if you have /dev/urandom]) fi if test -r /dev/random; then AC_MSG_NOTICE([You have /dev/random - Great]) AC_DEFINE(HAVE_DEV_RANDOM,,[Define if you have /dev/random]) fi AC_MSG_CHECKING(whether snprintf is C99 conformant) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #ifdef STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_UNISTD_H # include #endif int main(void) { char buf[4]; (void) fprintf(fopen("conftestval", "w"), "%d\n", (int) snprintf(buf, sizeof buf, "12345678")); return 0; } ]])],[CONF_SNPRINTF_TYPE=`cat conftestval` ],[],[]) AC_MSG_RESULT(done) if test "x$CONF_SNPRINTF_TYPE" = "x" ; then AC_MSG_WARN(your operating system doesn't implement snprintf) else AC_DEFINE_UNQUOTED(CONF_SNPRINTF_TYPE, $CONF_SNPRINTF_TYPE, [return value of an overflowed snprintf]) fi AC_MSG_CHECKING(whether you already have a standard SHA1 implementation) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include #include int main(void) { SHA1_CTX ctx; char b[41]; SHA1Init(&ctx); SHA1Update(&ctx, (const unsigned char *) "test", 4U); SHA1End(&ctx, b); b[40] = 0; return strcasecmp(b, "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"); } ]])],[ AC_MSG_RESULT(yes) AC_DEFINE(USE_SYSTEM_CRYPT_SHA1,,[Define if you already have standard SHA1 functions]) ],[AC_MSG_RESULT(no) ],[]) AC_MSG_CHECKING([whether syslog names are available]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define SYSLOG_NAMES 1 #include #include ]], [[ (void) facilitynames ]])],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_SYSLOG_NAMES,,[define if syslog names are available]) ],[ AC_MSG_RESULT(no) ]) sysconfdir="$CONFDIR" AC_SUBST(sysconfdir) CPPFLAGS="$CPPFLAGS -DCONFDIR=\\\"$sysconfdir\\\"" dnl Output AC_CONFIG_FILES(Makefile src/Makefile examples/Makefile examples/linux/Makefile examples/bsd/Makefile po/Makefile.in m4/Makefile ) AC_OUTPUT ucarp-1.5.2+git20192404.1a9aaf7/po/0000755000175000017500000000000013460025251015676 5ustar gxaviergxavierucarp-1.5.2+git20192404.1a9aaf7/po/POTFILES.in0000644000175000017500000000055113460025251017454 0ustar gxaviergxaviersrc/bsd-getopt_long.c src/bsd-getopt_long.h src/carp.c src/carp_p.h src/crypto.h src/crypto-sha1.c src/crypto-sha1.h src/daemonize.c src/daemonize.h src/fakesnprintf.c src/fakesnprintf.h src/fillmac.c src/fillmac.h src/garp.c src/garp.h src/globals.h src/ip_carp.h src/mysnprintf.c src/mysnprintf.h src/spawn.c src/spawn.h src/ucarp.c src/ucarp.h src/ucarp_p.h ucarp-1.5.2+git20192404.1a9aaf7/po/ucarp.pot0000644000175000017500000001630313460025251017537 0ustar gxaviergxavier# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR UCARP team # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: ucarp 1.5.2\n" "Report-Msgid-Bugs-To: nobody@example.org\n" "POT-Creation-Date: 2010-01-31 23:04+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: src/carp.c:58 msgid "Switching to state: INIT" msgstr "" #: src/carp.c:61 msgid "Switching to state: BACKUP" msgstr "" #: src/carp.c:67 msgid "Switching to state: MASTER" msgstr "" #: src/carp.c:72 #, c-format msgid "Unknown state: [%d]" msgstr "" #: src/carp.c:222 msgid "Out of memory to create packet" msgstr "" #: src/carp.c:287 #, c-format msgid "write() has failed: %s" msgstr "" #: src/carp.c:293 #, c-format msgid "write() error #%d/%d" msgstr "" #: src/carp.c:314 msgid "* advertisement injected *" msgstr "" #: src/carp.c:346 src/carp.c:772 #, c-format msgid "initializing now to gettimeofday() failed: %s" msgstr "" #: src/carp.c:397 msgid "master_down event in INIT state" msgstr "" #: src/carp.c:502 #, c-format msgid "Bad TTL: [%u]" msgstr "" #: src/carp.c:507 #, c-format msgid "Bad version: [%u]" msgstr "" #: src/carp.c:513 #, c-format msgid "Ignoring vhid: [%u]" msgstr "" #: src/carp.c:519 msgid "Bad IP checksum" msgstr "" #: src/carp.c:542 #, c-format msgid "" "Bad digest - md2=[%02x%02x%02x%02x...] md=[%02x%02x%02x%02x...] - Check " "vhid, password and virtual IP address" msgstr "" #: src/carp.c:598 msgid "Preferred master advertised: going back to BACKUP state" msgstr "" #: src/carp.c:613 msgid "" "Non-preferred master advertising: reasserting control of VIP with another " "gratuitous arp" msgstr "" #: src/carp.c:624 msgid "Putting MASTER down - preemption" msgstr "" #: src/carp.c:637 msgid "Putting MASTER DOWN (going to time out)" msgstr "" #: src/carp.c:724 msgid "Password too long" msgstr "" #: src/carp.c:737 #, c-format msgid "Unable to find MAC address of [%s]" msgstr "" #: src/carp.c:741 #, c-format msgid "Local advertised ethernet address is [%02x:%02x:%02x:%02x:%02x:%02x]" msgstr "" #: src/carp.c:748 #, c-format msgid "Unable to open interface [%s]: %s" msgstr "" #: src/carp.c:754 #, c-format msgid "Unable to compile pcap rule: %s [%s]" msgstr "" #: src/carp.c:778 #, c-format msgid "Error opening socket for interface [%s]: %s" msgstr "" #: src/carp.c:796 src/fillmac.c:51 msgid "Interface name too long" msgstr "" #: src/carp.c:854 src/carp.c:875 #, c-format msgid "gettimeofday() failed: %s" msgstr "" #: src/carp.c:867 #, c-format msgid "exiting: poll() error: %s" msgstr "" #: src/carp.c:870 #, c-format msgid "exiting: pfds[0].revents = %d" msgstr "" #: src/daemonize.c:53 #, c-format msgid "Unable to get in background: [fork: %s]" msgstr "" #: src/daemonize.c:61 #, c-format msgid "Unable to detach from the current session: %s" msgstr "" #: src/daemonize.c:74 msgid "Unable to detach: /dev/null can't be duplicated" msgstr "" #: src/fillmac.c:42 #, c-format msgid "Unable to open raw device: [%s]" msgstr "" #: src/fillmac.c:57 #, c-format msgid "Unable to get hardware info about an interface: %s" msgstr "" #: src/fillmac.c:67 #, c-format msgid "Unknown hardware type [%u]" msgstr "" #: src/fillmac.c:80 #, c-format msgid "Unable to get interface address: %s" msgstr "" #: src/fillmac.c:92 #, c-format msgid "Invalid media / hardware address for [%s]" msgstr "" #: src/fillmac.c:116 msgid "ioctl SIOCGLIFNUM error" msgstr "" #: src/fillmac.c:120 msgid "No interface found" msgstr "" #: src/fillmac.c:128 msgid "ioctl SIOCGLIFCONF error" msgstr "" #: src/fillmac.c:135 #, c-format msgid "Interface [%s] not found" msgstr "" #: src/fillmac.c:148 #, c-format msgid "Unable to get hardware info about [%s]" msgstr "" #: src/garp.c:50 msgid "out of memory to send gratuitous ARP" msgstr "" #: src/garp.c:60 #, c-format msgid "write() in garp: %s" msgstr "" #: src/spawn.c:24 #, c-format msgid "Unable to exec %s %s %s%s%s: %s" msgstr "" #: src/spawn.c:30 #, c-format msgid "Spawning [%s %s %s%s%s]" msgstr "" #: src/spawn.c:50 #, c-format msgid "Unable to spawn the script: %s" msgstr "" #: src/ucarp.c:26 msgid "" "--interface= (-i ): bind interface \n" "--srcip= (-s ): source (real) IP address of that host\n" "--vhid= (-v ): virtual IP identifier (1-255)\n" "--pass= (-p ): password\n" "--passfile= (-o ): read password from file\n" "--preempt (-P): becomes a master as soon as possible\n" "--neutral (-n): don't run downscript at start if backup\n" "--addr= (-a ): virtual shared IP address\n" "--help (-h): summary of command-line options\n" "--advbase= (-b ): advertisement frequency\n" "--advskew= (-k ): advertisement skew (0-255)\n" "--upscript= (-u ): run to become a master\n" "--downscript= (-d ): run to become a backup\n" "--deadratio= (-r ): ratio to consider a host as dead\n" "--shutdown (-z): call shutdown script at exit\n" "--daemonize (-B): run in background\n" "--ignoreifstate (-S): ignore interface state (down, no carrier)\n" "--nomcast (-M): use broadcast (instead of multicast) advertisements\n" "--facility= (-f): set syslog facility (default=daemon)\n" "--xparam= (-x): extra parameter to send to up/down scripts\n" "\n" "Sample usage:\n" "\n" "Manage the 10.1.1.252 shared virtual address on interface eth0, with\n" "1 as a virtual address idenfitier, mypassword as a password, and\n" "10.1.1.1 as a real permanent address for this host.\n" "Call /etc/vip-up.sh when the host becomes a master, and\n" "/etc/vip-down.sh when the virtual IP address has to be disabled.\n" "\n" "ucarp --interface=eth0 --srcip=10.1.1.1 --vhid=1 --pass=mypassword \\\n" " --addr=10.1.1.252 \\\n" " --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh\n" "\n" "\n" "Please report bugs to " msgstr "" #: src/ucarp.c:81 msgid "Out of memory" msgstr "" #: src/ucarp.c:115 src/ucarp.c:168 #, c-format msgid "Invalid address: [%s]" msgstr "" #: src/ucarp.c:137 #, c-format msgid "unable to open passfile %s for reading: %s" msgstr "" #: src/ucarp.c:142 #, c-format msgid "error reading passfile %s: %s" msgstr "" #: src/ucarp.c:144 msgid "unexpected end of file" msgstr "" #: src/ucarp.c:226 #, c-format msgid "Unknown syslog facility: [%s]" msgstr "" #: src/ucarp.c:254 msgid "You must supply a network interface" msgstr "" #: src/ucarp.c:257 #, c-format msgid "Using [%s] as a network interface" msgstr "" #: src/ucarp.c:260 msgid "You must supply a valid virtual host id" msgstr "" #: src/ucarp.c:264 msgid "You must supply a password" msgstr "" #: src/ucarp.c:268 msgid "You must supply an advertisement time base" msgstr "" #: src/ucarp.c:272 msgid "You must supply a persistent source address" msgstr "" #: src/ucarp.c:276 msgid "You must supply a virtual host address" msgstr "" #: src/ucarp.c:280 msgid "Warning: no script called when going up" msgstr "" #: src/ucarp.c:283 msgid "Warning: no script called when going down" msgstr "" #: src/ucarp.c:286 msgid "Dead ratio can't be zero" msgstr "" ucarp-1.5.2+git20192404.1a9aaf7/po/ChangeLog0000644000175000017500000000052213460025251017447 0ustar gxaviergxavier2009-05-27 gettextize * Makefile.in.in: Upgrade to gettext-0.17. 2008-01-19 gettextize * Makefile.in.in: Upgrade to gettext-0.16.1. 2006-02-25 gettextize * Makefile.in.in: New file, from gettext-0.14.5. * Rules-quot: Upgrade to gettext-0.14.5. ucarp-1.5.2+git20192404.1a9aaf7/po/LINGUAS0000644000175000017500000000002513460025251016720 0ustar gxaviergxavieren@quot en@boldquot ucarp-1.5.2+git20192404.1a9aaf7/po/Makevars.template0000644000175000017500000000341613460025251021210 0ustar gxaviergxavier# Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. DOMAIN = $(PACKAGE) # These two variables depend on the location of this directory. subdir = po top_builddir = .. # These options get passed to xgettext. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ # This is the copyright holder that gets inserted into the header of the # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding # package. (Note that the msgstr strings, extracted from the package's # sources, belong to the copyright holder of the package.) Translators are # expected to transfer the copyright for their translations to this person # or entity, or to disclaim their copyright. The empty string stands for # the public domain; in this case the translators are expected to disclaim # their copyright. COPYRIGHT_HOLDER = Free Software Foundation, Inc. # This is the email address or URL to which the translators shall report # bugs in the untranslated strings: # - Strings which are not entire sentences, see the maintainer guidelines # in the GNU gettext documentation, section 'Preparing Strings'. # - Strings which use unclear terms or require additional context to be # understood. # - Strings which make invalid assumptions about notation of date, time or # money. # - Pluralisation problems. # - Incorrect English spelling. # - Incorrect formatting. # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. MSGID_BUGS_ADDRESS = # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. EXTRA_LOCALE_CATEGORIES = ucarp-1.5.2+git20192404.1a9aaf7/po/Makefile.in.in0000644000175000017500000003552413460025251020361 0ustar gxaviergxavier# Makefile for PO directory in any package using GNU gettext. # Copyright (C) 1995-1997, 2000-2007 by Ulrich Drepper # # This file can be copied and used freely without restrictions. It can # be used in projects which are not available under the GNU General Public # License but which still want to provide support for the GNU gettext # functionality. # Please note that the actual code of GNU gettext is covered by the GNU # General Public License and is *not* in the public domain. # # Origin: gettext-0.17 GETTEXT_MACRO_VERSION = 0.17 PACKAGE = @PACKAGE@ VERSION = @VERSION@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ SHELL = /bin/sh @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ datadir = @datadir@ localedir = @localedir@ gettextsrcdir = $(datadir)/gettext/po INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ # We use $(mkdir_p). # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, # @install_sh@ does not start with $(SHELL), so we add it. # In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake # versions, $(mkinstalldirs) and $(install_sh) are unused. mkinstalldirs = $(SHELL) @install_sh@ -d install_sh = $(SHELL) @install_sh@ MKDIR_P = @MKDIR_P@ mkdir_p = @mkdir_p@ GMSGFMT_ = @GMSGFMT@ GMSGFMT_no = @GMSGFMT@ GMSGFMT_yes = @GMSGFMT_015@ GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) MSGFMT_ = @MSGFMT@ MSGFMT_no = @MSGFMT@ MSGFMT_yes = @MSGFMT_015@ MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) XGETTEXT_ = @XGETTEXT@ XGETTEXT_no = @XGETTEXT@ XGETTEXT_yes = @XGETTEXT_015@ XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) MSGMERGE = msgmerge MSGMERGE_UPDATE = @MSGMERGE@ --update MSGINIT = msginit MSGCONV = msgconv MSGFILTER = msgfilter POFILES = @POFILES@ GMOFILES = @GMOFILES@ UPDATEPOFILES = @UPDATEPOFILES@ DUMMYPOFILES = @DUMMYPOFILES@ DISTFILES.common = Makefile.in.in remove-potcdate.sin \ $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \ $(POFILES) $(GMOFILES) \ $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) POTFILES = \ CATALOGS = @CATALOGS@ # Makevars gets inserted here. (Don't remove this line!) .SUFFIXES: .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update .po.mo: @echo "$(MSGFMT) -c -o $@ $<"; \ $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ .po.gmo: @lang=`echo $* | sed -e 's,.*/,,'`; \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo .sin.sed: sed -e '/^#/d' $< > t-$@ mv t-$@ $@ all: check-macro-version all-@USE_NLS@ all-yes: stamp-po all-no: # Ensure that the gettext macros and this Makefile.in.in are in sync. check-macro-version: @test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ exit 1; \ } # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because # we don't want to bother translators with empty POT files). We assume that # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. # In this case, stamp-po is a nop (i.e. a phony target). # stamp-po is a timestamp denoting the last time at which the CATALOGS have # been loosely updated. Its purpose is that when a developer or translator # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent # invocations of "make" will do nothing. This timestamp would not be necessary # if updating the $(CATALOGS) would always touch them; however, the rule for # $(POFILES) has been designed to not touch files that don't need to be # changed. stamp-po: $(srcdir)/$(DOMAIN).pot test ! -f $(srcdir)/$(DOMAIN).pot || \ test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) @test ! -f $(srcdir)/$(DOMAIN).pot || { \ echo "touch stamp-po" && \ echo timestamp > stamp-poT && \ mv stamp-poT stamp-po; \ } # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', # otherwise packages like GCC can not be built if only parts of the source # have been downloaded. # This target rebuilds $(DOMAIN).pot; it is an expensive operation. # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \ package_gnu='GNU '; \ else \ package_gnu=''; \ fi; \ if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ else \ msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ fi; \ case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ --files-from=$(srcdir)/POTFILES.in \ --copyright-holder='$(COPYRIGHT_HOLDER)' \ --msgid-bugs-address="$$msgid_bugs_address" \ ;; \ *) \ $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ --files-from=$(srcdir)/POTFILES.in \ --copyright-holder='$(COPYRIGHT_HOLDER)' \ --package-name="$${package_gnu}@PACKAGE@" \ --package-version='@VERSION@' \ --msgid-bugs-address="$$msgid_bugs_address" \ ;; \ esac test ! -f $(DOMAIN).po || { \ if test -f $(srcdir)/$(DOMAIN).pot; then \ sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ else \ rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ fi; \ else \ mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ fi; \ } # This rule has no dependencies: we don't need to update $(DOMAIN).pot at # every "make" invocation, only create it when it is missing. # Only "make $(DOMAIN).pot-update" or "make dist" will force an update. $(srcdir)/$(DOMAIN).pot: $(MAKE) $(DOMAIN).pot-update # This target rebuilds a PO file if $(DOMAIN).pot has changed. # Note that a PO file is not touched if it doesn't need to be changed. $(POFILES): $(srcdir)/$(DOMAIN).pot @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ if test -f "$(srcdir)/$${lang}.po"; then \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ else \ $(MAKE) $${lang}.po-create; \ fi install: install-exec install-data install-exec: install-data: install-data-@USE_NLS@ if test "$(PACKAGE)" = "gettext-tools"; then \ $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ for file in $(DISTFILES.common) Makevars.template; do \ $(INSTALL_DATA) $(srcdir)/$$file \ $(DESTDIR)$(gettextsrcdir)/$$file; \ done; \ for file in Makevars; do \ rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ done; \ else \ : ; \ fi install-data-no: all install-data-yes: all $(mkdir_p) $(DESTDIR)$(datadir) @catalogs='$(CATALOGS)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ dir=$(localedir)/$$lang/LC_MESSAGES; \ $(mkdir_p) $(DESTDIR)$$dir; \ if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ if test -n "$$lc"; then \ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ for file in *; do \ if test -f $$file; then \ ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ fi; \ done); \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ else \ if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ :; \ else \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ fi; \ fi; \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ fi; \ done; \ done install-strip: install installdirs: installdirs-exec installdirs-data installdirs-exec: installdirs-data: installdirs-data-@USE_NLS@ if test "$(PACKAGE)" = "gettext-tools"; then \ $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ else \ : ; \ fi installdirs-data-no: installdirs-data-yes: $(mkdir_p) $(DESTDIR)$(datadir) @catalogs='$(CATALOGS)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ dir=$(localedir)/$$lang/LC_MESSAGES; \ $(mkdir_p) $(DESTDIR)$$dir; \ for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ if test -n "$$lc"; then \ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ for file in *; do \ if test -f $$file; then \ ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ fi; \ done); \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ else \ if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ :; \ else \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ fi; \ fi; \ fi; \ done; \ done # Define this as empty until I found a useful application. installcheck: uninstall: uninstall-exec uninstall-data uninstall-exec: uninstall-data: uninstall-data-@USE_NLS@ if test "$(PACKAGE)" = "gettext-tools"; then \ for file in $(DISTFILES.common) Makevars.template; do \ rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ done; \ else \ : ; \ fi uninstall-data-no: uninstall-data-yes: catalogs='$(CATALOGS)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ done; \ done check: all info dvi ps pdf html tags TAGS ctags CTAGS ID: mostlyclean: rm -f remove-potcdate.sed rm -f stamp-poT rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po rm -fr *.o clean: mostlyclean distclean: clean rm -f Makefile Makefile.in POTFILES *.mo maintainer-clean: distclean @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." rm -f stamp-po $(GMOFILES) distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) dist distdir: $(MAKE) update-po @$(MAKE) dist2 # This is a separate target because 'update-po' must be executed before. dist2: stamp-po $(DISTFILES) dists="$(DISTFILES)"; \ if test "$(PACKAGE)" = "gettext-tools"; then \ dists="$$dists Makevars.template"; \ fi; \ if test -f $(srcdir)/$(DOMAIN).pot; then \ dists="$$dists $(DOMAIN).pot stamp-po"; \ fi; \ if test -f $(srcdir)/ChangeLog; then \ dists="$$dists ChangeLog"; \ fi; \ for i in 0 1 2 3 4 5 6 7 8 9; do \ if test -f $(srcdir)/ChangeLog.$$i; then \ dists="$$dists ChangeLog.$$i"; \ fi; \ done; \ if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ for file in $$dists; do \ if test -f $$file; then \ cp -p $$file $(distdir) || exit 1; \ else \ cp -p $(srcdir)/$$file $(distdir) || exit 1; \ fi; \ done update-po: Makefile $(MAKE) $(DOMAIN).pot-update test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) $(MAKE) update-gmo # General rule for creating PO files. .nop.po-create: @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ exit 1 # General rule for updating PO files. .nop.po-update: @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ tmpdir=`pwd`; \ echo "$$lang:"; \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ cd $(srcdir); \ if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ rm -f $$tmpdir/$$lang.new.po; \ else \ if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ :; \ else \ echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ exit 1; \ fi; \ fi; \ else \ echo "msgmerge for $$lang.po failed!" 1>&2; \ rm -f $$tmpdir/$$lang.new.po; \ fi $(DUMMYPOFILES): update-gmo: Makefile $(GMOFILES) @: Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ cd $(top_builddir) \ && $(SHELL) ./config.status $(subdir)/$@.in po-directories force: # Tell versions [3.59,3.63) of GNU make not to export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: