Macros | Functions
tor_api.c File Reference
#include "feature/api/tor_api.h"
#include "orconfig.h"
#include "lib/cc/torint.h"
#include "feature/api/tor_api_internal.h"
#include "lib/cc/compat_compiler.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.


#define raw_malloc   malloc
#define raw_free   free
#define raw_realloc   realloc
#define raw_strdup   strdup
#define raw_socketpair   socketpair
#define raw_closesocket   close


static int cfg_add_owned_arg (tor_main_configuration_t *cfg, const char *arg)
tor_main_configuration_ttor_main_configuration_new (void)
int tor_main_configuration_set_command_line (tor_main_configuration_t *cfg, int argc, char *argv[])
tor_control_socket_t tor_main_configuration_setup_control_socket (tor_main_configuration_t *cfg)
void tor_main_configuration_free (tor_main_configuration_t *cfg)
const char * tor_api_get_provider_version (void)
int tor_main (int argc, char *argv[])

Function Documentation

◆ cfg_add_owned_arg()

static int cfg_add_owned_arg ( tor_main_configuration_t cfg,
const char *  arg 

Helper: Add a copy of arg to the owned arguments of cfg. Return 0 on success, -1 on failure.

Definition at line 57 of file tor_api.c.

◆ tor_api_get_provider_version()

const char* tor_api_get_provider_version ( void  )

Return the name and version of the software implementing the tor_api functionality. Current implementors are "tor" and "libtorrunner".

Note that if you're using libtorrunner, you'll see the version of libtorrunner, not the version of Tor that it's invoking for you.

Added in Tor

Example return values include "tor" when linked directly against tor, and "libtorrunner" when linked against libtorrunner while it is invoking an arbitrary version of Tor. HOWEVER, the user MUST NOT depend on any particular format or contents of this string: there may be other things that implement Tor in the future.

Definition at line 139 of file tor_api.c.

◆ tor_main_configuration_free()

void tor_main_configuration_free ( tor_main_configuration_t cfg)

Release all storage held in cfg.

Once you have passed a tor_main_configuration_t to tor_run_main(), you must not free it until tor_run_main() has finished.

Definition at line 122 of file tor_api.c.

References tor_main_configuration_t::argc_owned, and tor_main_configuration_t::argv_owned.

◆ tor_main_configuration_new()

tor_main_configuration_t* tor_main_configuration_new ( void  )

Create and return a new tor_main_configuration().

Definition at line 73 of file tor_api.c.

◆ tor_main_configuration_set_command_line()

int tor_main_configuration_set_command_line ( tor_main_configuration_t cfg,
int  argc,
char *  argv[] 

Set the command-line arguments in cfg.

The argc and argv values here are as for main(). The contents of the argv pointer must remain unchanged until tor_run_main() has finished and you call tor_main_configuration_free().

Return 0 on success, -1 on failure.

Definition at line 91 of file tor_api.c.

References tor_main_configuration_t::argc, and tor_main_configuration_t::argv.

◆ tor_main_configuration_setup_control_socket()

tor_control_socket_t tor_main_configuration_setup_control_socket ( tor_main_configuration_t cfg)


Definition at line 102 of file tor_api.c.

References tor_main_configuration_t::owning_controller_socket, and SOCKET_OK.