static gs_container_t* gs_container_init_from_location(gs_grid_storage_t *client, struct gs_container_location_s *location, gs_error_t **gserr) { GError *gerr = NULL; gs_container_t *container = NULL; container = calloc(1, sizeof(struct gs_container_s)); container->meta2_cnx = -1; container->opened = 0; l4_address_init_with_url(&(container->meta2_addr), location->m2_url[0], NULL); if (!oio_str_hex2bin(location->container_hexid, container->cID, sizeof(container_id_t))) { GSERRORCAUSE(gserr, gerr, "Invalid hexadecimal container ID"); g_error_free(gerr); free(container); return NULL; } if (gerr) g_clear_error(&gerr); container->info.gs = client; if (location->container_name) g_strlcpy(container->info.name, location->container_name, sizeof(container->info.name)-1); if (location->container_hexid) g_strlcpy(container->str_cID, location->container_hexid, sizeof(container->str_cID)-1); return container; }
static int init_srvinfo(const gchar *sid, service_info_t *si) { GMatchInfo *mi = NULL; if (!g_regex_match(regex_svc, sid, 0, &mi)) { g_printerr("Unrecognized pattern for service id [%s]\n", sid); return -1; } else { gchar *str_ns, *str_type, *str_addr; str_ns = g_match_info_fetch(mi, 1); str_type = g_match_info_fetch(mi, 2); str_addr = g_match_info_fetch(mi, 3); g_free(mi); g_strlcpy(si->type, str_type, sizeof(si->type)-1); g_free(str_type); g_strlcpy(si->ns_name, str_ns, sizeof(si->ns_name)-1); g_free(str_ns); if (!l4_address_init_with_url(&(si->addr), str_addr, NULL)) { g_printerr("Invalid service address [%s]", str_addr); return -1; } g_free(str_addr); } if (!si->tags) si->tags = g_ptr_array_sized_new(6); return 0; }
static meta2_raw_content_v2_t* generate_v2(void) { meta2_raw_content_v2_t *v2 = g_malloc0(sizeof(*v2)); memcpy(v2->header.container_id, hc_url_get_id(url), sizeof(container_id_t)); g_strlcpy(v2->header.path, hc_url_get(url, HCURL_PATH), sizeof(v2->header.path)); v2->header.nb_chunks = 1; v2->header.size = 0; v2->header.metadata = g_byte_array_new(); v2->header.system_metadata = g_byte_array_new(); meta2_raw_chunk_t *rc = g_malloc0(sizeof(*rc)); l4_address_init_with_url(&(rc->id.addr), "127.0.0.1:6000", NULL); g_strlcpy(rc->id.vol, "/rawx-1", sizeof(rc->id.vol)); rc->metadata = g_byte_array_new(); v2->raw_chunks = g_slist_prepend(v2->raw_chunks, rc); return v2; }
gboolean meta1_url_get_address(struct meta1_service_url_s *u, struct addr_info_s *dst) { return l4_address_init_with_url(dst, u->host, NULL); }