-
-/*
- * create a structure api_ws not connected to the 'uri'.
- */
-static struct api_ws *api_ws_make(const char *uri)
-{
- struct api_ws *api;
- size_t length;
-
- /* allocates the structure */
- length = strlen(uri);
- api = calloc(1, sizeof *api + 1 + length);
- if (api == NULL) {
- errno = ENOMEM;
- goto error;
- }
-
- /* uri is copied after the struct */
- api->uri = (char*)(api+1);
- memcpy(api->uri, uri, length + 1);
-
- /* api name is at the end of the uri */
- while (length && uri[length - 1] != '/' && uri[length - 1] != ':')
- length = length - 1;
- api->api = &api->uri[length];
- if (api->api == NULL || !afb_api_is_valid_name(api->api)) {
- errno = EINVAL;
- goto error2;
- }
-
- return api;
-
-error2:
- free(api);
-error:
- return NULL;
-}
-
-/**********************************************************************************/