Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 7d7f43c

Browse files
authored
1.0.0 beta.2 (#3)
1 parent 0c22011 commit 7d7f43c

37 files changed

+1513
-389
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the LaunchDarkly C server-side SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [1.0.0-beta.2] - 2019-04-05
6+
### Added
7+
- Windows support
8+
- Networking retry timing jitter
9+
- Analytics `debugEventsUntilDate` support
10+
511
## [1.0.0-beta.1] - 2019-03-27
612
### Added
713
- Initial public API

CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
cmake_minimum_required(VERSION 2.8)
2-
find_package(CURL REQUIRED)
32

43
enable_testing() # CTEST_OUTPUT_ON_FAILURE=1 make test
54

6-
set(CMAKE_C_FLAGS "-D__USE_XOPEN -D_GNU_SOURCE -Wall -Wextra -g3 -fno-omit-frame-pointer -Wno-pointer-to-int-cast -Wdeclaration-after-statement")
5+
if(MSVC)
6+
set(CMAKE_C_FLAGS "-D CURL_STATICLIB -D PCRE_STATIC -MD")
7+
set(CURL_LIBRARIES ../curl-7.59.0/builds/libcurl-vc-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a)
8+
set(CURL_INCLUDE_DIR curl-7.59.0/builds/libcurl-vc-x64-release-static-ipv6-sspi-winssl/include)
9+
set(PCRE_LIBRARIES ../pcre-8.43/build/Debug/pcred)
10+
set(PCRE_INCLUDE_DIR pcre-8.43/build)
11+
else()
12+
find_package(CURL REQUIRED)
13+
set(CMAKE_C_FLAGS "-D__USE_XOPEN -D_GNU_SOURCE -g3 -fno-omit-frame-pointer -fvisibility=hidden")
14+
set(PCRE_LIBRARIES pcre)
15+
set(LD_LIBRARIES pthread m)
16+
endif(MSVC)
717

8-
include_directories("include" "third-party/include" ${CURL_INCLUDE_DIR})
18+
include_directories("include" "third-party/include" ${CURL_INCLUDE_DIR} ${PCRE_INCLUDE_DIR})
919
file(GLOB SOURCES "src/*" "third-party/src/*")
1020

21+
set(LD_LIBRARIES ${LD_LIBRARIES} ${CURL_LIBRARIES} ${PCRE_LIBRARIES})
22+
1123
add_library(ldserverapi STATIC ${SOURCES})
12-
target_link_libraries(ldserverapi ${CURL_LIBRARIES} pthread pcre m gmp)
24+
target_link_libraries(ldserverapi ${LD_LIBRARIES})
1325

1426
add_library(ldserverapidynamic SHARED ${SOURCES})
15-
target_link_libraries(ldserverapidynamic ${CURL_LIBRARIES} pthread pcre m gmp)
27+
target_link_libraries(ldserverapidynamic ${LD_LIBRARIES})
1628

1729
file(GLOB TESTS "tests/*")
1830
foreach(testsource ${TESTS})

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ For using LaunchDarkly in C / C++ client-side applications, refer to our [C / C+
1010
Quick setup (POSIX)
1111
-------------------
1212

13-
The C / C++ SDK requires a POSIX environment, and assumes that `libcurl`, `libpthread`, `libpcre`, and `libgmp` are installed.
13+
The C / C++ SDK requires a POSIX environment, and assumes that `libcurl`, `libpthread`, and `libpcre` are installed.
1414

1515
Unlike other LaunchDarkly SDKs, the C SDK has no installation steps. To get started, clone [this repository](https://github.com/launchdarkly/c-client-server-side) or download a release archive from the [GitHub Releases](https://github.com/launchdarkly/c-client-server-side/releases) page. You can use the `Makefile` in this repository as a starting point for integrating this SDK into your application.
1616

1717
You can get the required dependencies on Ubuntu Linux with:
1818

1919
```
20-
sudo apt-get update && sudo apt-get install build-essential libcurl4-openssl-dev libpcre3-dev libgmp-dev
20+
sudo apt-get update && sudo apt-get install build-essential libcurl4-openssl-dev libpcre3-dev
2121
```
2222

2323
Getting started

azure-pipelines.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
variables:
2+
ld_tool_chain: 'call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64'
3+
4+
jobs:
5+
- job: build
6+
pool:
7+
vmImage: 'vs2017-win2016'
8+
steps:
9+
- task: PowerShell@2
10+
displayName: 'Fetch Curl'
11+
inputs:
12+
targetType: inline
13+
script: iwr -outf curl.zip https://curl.haxx.se/download/curl-7.59.0.zip
14+
- task: ExtractFiles@1
15+
displayName: 'Extract Curl'
16+
inputs:
17+
archiveFilePatterns: curl.zip
18+
cleanDestinationFolder: false
19+
- task: CmdLine@2
20+
displayName: 'Build Curl'
21+
inputs:
22+
script: |
23+
%ld_tool_chain%
24+
cd curl-7.59.0/winbuild
25+
nmake /f Makefile.vc mode=static
26+
27+
- task: PowerShell@2
28+
displayName: 'Fetch PCRE'
29+
inputs:
30+
targetType: inline
31+
script: iwr -outf pcre.zip https://ftp.pcre.org/pub/pcre/pcre-8.43.zip
32+
- task: ExtractFiles@1
33+
displayName: 'Extract PCRE'
34+
inputs:
35+
archiveFilePatterns: pcre.zip
36+
cleanDestinationFolder: false
37+
- task: CmdLine@2
38+
displayName: 'Build PCRE'
39+
inputs:
40+
script: |
41+
%ld_tool_chain%
42+
cd pcre-8.43
43+
mkdir build
44+
cd build
45+
cmake -G "Visual Studio 15 2017 Win64" ..
46+
cmake --build .
47+
48+
- task: CmdLine@2
49+
displayName: 'Build SDK'
50+
inputs:
51+
script: |
52+
%ld_tool_chain%
53+
mkdir build
54+
cd build
55+
cmake -G "Visual Studio 15 2017 Win64" ..
56+
cmake --build .
57+
58+
- task: CmdLine@2
59+
displayName: 'Test SDK'
60+
inputs:
61+
script: |
62+
%ld_tool_chain%
63+
cd build
64+
cmake --build . --target RUN_TESTS
65+
66+
- task: CopyFiles@2
67+
inputs:
68+
targetFolder: $(Build.ArtifactStagingDirectory)
69+
sourceFolder: $(System.DefaultWorkingDirectory)/build/Debug
70+
contents: 'ldserverapidynamic.dll'
71+
- task: CopyFiles@2
72+
inputs:
73+
targetFolder: $(Build.ArtifactStagingDirectory)
74+
sourceFolder: $(System.DefaultWorkingDirectory)/build/Debug
75+
contents: 'ldserverapidynamic.lib'
76+
- task: CopyFiles@2
77+
inputs:
78+
targetFolder: $(Build.ArtifactStagingDirectory)
79+
sourceFolder: $(System.DefaultWorkingDirectory)/build/Debug
80+
contents: 'ldserverapi.lib'
81+
82+
- task: PowerShell@2
83+
inputs:
84+
targetType: inline
85+
script: |
86+
Rename-Item -Path "ldserverapidynamic.dll" -NewName "windows-vs-64bit-ldserverapi-dynamic.dll"
87+
Rename-Item -Path "ldserverapidynamic.lib" -NewName "windows-vs-64bit-ldserverapi-dynamic.lib"
88+
Rename-Item -Path "ldserverapi.lib" -NewName "windows-vs-64bit-ldserverapi-static.lib"
89+
workingDirectory: '$(Build.ArtifactStagingDirectory)'
90+
displayName: 'Rename Artifacts'
91+
92+
- task: PublishBuildArtifacts@1
93+
inputs:
94+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
95+
artifactName: library

include/ldapi.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66
#pragma once
77

8-
#ifdef __cplusplus
9-
10-
extern "C" {
11-
#endif
12-
13-
#define LD_SDK_VERSION "1.0.0-beta.1"
8+
#define LD_SDK_VERSION "1.0.0-beta.2"
149

1510
#include <stdbool.h>
1611
#include <stddef.h>
@@ -22,7 +17,3 @@ extern "C" {
2217
#include "ldclient.h"
2318
#include "ldvariations.h"
2419
#include "ldmemory.h"
25-
26-
#ifdef __cplusplus
27-
}
28-
#endif

include/ldclient.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010

1111
#include "ldjson.h"
1212
#include "lduser.h"
13+
#include "ldexport.h"
1314

14-
struct LDClient *LDClientInit(struct LDConfig *const config,
15+
LD_EXPORT(struct LDClient *) LDClientInit(struct LDConfig *const config,
1516
const unsigned int maxwaitmilli);
1617

17-
void LDClientClose(struct LDClient *const client);
18+
LD_EXPORT(void) LDClientClose(struct LDClient *const client);
1819

19-
bool LDClientIsInitialized(struct LDClient *const client);
20+
LD_EXPORT(bool) LDClientIsInitialized(struct LDClient *const client);
2021

21-
bool LDClientTrack(struct LDClient *const client,
22+
LD_EXPORT(bool) LDClientTrack(struct LDClient *const client,
2223
const char *const key, const struct LDUser *const user,
2324
struct LDJSON *const data);
2425

25-
bool LDClientIdentify(struct LDClient *const client,
26+
LD_EXPORT(bool) LDClientIdentify(struct LDClient *const client,
2627
const struct LDUser *const user);
2728

28-
bool LDClientIsOffline(struct LDClient *const client);
29+
LD_EXPORT(bool) LDClientIsOffline(struct LDClient *const client);
2930

30-
void LDClientFlush(struct LDClient *const client);
31+
LD_EXPORT(void) LDClientFlush(struct LDClient *const client);

include/ldconfig.h

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <stdbool.h>
99
#include <stddef.h>
1010

11+
#include "ldexport.h"
12+
1113
/* **** Forward Declarations **** */
1214

1315
struct LDStore; struct LDConfig;
@@ -18,14 +20,14 @@ struct LDStore; struct LDConfig;
1820
* it should no longer be modified.
1921
* @return NULL on failure.
2022
*/
21-
struct LDConfig *LDConfigNew(const char *const key);
23+
LD_EXPORT(struct LDConfig *) LDConfigNew(const char *const key);
2224

2325
/**
2426
* @brief Destroy a config not associated with a client instance.
2527
* @param[in] config May be NULL.
2628
* @return Void.
2729
*/
28-
void LDConfigFree(struct LDConfig *const config);
30+
LD_EXPORT(void) LDConfigFree(struct LDConfig *const config);
2931

3032
/**
3133
* @brief Set the base URI for connecting to LaunchDarkly. You probably don't
@@ -35,7 +37,7 @@ void LDConfigFree(struct LDConfig *const config);
3537
* @param[in] baseURI The new base URI to use. May not be NULL (assert).
3638
* @return True on success, False on failure
3739
*/
38-
bool LDConfigSetBaseURI(struct LDConfig *const config,
40+
LD_EXPORT(bool) LDConfigSetBaseURI(struct LDConfig *const config,
3941
const char *const baseURI);
4042

4143
/**
@@ -46,7 +48,7 @@ bool LDConfigSetBaseURI(struct LDConfig *const config,
4648
* @param[in] streamURI The new stream URI to use. May not be NULL (assert).
4749
* @return True on success, False on failure
4850
*/
49-
bool LDConfigSetStreamURI(struct LDConfig *const config,
51+
LD_EXPORT(bool) LDConfigSetStreamURI(struct LDConfig *const config,
5052
const char *const streamURI);
5153

5254
/**
@@ -57,7 +59,7 @@ bool LDConfigSetStreamURI(struct LDConfig *const config,
5759
* @param[in] eventsURI The new events URI to use. May not be NULL (assert).
5860
* @return True on success, False on failure
5961
*/
60-
bool LDConfigSetEventsURI(struct LDConfig *const config,
62+
LD_EXPORT(bool) LDConfigSetEventsURI(struct LDConfig *const config,
6163
const char *const eventsURI);
6264

6365
/**
@@ -69,7 +71,8 @@ bool LDConfigSetEventsURI(struct LDConfig *const config,
6971
* @param[in] stream True for streaming, False for polling.
7072
* @return Void.
7173
*/
72-
void LDConfigSetStream(struct LDConfig *const config, const bool stream);
74+
LD_EXPORT(void) LDConfigSetStream(struct LDConfig *const config,
75+
const bool stream);
7376

7477
/**
7578
* @brief Sets whether to send analytics events back to LaunchDarkly. By
@@ -79,7 +82,7 @@ void LDConfigSetStream(struct LDConfig *const config, const bool stream);
7982
* @param[in] sendEvents
8083
* @return Void.
8184
*/
82-
void LDConfigSetSendEvents(struct LDConfig *const config,
85+
LD_EXPORT(void) LDConfigSetSendEvents(struct LDConfig *const config,
8386
const bool sendEvents);
8487

8588
/**
@@ -90,7 +93,7 @@ void LDConfigSetSendEvents(struct LDConfig *const config,
9093
* @param[in] eventsCapacity
9194
* @return Void.
9295
*/
93-
void LDConfigSetEventsCapacity(struct LDConfig *const config,
96+
LD_EXPORT(void) LDConfigSetEventsCapacity(struct LDConfig *const config,
9497
const unsigned int eventsCapacity);
9598

9699
/**
@@ -99,7 +102,7 @@ void LDConfigSetEventsCapacity(struct LDConfig *const config,
99102
* @param[in] milliseconds
100103
* @return Void.
101104
*/
102-
void LDConfigSetTimeout(struct LDConfig *const config,
105+
LD_EXPORT(void) LDConfigSetTimeout(struct LDConfig *const config,
103106
const unsigned int milliseconds);
104107

105108
/**
@@ -108,7 +111,7 @@ void LDConfigSetTimeout(struct LDConfig *const config,
108111
* @param[in] milliseconds
109112
* @return Void.
110113
*/
111-
void LDConfigSetFlushInterval(struct LDConfig *const config,
114+
LD_EXPORT(void) LDConfigSetFlushInterval(struct LDConfig *const config,
112115
const unsigned int milliseconds);
113116

114117
/**
@@ -117,7 +120,7 @@ void LDConfigSetFlushInterval(struct LDConfig *const config,
117120
* @param[in] milliseconds
118121
* @return Void.
119122
*/
120-
void LDConfigSetPollInterval(struct LDConfig *const config,
123+
LD_EXPORT(void) LDConfigSetPollInterval(struct LDConfig *const config,
121124
const unsigned int milliseconds);
122125

123126
/**
@@ -128,7 +131,8 @@ void LDConfigSetPollInterval(struct LDConfig *const config,
128131
* @param[in] offline
129132
* @return Void.
130133
*/
131-
void LDConfigSetOffline(struct LDConfig *const config, const bool offline);
134+
LD_EXPORT(void) LDConfigSetOffline(struct LDConfig *const config,
135+
const bool offline);
132136

133137
/**
134138
* @brief Sets whether this client should use the LaunchDarkly relay
@@ -138,7 +142,8 @@ void LDConfigSetOffline(struct LDConfig *const config, const bool offline);
138142
* @param[in] useLDD
139143
* @return Void.
140144
*/
141-
void LDConfigSetUseLDD(struct LDConfig *const config, const bool useLDD);
145+
LD_EXPORT(void) LDConfigSetUseLDD(struct LDConfig *const config,
146+
const bool useLDD);
142147

143148
/**
144149
* @brief Sets whether or not all user attributes (other than the key) should be
@@ -148,7 +153,7 @@ void LDConfigSetUseLDD(struct LDConfig *const config, const bool useLDD);
148153
* @param[in] allAttributesPrivate
149154
* @return Void.
150155
*/
151-
void LDConfigSetAllAttributesPrivate(struct LDConfig *const config,
156+
LD_EXPORT(void) LDConfigSetAllAttributesPrivate(struct LDConfig *const config,
152157
const bool allAttributesPrivate);
153158

154159
/**
@@ -158,7 +163,7 @@ void LDConfigSetAllAttributesPrivate(struct LDConfig *const config,
158163
* @param[in] userKeysCapacity
159164
* @return Void
160165
*/
161-
void LDConfigSetUserKeysCapacity(struct LDConfig *const config,
166+
LD_EXPORT(void) LDConfigSetUserKeysCapacity(struct LDConfig *const config,
162167
const unsigned int userKeysCapacity);
163168

164169
/**
@@ -168,7 +173,7 @@ void LDConfigSetUserKeysCapacity(struct LDConfig *const config,
168173
* @param[in] userKeysFlushInterval
169174
* @return Void
170175
*/
171-
void LDConfigSetUserKeysFlushInterval(struct LDConfig *const config,
176+
LD_EXPORT(void) LDConfigSetUserKeysFlushInterval(struct LDConfig *const config,
172177
const unsigned int userKeysFlushInterval);
173178

174179
/**
@@ -179,7 +184,7 @@ void LDConfigSetUserKeysFlushInterval(struct LDConfig *const config,
179184
* @param[in] attribute May not be NULL (assert).
180185
* @return NULL on failure.
181186
*/
182-
bool LDConfigAddPrivateAttribute(struct LDConfig *const config,
187+
LD_EXPORT(bool) LDConfigAddPrivateAttribute(struct LDConfig *const config,
183188
const char *const attribute);
184189

185190
/**
@@ -189,5 +194,5 @@ bool LDConfigAddPrivateAttribute(struct LDConfig *const config,
189194
* @param[in] store. May not be NULL (assert).
190195
* @return NULL on failure.
191196
*/
192-
void LDConfigSetFeatureStore(struct LDConfig *const config,
197+
LD_EXPORT(void) LDConfigSetFeatureStore(struct LDConfig *const config,
193198
struct LDStore *const store);

0 commit comments

Comments
 (0)