eport_write function;
This commit is contained in:
parent
4220890af6
commit
4b99ad0b7b
21
src/eport.c
21
src/eport.c
@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <ejabbermsg.h>
|
||||
|
||||
@ -52,7 +53,25 @@ ssize_t eport_read(FILE *stream, char *buffer, size_t buffer_size)
|
||||
|
||||
ssize_t eport_write(FILE *stream, char *buffer, size_t buffer_size)
|
||||
{
|
||||
return -1;
|
||||
int fd = fileno(stream);
|
||||
int16_t port_msg_len = (buffer_size << 8) | ((buffer_size >> 8) & 0xFF);
|
||||
ssize_t wr = 0;
|
||||
struct iovec msg[2];
|
||||
|
||||
if(buffer_size <= 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* write length and message itself */
|
||||
msg[0].iov_base = &port_msg_len;
|
||||
msg[0].iov_len = sizeof(int16_t);
|
||||
msg[1].iov_base = buffer;
|
||||
msg[1].iov_len = buffer_size;
|
||||
|
||||
wr = writev(fd, msg, 2);
|
||||
|
||||
return wr;
|
||||
}
|
||||
|
||||
int eport_ejabberd_msgread(char *buffer, size_t buffer_size,
|
||||
|
Loading…
x
Reference in New Issue
Block a user