forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatchman.h
167 lines (135 loc) · 3.98 KB
/
watchman.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* Copyright 2012-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
#ifndef WATCHMAN_H
#define WATCHMAN_H
#include "watchman_system.h"
#include "thirdparty/jansson/jansson.h"
#include "watchman_hash.h"
#include "watchman_ignore.h"
#include "watchman_stream.h"
#include "watchman_string.h"
struct watchman_file;
struct watchman_dir;
struct watchman_root;
struct watchman_pending_fs;
struct watchman_trigger_command;
typedef struct watchman_root w_root_t;
// Per-watch state for the selected watcher
typedef void *watchman_watcher_t;
#include "watchman_clockspec.h"
#include "watchman_pending.h"
#include "watchman_dir.h"
#include "watchman_watcher.h"
#include "watchman_opendir.h"
#include "watchman_file.h"
#define WATCHMAN_IO_BUF_SIZE 1048576
#define WATCHMAN_BATCH_LIMIT (16*1024)
#include "watchman_root.h"
#include "watchman_pdu.h"
#include "watchman_perf.h"
#include "watchman_query.h"
#include "watchman_client.h"
#include "watchman_cmd.h"
#include "watchman_config.h"
#include "watchman_trigger.h"
// Returns the name of the filesystem for the specified path
w_string w_fstype(const char *path);
extern char *poisoned_reason;
static inline void w_set_cloexec(int fd)
{
#ifndef _WIN32
ignore_result(fcntl(fd, F_SETFD, FD_CLOEXEC));
#else
unused_parameter(fd);
#endif
}
static inline void w_set_nonblock(int fd)
{
#ifndef _WIN32
ignore_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK));
#else
unused_parameter(fd);
#endif
}
static inline void w_clear_nonblock(int fd)
{
#ifndef _WIN32
ignore_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK));
#else
unused_parameter(fd);
#endif
}
// Make a temporary file name and open it.
// Marks the file as CLOEXEC
w_stm_t w_mkstemp(char *templ);
char *w_realpath(const char *filename);
#ifndef _WIN32
static inline bool w_path_exists(const char *path) {
return access(path, F_OK) == 0;
}
#else
bool w_path_exists(const char *path);
#endif
/* We leverage the fact that our aligned pointers will never set the LSB of a
* pointer value. We can use the LSB to indicate whether kqueue entries are
* dirs or files */
#define SET_DIR_BIT(dir) ((void*)(((intptr_t)dir) | 0x1))
#define IS_DIR_BIT_SET(dir) ((((intptr_t)dir) & 0x1) == 0x1)
#define DECODE_DIR(dir) ((void*)(((intptr_t)dir) & ~0x1))
bool w_is_stopping(void);
void w_request_shutdown(void);
#include "watchman_time.h"
extern const char *watchman_tmp_dir;
extern char *watchman_state_file;
extern int dont_save_state;
void w_state_shutdown(void);
void w_state_save(void);
bool w_state_load(void);
bool w_root_save_state(json_ref& state);
bool w_root_load_state(const json_ref& state);
json_ref w_root_watch_list_to_json(void);
#ifdef __APPLE__
int w_get_listener_socket_from_launchd(void);
#endif
bool w_listener_prep_inetd(void);
bool w_start_listener(const char *socket_path);
void w_check_my_sock(void);
char** w_argv_copy_from_json(const json_ref& arr, int skip);
#include "watchman_env.h"
#include "watchman_getopt.h"
#ifdef HAVE_SYS_SIGLIST
# define w_strsignal(val) sys_siglist[(val)]
#else
# define w_strsignal(val) strsignal((val))
#endif
const char *get_sock_name(void);
#ifndef _WIN32
/**
* Gets the group struct for the given group name. The return value may point
* to a static area so it should be used immediately and not passed to free(3).
*
* Returns null on failure.
*/
const struct group *w_get_group(const char *group_name);
#endif // ndef WIN32
int w_lstat(const char *path, struct stat *st, bool case_sensitive);
void w_ioprio_set_low(void);
void w_ioprio_set_normal(void);
struct flag_map {
uint32_t value;
const char *label;
};
void w_expand_flags(const struct flag_map *fmap, uint32_t flags,
char *buf, size_t len);
#ifdef __APPLE__
int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts);
int pthread_rwlock_timedwrlock(
pthread_rwlock_t* rwlock,
const struct timespec* ts);
int pthread_rwlock_timedrdlock(
pthread_rwlock_t* rwlock,
const struct timespec* ts);
#endif
#endif
/* vim:ts=2:sw=2:et:
*/