Beispiel #1
0
static void
encode_header (GString *g, gpointer bean)
{
	g_string_append(g, "\"id\":\"");
	metautils_gba_to_hexgstr(g, CONTENTS_HEADERS_get_id(bean));
	g_string_append_printf(g, "\",\"hash\":\"");
	metautils_gba_to_hexgstr(g, CONTENTS_HEADERS_get_hash(bean));
	g_string_append_printf(g, "\",\"size\":%"G_GINT64_FORMAT,
			CONTENTS_HEADERS_get_size(bean));
	g_string_append_printf(g, ",\"policy\":\"%s\"",
			CONTENTS_HEADERS_get_policy(bean)->str);
}
Beispiel #2
0
static void
encode_chunk (GString *g, gpointer bean)
{
	g_string_append_printf(g, "\"id\":\"%s\",\"hash\":\"",
			CHUNKS_get_id(bean)->str);
	metautils_gba_to_hexgstr(g, CHUNKS_get_hash(bean));
	g_string_append_printf(g, "\",\"size\":%"G_GINT64_FORMAT,
			CHUNKS_get_size(bean));
}
Beispiel #3
0
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);
}
	/* Test if a list has one and only one element */
	gboolean _has_only_one_element(gpointer k, gpointer v, gpointer d) {
		(void) d;
		GSList *chunk_list = (GSList *) v;
		guint length = g_slist_length(chunk_list);
		if (GRID_DEBUG_ENABLED()) {
			GString *hash_str = metautils_gba_to_hexgstr(NULL, (GByteArray *) k);
			if (length == 1) {
				GRID_TRACE("Removing bean of hash '%s' from hash table", hash_str->str);
			} else {
				GRID_DEBUG("Found % 4d beans with hash '%s'",
						length, hash_str->str);
			}
			g_string_free(hash_str, TRUE);
		}
		return (length == 1);
	}
Beispiel #5
0
static void
encode_alias (GString *g, gpointer bean)
{
	g_string_append_printf(g,
			"\"name\":\"%s\","
			"\"ver\":%"G_GINT64_FORMAT","
			"\"ctime\":%"G_GINT64_FORMAT","
			"\"system_metadata\":\"%s\","
			"\"header\":\"",
			ALIASES_get_alias(bean)->str,
			ALIASES_get_version(bean),
			ALIASES_get_ctime(bean),
			ALIASES_get_mdsys(bean)->str);
	metautils_gba_to_hexgstr(g, ALIASES_get_content_id(bean));
	g_string_append_c(g, '"');
}
void
meta2_json_alias_only(GString *gstr, GSList *l)
{
	void code(GString *g, gpointer bean) {
		g_string_append_printf(g,
				"{\"name\":\"%s\","
				"\"ver\":%"G_GINT64_FORMAT","
				"\"ctime\":%"G_GINT64_FORMAT","
				"\"system_metadata\":\"%s\","
				"\"header\":\"",
				ALIASES_get_alias(bean)->str,
				ALIASES_get_version(bean),
				ALIASES_get_ctime(bean),
				ALIASES_get_mdsys(bean)->str);
		metautils_gba_to_hexgstr(g, ALIASES_get_content_id(bean));
		g_string_append(g, "\"}");
	}