-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathslot.h
71 lines (53 loc) · 1.18 KB
/
slot.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _HSS_SLOT_H_
#define _HSS_SLOT_H_
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include "sstring.h"
#define PIPE_READ_END 0
#define PIPE_WRITE_END 1
struct
stdio_pipe {
int out[2];
int err[2];
};
struct
slot {
char host[1024];
int ssh_argc;
char **ssh_argv;
int pid;
int exit_code;
bool alive;
int poll_index;
FILE *output;
sstring out_buff;
sstring err_buff;
struct stdio_pipe io;
struct slot *next;
};
typedef
void (*fn_getline)(struct slot *pslot, int io_type, sstring str, void *data);
void
slot_read_line(struct slot *pslot, int io_type, fn_getline cb, void *cb_data);
void
slot_read_remains(struct slot *pslot, fn_getline cb, void *cb_data);
struct slot *
new_slot(const char *args);
void
slot_reinit(struct slot *pslot);
void
slot_append(struct slot *pslot_list, struct slot *next);
void
slot_close(struct slot *pslot, int exit_code);
void
slot_free(struct slot *pslot);
void
print_slot_args(struct slot *pslot);
struct slot *
slot_find_by_pid(struct slot *pslot_list, int pid);
void
slot_del_by_host(struct slot *pslot_list, const char *host);
#endif //_HSS_SLOT_H_