dispatch.c (793B)
1 #include <stddef.h> 2 3 #include "nvim/api/private/defs.h" 4 #include "nvim/api/private/dispatch.h" 5 #include "nvim/api/private/helpers.h" 6 7 #include "api/private/dispatch_wrappers.generated.h" 8 9 /// @param name API method name 10 /// @param name_len name size (includes terminating NUL) 11 MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name, size_t name_len, 12 Error *error) 13 { 14 int hash = msgpack_rpc_get_handler_for_hash(name, name_len); 15 16 if (hash < 0) { 17 api_set_error(error, kErrorTypeException, "Invalid method: %.*s", 18 name_len > 0 ? (int)name_len : (int)sizeof("<empty>"), 19 name_len > 0 ? name : "<empty>"); 20 return (MsgpackRpcRequestHandler){ 0 }; 21 } 22 return method_handlers[hash]; 23 }