2008-05-02 21:05:37 +02:00
|
|
|
/*
|
2009-03-25 15:21:04 +01:00
|
|
|
* Copyright (C) 2008-2009 Patrick Ohly <patrick.ohly@gmx.de>
|
2009-04-30 18:14:03 +02:00
|
|
|
*
|
|
|
|
* 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
|
2008-05-02 21:05:37 +02:00
|
|
|
*/
|
|
|
|
|
2011-02-25 12:16:20 +01:00
|
|
|
#include "icalstrdup.h"
|
2010-02-22 11:57:59 +01:00
|
|
|
#include <syncevo/eds_abi_wrapper.h>
|
2008-05-02 21:05:37 +02:00
|
|
|
|
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)
|
2008-05-02 21:05:37 +02:00
|
|
|
|
|
|
|
#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
|
2010-02-22 11:57:59 +01:00
|
|
|
// One situation when we must not dup strings is when
|
|
|
|
// running with a libecal with the modified string
|
|
|
|
// handling semantic. Check that here.
|
2008-05-02 21:05:37 +02:00
|
|
|
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) {
|
2008-05-04 17:40:34 +02:00
|
|
|
/* patch applied, no need to copy */
|
2008-05-02 21:05:37 +02:00
|
|
|
return (char *)x;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return x ? strdup(x) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !LIBICAL_MEMFIXES */
|