Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5
Browse files Browse the repository at this point in the history
bd83693 miniupnpc: VERSION 2.1 (Thomas Bernard)
4a9c12c VBscript to generate miniupnpcstrings.h (Thomas Bernard)
530b272 Modernize and cleanup CMakeLists.txt (Tengiz Sharafiev)
d2bbdee fix typo introduced in 00abd9e (Thomas Bernard)
a921383 add option LEASEFILE_USE_REMAINING_TIME (Thomas Bernard)
d0e7958 lease_file_remove(): replace strncpy/strncat by snprintf() (Thomas Bernard)
f6ac854 miniupnpd: fix storing of unlimited lease time in lease_file (Thomas Bernard)
17773f0 if LEASEFILE_USE_REMAINING_TIME is defined, only the remaining time is stored (Thomas Bernard)
00abd9e miniupnpd: store UNIX time in lease_file (Thomas Bernard)
61703ad miniupnpc/lisdevices.c: remove warnings. fix leak (Thomas Bernard)
073642d test2 (Thomas Bernard)
cc3541e appveyor: version (Thomas Bernard)
f65d344 miniupnpc/listdevices: remove duplicates (Thomas Bernard)
bdfd7bb miniupnpc/listdevices: show devices sorted by XML desc URL (Thomas BERNARD)
491ee9f miniupnpd/upnpevents.c: Add log when error (Thomas Bernard)
0e3dd7b appveyor: message (Thomas Bernard)
a78750c appveyor: push artifacts (Thomas Bernard)
b7e1b2e miniupnpc/miniupnpcmodule.c: small fix (Thomas Bernard)
4931404 miniupnpc: build python module with appveyor (Thomas Bernard)
9663c55 miniupnpc/Makefile.mingw: Support cross compiling for Ming32 (Thomas Bernard)
53e8185 miniupnpd/pf: set dst address in rule if use_ext_ip_addr is set (Thomas Bernard)
5dcd40a netfilter/iptpinhole.c: remove warning: implicit declaration of function 'upnp_time' (Thomas Bernard)
0366cd0 replace strlen(s) > 0 by s[0] != '\0' (Thomas Bernard)
2b6fa08 no more strlen(xxx) == 0. (Thomas Bernard)
9d56943 update MS VS 2010 project files (Thomas Bernard)
154d27c miniupnpc/upnpc.c: 2017=>2018 (Thomas Bernard)
  • Loading branch information
fluffypony committed Jul 6, 2018
2 parents 0767f37 + 0842f18 commit 6b9b73a
Show file tree
Hide file tree
Showing 29 changed files with 540 additions and 108 deletions.
14 changes: 14 additions & 0 deletions appveyor.yml
@@ -1,7 +1,21 @@
version: '2.1.{build}'

install:
- set PATH=%PATH%;C:\msys64\mingw32\bin

build_script:
- cd miniupnpc
- appveyor AddCompilationMessage "Building miniupnpc"
- mingw32-make -f Makefile.mingw
- mingw32-make -f Makefile.mingw pythonmodule PYTHON=C:\Python27\python
# - upnpc-static.exe -l

after_build:
- 7z a ..\miniupnpc-%APPVEYOR_BUILD_VERSION%.zip *.exe *.dll *.a *.lib
- 7z a ..\miniupnpc-python-%APPVEYOR_BUILD_VERSION%.zip build\ dist\

artifacts:
- path: miniupnpc-$(appveyor_build_version).zip
name: miniupnpc binaries
- path: miniupnpc-python-$(appveyor_build_version).zip
name: miniupnpc python module
4 changes: 2 additions & 2 deletions minissdpd/daemonize.c
Expand Up @@ -67,7 +67,7 @@ writepidfile(const char * fname, int pid)
int pidstringlen;
int pidfile;

if(!fname || (strlen(fname) == 0))
if(!fname || fname[0] == '\0')
return -1;

if( (pidfile = open(fname, O_WRONLY|O_CREAT, 0644)) < 0)
Expand Down Expand Up @@ -102,7 +102,7 @@ checkforrunning(const char * fname)
int pidfile;
pid_t pid;

if(!fname || (strlen(fname) == 0))
if(!fname || fname[0] == '\0')
return -1;

if( (pidfile = open(fname, O_RDONLY)) < 0)
Expand Down
2 changes: 1 addition & 1 deletion miniupnpc-libevent/miniupnpc-libevent.c
Expand Up @@ -412,7 +412,7 @@ static void upnpc_desc_received(struct evhttp_request * req, void * pvoid)
d->control_cif_url, d->cif_service_type);

if((d->cif_service_type == NULL)
|| (strlen(d->cif_service_type) == 0)
|| (d->cif_service_type[0] == '\0')
|| (!COMPARE(d->cif_service_type, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:"))) {
d->parent->ready_cb(UPNPC_ERR_NOT_IGD, d->parent, d, d->parent->cb_data);
} else {
Expand Down
164 changes: 92 additions & 72 deletions miniupnpc/CMakeLists.txt
@@ -1,8 +1,6 @@
cmake_minimum_required (VERSION 2.6)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project (miniupnpc C)
set (MINIUPNPC_VERSION 2.0)
set (MINIUPNPC_API_VERSION 17)

# - we comment out this block as we don't support these other build types
if(0)
Expand All @@ -18,58 +16,48 @@ if (NOT CMAKE_BUILD_TYPE)
endif()
endif()

set (MINIUPNPC_VERSION 2.1)
set (MINIUPNPC_API_VERSION 17)

option (UPNPC_BUILD_STATIC "Build static library" TRUE)
option (UPNPC_BUILD_SHARED "Build shared library" FALSE)
option (UPNPC_BUILD_TESTS "Build test executables" FALSE)
option (UPNPC_BUILD_SAMPLE "Build sample executables" FALSE)
option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)

mark_as_advanced (NO_GETADDRINFO)
if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
message (FATAL "Both shared and static libraries are disabled!")
endif ()

# Interface library for compile definitions, flags and option
add_library(miniupnpc-private INTERFACE)

if (NO_GETADDRINFO)
add_definitions (-DNO_GETADDRINFO)
endif (NO_GETADDRINFO)
target_compile_definitions(miniupnpc-private INTERFACE NO_GETADDRINFO)
endif ()

if (NOT WIN32)
add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
target_compile_definitions(miniupnpc-private INTERFACE
MINIUPNPC_SET_SOCKET_TIMEOUT
_BSD_SOURCE _DEFAULT_SOURCE)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# add_definitions (-D_POSIX_C_SOURCE=200112L)
add_definitions (-D_XOPEN_SOURCE=600)
endif (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
if (CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)")
add_definitions (-D__EXTENSIONS__ -std=c99)
target_compile_definitions(miniupnpc-private INTERFACE _XOPEN_SOURCE=600)
endif ()
else (NOT WIN32)
add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
endif (NOT WIN32)
else ()
target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
endif ()

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions (-D_DARWIN_C_SOURCE)
target_compile_definitions(miniupnpc-private INTERFACE _DARWIN_C_SOURCE)
endif ()

# - we comment out this block as we already set flags
if(0)
# Set compiler specific build flags
if (CMAKE_COMPILER_IS_GNUCC)
# Set our own default flags at first run.
if (NOT CONFIGURED)

if (NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
set (_PIC -fPIC)
endif (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")

set (CMAKE_C_FLAGS "${_PIC} -Wall $ENV{CFLAGS}" # CMAKE_C_FLAGS gets appended to the other C flags
CACHE STRING "Flags used by the C compiler during normal builds." FORCE)
set (CMAKE_C_FLAGS_DEBUG "-g -DDDEBUG"
CACHE STRING "Flags used by the C compiler during debug builds." FORCE)
set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)
set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)
set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)

endif (NOT CONFIGURED)
if (CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
target_compile_options(miniupnpc-private INTERFACE -Wall)
endif ()
endif()

Expand All @@ -80,8 +68,13 @@ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fPIC")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fPIC")
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -fPIC")

# Suppress noise warnings
if (MSVC)
target_compile_definitions(miniupnpc-private INTERFACE _CRT_SECURE_NO_WARNINGS)
endif()

configure_file (${CMAKE_CURRENT_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/miniupnpcstrings.h)
include_directories (${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(miniupnpc-private INTERFACE ${CMAKE_CURRENT_BINARY_DIR})

set (MINIUPNPC_SOURCES
igd_desc_parse.c
Expand All @@ -97,82 +90,109 @@ set (MINIUPNPC_SOURCES
connecthostport.c
portlistingparse.c
receivedata.c
connecthostport.h
igd_desc_parse.h
minisoap.h
minissdpc.h
miniupnpc.h
miniupnpctypes.h
miniwget.h
minixml.h
portlistingparse.h
receivedata.h
upnpcommands.h
upnpdev.h
upnperrors.h
upnpreplyparse.h
${CMAKE_CURRENT_BINARY_DIR}/miniupnpcstrings.h
)

if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")

if (WIN32)
set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
COMPILE_DEFINITIONS "MINIUPNP_STATICLIB;MINIUPNP_EXPORTS"
)
endif (WIN32)
endif ()

if (WIN32)
# We use set instead of find_library because otherwise static compilation on Windows breaks. Don't ask me why, just roll with it.
# find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
# find_library (IPHLPAPI_LIBRARY NAMES iphlpapi)
set (WINSOCK2_LIBRARY ws2_32)
set (IPHLPAPI_LIBRARY iphlpapi)
set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
target_link_libraries(miniupnpc-private INTERFACE ws2_32 iphlpapi)
#elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
# find_library (SOCKET_LIBRARY NAMES socket)
# find_library (NSL_LIBRARY NAMES nsl)
# find_library (RESOLV_LIBRARY NAMES resolv)
# set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS})
endif (WIN32)
endif ()

if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
message (FATAL "Both shared and static libraries are disabled!")
endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)

if (UPNPC_BUILD_STATIC)
add_library (libminiupnpc-static STATIC ${MINIUPNPC_SOURCES})
set_target_properties (libminiupnpc-static PROPERTIES OUTPUT_NAME "miniupnpc")
target_link_libraries (libminiupnpc-static ${LDLIBS})
set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} libminiupnpc-static)
set (UPNPC_LIBRARY_TARGET libminiupnpc-static)
# add_executable (upnpc-static upnpc.c)
# target_link_libraries (upnpc-static LINK_PRIVATE libminiupnpc-static)
endif (UPNPC_BUILD_STATIC)
target_link_libraries (libminiupnpc-static PRIVATE miniupnpc-private)
target_include_directories(libminiupnpc-static INTERFACE ../${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(libminiupnpc-static PUBLIC MINIUPNP_STATICLIB)

install (TARGETS libminiupnpc-static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})

if (UPNPC_BUILD_SAMPLE)
add_executable (upnpc-static upnpc.c)
target_link_libraries (upnpc-static PRIVATE libminiupnpc-static)
target_include_directories(upnpc-static PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif ()
endif ()

if (UPNPC_BUILD_SHARED)
add_library (libminiupnpc-shared SHARED ${MINIUPNPC_SOURCES})
set_target_properties (libminiupnpc-shared PROPERTIES OUTPUT_NAME "miniupnpc")
set_target_properties (libminiupnpc-shared PROPERTIES VERSION ${MINIUPNPC_VERSION})
set_target_properties (libminiupnpc-shared PROPERTIES SOVERSION ${MINIUPNPC_API_VERSION})
target_link_libraries (libminiupnpc-shared ${LDLIBS})
set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} libminiupnpc-shared)
set (UPNPC_LIBRARY_TARGET libminiupnpc-shared)
add_executable (upnpc-shared upnpc.c)
target_link_libraries (upnpc-shared LINK_PRIVATE libminiupnpc-shared)
endif (UPNPC_BUILD_SHARED)
target_link_libraries (libminiupnpc-shared PRIVATE miniupnpc-private)
target_compile_definitions(libminiupnpc-shared PRIVATE MINIUPNP_EXPORTS)

target_include_directories(libminiupnpc-static INTERFACE ../${CMAKE_CURRENT_SOURCE_DIR})
if (WIN32)
target_link_libraries(libminiupnpc-shared INTERFACE ws2_32 iphlpapi)
endif()

install (TARGETS libminiupnpc-shared
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})

if (UPNPC_BUILD_SAMPLE)
add_executable (upnpc-shared upnpc.c)
target_link_libraries (upnpc-shared PRIVATE libminiupnpc-shared)
target_include_directories(upnpc-shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif ()
endif ()

if (UPNPC_BUILD_TESTS)
add_library(miniupnpc-tests INTERFACE)
target_link_libraries(miniupnpc-tests INTERFACE miniupnpc-private)
target_compile_definitions(miniupnpc-tests INTERFACE MINIUPNP_STATICLIB)

add_executable (testminixml testminixml.c minixml.c igd_desc_parse.c)
target_link_libraries (testminixml ${LDLIBS})
target_link_libraries (testminixml PRIVATE miniupnpc-tests)

add_executable (minixmlvalid minixmlvalid.c minixml.c)
target_link_libraries (minixmlvalid ${LDLIBS})
target_link_libraries (minixmlvalid PRIVATE miniupnpc-tests)

add_executable (testupnpreplyparse testupnpreplyparse.c
minixml.c upnpreplyparse.c)
target_link_libraries (testupnpreplyparse ${LDLIBS})
target_link_libraries (testupnpreplyparse PRIVATE miniupnpc-tests)

add_executable (testigddescparse testigddescparse.c
igd_desc_parse.c minixml.c miniupnpc.c miniwget.c minissdpc.c
upnpcommands.c upnpreplyparse.c minisoap.c connecthostport.c
portlistingparse.c receivedata.c
)
target_link_libraries (testigddescparse ${LDLIBS})
target_link_libraries (testigddescparse PRIVATE miniupnpc-tests)

add_executable (testminiwget testminiwget.c
miniwget.c miniupnpc.c minisoap.c upnpcommands.c minissdpc.c
upnpreplyparse.c minixml.c igd_desc_parse.c connecthostport.c
portlistingparse.c receivedata.c
)
target_link_libraries (testminiwget ${LDLIBS})
target_link_libraries (testminiwget PRIVATE miniupnpc-tests)

# set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
endif (UPNPC_BUILD_TESTS)
Expand Down
15 changes: 14 additions & 1 deletion miniupnpc/Changelog.txt
@@ -1,6 +1,19 @@
$Id: Changelog.txt,v 1.229 2017/12/12 11:26:25 nanard Exp $
$Id: Changelog.txt,v 1.235 2018/05/07 11:05:16 nanard Exp $
miniUPnP client Changelog.

VERSION 2.1 : released 2018/05/07

2018/05/07:
CMake Modernize and cleanup CMakeLists.txt
Update MS Visual Studio projects

2018/04/30:
listdevices: show devices sorted by XML desc URL

2018/04/26:
Small fix in miniupnpcmodule.c (python module)
Support cross compiling in Makefile.mingw

2018/04/06:
Use SOCKET type instead of int (for Win64 compilation)
Increments API_VERSION to 17
Expand Down
35 changes: 27 additions & 8 deletions miniupnpc/Makefile.mingw
@@ -1,10 +1,20 @@
# $Id: Makefile.mingw,v 1.21 2015/09/18 12:45:16 nanard Exp $
# Miniupnp project.
# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
# (c) 2005-2015 Thomas Bernard
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
# (c) 2005-2018 Thomas Bernard
# This Makefile is made for MinGW
#
# To cross compile on a *nix machine :
# make -f Makefile.mingw DLLWRAP=mingw32-dllwrap CC=mingw32-gcc AR=mingw32-ar
#
CC ?= gcc
DLLWRAP = dllwrap
SH = /bin/sh
ifeq ($(OS),Windows_NT)
RM = del
else
RM = rm -f
endif
#CFLAGS = -Wall -g -DDEBUG -D_WIN32_WINNT=0X501
CFLAGS = -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501
LDLIBS = -lws2_32 -liphlpapi
Expand All @@ -26,11 +36,11 @@ init:
echo init > init

clean:
del upnpc testminixml *.o
del dll\*.o
del *.exe
del miniupnpc.dll
del libminiupnpc.a
$(RM) upnpc testminixml *.o
$(RM) dll\*.o
$(RM) *.exe
$(RM) miniupnpc.dll
$(RM) libminiupnpc.a

libminiupnpc.a: $(OBJS)
$(AR) cr $@ $?
Expand All @@ -40,7 +50,7 @@ pythonmodule: libminiupnpc.a
$(PYTHON) setupmingw32.py install --skip-build

miniupnpc.dll: libminiupnpc.a $(OBJSDLL)
dllwrap -k --driver-name gcc \
$(DLLWRAP) -k --driver-name $(CC) \
--def miniupnpc.def \
--output-def miniupnpc.dll.def \
--implib miniupnpc.lib -o $@ \
Expand Down Expand Up @@ -74,8 +84,17 @@ wingenminiupnpcstrings: wingenminiupnpcstrings.o

wingenminiupnpcstrings.o: wingenminiupnpcstrings.c

# To make miniupnpcstrings.h from miniupnpcstrings.h.in we either
# use a custom executable (if running make under windows) or use
# sed (if cross compiling from another platform).
ifeq ($(OS),Windows_NT)
miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings
wingenminiupnpcstrings $< $@
else
miniupnpcstrings.h: miniupnpcstrings.h.in VERSION
sed 's|OS_STRING ".*"|OS_STRING "Windows/Mingw32"|' $< | \
sed 's|MINIUPNPC_VERSION_STRING ".*"|MINIUPNPC_VERSION_STRING "$(shell cat VERSION)"|' > $@
endif

minixml.o: minixml.c minixml.h

Expand Down
2 changes: 1 addition & 1 deletion miniupnpc/VERSION
@@ -1 +1 @@
2.0
2.1

0 comments on commit 6b9b73a

Please sign in to comment.