]>
jfr.im git - irc/thales.git/blob - src/sentry.c
c5d4b796951dd5026b0f973e58c05125a69c7e97
6 #include "init_queries.sql.h"
14 initialize_tables(MYSQL
*db_handle
)
16 for (const char *query
= *init_queries(); *query
; ++query
)
17 if (!mysql_query(db_handle
, query
))
23 sentry_initialize (const struct mysql_options
*opts
, const char *server
)
26 mysql_init (&db_handle
);
27 if (!mysql_real_connect (&db_handle
, opts
->host
, opts
->username
,
28 opts
->password
, opts
->database
, opts
->port
,
31 fprintf(stderr
, "Failed to connect to database: Error: %s\n",
32 mysql_error(&db_handle
));
35 if (!initialize_tables(&db_handle
)) {
36 fprintf(stderr
, "Failed to connect to database: Error: %s\n",
37 mysql_error(&db_handle
));
41 struct sentry
*new = xcalloc (1, sizeof *new);
43 new->db_handle
= db_handle
;
44 new->server
= xstrdup(server
);
48 mysql_close(&db_handle
);
54 sentry_channel_presence_clear(SENTRY
*sentry
, const char *channel
)
56 static const char *query
=
60 sentry_channel_presence_add(SENTRY
*sentry
, const char *channel
,
63 const char *query
= "INSERT INTO presence VALUES (nickid, chanid, servid) where