aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol.h
blob: 1a4ad7ca95ad3f838b8f3cfbe8f17283647c7fbe (plain) (blame)
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
#ifndef _RUNES_PROTOCOL_H
#define _RUNES_PROTOCOL_H

#include <stdint.h>

#define RUNES_PROTOCOL_MESSAGE_VERSION 1

struct runes_protocol_new_term_message {
    uint32_t argc;
    char **argv;
    char **envp;
    char *cwd;
};

enum runes_protocol_message_type {
    RUNES_PROTOCOL_NEW_TERM,
    RUNES_PROTOCOL_KILL_DAEMON,
    RUNES_PROTOCOL_NUM_MESSAGE_TYPES
};

int runes_protocol_parse_new_term_message(
    char *buf, size_t len, struct runes_protocol_new_term_message *outmsg);
int runes_protocol_create_new_term_message(
    struct runes_protocol_new_term_message *msg,
    char **outbuf, size_t *outlen);
void runes_protocol_free_new_term_message(
    struct runes_protocol_new_term_message *msg);
int runes_protocol_read_packet(
    int sock, int *outtype, char **outbuf, size_t *outlen);
int runes_protocol_send_packet(int s, int type, char *buf, size_t len);

#endif