/
remote.c
40 lines (33 loc) · 1.04 KB
/
remote.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "conv.h"
#include "remote.h"
static char *serverConvert(VimRemotingClient *client, const char *client_enc, char *data, char **tofree);
#ifdef WIN3264
#include "remote_win32.c"
#elif defined(USE_X11)
#include "remote_x.c"
#endif
/*
* If conversion is needed, convert "data" from "client_enc" to 'encoding' and
* return an allocated string. Otherwise return "data".
* "*tofree" is set to the result when it needs to be freed later.
*/
static char *serverConvert(VimRemotingClient *client, const char *client_enc, char *data, char **tofree)
{
char *res = data;
*tofree = 0;
if (client_enc && client->enc) {
vimconv_T vimconv;
vimconv.vc_type = CONV_NONE;
if (!convert_setup(&vimconv, client_enc, client->enc) &&
vimconv.vc_type != CONV_NONE)
{
res = string_convert(&vimconv, data, NULL);
if (res == NULL)
res = data;
else
*tofree = res;
}
convert_setup(&vimconv, NULL, NULL);
}
return res;
}