- afb_apis_call(req, context, api, strlen(api), verb, strlen(verb));
+ int i, c, up, lo;
+ const struct api_desc *a;
+
+ /* init hooking the request */
+ req = afb_hook_req_call(req, context, api, verb);
+
+ /* dichotomic search of the api */
+ /* initial slice */
+ lo = 0;
+ up = apis_count;
+ for (;;) {
+ /* check remaining slice */
+ if (lo >= up) {
+ /* empty ?! */
+ afb_req_fail(req, "fail", "api not found");
+ break;
+ }
+ /* check the mid of the slice */
+ i = (lo + up) >> 1;
+ a = &apis_array[i];
+ c = strcasecmp(a->name, api);
+ if (c == 0) {
+ /* api found */
+ context->api_key = a->api.closure;
+ a->api.call(a->api.closure, req, context, verb);
+ break;
+ }
+ /* update the slice */
+ if (c < 0)
+ lo = i + 1;
+ else
+ up = i;
+ }