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 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <string.h>
#include "ipc.h"
#include "gjay.h"
char * daemon_pipe;
char * ui_pipe;
gchar * gjay_pipe_dir;
void send_ipc_text(int fd, ipc_type type, char * text) {
int len, slen;
if (fd == -1)
return;
slen = strlen(text);
len = sizeof(ipc_type) + slen;
if (write(fd, &len, sizeof(int)) <= 0)
perror("send_ipc_text(): write length:");
if (write(fd, &type, sizeof(ipc_type)) <= 0)
perror("send_ipc_text(): write type:");
if (write(fd, text, slen) <= 0)
perror("send_ipc_text(): write text:");
}
void send_ipc_int (int fd, ipc_type type, int val) {
int len;
if (fd == -1)
return;
len = sizeof(ipc_type) + sizeof(int);
if (write(fd, &len, sizeof(int)) <= 0)
perror("send_ipc_int(): write length:");
if (write(fd, &type, sizeof(ipc_type)) <= 0)
perror("send_ipc_int(): write type:");
if (write(fd, &val, sizeof(int)) <= 0)
perror("send_ipc_int(): write value:");
}
void send_ipc (int fd, ipc_type type) {
int len;
if (fd == -1)
return;
len = sizeof(ipc_type);
if (write(fd, &len, sizeof(int)) <= 0)
perror("send_ipc(): write length:");
if (write(fd, &type, sizeof(ipc_type)) <= 0)
perror("send_ipc(): write type:");
}
|