Skip to content

Commit

Permalink
format sources with current clang-format configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Koviazin <[email protected]>
  • Loading branch information
mkmkme committed Aug 23, 2024
1 parent 85c56ee commit fc21fa8
Show file tree
Hide file tree
Showing 77 changed files with 2,603 additions and 2,336 deletions.
28 changes: 15 additions & 13 deletions examples/async-ae.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/ae.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/adapters/ae.h>

/* Put event loop in the global scope, so it can be explicitly stopped */
static aeEventLoop *loop;

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
if (reply == NULL)
return;
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand All @@ -40,7 +42,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
aeStop(loop);
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
signal(SIGPIPE, SIG_IGN);

valkeyAsyncContext *c = valkeyAsyncConnect("127.0.0.1", 6379);
Expand All @@ -52,11 +54,11 @@ int main (int argc, char **argv) {

loop = aeCreateEventLoop(64);
valkeyAeAttach(loop, c);
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(
c, NULL, NULL, "SET key %b", argv[argc - 1], strlen(argv[argc - 1]));
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");
aeMain(loop);
return 0;
}

25 changes: 10 additions & 15 deletions examples/async-glib.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <stdlib.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/glib.h>

#include <stdlib.h>

static GMainLoop *mainloop;

static void
connect_cb (const valkeyAsyncContext *ac G_GNUC_UNUSED,
int status)
{
connect_cb(const valkeyAsyncContext *ac G_GNUC_UNUSED,
int status) {
if (status != VALKEY_OK) {
g_printerr("Failed to connect: %s\n", ac->errstr);
g_main_loop_quit(mainloop);
Expand All @@ -19,9 +19,8 @@ connect_cb (const valkeyAsyncContext *ac G_GNUC_UNUSED,
}

static void
disconnect_cb (const valkeyAsyncContext *ac G_GNUC_UNUSED,
int status)
{
disconnect_cb(const valkeyAsyncContext *ac G_GNUC_UNUSED,
int status) {
if (status != VALKEY_OK) {
g_error("Failed to disconnect: %s", ac->errstr);
} else {
Expand All @@ -33,8 +32,7 @@ disconnect_cb (const valkeyAsyncContext *ac G_GNUC_UNUSED,
static void
command_cb(valkeyAsyncContext *ac,
gpointer r,
gpointer user_data G_GNUC_UNUSED)
{
gpointer user_data G_GNUC_UNUSED) {
valkeyReply *reply = r;

if (reply) {
Expand All @@ -44,10 +42,7 @@ command_cb(valkeyAsyncContext *ac,
valkeyAsyncDisconnect(ac);
}

gint
main (gint argc G_GNUC_UNUSED,
gchar *argv[] G_GNUC_UNUSED)
{
gint main(gint argc G_GNUC_UNUSED, gchar *argv[] G_GNUC_UNUSED) {
valkeyAsyncContext *ac;
GMainContext *context = NULL;
GSource *source;
Expand Down
27 changes: 15 additions & 12 deletions examples/async-ivykis.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/ivykis.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/adapters/ivykis.h>

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
if (reply == NULL)
return;
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand All @@ -32,7 +34,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
printf("Disconnected...\n");
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif
Expand All @@ -47,10 +49,11 @@ int main (int argc, char **argv) {
}

valkeyIvykisAttach(c);
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(
c, NULL, NULL, "SET key %b", argv[argc - 1], strlen(argv[argc - 1]));
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");

iv_main();

Expand Down
27 changes: 15 additions & 12 deletions examples/async-libev.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/libev.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/adapters/libev.h>

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
if (reply == NULL)
return;
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand All @@ -32,7 +34,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
printf("Disconnected...\n");
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif
Expand All @@ -45,10 +47,11 @@ int main (int argc, char **argv) {
}

valkeyLibevAttach(EV_DEFAULT_ c);
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(
c, NULL, NULL, "SET key %b", argv[argc - 1], strlen(argv[argc - 1]));
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");
ev_loop(EV_DEFAULT_ 0);
return 0;
}
30 changes: 16 additions & 14 deletions examples/async-libevent-ssl.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/async.h>
#include <valkey/valkey.h>
#include <valkey/valkey_ssl.h>
#include <valkey/async.h>

#include <valkey/adapters/libevent.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
if (reply == NULL)
return;
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand All @@ -33,7 +35,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
printf("Disconnected...\n");
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif
Expand Down Expand Up @@ -61,7 +63,7 @@ int main (int argc, char **argv) {
valkeyInitOpenSSL();

ssl = valkeyCreateSSLContext(caCert, NULL,
cert, certKey, NULL, &ssl_error);
cert, certKey, NULL, &ssl_error);
if (!ssl) {
printf("Error: %s\n", valkeySSLContextGetError(ssl_error));
return 1;
Expand All @@ -78,11 +80,11 @@ int main (int argc, char **argv) {
exit(1);
}

valkeyLibeventAttach(c,base);
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyLibeventAttach(c, base);
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", value, nvalue);
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");
event_base_dispatch(base);

valkeyFreeSSLContext(ssl);
Expand Down
27 changes: 14 additions & 13 deletions examples/async-libevent.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/libevent.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/adapters/libevent.h>

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
Expand All @@ -15,7 +16,7 @@ void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
}
return;
}
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand All @@ -37,7 +38,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
printf("Disconnected...\n");
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif
Expand All @@ -49,19 +50,19 @@ int main (int argc, char **argv) {
tv.tv_sec = 1;
options.connect_timeout = &tv;


valkeyAsyncContext *c = valkeyAsyncConnectWithOptions(&options);
if (c->err) {
/* Let *c leak for now... */
printf("Error: %s\n", c->errstr);
return 1;
}

valkeyLibeventAttach(c,base);
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyLibeventAttach(c, base);
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(
c, NULL, NULL, "SET key %b", argv[argc - 1], strlen(argv[argc - 1]));
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");
event_base_dispatch(base);
return 0;
}
29 changes: 16 additions & 13 deletions examples/async-libhv.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include <valkey/async.h>
#include <valkey/valkey.h>

#include <valkey/adapters/libhv.h>

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <valkey/valkey.h>
#include <valkey/async.h>
#include <valkey/adapters/libhv.h>

void getCallback(valkeyAsyncContext *c, void *r, void *privdata) {
valkeyReply *reply = r;
if (reply == NULL) return;
printf("argv[%s]: %s\n", (char*)privdata, reply->str);
if (reply == NULL)
return;
printf("argv[%s]: %s\n", (char *)privdata, reply->str);

/* Disconnect after receiving the reply to GET */
valkeyAsyncDisconnect(c);
Expand Down Expand Up @@ -44,7 +46,7 @@ void disconnectCallback(const valkeyAsyncContext *c, int status) {
printf("Disconnected...\n");
}

int main (int argc, char **argv) {
int main(int argc, char **argv) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif
Expand All @@ -56,13 +58,14 @@ int main (int argc, char **argv) {
return 1;
}

hloop_t* loop = hloop_new(HLOOP_FLAG_QUIT_WHEN_NO_ACTIVE_EVENTS);
hloop_t *loop = hloop_new(HLOOP_FLAG_QUIT_WHEN_NO_ACTIVE_EVENTS);
valkeyLibhvAttach(c, loop);
valkeyAsyncSetTimeout(c, (struct timeval){.tv_sec = 0, .tv_usec = 500000});
valkeyAsyncSetConnectCallback(c,connectCallback);
valkeyAsyncSetDisconnectCallback(c,disconnectCallback);
valkeyAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
valkeyAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
valkeyAsyncSetConnectCallback(c, connectCallback);
valkeyAsyncSetDisconnectCallback(c, disconnectCallback);
valkeyAsyncCommand(
c, NULL, NULL, "SET key %b", argv[argc - 1], strlen(argv[argc - 1]));
valkeyAsyncCommand(c, getCallback, (char *)"end-1", "GET key");
valkeyAsyncCommand(c, debugCallback, NULL, "DEBUG SLEEP %d", 1);
hloop_run(loop);
hloop_free(&loop);
Expand Down
Loading

0 comments on commit fc21fa8

Please sign in to comment.