summaryrefslogtreecommitdiff
path: root/examples/example-ssl.c
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-03-23 01:21:46 +0100
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-03-23 01:21:46 +0100
commitbb3475e8eb379ee18f3d8f37caa8040b852a6213 (patch)
tree89975f1c23814a7ab5e16f5c7887f55f1888a27a /examples/example-ssl.c
parentaee72918851db8af296e096b759dfb7aaea17968 (diff)
all: rename redis -> redict symbols and commentsmaster
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'examples/example-ssl.c')
-rw-r--r--examples/example-ssl.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/example-ssl.c b/examples/example-ssl.c
index ac3dfb8..c9b8818 100644
--- a/examples/example-ssl.c
+++ b/examples/example-ssl.c
@@ -9,7 +9,7 @@
#include <string.h>
#include <hiredict.h>
-#include <hiredis_ssl.h>
+#include <hiredict_ssl.h>
#ifdef _MSC_VER
#include <winsock2.h> /* For struct timeval */
@@ -17,10 +17,10 @@
int main(int argc, char **argv) {
unsigned int j;
- redisSSLContext *ssl;
- redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
- redisContext *c;
- redisReply *reply;
+ redictSSLContext *ssl;
+ redictSSLContextError ssl_error = REDICT_SSL_CTX_NONE;
+ redictContext *c;
+ redictReply *reply;
if (argc < 4) {
printf("Usage: %s <host> <port> <cert> <key> [ca]\n", argv[0]);
exit(1);
@@ -31,78 +31,78 @@ int main(int argc, char **argv) {
const char *key = argv[4];
const char *ca = argc > 4 ? argv[5] : NULL;
- redisInitOpenSSL();
- ssl = redisCreateSSLContext(ca, NULL, cert, key, NULL, &ssl_error);
- if (!ssl || ssl_error != REDIS_SSL_CTX_NONE) {
+ redictInitOpenSSL();
+ ssl = redictCreateSSLContext(ca, NULL, cert, key, NULL, &ssl_error);
+ if (!ssl || ssl_error != REDICT_SSL_CTX_NONE) {
printf("SSL Context error: %s\n", redictSSLContextGetError(ssl_error));
exit(1);
}
struct timeval tv = { 1, 500000 }; // 1.5 seconds
- redisOptions options = {0};
- REDIS_OPTIONS_SET_TCP(&options, hostname, port);
+ redictOptions options = {0};
+ REDICT_OPTIONS_SET_TCP(&options, hostname, port);
options.connect_timeout = &tv;
- c = redisConnectWithOptions(&options);
+ c = redictConnectWithOptions(&options);
if (c == NULL || c->err) {
if (c) {
printf("Connection error: %s\n", c->errstr);
- redisFree(c);
+ redictFree(c);
} else {
printf("Connection error: can't allocate redict context\n");
}
exit(1);
}
- if (redisInitiateSSLWithContext(c, ssl) != REDIS_OK) {
+ if (redictInitiateSSLWithContext(c, ssl) != REDICT_OK) {
printf("Couldn't initialize SSL!\n");
printf("Error: %s\n", c->errstr);
- redisFree(c);
+ redictFree(c);
exit(1);
}
/* PING server */
- reply = redisCommand(c,"PING");
+ reply = redictCommand(c,"PING");
printf("PING: %s\n", reply->str);
freeReplyObject(reply);
/* Set a key */
- reply = redisCommand(c,"SET %s %s", "foo", "hello world");
+ reply = redictCommand(c,"SET %s %s", "foo", "hello world");
printf("SET: %s\n", reply->str);
freeReplyObject(reply);
/* Set a key using binary safe API */
- reply = redisCommand(c,"SET %b %b", "bar", (size_t) 3, "hello", (size_t) 5);
+ reply = redictCommand(c,"SET %b %b", "bar", (size_t) 3, "hello", (size_t) 5);
printf("SET (binary API): %s\n", reply->str);
freeReplyObject(reply);
/* Try a GET and two INCR */
- reply = redisCommand(c,"GET foo");
+ reply = redictCommand(c,"GET foo");
printf("GET foo: %s\n", reply->str);
freeReplyObject(reply);
- reply = redisCommand(c,"INCR counter");
+ reply = redictCommand(c,"INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
/* again ... */
- reply = redisCommand(c,"INCR counter");
+ reply = redictCommand(c,"INCR counter");
printf("INCR counter: %lld\n", reply->integer);
freeReplyObject(reply);
/* Create a list of numbers, from 0 to 9 */
- reply = redisCommand(c,"DEL mylist");
+ reply = redictCommand(c,"DEL mylist");
freeReplyObject(reply);
for (j = 0; j < 10; j++) {
char buf[64];
snprintf(buf,64,"%u",j);
- reply = redisCommand(c,"LPUSH mylist element-%s", buf);
+ reply = redictCommand(c,"LPUSH mylist element-%s", buf);
freeReplyObject(reply);
}
/* Let's check what we have inside the list */
- reply = redisCommand(c,"LRANGE mylist 0 -1");
- if (reply->type == REDIS_REPLY_ARRAY) {
+ reply = redictCommand(c,"LRANGE mylist 0 -1");
+ if (reply->type == REDICT_REPLY_ARRAY) {
for (j = 0; j < reply->elements; j++) {
printf("%u) %s\n", j, reply->element[j]->str);
}
@@ -110,9 +110,9 @@ int main(int argc, char **argv) {
freeReplyObject(reply);
/* Disconnects and frees the context */
- redisFree(c);
+ redictFree(c);
- redisFreeSSLContext(ssl);
+ redictFreeSSLContext(ssl);
return 0;
}