34 size_t len = strlen(s);
35 connection_buf_add(s, len,
TO_CONN(conn));
52 log_err(
LD_BUG,
"Unable to format string for controller.");
56 connection_buf_add(buf, (
size_t)len,
TO_CONN(conn));
74 size_t sz_out = len+8+1;
76 const char *start = data, *end;
79 for (i=0; i < len; ++i) {
80 if (data[i] ==
'\n') {
83 log_warn(
LD_BUG,
"Input to write_escaped_data was too long");
84 *out = tor_strdup(
".\r\n");
89 *out = outp = tor_malloc(sz_out);
94 if (data > start && data[-1] !=
'\r')
97 }
else if (*data ==
'.') {
107 if (outp < *out+2 ||
fast_memcmp(outp-2,
"\r\n", 2)) {
136 *out = outp = tor_malloc(len+1);
144 next = memchr(data,
'\n', end-data);
146 size_t n_to_copy = next-data;
148 if (n_to_copy && *(next-1) ==
'\r')
150 memcpy(outp, data, n_to_copy);
155 memcpy(outp, data, end-data);
198 const char *fmt, va_list ap)
205 log_err(
LD_BUG,
"Unable to format string for controller.");
222 const char *fmt, ...)
277 connection_buf_add(esc, esc_len,
TO_CONN(conn));
294 if (strpbrk(kvline->value,
"\r\n") != NULL) {
319 bool lastone =
false;
322 if (line_sl_idx >= line_sl_len - 1)
325 } SMARTLIST_FOREACH_END(line);
339 const char *key,
const char *val)
359 int len = smartlist_len(reply);
364 line = smartlist_get(reply, len - 1);
413 config_free_lines(line->
kvline);
Header file for circuitbuild.c.
Header file for circuitlist.c.
void config_line_append(config_line_t **lst, const char *key, const char *val)
Header file for connection.c.
Header file for connection_edge.c.
Controller connection structure.
void control_write_data(control_connection_t *conn, const char *data)
void control_printf_datareply(control_connection_t *conn, int code, const char *fmt,...)
void control_write_endreply(control_connection_t *conn, int code, const char *s)
void control_printf_midreply(control_connection_t *conn, int code, const char *fmt,...)
void control_write_midreply(control_connection_t *conn, int code, const char *s)
void send_control_done(control_connection_t *conn)
void control_vprintf_reply(control_connection_t *conn, int code, int c, const char *fmt, va_list ap)
void control_write_reply(control_connection_t *conn, int code, int c, const char *s)
void control_printf_endreply(control_connection_t *conn, int code, const char *fmt,...)
size_t read_escaped_data(const char *data, size_t len, char **out)
void connection_write_str_to_buf(const char *s, control_connection_t *conn)
void control_write_datareply(control_connection_t *conn, int code, const char *s)
size_t write_escaped_data(const char *data, size_t len, char **out)
void connection_printf_to_buf(control_connection_t *conn, const char *format,...)
Header file for control_proto.c.
Circuit-build-stse structure.
#define fast_memcmp(a, b, c)
Entry connection structure.
void control_reply_append_kv(smartlist_t *reply, const char *key, const char *val)
void control_write_reply_lines(control_connection_t *conn, smartlist_t *lines)
void control_reply_clear(smartlist_t *reply)
void control_reply_add_printf(smartlist_t *reply, int code, const char *fmt,...)
void control_reply_add_one_kv(smartlist_t *reply, int code, int flags, const char *key, const char *val)
void control_reply_line_free_(control_reply_line_t *line)
void control_reply_add_str(smartlist_t *reply, int code, const char *s)
void control_reply_add_done(smartlist_t *reply)
void control_write_reply_line(control_connection_t *conn, const control_reply_line_t *line, bool lastone)
void control_reply_free_(smartlist_t *reply)
#define control_reply_line_free(line)
Free and null a control_reply_line_t.
char * kvline_encode(const config_line_t *line, unsigned flags)
void tor_free_(void *mem)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
Origin circuit structure.
int tor_vasprintf(char **strp, const char *fmt, va_list args)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_clear(smartlist_t *sl)
void smartlist_free_(smartlist_t *sl)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Client request structure.
A reply line for the control protocol.
#define MOCK_IMPL(rv, funcname, arglist)