File: ipc.c

package info (click to toggle)
gjay 0.2.8.3-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 532 kB
  • ctags: 717
  • sloc: ansic: 6,757; makefile: 101
file content (38 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (2)
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 <string.h>
#include "ipc.h"
#include "gjay.h"

void send_ipc_text(int fd, ipc_type type, char * text) {
    int len, slen;
    if (mode == DAEMON_DETACHED)
        return;

    slen = strlen(text);
    len = sizeof(ipc_type) + slen;
    write(fd, &len,  sizeof(int)); 
    write(fd, &type, sizeof(ipc_type)); 
    write(fd, text,  slen);
}


void send_ipc_int (int fd, ipc_type type, int val) {
    int len;
    if (mode == DAEMON_DETACHED)
        return;
    
    len = sizeof(ipc_type) + sizeof(int);
    write(fd, &len,  sizeof(int)); 
    write(fd, &type, sizeof(ipc_type)); 
    write(fd, &val,  sizeof(int));
}


void send_ipc (int fd, ipc_type type) {
    int len;
    if (mode == DAEMON_DETACHED)
        return;

    len = sizeof(ipc_type);
    write(fd, &len,  sizeof(int)); 
    write(fd, &type, sizeof(ipc_type)); 
}