static void encode_content (GString *g, gpointer bean) { g_string_append(g, "\"hdr\":\""); metautils_gba_to_hexgstr(g, CONTENTS_get_content_id(bean)); g_string_append_printf(g, "\",\"chunk\":\"%s\",\"pos\":\"%s\"", CONTENTS_get_chunk_id(bean)->str, CONTENTS_get_position(bean)->str); }
/** * Extract host, port and chunk hexadecimal id from a bean. * * @param bean A pointer to a bean_CHUNKS_s or bean_CONTENTS_s * @param[out] host * @param[out] port * @param[out] chunk_hexid The chunk hexadecimal id (with leading '/') * @param[out] err */ static void extract_chunk_url(gpointer bean, gchar **host, gint *port, gchar **chunk_hexid, GError **err) { gchar *cid_url = NULL; if (DESCR(bean) == &descr_struct_CHUNKS) { cid_url = CHUNKS_get_id((struct bean_CHUNKS_s*)bean)->str; } else if (DESCR(bean) == &descr_struct_CONTENTS) { cid_url = CONTENTS_get_chunk_id((struct bean_CONTENTS_s*)bean)->str; } else { if (err) *err = NEWERROR(0, "Invalid 'bean' argument, must be " "(struct bean_CHUNKS_s*) or (struct bean_CONTENTS_s*)"); else return; } return split_chunk_url(cid_url, host, port, chunk_hexid, err); }