diff options
| author | Mark Nunberg <mnunberg@haskalah.org> | 2019-04-10 08:36:34 -0400 | 
|---|---|---|
| committer | Mark Nunberg <mnunberg@haskalah.org> | 2019-04-10 08:36:34 -0400 | 
| commit | dc3c6ce85cf17e1da653a4a17bf3cca69ed02732 (patch) | |
| tree | a4e734fe1d0e06a295ae96d76a7ddb6b53234418 | |
| parent | 4830786c84b96d2a2e95b49fba55a1548d9971e1 (diff) | |
| download | hiredict-dc3c6ce85cf17e1da653a4a17bf3cca69ed02732.tar.xz | |
build ssl example if ssl is enabled
| -rw-r--r-- | examples/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | examples/example-ssl.c | 8 | 
2 files changed, 11 insertions, 2 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 27388cb..8ab4b42 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,5 +37,10 @@ IF (APPLE)      TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF})  ENDIF() +IF (HIREDIS_SSL) +    ADD_EXECUTABLE(example-ssl example-ssl.c) +    TARGET_LINK_LIBRARIES(example-ssl hiredis) +ENDIF() +  ADD_EXECUTABLE(example example.c)  TARGET_LINK_LIBRARIES(example hiredis)
\ No newline at end of file diff --git a/examples/example-ssl.c b/examples/example-ssl.c index a90b78a..156f524 100644 --- a/examples/example-ssl.c +++ b/examples/example-ssl.c @@ -18,8 +18,12 @@ int main(int argc, char **argv) {      const char *key = argv[4];      const char *ca = argc > 4 ? argv[5] : NULL; -    struct timeval timeout = { 1, 500000 }; // 1.5 seconds -    c = redisConnectWithTimeout(hostname, port, timeout); +    struct timeval tv = { 1, 500000 }; // 1.5 seconds +    redisOptions options = {0}; +    REDIS_OPTIONS_SET_TCP(&options, hostname, port); +    options.timeout = &tv; +    c = redisConnectWithOptions(&options); +      if (c == NULL || c->err) {          if (c) {              printf("Connection error: %s\n", c->errstr);  | 
