syncevolution/src/syncevo/icalstrdup.c

63 lines
1.7 KiB
C
Raw Normal View History

/*
* Copyright (C) 2008-2009 Patrick Ohly <patrick.ohly@gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) version 3.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "icalstrdup.h"
#include <syncevo/eds_abi_wrapper.h>
syncevolution.org: compile on Ubuntu Trusty, libical v1/v2 compatibility syncevolution.org binaries are now getting compiled on Ubuntu Trusty and thus no longer support distros with older EDS. The code should still compile against older EDS (for example, for Maemo), but that is not getting tested anymore. This allows removing the dynamic linker hacks related to older libraries, which was only used in those binaries. Instead, backends using libical or EDS get compiled on Ubuntu Trusty and then the soname of those libs get patched to make the backend module usable in combination with a different set of libs. That patching is part of a script maintained in the syncevolution.org build infrastructure. This approach was already used before to generate different EDS backends for EDS versions with the newer EClient API, because that turned out to be easier than the dynamic loading approach. It works because none of the methods used by SyncEvolution changed their ABI, only some other parts of the libraries did. Should there ever be a situation again that cannot be handled like this, then backends might also get compiled on different distros than Ubuntu Trusty (however, that may lead to problems due to the libstdc++ ABI changes - to be decided...). libical still requires one special hack: system time zone loading in libical v1 (and only in that version, v2 has builtin support again) must be overridden such that time zones are generated with rules instead of transitions because that is more compatible with the peers that SyncEvolution exchanges data with. That hack now relies on overriding the two relevant functions inside the main binaries (has to be there, otherwise libical still ends up calling its own internal implementation). The overriding code is in libsyncevo-icaltz-util.so.0 and depends on libical.so.1. If libsyncevo-icaltz-util.so.0 can be loaded, the wrappers in the main binary use it, otherwise they fall through to the code from the current libical.so, which then should be libical.so.2 or more recent. This hack is active by default when libical v1 is detected during configuration.
2016-09-20 17:19:08 +02:00
#if !defined(LIBICAL_MEMFIXES)
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined(_GNU_SOURCE) && defined(HAVE_DLFCN_H)
# include <dlfcn.h>
# define LIBICAL_RUNTIME_CHECK
#endif
#include <string.h>
char *ical_strdup(const char *x)
{
#ifdef LIBICAL_RUNTIME_CHECK
// One situation when we must not dup strings is when
// running with a libecal with the modified string
// handling semantic. Check that here.
static enum {
PATCH_UNCHECKED,
PATCH_FOUND,
PATCH_NOT_FOUND
} patch_status;
if (patch_status == PATCH_UNCHECKED) {
patch_status = dlsym(RTLD_NEXT, "ical_memfixes") != NULL ?
PATCH_FOUND : PATCH_NOT_FOUND;
}
if (patch_status == PATCH_FOUND) {
/* patch applied, no need to copy */
return (char *)x;
}
#endif
return x ? strdup(x) : NULL;
}
#endif /* !LIBICAL_MEMFIXES */