Skip to content

Commit

Permalink
Medium: attr: keep attributes in the CIB
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhamedagic committed Nov 20, 2015
1 parent f42b3ef commit 88c3d6a
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 69 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ AC_PROG_RANLIB

AC_PATH_PROGS(PKGCONFIG, pkg-config)
AC_PATH_PROGS(ASCIIDOC, asciidoc)
AC_PATH_PROGS(XML2CONFIG, xml2-config)

AM_CONDITIONAL(BUILD_ASCIIDOC, test x"${ASCIIDOC}" != x"")

Expand All @@ -82,6 +83,17 @@ if test "x$libgcrypt_installed" = "xno"; then
AM_CONDITIONAL(BUILD_AUTH_C, test "x${mhash_installed}" = "xyes")
fi

AC_MSG_CHECKING(for special libxml2 includes)
if test "x$XML2CONFIG" = "x"; then
AC_MSG_ERROR(libxml2 config not found)
else
XML2HEAD="`$XML2CONFIG --cflags`"
AC_MSG_RESULT($XML2HEAD)
AC_CHECK_LIB(xml2, xmlReadMemory)
fi

CPPFLAGS="$CPPFLAGS $XML2HEAD"

PKG_CHECK_MODULES(GLIB, [glib-2.0])

# Checks for header files.
Expand Down
30 changes: 24 additions & 6 deletions src/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdio.h>
#include "attr.h"
#include "ticket.h"
#include "pacemaker.h"

void print_geostore_usage(void)
{
Expand Down Expand Up @@ -243,11 +244,13 @@ static void free_geo_attr(gpointer data)
g_free(a);
}

static cmd_result_t attr_set(struct ticket_config *tk, struct boothc_attr_msg *msg)
int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime)
{
struct geo_attr *a;
GDestroyNotify free_geo_attr_notify = free_geo_attr;

if (!tk)
return -1;
/*
* allocate new, if attr doesn't already exist
* copy the attribute value
Expand All @@ -258,21 +261,34 @@ static cmd_result_t attr_set(struct ticket_config *tk, struct boothc_attr_msg *m
free_geo_attr_notify, g_free);
if (!tk->attr) {
log_error("out of memory");
return RLT_SYNC_FAIL;
return -1;
}

a = (struct geo_attr *)calloc(1, sizeof(struct geo_attr));
if (!a) {
log_error("out of memory");
return RLT_SYNC_FAIL;
return -1;
}

a->val = g_strdup(msg->attr.val);
get_time(&a->update_ts);
a->val = g_strdup(val);
if (!notime)
get_time(&a->update_ts);

g_hash_table_insert(tk->attr,
g_strndup(msg->attr.name, BOOTH_NAME_LEN), a);
g_strndup(name, BOOTH_NAME_LEN), a);

return 0;
}

static cmd_result_t attr_set(struct ticket_config *tk, struct boothc_attr_msg *msg)
{
int rc;

rc = store_geo_attr(tk, msg->attr.name, msg->attr.val, 0);
if (rc) {
return RLT_SYNC_FAIL;
}
(void)pcmk_handler.set_attr(tk, msg->attr.name, msg->attr.val);
return RLT_SUCCESS;
}

Expand All @@ -296,6 +312,8 @@ static cmd_result_t attr_del(struct ticket_config *tk, struct boothc_attr_msg *m

rv = g_hash_table_remove(tk->attr, msg->attr.name);

(void)pcmk_handler.del_attr(tk, msg->attr.name);

return gbool2rlt(rv);
}

Expand Down
1 change: 1 addition & 0 deletions src/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ int test_attr_reply(cmd_result_t reply_code, cmd_request_t cmd);
int do_attr_command(cmd_request_t cmd);
int process_attr_request(struct client *req_client, void *buf);
int attr_recv(void *buf, struct booth_site *source);
int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime);

#endif /* _ATTR_H */
Loading

0 comments on commit 88c3d6a

Please sign in to comment.