Tor 0.4.9.0-alpha-dev
Data Structures | Macros | Functions
Control reply lines

Key-value structures for control reply lines. More...

Data Structures

struct  control_reply_line_t
 A reply line for the control protocol. More...
 

Macros

#define control_reply_line_free(line)
 Free and null a control_reply_line_t. More...
 
#define control_reply_free(r)    FREE_AND_NULL(smartlist_t, control_reply_free_, (r))
 Free and null a smartlist of control_reply_line_t. More...
 

Functions

void control_reply_line_free_ (control_reply_line_t *line)
 
void control_write_reply_line (control_connection_t *conn, const control_reply_line_t *line, bool lastone)
 
void control_write_reply_lines (control_connection_t *conn, smartlist_t *lines)
 
void control_reply_add_one_kv (smartlist_t *reply, int code, int flags, const char *key, const char *val)
 
void control_reply_append_kv (smartlist_t *reply, const char *key, const char *val)
 
void control_reply_add_str (smartlist_t *reply, int code, const char *s)
 
void control_reply_add_printf (smartlist_t *reply, int code, const char *fmt,...)
 
void control_reply_add_done (smartlist_t *reply)
 
void control_reply_clear (smartlist_t *reply)
 
void control_reply_free_ (smartlist_t *reply)
 

Detailed Description

Key-value structures for control reply lines.

Control reply lines are config_line_t key-value structures with some additional information to help formatting, such as the numeric result code specified in the control protocol and flags affecting the way kvline_encode() formats the kvline.

Generally, modules implementing control commands will work with smartlists of these structures, using functions like control_reply_add_str() for adding a reply line consisting of a single string, or control_reply_add_one_kv() and control_reply_append_kv() for composing a line containing one or more key-value pairs.

Macro Definition Documentation

◆ control_reply_free

#define control_reply_free (   r)     FREE_AND_NULL(smartlist_t, control_reply_free_, (r))

Free and null a smartlist of control_reply_line_t.

Parameters
rpointer to smartlist_t of control_reply_line_t to free

Definition at line 116 of file control_proto.h.

◆ control_reply_line_free

#define control_reply_line_free (   line)
Value:
FREE_AND_NULL(control_reply_line_t, \
void control_reply_line_free_(control_reply_line_t *line)
A reply line for the control protocol.
Definition: control_proto.h:43

Free and null a control_reply_line_t.

Parameters
linepointer to control_reply_line_t to free

Definition at line 55 of file control_proto.h.

Function Documentation

◆ control_reply_add_done()

void control_reply_add_done ( smartlist_t reply)

Add a "250 OK" line to a set of control reply lines

Definition at line 401 of file control_proto.c.

◆ control_reply_add_one_kv()

void control_reply_add_one_kv ( smartlist_t reply,
int  code,
int  flags,
const char *  key,
const char *  val 
)

Add a single key-value pair as a new reply line to a control reply line list.

Parameters
replysmartlist of pointers to control_reply_line_t
codenumeric control reply code
flagskvline encoding flags
keykey
valvalue

Definition at line 338 of file control_proto.c.

Referenced by control_reply_add_str(), handle_control_getconf(), and handle_control_getinfo().

◆ control_reply_add_printf()

void control_reply_add_printf ( smartlist_t reply,
int  code,
const char *  fmt,
  ... 
)

Format a new reply line

Parameters
replysmartlist of pointers to control_reply_line_t
codenumeric control reply code
fmtformat string

Definition at line 387 of file control_proto.c.

Referenced by handle_control_getconf(), and handle_control_getinfo().

◆ control_reply_add_str()

void control_reply_add_str ( smartlist_t reply,
int  code,
const char *  s 
)

Add new reply line consisting of the string s

Parameters
replysmartlist of pointers to control_reply_line_t
codenumeric control reply code
sstring containing the rest of the reply line

Definition at line 375 of file control_proto.c.

Referenced by add_authmethods(), control_reply_add_done(), control_reply_add_printf(), and handle_control_getinfo().

◆ control_reply_append_kv()

void control_reply_append_kv ( smartlist_t reply,
const char *  key,
const char *  val 
)

Append a single key-value pair to last reply line in a control reply line list.

Parameters
replysmartlist of pointers to control_reply_line_t
keykey
valvalue

Definition at line 357 of file control_proto.c.

Referenced by add_authmethods().

◆ control_reply_clear()

void control_reply_clear ( smartlist_t reply)

Clear a smartlist of control_reply_line_t. Doesn't free the smartlist, but does free each individual line.

Definition at line 420 of file control_proto.c.

Referenced by control_reply_free_().

◆ control_reply_free_()

void control_reply_free_ ( smartlist_t reply)

Free a smartlist of control_reply_line_t. Don't call this directly; use the control_reply_free() macro instead.

Definition at line 430 of file control_proto.c.

◆ control_reply_line_free_()

void control_reply_line_free_ ( control_reply_line_t line)

Free a control_reply_line_t. Don't call this directly; use the control_reply_line_free() macro instead.

Definition at line 409 of file control_proto.c.

◆ control_write_reply_line()

void control_write_reply_line ( control_connection_t conn,
const control_reply_line_t line,
bool  lastone 
)

Write a single reply line to conn.

Parameters
conncontrol connection
linecontrol reply line to write
lastonetrue if this is the last reply line of a multi-line reply

Definition at line 288 of file control_proto.c.

Referenced by control_write_reply_lines().

◆ control_write_reply_lines()

void control_write_reply_lines ( control_connection_t conn,
smartlist_t lines 
)

Write a set of reply lines to conn.

Parameters
conncontrol connection
linessmartlist of pointers to control_reply_line_t to write

Definition at line 317 of file control_proto.c.