Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
18c11eb3
Commit
18c11eb3
authored
Jul 22, 2005
by
Nick Mathewson
🥄
Browse files
Be consistent about preferring foo* to struct foo*
svn:r4637
parent
d42aae7c
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/common/compat.c
View file @
18c11eb3
...
@@ -733,14 +733,14 @@ get_uname(void)
...
@@ -733,14 +733,14 @@ get_uname(void)
*/
*/
#if defined(USE_PTHREADS)
#if defined(USE_PTHREADS)
struct
tor_pthread_data_t
{
typedef
struct
tor_pthread_data_t
{
int
(
*
func
)(
void
*
);
int
(
*
func
)(
void
*
);
void
*
data
;
void
*
data
;
};
}
tor_pthread_data_t
;
static
void
*
static
void
*
tor_pthread_helper_fn
(
void
*
_data
)
tor_pthread_helper_fn
(
void
*
_data
)
{
{
struct
tor_pthread_data_t
*
data
=
_data
;
tor_pthread_data_t
*
data
=
_data
;
int
(
*
func
)(
void
*
);
int
(
*
func
)(
void
*
);
void
*
arg
;
void
*
arg
;
func
=
data
->
func
;
func
=
data
->
func
;
...
@@ -771,8 +771,8 @@ spawn_func(int (*func)(void *), void *data)
...
@@ -771,8 +771,8 @@ spawn_func(int (*func)(void *), void *data)
return
0
;
return
0
;
#elif defined(USE_PTHREADS)
#elif defined(USE_PTHREADS)
pthread_t
thread
;
pthread_t
thread
;
struct
tor_pthread_data_t
*
d
;
tor_pthread_data_t
*
d
;
d
=
tor_malloc
(
sizeof
(
struct
tor_pthread_data_t
));
d
=
tor_malloc
(
sizeof
(
tor_pthread_data_t
));
d
->
data
=
data
;
d
->
data
=
data
;
d
->
func
=
func
;
d
->
func
=
func
;
if
(
pthread_create
(
&
thread
,
NULL
,
tor_pthread_helper_fn
,
d
))
if
(
pthread_create
(
&
thread
,
NULL
,
tor_pthread_helper_fn
,
d
))
...
...
src/common/container.c
View file @
18c11eb3
...
@@ -388,18 +388,18 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
...
@@ -388,18 +388,18 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
/* Splay-tree implementation of string-to-void* map
/* Splay-tree implementation of string-to-void* map
*/
*/
struct
strmap_entry_t
{
typedef
struct
strmap_entry_t
{
SPLAY_ENTRY
(
strmap_entry_t
)
node
;
SPLAY_ENTRY
(
strmap_entry_t
)
node
;
char
*
key
;
char
*
key
;
void
*
val
;
void
*
val
;
};
}
strmap_entry_t
;
struct
strmap_t
{
struct
strmap_t
{
SPLAY_HEAD
(
strmap_tree
,
strmap_entry_t
)
head
;
SPLAY_HEAD
(
strmap_tree
,
strmap_entry_t
)
head
;
};
};
static
int
compare_strmap_entries
(
struct
strmap_entry_t
*
a
,
static
int
compare_strmap_entries
(
strmap_entry_t
*
a
,
struct
strmap_entry_t
*
b
)
strmap_entry_t
*
b
)
{
{
return
strcmp
(
a
->
key
,
b
->
key
);
return
strcmp
(
a
->
key
,
b
->
key
);
}
}
...
...
src/common/container.h
View file @
18c11eb3
...
@@ -72,7 +72,6 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
...
@@ -72,7 +72,6 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
/* Map from const char * to void*. Implemented with a splay tree. */
/* Map from const char * to void*. Implemented with a splay tree. */
typedef
struct
strmap_t
strmap_t
;
typedef
struct
strmap_t
strmap_t
;
typedef
struct
strmap_entry_t
strmap_entry_t
;
typedef
struct
strmap_entry_t
strmap_iter_t
;
typedef
struct
strmap_entry_t
strmap_iter_t
;
strmap_t
*
strmap_new
(
void
);
strmap_t
*
strmap_new
(
void
);
void
*
strmap_set
(
strmap_t
*
map
,
const
char
*
key
,
void
*
val
);
void
*
strmap_set
(
strmap_t
*
map
,
const
char
*
key
,
void
*
val
);
...
...
src/or/circuitbuild.c
View file @
18c11eb3
...
@@ -86,7 +86,7 @@ get_unique_circ_id_by_conn(connection_t *conn)
...
@@ -86,7 +86,7 @@ get_unique_circ_id_by_conn(connection_t *conn)
char
*
char
*
circuit_list_path
(
circuit_t
*
circ
,
int
verbose
)
circuit_list_path
(
circuit_t
*
circ
,
int
verbose
)
{
{
struct
crypt_path_t
*
hop
;
crypt_path_t
*
hop
;
smartlist_t
*
elements
;
smartlist_t
*
elements
;
const
char
*
states
[]
=
{
"closed"
,
"waiting for keys"
,
"open"
};
const
char
*
states
[]
=
{
"closed"
,
"waiting for keys"
,
"open"
};
char
buf
[
128
];
char
buf
[
128
];
...
@@ -156,7 +156,7 @@ circuit_log_path(int severity, circuit_t *circ)
...
@@ -156,7 +156,7 @@ circuit_log_path(int severity, circuit_t *circ)
void
void
circuit_rep_hist_note_result
(
circuit_t
*
circ
)
circuit_rep_hist_note_result
(
circuit_t
*
circ
)
{
{
struct
crypt_path_t
*
hop
;
crypt_path_t
*
hop
;
char
*
prev_digest
=
NULL
;
char
*
prev_digest
=
NULL
;
routerinfo_t
*
router
;
routerinfo_t
*
router
;
hop
=
circ
->
cpath
;
hop
=
circ
->
cpath
;
...
...
src/or/circuitlist.c
View file @
18c11eb3
...
@@ -26,19 +26,19 @@ static void circuit_free_cpath_node(crypt_path_t *victim);
...
@@ -26,19 +26,19 @@ static void circuit_free_cpath_node(crypt_path_t *victim);
/** A map from OR connection and circuit ID to circuit. (Lookup performance is
/** A map from OR connection and circuit ID to circuit. (Lookup performance is
* very important here, since we need to do it every time a cell arrives.) */
* very important here, since we need to do it every time a cell arrives.) */
struct
orconn_circid_circuit_map_t
{
typedef
struct
orconn_circid_circuit_map_t
{
RB_ENTRY
(
orconn_circid_circuit_map_t
)
node
;
RB_ENTRY
(
orconn_circid_circuit_map_t
)
node
;
connection_t
*
or_conn
;
connection_t
*
or_conn
;
uint16_t
circ_id
;
uint16_t
circ_id
;
circuit_t
*
circuit
;
circuit_t
*
circuit
;
};
}
orconn_circid_circuit_map_t
;
/** Helper for RB tree: compare the OR connection and circuit ID for a and b,
/** Helper for RB tree: compare the OR connection and circuit ID for a and b,
* and return less than, equal to, or greater than zero appropriately.
* and return less than, equal to, or greater than zero appropriately.
*/
*/
static
INLINE
int
static
INLINE
int
compare_orconn_circid_entries
(
struct
orconn_circid_circuit_map_t
*
a
,
compare_orconn_circid_entries
(
orconn_circid_circuit_map_t
*
a
,
struct
orconn_circid_circuit_map_t
*
b
)
orconn_circid_circuit_map_t
*
b
)
{
{
if
(
a
->
or_conn
<
b
->
or_conn
)
if
(
a
->
or_conn
<
b
->
or_conn
)
return
-
1
;
return
-
1
;
...
@@ -58,7 +58,7 @@ RB_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, compare_orcon
...
@@ -58,7 +58,7 @@ RB_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, compare_orcon
*/
*/
/* (We tried using splay trees, but round-robin turned out to make them
/* (We tried using splay trees, but round-robin turned out to make them
* suck.) */
* suck.) */
struct
orconn_circid_circuit_map_t
*
_last_circid_orconn_ent
=
NULL
;
orconn_circid_circuit_map_t
*
_last_circid_orconn_ent
=
NULL
;
/** Set the p_conn or n_conn field of a circuit <b>circ</b>, along
/** Set the p_conn or n_conn field of a circuit <b>circ</b>, along
* with the corresponding circuit ID, and add the circuit as appropriate
* with the corresponding circuit ID, and add the circuit as appropriate
...
@@ -70,8 +70,8 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
...
@@ -70,8 +70,8 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
{
{
uint16_t
old_id
;
uint16_t
old_id
;
connection_t
*
old_conn
;
connection_t
*
old_conn
;
struct
orconn_circid_circuit_map_t
search
;
orconn_circid_circuit_map_t
search
;
struct
orconn_circid_circuit_map_t
*
found
;
orconn_circid_circuit_map_t
*
found
;
tor_assert
(
!
conn
||
conn
->
type
==
CONN_TYPE_OR
);
tor_assert
(
!
conn
||
conn
->
type
==
CONN_TYPE_OR
);
...
@@ -114,7 +114,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
...
@@ -114,7 +114,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
if
(
found
)
{
if
(
found
)
{
found
->
circuit
=
circ
;
found
->
circuit
=
circ
;
}
else
{
}
else
{
found
=
tor_malloc_zero
(
sizeof
(
struct
orconn_circid_circuit_map_t
));
found
=
tor_malloc_zero
(
sizeof
(
orconn_circid_circuit_map_t
));
found
->
circ_id
=
id
;
found
->
circ_id
=
id
;
found
->
or_conn
=
conn
;
found
->
or_conn
=
conn
;
found
->
circuit
=
circ
;
found
->
circuit
=
circ
;
...
@@ -341,8 +341,8 @@ circuit_get_by_global_id(uint32_t id)
...
@@ -341,8 +341,8 @@ circuit_get_by_global_id(uint32_t id)
circuit_t
*
circuit_t
*
circuit_get_by_circid_orconn
(
uint16_t
circ_id
,
connection_t
*
conn
)
circuit_get_by_circid_orconn
(
uint16_t
circ_id
,
connection_t
*
conn
)
{
{
struct
orconn_circid_circuit_map_t
search
;
orconn_circid_circuit_map_t
search
;
struct
orconn_circid_circuit_map_t
*
found
;
orconn_circid_circuit_map_t
*
found
;
tor_assert
(
conn
->
type
==
CONN_TYPE_OR
);
tor_assert
(
conn
->
type
==
CONN_TYPE_OR
);
...
...
src/or/config.c
View file @
18c11eb3
...
@@ -206,7 +206,7 @@ typedef struct {
...
@@ -206,7 +206,7 @@ typedef struct {
/** Largest allowed config line */
/** Largest allowed config line */
#define CONFIG_LINE_T_MAXLEN 4096
#define CONFIG_LINE_T_MAXLEN 4096
static
void
config_line_append
(
struct
config_line_t
**
lst
,
static
void
config_line_append
(
config_line_t
**
lst
,
const
char
*
key
,
const
char
*
val
);
const
char
*
key
,
const
char
*
val
);
static
void
option_reset
(
config_format_t
*
fmt
,
or_options_t
*
options
,
static
void
option_reset
(
config_format_t
*
fmt
,
or_options_t
*
options
,
config_var_t
*
var
);
config_var_t
*
var
);
...
@@ -221,19 +221,19 @@ static void config_register_addressmaps(or_options_t *options);
...
@@ -221,19 +221,19 @@ static void config_register_addressmaps(or_options_t *options);
static
int
parse_dir_server_line
(
const
char
*
line
,
int
validate_only
);
static
int
parse_dir_server_line
(
const
char
*
line
,
int
validate_only
);
static
int
parse_redirect_line
(
smartlist_t
*
result
,
static
int
parse_redirect_line
(
smartlist_t
*
result
,
struct
config_line_t
*
line
);
config_line_t
*
line
);
static
int
parse_log_severity_range
(
const
char
*
range
,
int
*
min_out
,
static
int
parse_log_severity_range
(
const
char
*
range
,
int
*
min_out
,
int
*
max_out
);
int
*
max_out
);
static
int
convert_log_option
(
or_options_t
*
options
,
static
int
convert_log_option
(
or_options_t
*
options
,
struct
config_line_t
*
level_opt
,
config_line_t
*
level_opt
,
struct
config_line_t
*
file_opt
,
int
isDaemon
);
config_line_t
*
file_opt
,
int
isDaemon
);
static
int
add_single_log_option
(
or_options_t
*
options
,
int
minSeverity
,
static
int
add_single_log_option
(
or_options_t
*
options
,
int
minSeverity
,
int
maxSeverity
,
int
maxSeverity
,
const
char
*
type
,
const
char
*
fname
);
const
char
*
type
,
const
char
*
fname
);
static
int
normalize_log_options
(
or_options_t
*
options
);
static
int
normalize_log_options
(
or_options_t
*
options
);
static
int
validate_data_directory
(
or_options_t
*
options
);
static
int
validate_data_directory
(
or_options_t
*
options
);
static
int
write_configuration_file
(
const
char
*
fname
,
or_options_t
*
options
);
static
int
write_configuration_file
(
const
char
*
fname
,
or_options_t
*
options
);
static
struct
config_line_t
*
get_assigned_option
(
config_format_t
*
fmt
,
static
config_line_t
*
get_assigned_option
(
config_format_t
*
fmt
,
or_options_t
*
options
,
const
char
*
key
);
or_options_t
*
options
,
const
char
*
key
);
static
void
config_init
(
config_format_t
*
fmt
,
or_options_t
*
options
);
static
void
config_init
(
config_format_t
*
fmt
,
or_options_t
*
options
);
...
@@ -325,7 +325,7 @@ safe_str(const char *address)
...
@@ -325,7 +325,7 @@ safe_str(const char *address)
int
int
options_act
(
void
)
options_act
(
void
)
{
{
struct
config_line_t
*
cl
;
config_line_t
*
cl
;
or_options_t
*
options
=
get_options
();
or_options_t
*
options
=
get_options
();
static
int
libevent_initialized
=
0
;
static
int
libevent_initialized
=
0
;
...
@@ -474,11 +474,11 @@ expand_abbrev(config_format_t *fmt, const char *option, int command_line)
...
@@ -474,11 +474,11 @@ expand_abbrev(config_format_t *fmt, const char *option, int command_line)
}
}
/** Helper: Read a list of configuration options from the command line. */
/** Helper: Read a list of configuration options from the command line. */
static
struct
config_line_t
*
static
config_line_t
*
config_get_commandlines
(
int
argc
,
char
**
argv
)
config_get_commandlines
(
int
argc
,
char
**
argv
)
{
{
struct
config_line_t
*
front
=
NULL
;
config_line_t
*
front
=
NULL
;
struct
config_line_t
**
new
=
&
front
;
config_line_t
**
new
=
&
front
;
char
*
s
;
char
*
s
;
int
i
=
1
;
int
i
=
1
;
...
@@ -495,7 +495,7 @@ config_get_commandlines(int argc, char **argv)
...
@@ -495,7 +495,7 @@ config_get_commandlines(int argc, char **argv)
continue
;
continue
;
}
}
*
new
=
tor_malloc_zero
(
sizeof
(
struct
config_line_t
));
*
new
=
tor_malloc_zero
(
sizeof
(
config_line_t
));
s
=
argv
[
i
];
s
=
argv
[
i
];
while
(
*
s
==
'-'
)
while
(
*
s
==
'-'
)
...
@@ -516,13 +516,13 @@ config_get_commandlines(int argc, char **argv)
...
@@ -516,13 +516,13 @@ config_get_commandlines(int argc, char **argv)
/** Helper: allocate a new configuration option mapping 'key' to 'val',
/** Helper: allocate a new configuration option mapping 'key' to 'val',
* append it to *<b>lst</b>. */
* append it to *<b>lst</b>. */
static
void
static
void
config_line_append
(
struct
config_line_t
**
lst
,
config_line_append
(
config_line_t
**
lst
,
const
char
*
key
,
const
char
*
key
,
const
char
*
val
)
const
char
*
val
)
{
{
struct
config_line_t
*
newline
;
config_line_t
*
newline
;
newline
=
tor_malloc
(
sizeof
(
struct
config_line_t
));
newline
=
tor_malloc
(
sizeof
(
config_line_t
));
newline
->
key
=
tor_strdup
(
key
);
newline
->
key
=
tor_strdup
(
key
);
newline
->
value
=
tor_strdup
(
val
);
newline
->
value
=
tor_strdup
(
val
);
newline
->
next
=
NULL
;
newline
->
next
=
NULL
;
...
@@ -537,9 +537,9 @@ config_line_append(struct config_line_t **lst,
...
@@ -537,9 +537,9 @@ config_line_append(struct config_line_t **lst,
* failed. Return 0 on success, -1 on failure. Warn and ignore any
* failed. Return 0 on success, -1 on failure. Warn and ignore any
* misformatted lines. */
* misformatted lines. */
int
int
config_get_lines
(
char
*
string
,
struct
config_line_t
**
result
)
config_get_lines
(
char
*
string
,
config_line_t
**
result
)
{
{
struct
config_line_t
*
list
=
NULL
,
**
next
;
config_line_t
*
list
=
NULL
,
**
next
;
char
*
k
,
*
v
;
char
*
k
,
*
v
;
next
=
&
list
;
next
=
&
list
;
...
@@ -553,7 +553,7 @@ config_get_lines(char *string, struct config_line_t **result)
...
@@ -553,7 +553,7 @@ config_get_lines(char *string, struct config_line_t **result)
/* This list can get long, so we keep a pointer to the end of it
/* This list can get long, so we keep a pointer to the end of it
* rather than using config_line_append over and over and getting n^2
* rather than using config_line_append over and over and getting n^2
* performance. This is the only really long list. */
* performance. This is the only really long list. */
*
next
=
tor_malloc
(
sizeof
(
struct
config_line_t
));
*
next
=
tor_malloc
(
sizeof
(
config_line_t
));
(
*
next
)
->
key
=
tor_strdup
(
k
);
(
*
next
)
->
key
=
tor_strdup
(
k
);
(
*
next
)
->
value
=
tor_strdup
(
v
);
(
*
next
)
->
value
=
tor_strdup
(
v
);
(
*
next
)
->
next
=
NULL
;
(
*
next
)
->
next
=
NULL
;
...
@@ -569,9 +569,9 @@ config_get_lines(char *string, struct config_line_t **result)
...
@@ -569,9 +569,9 @@ config_get_lines(char *string, struct config_line_t **result)
* Free all the configuration lines on the linked list <b>front</b>.
* Free all the configuration lines on the linked list <b>front</b>.
*/
*/
void
void
config_free_lines
(
struct
config_line_t
*
front
)
config_free_lines
(
config_line_t
*
front
)
{
{
struct
config_line_t
*
tmp
;
config_line_t
*
tmp
;
while
(
front
)
{
while
(
front
)
{
tmp
=
front
;
tmp
=
front
;
...
@@ -621,7 +621,7 @@ config_find_option(config_format_t *fmt, const char *key)
...
@@ -621,7 +621,7 @@ config_find_option(config_format_t *fmt, const char *key)
*/
*/
static
int
static
int
config_assign_line
(
config_format_t
*
fmt
,
config_assign_line
(
config_format_t
*
fmt
,
or_options_t
*
options
,
struct
config_line_t
*
c
,
int
reset
)
or_options_t
*
options
,
config_line_t
*
c
,
int
reset
)
{
{
int
i
,
ok
;
int
i
,
ok
;
config_var_t
*
var
;
config_var_t
*
var
;
...
@@ -708,7 +708,7 @@ config_assign_line(config_format_t *fmt,
...
@@ -708,7 +708,7 @@ config_assign_line(config_format_t *fmt,
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST_S
:
case
CONFIG_TYPE_LINELIST_S
:
config_line_append
((
struct
config_line_t
**
)
lvalue
,
c
->
key
,
c
->
value
);
config_line_append
((
config_line_t
**
)
lvalue
,
c
->
key
,
c
->
value
);
break
;
break
;
case
CONFIG_TYPE_OBSOLETE
:
case
CONFIG_TYPE_OBSOLETE
:
...
@@ -755,22 +755,21 @@ config_option_get_canonical_name(const char *key)
...
@@ -755,22 +755,21 @@ config_option_get_canonical_name(const char *key)
return
var
->
name
;
return
var
->
name
;
}
}
/** Return a canonicalized list of the options assigned for key.
/** Return a canonicalized list of the options assigned for key.
*/
*/
struct
config_line_t
*
config_line_t
*
config_get_assigned_option
(
or_options_t
*
options
,
const
char
*
key
)
config_get_assigned_option
(
or_options_t
*
options
,
const
char
*
key
)
{
{
return
get_assigned_option
(
&
config_format
,
options
,
key
);
return
get_assigned_option
(
&
config_format
,
options
,
key
);
}
}
static
struct
config_line_t
*
static
config_line_t
*
get_assigned_option
(
config_format_t
*
fmt
,
or_options_t
*
options
,
const
char
*
key
)
get_assigned_option
(
config_format_t
*
fmt
,
or_options_t
*
options
,
const
char
*
key
)
{
{
config_var_t
*
var
;
config_var_t
*
var
;
const
void
*
value
;
const
void
*
value
;
char
buf
[
32
];
char
buf
[
32
];
struct
config_line_t
*
result
;
config_line_t
*
result
;
tor_assert
(
options
&&
key
);
tor_assert
(
options
&&
key
);
CHECK
(
fmt
,
options
);
CHECK
(
fmt
,
options
);
...
@@ -788,10 +787,10 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
...
@@ -788,10 +787,10 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
if
(
var
->
type
==
CONFIG_TYPE_LINELIST
||
if
(
var
->
type
==
CONFIG_TYPE_LINELIST
||
var
->
type
==
CONFIG_TYPE_LINELIST_V
)
{
var
->
type
==
CONFIG_TYPE_LINELIST_V
)
{
/* Linelist requires special handling: we just copy and return it. */
/* Linelist requires special handling: we just copy and return it. */
const
struct
config_line_t
*
next_in
=
*
(
const
struct
config_line_t
**
)
value
;
const
config_line_t
*
next_in
=
*
(
const
config_line_t
**
)
value
;
struct
config_line_t
**
next_out
=
&
result
;
config_line_t
**
next_out
=
&
result
;
while
(
next_in
)
{
while
(
next_in
)
{
*
next_out
=
tor_malloc
(
sizeof
(
struct
config_line_t
));
*
next_out
=
tor_malloc
(
sizeof
(
config_line_t
));
(
*
next_out
)
->
key
=
tor_strdup
(
next_in
->
key
);
(
*
next_out
)
->
key
=
tor_strdup
(
next_in
->
key
);
(
*
next_out
)
->
value
=
tor_strdup
(
next_in
->
value
);
(
*
next_out
)
->
value
=
tor_strdup
(
next_in
->
value
);
next_in
=
next_in
->
next
;
next_in
=
next_in
->
next
;
...
@@ -801,7 +800,7 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
...
@@ -801,7 +800,7 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
return
result
;
return
result
;
}
}
result
=
tor_malloc_zero
(
sizeof
(
struct
config_line_t
));
result
=
tor_malloc_zero
(
sizeof
(
config_line_t
));
result
->
key
=
tor_strdup
(
var
->
name
);
result
->
key
=
tor_strdup
(
var
->
name
);
switch
(
var
->
type
)
switch
(
var
->
type
)
{
{
...
@@ -866,9 +865,9 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
...
@@ -866,9 +865,9 @@ get_assigned_option(config_format_t *fmt, or_options_t *options, const char *key
*/
*/
static
int
static
int
config_assign
(
config_format_t
*
fmt
,
config_assign
(
config_format_t
*
fmt
,
or_options_t
*
options
,
struct
config_line_t
*
list
,
int
reset
)
or_options_t
*
options
,
config_line_t
*
list
,
int
reset
)
{
{
struct
config_line_t
*
p
;
config_line_t
*
p
;
CHECK
(
fmt
,
options
);
CHECK
(
fmt
,
options
);
...
@@ -905,7 +904,7 @@ config_assign(config_format_t *fmt,
...
@@ -905,7 +904,7 @@ config_assign(config_format_t *fmt,
* keys, -2 on bad values, -3 on bad transition.
* keys, -2 on bad values, -3 on bad transition.
*/
*/
int
int
config_trial_assign
(
struct
config_line_t
*
list
,
int
reset
)
config_trial_assign
(
config_line_t
*
list
,
int
reset
)
{
{
int
r
;
int
r
;
or_options_t
*
trial_options
=
options_dup
(
&
config_format
,
get_options
());
or_options_t
*
trial_options
=
options_dup
(
&
config_format
,
get_options
());
...
@@ -934,7 +933,7 @@ config_trial_assign(struct config_line_t *list, int reset)
...
@@ -934,7 +933,7 @@ config_trial_assign(struct config_line_t *list, int reset)
static
void
static
void
option_reset
(
config_format_t
*
fmt
,
or_options_t
*
options
,
config_var_t
*
var
)
option_reset
(
config_format_t
*
fmt
,
or_options_t
*
options
,
config_var_t
*
var
)
{
{
struct
config_line_t
*
c
;
config_line_t
*
c
;
void
*
lvalue
;
void
*
lvalue
;
CHECK
(
fmt
,
options
);
CHECK
(
fmt
,
options
);
...
@@ -964,8 +963,8 @@ option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
...
@@ -964,8 +963,8 @@ option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
break
;
break
;
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST_S
:
case
CONFIG_TYPE_LINELIST_S
:
config_free_lines
(
*
(
struct
config_line_t
**
)
lvalue
);
config_free_lines
(
*
(
config_line_t
**
)
lvalue
);
*
(
struct
config_line_t
**
)
lvalue
=
NULL
;
*
(
config_line_t
**
)
lvalue
=
NULL
;
break
;
break
;
case
CONFIG_TYPE_LINELIST_V
:
case
CONFIG_TYPE_LINELIST_V
:
/* handled by linelist_s. */
/* handled by linelist_s. */
...
@@ -974,7 +973,7 @@ option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
...
@@ -974,7 +973,7 @@ option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
break
;
break
;
}
}
if
(
var
->
initvalue
)
{
if
(
var
->
initvalue
)
{
c
=
tor_malloc_zero
(
sizeof
(
struct
config_line_t
));
c
=
tor_malloc_zero
(
sizeof
(
config_line_t
));
c
->
key
=
tor_strdup
(
var
->
name
);
c
->
key
=
tor_strdup
(
var
->
name
);
c
->
value
=
tor_strdup
(
var
->
initvalue
);
c
->
value
=
tor_strdup
(
var
->
initvalue
);
config_assign_line
(
fmt
,
options
,
c
,
0
);
config_assign_line
(
fmt
,
options
,
c
,
0
);
...
@@ -1154,8 +1153,8 @@ options_free(config_format_t *fmt,or_options_t *options)
...
@@ -1154,8 +1153,8 @@ options_free(config_format_t *fmt,or_options_t *options)
break
;
break
;
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST
:
case
CONFIG_TYPE_LINELIST_V
:
case
CONFIG_TYPE_LINELIST_V
:
config_free_lines
(
*
(
struct
config_line_t
**
)
lvalue
);
config_free_lines
(
*
(
config_line_t
**
)
lvalue
);
*
(
struct
config_line_t
**
)
lvalue
=
NULL
;
*
(
config_line_t
**
)
lvalue
=
NULL
;
break
;
break
;
case
CONFIG_TYPE_CSV
:
case
CONFIG_TYPE_CSV
:
if
(
*
(
smartlist_t
**
)
lvalue
)
{
if
(
*
(
smartlist_t
**
)
lvalue
)
{
...
@@ -1179,7 +1178,7 @@ static int
...
@@ -1179,7 +1178,7 @@ static int
option_is_same
(
config_format_t
*
fmt
,
option_is_same
(
config_format_t
*
fmt
,
or_options_t
*
o1
,
or_options_t
*
o2
,
const
char
*
name
)
or_options_t
*
o1
,
or_options_t
*
o2
,
const
char
*
name
)
{
{
struct
config_line_t
*
c1
,
*
c2
;
config_line_t
*
c1
,
*
c2
;
int
r
=
1
;
int
r
=
1
;
CHECK
(
fmt
,
o1
);
CHECK
(
fmt
,
o1
);
CHECK
(
fmt
,
o2
);
CHECK
(
fmt
,
o2
);
...
@@ -1209,7 +1208,7 @@ options_dup(config_format_t *fmt, or_options_t *old)
...
@@ -1209,7 +1208,7 @@ options_dup(config_format_t *fmt, or_options_t *old)
{
{
or_options_t
*
newopts
;
or_options_t
*
newopts
;
int
i
;
int
i
;
struct
config_line_t
*
line
;
config_line_t
*
line
;
newopts
=
config_alloc
(
fmt
);
newopts
=
config_alloc
(
fmt
);
for
(
i
=
0
;
fmt
->
vars
[
i
].
name
;
++
i
)
{
for
(
i
=
0
;
fmt
->
vars
[
i
].
name
;
++
i
)
{
...
@@ -1258,7 +1257,7 @@ config_dump(config_format_t *fmt, or_options_t *options, int minimal)
...
@@ -1258,7 +1257,7 @@ config_dump(config_format_t *fmt, or_options_t *options, int minimal)
{
{
smartlist_t
*
elements
;
smartlist_t
*
elements
;
or_options_t
*
defaults
;
or_options_t
*
defaults
;
struct
config_line_t
*
line
;
config_line_t
*
line
;
char
*
result
;
char
*
result
;
int
i
;
int
i
;
...
@@ -1334,7 +1333,7 @@ static int
...
@@ -1334,7 +1333,7 @@ static int
options_validate
(
or_options_t
*
options
)
options_validate
(
or_options_t
*
options
)
{
{
int
result
=
0
;
int
result
=
0
;
struct
config_line_t
*
cl
;
config_line_t
*
cl
;
addr_policy_t
*
addr_policy
=
NULL
;
addr_policy_t
*
addr_policy
=
NULL
;
if
(
options
->
ORPort
<
0
||
options
->
ORPort
>
65535
)
{
if
(
options
->
ORPort
<
0
||
options
->
ORPort
>
65535
)
{
...
@@ -1857,7 +1856,7 @@ int
...
@@ -1857,7 +1856,7 @@ int
init_from_config
(
int
argc
,
char
**
argv
)
init_from_config
(
int
argc
,
char
**
argv
)
{
{
or_options_t
*
oldoptions
,
*
newoptions
;
or_options_t
*
oldoptions
,
*
newoptions
;
struct
config_line_t
*
cl
;
config_line_t
*
cl
;
char
*
cf
=
NULL
,
*
fname
=
NULL
;
char
*
cf
=
NULL
,
*
fname
=
NULL
;
int
i
,
retval
;
int
i
,
retval
;