Skip to content

Commit 3b3f498

Browse files
committed
Merge commit '79623d6'
Conflicts: lib/curl_transport/curltransaction.c
2 parents 2f56673 + 79623d6 commit 3b3f498

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1308
-772
lines changed

Windows/UsingCURLinWin32.txt

Lines changed: 54 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,73 @@
1-
Background:
1+
Motivation:
22

3-
Let�s say you need to have a Xmlrpc-c client running as a service.
4-
In this situation you cannot use WinInet. Details of the restriction
5-
can be found on the libcurl website or various Microsoft KB articles.
6-
The alternative is to use libcurl. This document describes the steps
7-
required to use libcurl as your client XML transport mechanism.
3+
Let�s say you need to have a Xmlrpc-c client running as a service. In this
4+
situation you cannot use WinInet. You can find details of the restriction on
5+
the Curl website or various Microsoft KB articles. Your alternative is to use
6+
the Curl HTTP client library. This document tells how to use use the Curl
7+
library instead of the default Wininet as your client XML transport mechanism.
88

99
Overview:
1010

11-
The default projects in Xmlrpc-c create standalone executables that do
12-
not require other DLL�s (release mode). While the case can be made
13-
for this behavior pro and con, it is beyond this document to justify
14-
it. Therefore, we need to create static link libraries for libcurl
15-
that mimics this behavior. Once the link libraries are created, we
16-
can then add them (plus the requisite curl headers) into the Xmlrpc-c
17-
project. Finally, we enable the compilation of the curl transport
18-
file and tell Xmlrpc-c that we will be using curl. Lastly, we build
19-
and test the project.
20-
21-
Steps to use CURL with Win32 Xmlrpc-c:
22-
23-
1. Download the CURL source. In the �include� folder of the
24-
CURL distribution, copy the curl directory to the �lib�
25-
directory of xmlrpc-c. When you are done with this step, you should
26-
have a curl.h file located in the directory xmlrpc-c\lib\curl\. The
27-
xmlrpc project looks in this relative path for the necessary headers.
28-
29-
2. In the CURL distribution, lib directory, is a file called
30-
Makefile.vc6. Edit this file. The line starting with CCNODBG should
31-
be changed to:
32-
33-
CCNODBG = cl.exe /MT /O2 /DNDEBUG
34-
35-
The /MT option links with the Multithreaded non-dll version of the c
36-
runtime. If this change is not made, the project will not link, as
37-
this is the default setting for the Xmlrpc-c projects.
38-
39-
3. Open a command prompt window and run the vcvars32.bat file in your
40-
Visual C++ distribution. If you are using Studio 2002 or 2003, use
41-
the �Visual Studio Command Prompt� from the Start menu to open
42-
the console.
43-
44-
4. Compile release and debug mode libraries. For the purposes of this
45-
tutorial, we are going to build only the curl library without ssl or
46-
zlib compression capability. In the command prompt, navigate to the
47-
curl\lib directory and execute the following commands:
48-
49-
nmake -f Makefile.vc6 CFG=debug RTLIBCFG=static
50-
nmake -f Makefile.vc6 CFG=release RTLIBCFG=static
51-
52-
5. The above step should have generated two static link libraries in
53-
the curl\lib directory: libcurl.lib and libcurld.lib. Copy these
54-
files into the root of the xmlrpc-c\lib\ directory. This step ends
55-
our involvement with the actual CURL distribution. The remainder of
56-
the steps are for Xmlrpc-c.
57-
58-
6. Open the Xmlrpc-c Visual Studio workspace (Instructions for VC++ 6,
59-
other versions are slightly different). In File View, expand the
60-
xmlrpc project. Under "Source Files" there is an entry for
61-
xmlrpc_curl_transport.c This is not included in any build paths by
62-
default. To enable it for compilation, right click the file to change
63-
the settings. In the dropdown, select "All Configurations." Pick the
64-
General tab and uncheck the "Exclude File From Build" setting. Press
65-
OK to save your changes to the project.
66-
67-
7. In the "Header Files" section of the xmlrpc project is a file
68-
called "transport_config.h". Edit this file to set the
69-
MUST_BUILD_CURL_CLIENT to 1, and if you wish to change the default
70-
transport to curl, change the XMLRPC_DEFAULT_TRANSPORT to "curl".
71-
72-
8. Compile and test one or more of the sample client projects.
73-
74-
USING MSVC8 - 2007/11/25
75-
========================
76-
77-
This is for MSVC8, but most will apply to all version of Microsoft
78-
Visual Studio.
79-
80-
Download the CURL source. Run the buildconf.bat to generate some
81-
additional files. This builds a 'dummy' hugehelp.c, but it can also
82-
be built using the src\mkhelp.pl Perl script. You may have to build
83-
you own VCPROJ file for CURL, if you want to use MSVC. It does
84-
provide a Makefile.vc6 as mentioned above.
11+
The default projects in Xmlrpc-c create standalone executables that do not
12+
require other DLL�s. Therefore, we need to create static link libraries for
13+
libcurl. Once we create the link libraries, we add them (plus the requisite
14+
curl headers) into the Xmlrpc-c project. Finally, we configure the build to
15+
build the curl transport and build client libraries that use it. Finally, we
16+
build and test the project.
17+
18+
19+
BUILD THE CURL LIBRARY
20+
----------------------
21+
22+
Download the Curl source code. Run the buildconf.bat to generate some
23+
additional files. This builds a 'dummy' hugehelp.c, but it can also be built
24+
using the src\mkhelp.pl Perl script. You may have to build your own VCPROJ
25+
file for CURL, if you want to use MSVC.
8526

8627
To build all the CURL library variations, use
87-
> nmake /nologo vc-all
28+
29+
> nmake /nologo vc-all
30+
8831
but note this will use the /MD[d] DLL runtime. Only by adding
8932
RTCFGLIB=static to each of the makefile commands will /MT[d] be
9033
used.
9134

92-
Essentially, for building the static Debug or Release CURL libraries,
93-
it is all the sources in the curl\lib folder. Make sure you choose /MT
94-
and /MTd for the runtime, and build both using say the name libcurl.lib.
35+
Essentially, for building the static Debug or Release CURL libraries, it is
36+
all the sources in the curl\lib folder. Make sure you choose /MT and /MTd for
37+
the runtime, and build both using the name 'libcurl.lib'.
9538

96-
When you have Debug\libcurl.lib and Release\libcurl.lib built, you
97-
are ready to build and link them with Xmlrpc-c.
9839

99-
After running xmlrpc-c\Windows\configurewin32.bat, loading xmlrpc.dsw
100-
will convert all the projects to VCPROJ files. In the File View, in
101-
the xmlrpc project, in the properties of xmlrpc_curl_transport.c,
102-
change 'Exclude file from build' from 'yes' to 'no', for Debug
103-
and Release.
40+
BUILD XMLRPC-C, LINK WITH CURL
41+
------------------------------
42+
43+
From the step above, you have Debug\libcurl.lib and Release\libcurl.lib.
44+
45+
After running xmlrpc-c\Windows\configurewin32.bat, start Visual Studio.
46+
47+
In the File View, in the 'xmlrpc' project, in the properties of
48+
xmlrpc_curl_transport.c, change "Exclude file from build" from "yes" to "no",
49+
for Debug and Release. ==>BUT NOTE: as late as Xmlrpc-c 1.30, this is
50+
broken - there is no xmlrpc_curl_transport.c in the projects. You need to
51+
add it. If you do, please send your changes to the Xmlrpc-c maintainer to
52+
help the next person.
10453

10554
In the 'Header Files' section, open the "transport_config.h" file,
10655
and change MUST_BUILD_CURL_CLIENT to 1, and the XMLRPC_DEFAULT_TRANSPORT
107-
to "curl", if desired.
108-
109-
As usual, for each of the 'client' projects, and rpctest, in the properties,
110-
Linker section, you can add the library libcurl.lib on the Input tab, and
111-
the relative path to the library in the General tab to something like -
112-
..\..\curl\Debug and ..\..\curl\Release, or where ever you built or
113-
copied these static libraries too.
56+
to "curl", if you want.
11457

115-
Or you can adjust the Windows/curlink.h, to directly point to your
116-
respective Debug and Release static CURL libraries, either where you
117-
built them, or where you copied them too.
58+
As usual, for each of the "client" projects, and 'rpctest', in the properties,
59+
Linker section, you can add the library libcurl.lib on the Input tab, and the
60+
relative path to the library in the General tab to something like -
61+
..\..\curl\Debug and ..\..\curl\Release (or wherever you placed the static
62+
Curl libraries you built if you didn't follow recommendations above).
11863

119-
Now, Xmlrpc-c should build using the CURL transport.
64+
Or you can adjust the Windows/curlink.h, to directly point to your respective
65+
Debug and Release static Curl libraries.
12066

121-
Note, for the final linking, all RUNTIME libraries MUST be the SAME.
122-
A mixture of /MD and /MT will give big linkage problems. Any one project
123-
built with the alterate RUNTIME will show many items defined more than
124-
once. And of course, you can also NOT mix Debug with Release. That is
125-
/MDd with /MD, nor /MTd with /MT, or else there will be unresolved
126-
debug items.
67+
Now, Xmlrpc-c should build using the Curl transport.
12768

128-
EOF
69+
Note, for the final linking, all libraries must be linked the same. A mixture
70+
of /MD and /MT will give big linkage problems. Any one project built with the
71+
alterate library will show many items defined more than once. And of course,
72+
you also cannot mix Debug with Release. That is /MDd with /MD, nor /MTd with
73+
/MT. Otherwise, there will be unresolved debug items.

Windows/project/vs2008/xmlrpc.vcproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,6 @@
678678
RelativePath="..\..\..\src\xmlrpc_array.c"
679679
>
680680
</File>
681-
<File
682-
RelativePath="..\..\..\src\xmlrpc_base64.c"
683-
>
684-
</File>
685681
<File
686682
RelativePath="..\..\..\src\xmlrpc_build.c"
687683
>

Windows/xmlrpc_win32_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,11 @@
239239
#define XMLRPC_S_IRUSR S_IRUSR
240240
#endif
241241

242+
243+
#if MSVCRT
244+
#define XMLRPC_CHDIR _chdir
245+
#else
246+
#define XMLRPC_CHDIR chdir
247+
#endif
248+
242249
#endif

common.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ endif
493493
$(TARGET_MODS:%=%.o) $(TARGET_MODS:%=%.osh): \
494494
$(BLDDIR)/include/xmlrpc-c/config.h
495495

496+
ifneq ($(OMIT_XMLRPC_LIB_RULE),Y)
497+
$(BLDDIR)/src/libxmlrpc_client.cflags:
498+
$(MAKE) -C $(dir $@) -f $(SRCDIR)/src/Makefile $(notdir $@)
499+
$(BLDDIR)/src/libxmlrpc_client.ldflags:
500+
$(MAKE) -C $(dir $@) -f $(SRCDIR)/src/Makefile $(notdir $@)
501+
endif
502+
496503
# With a separate build directory, you have to make the directory itself
497504
# before you can make anything in it. Here's the rule to do that.
498505
$(SUBDIRS:%=$(CURDIR)/%):

config.mk.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@ ifeq ($(patsubst cygwin%,cygwin,$(HOST_OS)),cygwin)
322322
LDFLAGS_SHLIB = -shared -Wl,-soname,$(SONAME) $(SHLIB_CLIB)
323323
endif
324324

325+
ifeq ($(patsubst mingw32%,mingw32,$(HOST_OS)),mingw32)
326+
SHARED_LIB_TYPE = dll
327+
MUST_BUILD_SHLIB = Y
328+
MUST_BUILD_SHLIBLE = N
329+
SHLIB_SUFFIX = dll
330+
shlibfn = $(1:%=%.$(SHLIB_SUFFIX))
331+
shliblefn = $(1:%=%.$(SHLIB_SUFFIX))
332+
LDFLAGS_SHLIB = -shared -Wl,-soname,$(SONAME) $(SHLIB_CLIB)
333+
MSVCRT = yes
334+
endif
335+
325336
##############################################################################
326337
# MISCELLANEOUS
327338
##############################################################################

examples/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,26 @@ CLIENTPROGS = \
3131
xmlrpc_asynch_client \
3232

3333
ifeq ($(MUST_BUILD_CURL_CLIENT),yes)
34-
CLIENTPROGS += interrupted_client
34+
ifneq ($(MSVCRT),yes)
35+
CLIENTPROGS += interrupted_client
36+
endif
3537
endif
3638

3739
SERVERPROGS_CGI = \
3840
xmlrpc_sample_add_server.cgi
3941

4042
SERVERPROGS_ABYSS = \
4143
compound_value_server \
42-
interrupted_server \
4344
xmlrpc_inetd_server \
4445
xmlrpc_socket_server \
4546
xmlrpc_loop_server \
4647
xmlrpc_sample_add_server \
4748
xmlrpc_server_validatee \
4849

50+
ifneq ($(MSVCRT),yes)
51+
SERVERPROGS_ABYSS += interrupted_server
52+
endif
53+
4954
BASIC_PROGS = \
5055
json \
5156
gen_sample_add_xml \

examples/cpp/callinfo_abyss_server.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
#include <stdexcept>
2020
#include <iostream>
2121
#include <unistd.h>
22+
#include <stdio.h>
23+
#ifndef _WIN32
2224
#include <sys/socket.h>
2325
#include <netinet/in.h>
24-
#include <stdio.h>
26+
#endif
2527

2628
#include <xmlrpc-c/base.hpp>
2729
#include <xmlrpc-c/registry.hpp>
@@ -63,14 +65,26 @@ tcpAddrFromSockAddr(struct sockaddr const sockAddr) {
6365

6466

6567

66-
static std::string
68+
/* On Windows, we have struct abyss_win_chaninfo, while on Unix we have
69+
struct abyss_unix_chaninfo, but for what we're doing here, they're
70+
fungible -- we use only members that exist in both. So we refer to the
71+
generically with macro CHANINFO_TYPE.
72+
*/
73+
74+
#ifdef _WIN32
75+
#define CHANINFO_TYPE abyss_win_chaninfo
76+
#else
77+
#define CHANINFO_TYPE abyss_unix_chaninfo
78+
#endif
79+
80+
static string
6781
rpcIpAddrMsg(xmlrpc_c::callInfo_serverAbyss const& callInfo) {
6882

6983
void * chanInfoPtr;
7084
SessionGetChannelInfo(callInfo.abyssSessionP, &chanInfoPtr);
7185

72-
struct abyss_unix_chaninfo * const chanInfoP(
73-
static_cast<struct abyss_unix_chaninfo *>(chanInfoPtr));
86+
struct CHANINFO_TYPE * const chanInfoP(
87+
static_cast<struct CHANINFO_TYPE *>(chanInfoPtr));
7488

7589
struct tcpPortAddr const tcpAddr(tcpAddrFromSockAddr(chanInfoP->peerAddr));
7690

@@ -83,7 +97,7 @@ rpcIpAddrMsg(xmlrpc_c::callInfo_serverAbyss const& callInfo) {
8397
tcpAddr.ipAddr[3],
8498
tcpAddr.portNumber);
8599

86-
return std::string(msg);
100+
return string(msg);
87101
}
88102

89103

examples/cpp/pstream_client.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ main(int argc, char **) {
4242
exit(1);
4343
}
4444

45+
#ifndef _WIN32
4546
// It's a good idea to disable SIGPIPE signals; if server closes his end
4647
// of the pipe/socket, we'd rather see a failure to send a call than
4748
// get killed by the OS.
4849
signal(SIGPIPE, SIG_IGN);
50+
#endif
4951

5052
try {
5153
xmlrpc_c::clientXmlTransport_pstream myTransport(

examples/cpp/pstream_inetd_server.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$ socketexec -accept -local_port=8080 ./pstream_inetd_server
1818
*/
1919

20-
#ifndef WIN32
20+
#ifndef _WIN32
2121
#include <unistd.h>
2222
#endif
2323
#include <cassert>
@@ -59,10 +59,12 @@ int
5959
main(int const,
6060
const char ** const) {
6161

62+
#ifndef _WIN32
6263
// It's a good idea to disable SIGPIPE signals; if client closes his end
6364
// of the pipe/socket, we'd rather see a failure to send a response than
6465
// get killed by the OS.
6566
signal(SIGPIPE, SIG_IGN);
67+
#endif
6668

6769
try {
6870
xmlrpc_c::registry myRegistry;

examples/cpp/pstream_serial_server.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ int
5858
main(int const,
5959
const char ** const) {
6060

61+
#ifndef _WIN32
6162
// It's a good idea to disable SIGPIPE signals; if client closes his end
6263
// of the pipe/socket, we'd rather see a failure to send a response than
6364
// get killed by the OS.
6465
signal(SIGPIPE, SIG_IGN);
66+
#endif
6567

6668
try {
6769
xmlrpc_c::registry myRegistry;

examples/cpp/xmlrpc_inetd_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#define WIN32_LEAN_AND_MEAN /* required by xmlrpc-c/server_abyss.hpp */
2626

27-
#ifndef WIN32
27+
#ifndef _WIN32
2828
# include <unistd.h>
2929
#endif
3030
#include <cassert>

examples/cpp/xmlrpc_sample_add_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <cassert>
44
#include <stdexcept>
55
#include <iostream>
6-
#ifdef WIN32
6+
#ifdef _WIN32
77
# include <windows.h>
88
#else
99
# include <unistd.h>
@@ -15,7 +15,7 @@
1515

1616
using namespace std;
1717

18-
#ifdef WIN32
18+
#ifdef _WIN32
1919
#define SLEEP(seconds) SleepEx(seconds * 1000);
2020
#else
2121
#define SLEEP(seconds) sleep(seconds);

0 commit comments

Comments
 (0)