|
|
@ -22,6 +22,7 @@
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <sys/uio.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <ejabbermsg.h>
|
|
|
|
#include <ejabbermsg.h>
|
|
|
|
|
|
|
|
|
|
|
@ -52,9 +53,27 @@ ssize_t eport_read(FILE *stream, char *buffer, size_t buffer_size)
|
|
|
|
|
|
|
|
|
|
|
|
ssize_t eport_write(FILE *stream, char *buffer, size_t buffer_size)
|
|
|
|
ssize_t eport_write(FILE *stream, char *buffer, size_t buffer_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
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;
|
|
|
|
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,
|
|
|
|
int eport_ejabberd_msgread(char *buffer, size_t buffer_size,
|
|
|
|
struct ejabber_msg *m)
|
|
|
|
struct ejabber_msg *m)
|
|
|
|
{
|
|
|
|
{
|
|
|
|