Tor  0.4.7.0-alpha-dev
tor_main.c
Go to the documentation of this file.
1 /* Copyright 2001-2004 Roger Dingledine.
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 #include "orconfig.h"
7 #ifdef ENABLE_RESTART_DEBUGGING
8 #include <stdlib.h>
9 #endif
10 
11 /**
12  * \file tor_main.c
13  * \brief Stub module containing a main() function.
14  *
15  * We keep the main function in a separate module so that the unit
16  * tests, which have their own main()s, can link against main.c.
17  **/
18 
19 int tor_main(int argc, char *argv[]);
20 
21 /** We keep main() in a separate file so that our unit tests can use
22  * functions from main.c.
23  */
24 int
25 main(int argc, char *argv[])
26 {
27  int r;
28 #ifdef ENABLE_RESTART_DEBUGGING
29  int restart_count = getenv("TOR_DEBUG_RESTART") ? 1 : 0;
30  again:
31 #endif
32  r = tor_main(argc, argv);
33  if (r < 0 || r > 255)
34  return 1;
35 #ifdef ENABLE_RESTART_DEBUGGING
36  else if (r == 0 && restart_count--)
37  goto again;
38 #endif
39  else
40  return r;
41 }
42 
int tor_main(int argc, char **argv)
int main(int argc, char *argv[])
Definition: tor_main.c:25