Housekeeping fixes (#764)

Housekeeping

* Check for C++ (#758, #750) 
* Include `alloc.h` in `make install` and `cmake`
* Add a `.def` file for Windows (#760)
* Include allocation wrappers referenced in adapter headers
* Fix minor syntax errors and typos in README
* Fix CI in Windows by properly escaping arguments (#761)
This commit is contained in:
Michael Grunder 2020-02-27 21:29:05 -08:00 committed by GitHub
parent 3421ac3093
commit 38675d23cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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 */

38
hiredis.def Normal file
View File

@ -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

View File

@ -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 */