-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallium.h
56 lines (47 loc) · 1.37 KB
/
allium.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
#ifndef ALLIUM_H
#define ALLIUM_H
#include <stdbool.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
// SHA1 digest length
#define DIGEST_LEN 20
// Length of RFC2440-style S2K specifier: the first 8 bytes are a salt,
// the 9th describes how much iteration needs to be performed.
#define S2K_SPECIFIER_LEN 9
// Length of the final hashed key
#define KEY_LEN DIGEST_LEN + S2K_SPECIFIER_LEN
#ifdef _WIN32
typedef HANDLE allium_pipe;
#else
typedef int allium_pipe;
#endif
enum allium_status {RUNNING, DATA_AVAILABLE, STOPPED};
struct TorInstance {
#ifdef _WIN32
STARTUPINFO startup_info;
PROCESS_INFORMATION process;
#else
int exit_code;
#endif
allium_pipe stdout_pipe;
unsigned long pid;
char *tor_path;
struct {
size_t size;
char *data;
} buffer;
};
struct TorInstance *allium_new_instance(char *tor_path);
bool allium_start(struct TorInstance *instance, char *config, allium_pipe *output_pipes);
void allium_stop(struct TorInstance *instance);
void allium_kill(struct TorInstance *instance);
enum allium_status allium_get_status(struct TorInstance *instance, int timeout);
bool allium_wait_for_output(struct TorInstance *instance, int timeout);
char *allium_read_stdout_line(struct TorInstance *instance);
int allium_get_exit_code(struct TorInstance *instance);
char *allium_hash(char *password);
void allium_clean(struct TorInstance *instance);
#endif