END_TEST START_TEST(test_create_from_string_any_v6) { host_t *host; host = host_create_from_string("%any6", 500); verify_any(host, AF_INET6, 500); host->destroy(host); host = host_create_from_string("::", 500); verify_any(host, AF_INET6, 500); host->destroy(host); host = host_create_from_string("fec1::1", 500); verify_address(host, addr_v6, AF_INET6, 500); host->destroy(host); host = host_create_from_string("fec1::1.500", 500); ck_assert(host == NULL); host = host_create_from_string("f::e::c::1::1", 500); ck_assert(host == NULL); host = host_create_from_string("foo::bar", 500); ck_assert(host == NULL); }
static void test_create_any(int family) { host_t *host; host = host_create_any(family); verify_any(host, family, 0); host->destroy(host); }
END_TEST /******************************************************************************* * host_create_from_string_and_family */ static void test_create_from_string_and_family_any(char *string, int family, int expected) { host_t *host; host = host_create_from_string_and_family(string, family, 500); if (expected == AF_UNSPEC) { ck_assert(host == NULL); } else { verify_any(host, expected, 500); host->destroy(host); } }
int connection_cb(void* cls, struct MHD_Connection* conn, const char* url, const char* method, const char* version, const char* data, size_t* size, void** con_cls) { #ifdef PLATFORM_OSX pthread_setname_np("http"); #else prctl(PR_SET_NAME, "http"); #endif if (*con_cls == NULL) { ConnectionInfo *con_info = create_connection_info(); if (g_strcmp0(method, "POST") == 0 && g_strcmp0(url, "/send") == 0) { con_info->stbbr_op = STBBR_OP_SEND; } else if (g_strcmp0(method, "POST") == 0 && g_strcmp0(url, "/for") == 0) { con_info->stbbr_op = STBBR_OP_FOR; } else if (g_strcmp0(method, "POST") == 0 && g_strcmp0(url, "/verify") == 0) { con_info->stbbr_op = STBBR_OP_VERIFY; } else { con_info->stbbr_op = STBBR_OP_UNKNOWN; return send_response(conn, NULL, MHD_HTTP_BAD_REQUEST); } *con_cls = (void*) con_info; return MHD_YES; } ConnectionInfo *con_info = (ConnectionInfo*) *con_cls; if (*size != 0) { g_string_append_len(con_info->body, data, *size); *size = 0; return MHD_YES; } const char *id = NULL; const char *query = NULL; int res = 0; switch (con_info->stbbr_op) { case STBBR_OP_SEND: server_send(con_info->body->str); return send_response(conn, NULL, MHD_HTTP_OK); case STBBR_OP_FOR: id = MHD_lookup_connection_value(conn, MHD_GET_ARGUMENT_KIND, "id"); query = MHD_lookup_connection_value(conn, MHD_GET_ARGUMENT_KIND, "query"); if (id && query) { return send_response(conn, NULL, MHD_HTTP_BAD_REQUEST); } if (id) { prime_for_id(id, con_info->body->str); return send_response(conn, NULL, MHD_HTTP_CREATED); } if (query) { prime_for_query(query, con_info->body->str); return send_response(conn, NULL, MHD_HTTP_CREATED); } return send_response(conn, NULL, MHD_HTTP_BAD_REQUEST); case STBBR_OP_VERIFY: res = verify_any(con_info->body->str, TRUE); if (res) { return send_response(conn, "true", MHD_HTTP_OK); } else { return send_response(conn, "false", MHD_HTTP_OK); } default: return send_response(conn, NULL, MHD_HTTP_BAD_REQUEST); } }
int stbbr_received(char *stanza) { return verify_any(stanza, FALSE); }