Kaydet (Commit) 9ec0e6d9 authored tarafından Michael Stahl's avatar Michael Stahl

sd: replace embedded mDNSResponder code with proper external tarball

The diff against the 379.37 release is 2500 lines, one of which
actually does anything at runtime (missing va_end()).

Change-Id: I1824e61fd4ac6c3ce28084913a2661134a03fd51
Reviewed-on: https://gerrit.libreoffice.org/20248Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 883321e1
......@@ -165,6 +165,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,LPSOLVE,LPSOLVE_TARBALL) \
$(call fetch_Optional,MARIADB,MARIADB_TARBALL) \
$(call fetch_Optional,MDDS,MDDS_TARBALL) \
$(call fetch_Optional,MDNSRESPONDER,MDNSRESPONDER_TARBALL) \
$(call fetch_Optional,MORE_FONTS,FONT_CALADEA_TARBALL) \
$(call fetch_Optional,MORE_FONTS,FONT_CARLITO_TARBALL) \
$(call fetch_Optional,MORE_FONTS,FONT_DEJAVU_TARBALL) \
......
......@@ -2442,6 +2442,18 @@ gb_LinkTarget__use_coinmp :=
endif # ENABLE_COINMP
ifneq (,$(filter MDNSRESPONDER,$(BUILD_TYPE)))
define gb_LinkTarget__use_mDNSResponder
$(call gb_LinkTarget_set_include,$(1),\
-I$(call gb_UnpackedTarball_get_dir,mDNSResponder)/mDNSShared \
$$(INCLUDE) \
)
$(call gb_LinkTarget_use_static_libraries,$(1),mDNSResponder)
endef
endif # MDNSRESPONDER
ifeq ($(ENABLE_GIO),TRUE)
define gb_LinkTarget__use_gio
......
......@@ -11805,7 +11805,10 @@ AC_SUBST(CAIRO_LIBS)
dnl ===================================================================
dnl Test whether to use avahi
dnl ===================================================================
if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
if test "$_os" = "WINNT"; then
# Windows uses bundled mDNSResponder
BUILD_TYPE="$BUILD_TYPE MDNSRESPONDER"
elif test "$_os" != "Darwin" -a "$enable_avahi" = "yes"; then
PKG_CHECK_MODULES([AVAHI], [avahi-client >= 0.6.10],
[ENABLE_AVAHI="TRUE"])
AC_DEFINE(HAVE_FEATURE_AVAHI)
......
......@@ -95,6 +95,8 @@ export LPSOLVE_TARBALL := 26b3e95ddf3d9c077c480ea45874b3b8-lp_solve_5.5.tar.gz
export MARIADB_TARBALL := a233181e03d3c307668b4c722d881661-mariadb_client-2.0.0-src.tar.gz
export MDDS_MD5SUM := 74e0a81c5af4137285fe6a52217f71e4
export MDDS_TARBALL := mdds_1.0.0.tar.bz2
export MDNSRESPONDER_MD5SUM := dd557e1058b51ac2f29cd01d67be0145
export MDNSRESPONDER_TARBALL := mDNSResponder-379.37.tar.gz
export MSPUB_MD5SUM := ff9d0f9dd8fbc523408ea1953d5bde41
export MSPUB_TARBALL := libmspub-0.1.2.tar.bz2
export MWAW_MD5SUM := 4a8a53a9d997cf0e2bd208178797dbfb
......
......@@ -68,6 +68,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,LPSOLVE,lpsolve) \
$(call gb_Helper_optional,MARIADB,libmariadb) \
$(call gb_Helper_optional,MDDS,mdds) \
$(call gb_Helper_optional,MDNSRESPONDER,mdnsresponder) \
$(if $(WITH_EXTRA_EXTENSIONS),misc_extensions) \
$(call gb_Helper_optional,MORE_FONTS,more_fonts) \
$(call gb_Helper_optional,MSPUB,libmspub) \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
include $(module_directory)/../../solenv/gbuild/partial_build.mk
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Module_Module,mdnsresponder))
$(eval $(call gb_Module_add_targets,mdnsresponder,\
UnpackedTarball_mDNSResponder \
))
$(eval $(call gb_Module_add_targets,mdnsresponder,\
StaticLibrary_mDNSResponder \
))
# vim: set noet sw=4 ts=4:
Apple's ZeroConf Multicast DNS implementation
https://developer.apple.com/bonjour/
http://www.opensource.apple.com/tarballs/mDNSResponder/
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_StaticLibrary_StaticLibrary,mDNSResponder))
$(eval $(call gb_StaticLibrary_set_warnings_not_errors,mDNSResponder))
$(eval $(call gb_StaticLibrary_use_unpacked,mDNSResponder,mDNSResponder))
$(eval $(call gb_StaticLibrary_set_include,mDNSResponder,\
-I$(call gb_UnpackedTarball_get_dir,mDNSResponder)/mDNSShared \
$$(INCLUDE) \
))
$(eval $(call gb_StaticLibrary_add_defs,mDNSResponder,\
-DWIN32_LEAN_AND_MEAN \
-D_WINSOCK_DEPRECATED_NO_WARNINGS \
-DUSE_TCP_LOOPBACK \
-DNOT_HAVE_SA_LEN \
))
$(eval $(call gb_StaticLibrary_add_generated_cobjects,mDNSResponder,\
UnpackedTarball/mDNSResponder/mDNSShared/DebugServices \
UnpackedTarball/mDNSResponder/mDNSShared/GenLinkedList \
UnpackedTarball/mDNSResponder/mDNSShared/dnssd_clientlib \
UnpackedTarball/mDNSResponder/mDNSShared/dnssd_clientstub \
UnpackedTarball/mDNSResponder/mDNSShared/dnssd_ipc \
UnpackedTarball/mDNSResponder/mDNSWindows/DLL/dllmain \
))
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_UnpackedTarball_UnpackedTarball,mDNSResponder))
$(eval $(call gb_UnpackedTarball_set_tarball,mDNSResponder,$(MDNSRESPONDER_TARBALL)))
# vim: set noet sw=4 ts=4:
......@@ -79,6 +79,7 @@ $(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
$(if $(ENABLE_AVAHI), \
avahi \
) \
$(if $(filter WNT,$(OS)),mDNSResponder) \
libxml2 \
))
......
......@@ -529,14 +529,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/remotecontrol/WINNetworkService \
))
$(eval $(call gb_Library_add_cobjects,sd,\
sd/source/ui/remotecontrol/mDNSResponder/DebugServices \
sd/source/ui/remotecontrol/mDNSResponder/dnssd_clientlib \
sd/source/ui/remotecontrol/mDNSResponder/dnssd_clientstub \
sd/source/ui/remotecontrol/mDNSResponder/dnssd_ipc \
sd/source/ui/remotecontrol/mDNSResponder/GenLinkedList \
sd/source/ui/remotecontrol/mDNSResponder/dllmain \
))
$(eval $(call gb_Library_use_external,sd,mDNSResponder))
endif # OS=WNT
......
#include <string>
#include <iostream>
#include "WINNetworkService.hxx"
#include "mDNSResponder/dns_sd.h"
#include <sal/log.hxx>
void sd::WINNetworkService::setup()
......
......@@ -4,7 +4,7 @@
#include <string>
#undef WB_LEFT
#undef WB_RIGHT
#include "mDNSResponder/dns_sd.h"
#include <dns_sd.h>
#include "ZeroconfService.hxx"
namespace sd{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
File: GenLinkedList.c
Contains: implementation of generic linked lists.
Version: 1.0
Tabs: 4 spaces
*/
#include "GenLinkedList.h"
// Return the link pointer contained within element e at offset o.
#define GETLINK( e, o) ( *(void**)((char*) (e) + (o)) )
// Assign the link pointer l to element e at offset o.
#define ASSIGNLINK( e, l, o) ( *((void**)((char*) (e) + (o))) = (l))
// GenLinkedList
void InitLinkedList( GenLinkedList *pList, size_t linkOffset)
/* Initialize the block of memory pointed to by pList as a linked list. */
{
pList->Head = NULL;
pList->Tail = NULL;
pList->LinkOffset = linkOffset;
}
void AddToTail( GenLinkedList *pList, void *elem)
/* Add a linked list element to the tail of the list. */
{
if ( pList->Tail) {
ASSIGNLINK( pList->Tail, elem, pList->LinkOffset);
} else
pList->Head = elem;
ASSIGNLINK( elem, NULL, pList->LinkOffset);
pList->Tail = elem;
}
void AddToHead( GenLinkedList *pList, void *elem)
/* Add a linked list element to the head of the list. */
{
ASSIGNLINK( elem, pList->Head, pList->LinkOffset);
if ( pList->Tail == NULL)
pList->Tail = elem;
pList->Head = elem;
}
int RemoveFromList( GenLinkedList *pList, void *elem)
/* Remove a linked list element from the list. Return 0 if it was not found. */
/* If the element is removed, its link will be set to NULL. */
{
void *iElem, *lastElem;
for ( iElem = pList->Head, lastElem = NULL; iElem; iElem = GETLINK( iElem, pList->LinkOffset)) {
if ( iElem == elem) {
if ( lastElem) { // somewhere past the head
ASSIGNLINK( lastElem, GETLINK( elem, pList->LinkOffset), pList->LinkOffset);
} else { // at the head
pList->Head = GETLINK( elem, pList->LinkOffset);
}
if ( pList->Tail == elem)
pList->Tail = lastElem ? lastElem : NULL;
ASSIGNLINK( elem, NULL, pList->LinkOffset); // maybe catch a stale reference bug.
return 1;
}
lastElem = iElem;
}
return 0;
}
int ReplaceElem( GenLinkedList *pList, void *elemInList, void *newElem)
/* Replace an element in the list with a new element, in the same position. */
{
void *iElem, *lastElem;
if ( elemInList == NULL || newElem == NULL)
return 0;
for ( iElem = pList->Head, lastElem = NULL; iElem; iElem = GETLINK( iElem, pList->LinkOffset))
{
if ( iElem == elemInList)
{
ASSIGNLINK( newElem, GETLINK( elemInList, pList->LinkOffset), pList->LinkOffset);
if ( lastElem) // somewhere past the head
{
ASSIGNLINK( lastElem, newElem, pList->LinkOffset);
}
else // at the head
{
pList->Head = newElem;
}
if ( pList->Tail == elemInList)
pList->Tail = newElem;
return 1;
}
lastElem = iElem;
}
return 0;
}
// GenDoubleLinkedList
void InitDoubleLinkedList( GenDoubleLinkedList *pList, size_t fwdLinkOffset,
size_t backLinkOffset)
/* Initialize the block of memory pointed to by pList as a double linked list. */
{
pList->Head = NULL;
pList->Tail = NULL;
pList->FwdLinkOffset = fwdLinkOffset;
pList->BackLinkOffset = backLinkOffset;
}
void DLLAddToHead( GenDoubleLinkedList *pList, void *elem)
/* Add a linked list element to the head of the list. */
{
void *pNext;
pNext = pList->Head;
// fix up the forward links
ASSIGNLINK( elem, pList->Head, pList->FwdLinkOffset);
pList->Head = elem;
// fix up the backward links
if ( pNext) {
ASSIGNLINK( pNext, elem, pList->BackLinkOffset);
} else
pList->Tail = elem;
ASSIGNLINK( elem, NULL, pList->BackLinkOffset);
}
void DLLRemoveFromList( GenDoubleLinkedList *pList, void *elem)
/* Remove a linked list element from the list. */
/* When the element is removed, its link will be set to NULL. */
{
void *pNext, *pPrev;
pNext = GETLINK( elem, pList->FwdLinkOffset);
pPrev = GETLINK( elem, pList->BackLinkOffset);
// fix up the forward links
if ( pPrev)
ASSIGNLINK( pPrev, pNext, pList->FwdLinkOffset);
else
pList->Head = pNext;
// fix up the backward links
if ( pNext)
ASSIGNLINK( pNext, pPrev, pList->BackLinkOffset);
else
pList->Tail = pPrev;
ASSIGNLINK( elem, NULL, pList->FwdLinkOffset);
ASSIGNLINK( elem, NULL, pList->BackLinkOffset);
}
// GenLinkedOffsetList
// Extract the Next offset from element
#define GETOFFSET( e, o) ( *(size_t*)((char*) (e) + (o)) )
static void AssignOffsetLink( void *elem, void *link, size_t linkOffset);
static void AssignOffsetLink( void *elem, void *link, size_t linkOffset)
// Assign link to elem as an offset from elem. Assign 0 to elem if link is NULL.
{
GETOFFSET( elem, linkOffset) = link ? (size_t) link - (size_t) elem : 0;
}
void *GetHeadPtr( GenLinkedOffsetList *pList)
/* Return a pointer to the head element of a list, or NULL if none. */
{
return pList->Head ? ( (char*) (pList) + pList->Head) : NULL;
}
void *GetTailPtr( GenLinkedOffsetList *pList)
/* Return a pointer to the tail element of a list, or NULL if none. */
{
return pList->Tail ? ( (char*) (pList) + pList->Tail) : NULL;
}
void *GetOffsetLink( GenLinkedOffsetList *pList, void *elem)
/* Return the link pointer contained within element e for pList, or NULL if it is 0. */
{
size_t nextOffset;
nextOffset = GETOFFSET( elem, pList->LinkOffset);
return nextOffset ? (char*) elem + nextOffset : NULL;
}
void InitLinkedOffsetList( GenLinkedOffsetList *pList, size_t linkOffset)
/* Initialize the block of memory pointed to by pList as a linked list. */
{
pList->Head = 0;
pList->Tail = 0;
pList->LinkOffset = linkOffset;
}
void OffsetAddToTail( GenLinkedOffsetList *pList, void *elem)
/* Add a linked list element to the tail of the list. */
{
if ( pList->Tail) {
AssignOffsetLink( GetTailPtr( pList), elem, pList->LinkOffset);
} else
pList->Head = (size_t) elem - (size_t) pList;
AssignOffsetLink( elem, NULL, pList->LinkOffset);
pList->Tail = (size_t) elem - (size_t) pList;
}
void OffsetAddToHead( GenLinkedOffsetList *pList, void *elem)
/* Add a linked list element to the head of the list. */
{
AssignOffsetLink( elem, GetHeadPtr( pList), pList->LinkOffset);
if ( pList->Tail == 0)
pList->Tail = (size_t) elem - (size_t) pList;
pList->Head = (size_t) elem - (size_t) pList;
}
int OffsetRemoveFromList( GenLinkedOffsetList *pList, void *elem)
/* Remove a linked list element from the list. Return 0 if it was not found. */
/* If the element is removed, its link will be set to NULL. */
{
void *iElem, *lastElem;
for ( iElem = GetHeadPtr( pList), lastElem = NULL; iElem;
iElem = GetOffsetLink( pList, iElem))
{
if ( iElem == elem) {
if ( lastElem) { // somewhere past the head
AssignOffsetLink( lastElem, GetOffsetLink( pList, elem), pList->LinkOffset);
} else { // at the head
iElem = GetOffsetLink( pList, elem);
pList->Head = iElem ? (size_t) iElem - (size_t) pList : 0;
}
if ( GetTailPtr( pList) == elem)
pList->Tail = lastElem ? (size_t) lastElem - (size_t) pList : 0;
AssignOffsetLink( elem, NULL, pList->LinkOffset); // maybe catch a stale reference bug.
return 1;
}
lastElem = iElem;
}
return 0;
}
int OffsetReplaceElem( GenLinkedOffsetList *pList, void *elemInList, void *newElem)
/* Replace an element in the list with a new element, in the same position. */
{
void *iElem, *lastElem;
if ( elemInList == NULL || newElem == NULL)
return 0;
for ( iElem = GetHeadPtr( pList), lastElem = NULL; iElem;
iElem = GetOffsetLink( pList, iElem))
{
if ( iElem == elemInList)
{
AssignOffsetLink( newElem, GetOffsetLink( pList, elemInList), pList->LinkOffset);
if ( lastElem) // somewhere past the head
{
AssignOffsetLink( lastElem, newElem, pList->LinkOffset);
}
else // at the head
{
pList->Head = (size_t) newElem - (size_t) pList;
}
if ( GetTailPtr( pList) == elemInList)
pList->Tail = (size_t) newElem - (size_t) pList;
return 1;
}
lastElem = iElem;
}
return 0;
}
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __GenLinkedList__
#define __GenLinkedList__
#include <stddef.h>
struct GenLinkedList
{
void *Head,
*Tail;
size_t LinkOffset;
};
typedef struct GenLinkedList GenLinkedList;
void InitLinkedList( GenLinkedList *pList, size_t linkOffset);
void AddToHead( GenLinkedList *pList, void *elem);
void AddToTail( GenLinkedList *pList, void *elem);
int RemoveFromList( GenLinkedList *pList, void *elem);
int ReplaceElem( GenLinkedList *pList, void *elemInList, void *newElem);
struct GenDoubleLinkedList
{
void *Head,
*Tail;
size_t FwdLinkOffset,
BackLinkOffset;
};
typedef struct GenDoubleLinkedList GenDoubleLinkedList;
void InitDoubleLinkedList( GenDoubleLinkedList *pList, size_t fwdLinkOffset,
size_t backLinkOffset);
void DLLAddToHead( GenDoubleLinkedList *pList, void *elem);
void DLLRemoveFromList( GenDoubleLinkedList *pList, void *elem);
/* A GenLinkedOffsetList is like a GenLinkedList that stores the *Next field as a signed */
/* offset from the address of the beginning of the element, rather than as a pointer. */
struct GenLinkedOffsetList
{
size_t Head,
Tail;
size_t LinkOffset;
};
typedef struct GenLinkedOffsetList GenLinkedOffsetList;
void InitLinkedOffsetList( GenLinkedOffsetList *pList, size_t linkOffset);
void *GetHeadPtr( GenLinkedOffsetList *pList);
void *GetTailPtr( GenLinkedOffsetList *pList);
void *GetOffsetLink( GenLinkedOffsetList *pList, void *elem);
void OffsetAddToHead( GenLinkedOffsetList *pList, void *elem);
void OffsetAddToTail( GenLinkedOffsetList *pList, void *elem);
int OffsetRemoveFromList( GenLinkedOffsetList *pList, void *elem);
int OffsetReplaceElem( GenLinkedOffsetList *pList, void *elemInList, void *newElem);
#endif // __GenLinkedList__
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// #include <windows.h>
#include <DebugServices.h>
#include <stdlib.h>
BOOL APIENTRY DllMain( HANDLE inModule, DWORD inReason, LPVOID inReserved )
{
(void) inModule;
(void) inReserved;
switch( inReason )
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
BOOL
IsSystemServiceDisabled()
{
ENUM_SERVICE_STATUS * lpService = NULL;
SC_HANDLE sc;
BOOL ret = FALSE;
BOOL ok;
DWORD bytesNeeded = 0;
DWORD srvCount;
DWORD resumeHandle = 0;
DWORD srvType;
DWORD srvState;
DWORD dwBytes = 0;
DWORD i;
OSStatus err;
sc = OpenSCManager( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE );
err = translate_errno( sc, GetLastError(), kUnknownErr );
require_noerr( err, exit );
srvType = SERVICE_WIN32;
srvState = SERVICE_STATE_ALL;
for ( ;; )
{
// Call EnumServicesStatus using the handle returned by OpenSCManager
ok = EnumServicesStatus ( sc, srvType, srvState, lpService, dwBytes, &bytesNeeded, &srvCount, &resumeHandle );
if ( ok || ( GetLastError() != ERROR_MORE_DATA ) )
{
break;
}
if ( lpService )
{
free( lpService );
}
dwBytes = bytesNeeded;
lpService = ( ENUM_SERVICE_STATUS* ) malloc( dwBytes );
require_action( lpService, exit, ret = FALSE );
}
err = translate_errno( ok, GetLastError(), kUnknownErr );
require_noerr( err, exit );
for ( i = 0; i < srvCount; i++ )
{
if ( strcmp( lpService[i].lpServiceName, "Bonjour Service" ) == 0 )
{
if ( ( lpService[i].ServiceStatus.dwCurrentState == SERVICE_PAUSED ) || ( lpService[i].ServiceStatus.dwCurrentState == SERVICE_STOPPED ) )
{
ret = TRUE;
}
break;
}
}
exit: