forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watchman_cmd.h
91 lines (72 loc) · 2.61 KB
/
watchman_cmd.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Copyright 2013-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
#ifndef WATCHMAN_CMD_H
#define WATCHMAN_CMD_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*watchman_command_func)(
struct watchman_client *client,
json_t *args);
typedef bool (*watchman_cli_cmd_validate_func)(
json_t *args, char **errmsg);
#define CMD_DAEMON 1
#define CMD_CLIENT 2
#define CMD_POISON_IMMUNE 4
struct watchman_command_handler_def {
const char *name;
watchman_command_func func;
int flags;
watchman_cli_cmd_validate_func cli_validate;
};
// For commands that take the root dir as the second parameter,
// realpath's that parameter on the client side and updates the
// argument list
bool w_cmd_realpath_root(json_t *args, char **errmsg);
void preprocess_command(json_t *args, enum w_pdu_type output_pdu);
bool dispatch_command(struct watchman_client *client, json_t *args, int mode);
bool try_client_mode_command(json_t *cmd, bool pretty);
void w_register_command(struct watchman_command_handler_def *defs);
#define W_CMD_REG_1(symbol, name, func, flags, clivalidate) \
static w_ctor_fn_type(symbol) { \
static struct watchman_command_handler_def d = { \
name, func, flags, clivalidate \
}; \
w_register_command(&d); \
} \
w_ctor_fn_reg(symbol)
#define W_CMD_REG(name, func, flags, clivalidate) \
W_CMD_REG_1(w_gen_symbol(w_cmd_register_), \
name, func, flags, clivalidate)
#define W_CAP_REG1(symbol, name) \
static w_ctor_fn_type(symbol) { \
w_capability_register(name); \
} \
w_ctor_fn_reg(symbol)
#define W_CAP_REG(name) \
W_CAP_REG1(w_gen_symbol(w_cap_reg_), name)
void w_capability_register(const char *name);
bool w_capability_supported(const char *name);
json_t *w_capability_get_list(void);
void send_error_response(struct watchman_client *client,
const char *fmt, ...);
void send_and_dispose_response(struct watchman_client *client,
json_t *response);
bool enqueue_response(struct watchman_client *client,
json_t *json, bool ping);
w_root_t *resolve_root_or_err(
struct watchman_client *client,
json_t *args,
int root_index,
bool create);
json_t *make_response(void);
void annotate_with_clock(w_root_t *root, json_t *resp);
void add_root_warnings_to_response(json_t *response, w_root_t *root);
bool clock_id_string(uint32_t root_number, uint32_t ticks, char *buf,
size_t bufsize);
#ifdef __cplusplus
}
#endif
#endif
/* vim:ts=2:sw=2:et:
*/