/*
* Store "buf[len]" on channel "idx".
+ * Returns OK or FAIL.
*/
- void
+ int
channel_save(int idx, char_u *buf, int len)
{
queue_T *node;
node = (queue_T *)alloc(sizeof(queue_T));
if (node == NULL)
- return; /* out of memory */
+ return FAIL; /* out of memory */
node->buffer = alloc(len + 1);
if (node->buffer == NULL)
{
vim_free(node);
- return; /* out of memory */
+ return FAIL; /* out of memory */
}
mch_memmove(node->buffer, buf, (size_t)len);
node->buffer[len] = NUL;
if (debugfd != NULL)
{
fprintf(debugfd, "RECV on %d: ", idx);
- fwrite(buf, len, 1, debugfd);
+ if (fwrite(buf, len, 1, debugfd) != 1)
+ return FAIL;
fprintf(debugfd, "\n");
}
+ return OK;
}
/*
int channel_decode_json(char_u *msg, typval_T *tv);
int channel_is_open(int idx);
void channel_close(int idx);
-void channel_save(int idx, char_u *buf, int len);
+int channel_save(int idx, char_u *buf, int len);
char_u *channel_peek(int idx);
char_u *channel_get(int idx);
int channel_collapse(int idx);