Macros | Functions
server.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/ascii.h"
#include "nvim/eval.h"
#include "nvim/event/socket.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/memory.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/strings.h"
#include "nvim/vim.h"


#define MAX_CONNECTIONS   32
#define ENV_NVIM   "NVIM"


bool server_init (const char *listen_addr)
 Initializes the module. More...
void server_teardown (void)
 Teardown the server module. More...
char * server_address_new (void)
bool server_owns_pipe_address (const char *path)
int server_start (const char *endpoint)
bool server_stop (char *endpoint)
char ** server_address_list (size_t *size) FUNC_ATTR_NONNULL_ALL

Macro Definition Documentation




#define ENV_NVIM   "NVIM"


#define MAX_CONNECTIONS   32

Function Documentation

◆ server_address_list()

char** server_address_list ( size_t *  size)

Returns an allocated array of server addresses.

[out]sizeThe size of the returned array.

◆ server_address_new()

char* server_address_new ( void  )

Generates unique address for local server.

In Windows this is a named pipe in the format \.\pipe\nvim-<PID>-<COUNTER>.

For other systems it is a path returned by vim_tempname().

This function is NOT thread safe

◆ server_init()

bool server_init ( const char *  listen_addr)

Initializes the module.

◆ server_owns_pipe_address()

bool server_owns_pipe_address ( const char *  path)

Check if this instance owns a pipe address. The argument must already be resolved to an absolute path!

◆ server_start()

int server_start ( const char *  endpoint)

Starts listening for API calls.

The socket type is determined by parsing endpoint: If it's a valid IPv4 or IPv6 address in 'ip:[port]' format, then it will be a TCP socket. Otherwise it will be a Unix socket or named pipe (Windows).

If no port is given, a random one will be assigned.

endpointAddress of the server. Either a 'ip:[port]' string or an arbitrary identifier (trimmed to 256 bytes) for the Unix socket or named pipe.
0: success, 1: validation error, 2: already listening, -errno: failed to bind or listen.

◆ server_stop()

bool server_stop ( char *  endpoint)

Stops listening on the address specified by endpoint.

endpointAddress of the server.

◆ server_teardown()

void server_teardown ( void  )

Teardown the server module.