summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--CMakeLists.txt13
-rw-r--r--README.md10
-rw-r--r--alloc.h8
-rw-r--r--hiredis.def38
-rw-r--r--hiredis_ssl.h8
6 files changed, 72 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml
index dd8e0e7..ba63134 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -91,7 +91,6 @@ matrix:
- choco install ninja
script:
- mkdir build && cd build
- - cmd.exe /C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 &&
- cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release &&
- ninja -v'
+ - cmd.exe //C 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat' amd64 '&&'
+ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release '&&' ninja -v
- ctest -V
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 770e1a1..564c138 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,7 +23,7 @@ PROJECT(hiredis VERSION "${VERSION}")
SET(ENABLE_EXAMPLES OFF CACHE BOOL "Enable building hiredis examples")
-ADD_LIBRARY(hiredis SHARED
+SET(hiredis_sources
async.c
dict.c
hiredis.c
@@ -33,6 +33,15 @@ ADD_LIBRARY(hiredis SHARED
sockcompat.c
alloc.c)
+IF(WIN32)
+ SET(hiredis_sources
+ ${hiredis_sources}
+ hiredis.def
+ )
+ENDIF()
+
+ADD_LIBRARY(hiredis SHARED ${hiredis_sources})
+
SET_TARGET_PROPERTIES(hiredis
PROPERTIES
VERSION "${HIREDIS_SONAME}")
@@ -46,7 +55,7 @@ CONFIGURE_FILE(hiredis.pc.in hiredis.pc @ONLY)
INSTALL(TARGETS hiredis
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-INSTALL(FILES hiredis.h read.h sds.h async.h
+INSTALL(FILES hiredis.h read.h sds.h async.h alloc.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
INSTALL(DIRECTORY adapters
diff --git a/README.md b/README.md
index 6095cec..a7c46ba 100644
--- a/README.md
+++ b/README.md
@@ -205,16 +205,16 @@ a single call to `read(2)`):
redisReply *reply;
redisAppendCommand(context,"SET foo bar");
redisAppendCommand(context,"GET foo");
-redisGetReply(context,&reply); // reply for SET
+redisGetReply(context,(void *)&reply); // reply for SET
freeReplyObject(reply);
-redisGetReply(context,&reply); // reply for GET
+redisGetReply(context,(void *)&reply); // reply for GET
freeReplyObject(reply);
```
This API can also be used to implement a blocking subscriber:
```c
reply = redisCommand(context,"SUBSCRIBE foo");
freeReplyObject(reply);
-while(redisGetReply(context,&reply) == REDIS_OK) {
+while(redisGetReply(context,(void *)&reply) == REDIS_OK) {
// consume message
freeReplyObject(reply);
}
@@ -432,7 +432,7 @@ SSL can only be enabled on a `redisContext` connection after the connection has
been established and before any command has been processed. For example:
```c
-c = redisConnect('localhost', 6443);
+c = redisConnect("localhost", 6443);
if (c == NULL || c->err) {
/* Handle error and abort... */
}
@@ -440,7 +440,7 @@ if (c == NULL || c->err) {
if (redisSecureConnection(c,
"cacertbundle.crt", /* File name of trusted CA/ca bundle file */
"client_cert.pem", /* File name of client certificate file */
- "client_key.pem", /* File name of client privat ekey */
+ "client_key.pem", /* File name of client private key */
"redis.mydomain.com" /* Server name to request (SNI) */
) != REDIS_OK) {
printf("SSL error: %s\n", c->errstr);
diff --git a/alloc.h b/alloc.h
index 803129c..fdabd2a 100644
--- a/alloc.h
+++ b/alloc.h
@@ -36,9 +36,17 @@
#define HIREDIS_OOM_HANDLER abort()
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void *hi_malloc(size_t size);
void *hi_calloc(size_t nmemb, size_t size);
void *hi_realloc(void *ptr, size_t size);
char *hi_strdup(const char *str);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* HIREDIS_ALLOC_H */
diff --git a/hiredis.def b/hiredis.def
new file mode 100644
index 0000000..7e7dbb4
--- /dev/null
+++ b/hiredis.def
@@ -0,0 +1,38 @@
+EXPORTS
+ redisAppendCommand
+ redisAppendCommandArgv
+ redisAppendFormattedCommand
+ redisBufferRead
+ redisBufferWrite
+ redisCommand
+ redisCommand
+ redisCommandArgv
+ redisConnect
+ redisConnectBindNonBlock
+ redisConnectBindNonBlockWithReuse
+ redisConnectFd
+ redisConnectNonBlock
+ redisConnectUnix
+ redisConnectUnixNonBlock
+ redisConnectUnixWithTimeout
+ redisConnectWithOptions
+ redisConnectWithTimeout
+ redisEnableKeepAlive
+ redisFormatCommand
+ redisFormatCommandArgv
+ redisFormatSdsCommandArgv
+ redisFree
+ redisFreeCommand
+ redisFreeKeepFd
+ redisFreeSdsCommand
+ redisGetReply
+ redisGetReplyFromReader
+ redisReaderCreate
+ redisReconnect
+ redisSetTimeout
+ redisvAppendCommand
+ redisvCommand
+ redisvFormatCommand
+ freeReplyObject
+ hi_calloc
+ hi_malloc
diff --git a/hiredis_ssl.h b/hiredis_ssl.h
index f844f95..21e8580 100644
--- a/hiredis_ssl.h
+++ b/hiredis_ssl.h
@@ -32,6 +32,10 @@
#ifndef __HIREDIS_SSL_H
#define __HIREDIS_SSL_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* This is the underlying struct for SSL in ssl.h, which is not included to
* keep build dependencies short here.
*/
@@ -50,4 +54,8 @@ int redisSecureConnection(redisContext *c, const char *capath, const char *certp
int redisInitiateSSL(redisContext *c, struct ssl_st *ssl);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __HIREDIS_SSL_H */