#ifndef TOR_DIRECTORY_H
#define TOR_DIRECTORY_H
dir_connection_t *TO_DIR_CONN(connection_t *c);
#define DIR_CONN_STATE_MIN_ 1
#define DIR_CONN_STATE_CONNECTING 1
#define DIR_CONN_STATE_CLIENT_SENDING 2
#define DIR_CONN_STATE_CLIENT_READING 3
#define DIR_CONN_STATE_CLIENT_FINISHED 4
#define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5
#define DIR_CONN_STATE_SERVER_WRITING 6
#define DIR_CONN_STATE_MAX_ 6
#define DIR_PURPOSE_MIN_ 4
#define DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 4
#define DIR_PURPOSE_FETCH_SERVERDESC 6
#define DIR_PURPOSE_FETCH_EXTRAINFO 7
#define DIR_PURPOSE_UPLOAD_DIR 8
#define DIR_PURPOSE_UPLOAD_VOTE 10
#define DIR_PURPOSE_UPLOAD_SIGNATURES 11
#define DIR_PURPOSE_FETCH_STATUS_VOTE 12
#define DIR_PURPOSE_FETCH_DETACHED_SIGNATURES 13
#define DIR_PURPOSE_FETCH_CONSENSUS 14
#define DIR_PURPOSE_FETCH_CERTIFICATE 15
#define DIR_PURPOSE_SERVER 16
#define DIR_PURPOSE_UPLOAD_RENDDESC_V2 17
#define DIR_PURPOSE_FETCH_RENDDESC_V2 18
#define DIR_PURPOSE_FETCH_MICRODESC 19
#define DIR_PURPOSE_UPLOAD_HSDESC 20
#define DIR_PURPOSE_FETCH_HSDESC 21
#define DIR_PURPOSE_HAS_FETCHED_HSDESC 22
#define DIR_PURPOSE_MAX_ 22
#define DIR_PURPOSE_IS_UPLOAD(p) \
((p)==DIR_PURPOSE_UPLOAD_DIR || \
(p)==DIR_PURPOSE_UPLOAD_VOTE || \
(p)==DIR_PURPOSE_UPLOAD_SIGNATURES || \
(p)==DIR_PURPOSE_UPLOAD_RENDDESC_V2 || \
(p)==DIR_PURPOSE_UPLOAD_HSDESC)
enum compress_method_t;
int parse_http_response(const char *headers, int *code, time_t *date,
enum compress_method_t *compression, char **response);
int parse_http_command(const char *headers,
char **command_out, char **url_out);
char *http_get_header(const char *headers, const char *which);
int connection_dir_is_encrypted(const dir_connection_t *conn);
bool connection_dir_is_anonymous(const dir_connection_t *conn);
int connection_dir_reached_eof(dir_connection_t *conn);
int connection_dir_process_inbuf(dir_connection_t *conn);
int connection_dir_finished_flushing(dir_connection_t *conn);
int connection_dir_finished_connecting(dir_connection_t *conn);
void connection_dir_about_to_close(dir_connection_t *dir_conn);
#define DSR_HEX (1<<0)
#define DSR_BASE64 (1<<1)
#define DSR_DIGEST256 (1<<2)
#define DSR_SORT_UNIQ (1<<3)
int dir_split_resource_into_fingerprints(const char *resource,
smartlist_t *fp_out, int *compressed_out,
int flags);
int dir_split_resource_into_fingerprint_pairs(const char *res,
smartlist_t *pairs_out);
char *directory_dump_request_log(void);
void note_request(const char *key, size_t bytes);
int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose,
const char *resource);
char *authdir_type_to_string(dirinfo_type_t auth);
#define X_ADDRESS_HEADER "X-Your-Address-Is: "
#define X_OR_DIFF_FROM_CONSENSUS_HEADER "X-Or-Diff-From-Consensus: "
#endif