Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

main.c File Reference


Detailed Description

Main functions for gtk-gnutella.

Author:
Raphael Manfredi
Date:
2001-2003

#include "common.h"
#include "revision.h"
#include "core/ban.h"
#include "core/bitzi.h"
#include "core/bogons.h"
#include "core/bsched.h"
#include "core/clock.h"
#include "core/dh.h"
#include "core/dmesh.h"
#include "core/downloads.h"
#include "core/dq.h"
#include "core/extensions.h"
#include "core/features.h"
#include "core/fileinfo.h"
#include "core/file_object.h"
#include "core/geo_ip.h"
#include "core/gmsg.h"
#include "core/gnet_stats.h"
#include "core/gnutella.h"
#include "core/guid.h"
#include "core/hcache.h"
#include "core/hostiles.h"
#include "core/hosts.h"
#include "core/hsep.h"
#include "core/http.h"
#include "core/ignore.h"
#include "core/inet.h"
#include "core/local_shell.h"
#include "core/move.h"
#include "core/nodes.h"
#include "core/ntp.h"
#include "core/oob.h"
#include "core/parq.h"
#include "core/pcache.h"
#include "core/pproxy.h"
#include "core/routing.h"
#include "core/rx.h"
#include "core/search.h"
#include "core/settings.h"
#include "core/share.h"
#include "core/shell.h"
#include "core/sockets.h"
#include "core/spam.h"
#include "core/sq.h"
#include "core/tls_cache.h"
#include "core/tls_common.h"
#include "core/tsync.h"
#include "core/tx.h"
#include "core/udp.h"
#include "core/uhc.h"
#include "core/upload_stats.h"
#include "core/verify_sha1.h"
#include "core/verify_tth.h"
#include "core/version.h"
#include "core/vmsg.h"
#include "core/whitelist.h"
#include "dht/kuid.h"
#include "dht/routing.h"
#include "dht/rpc.h"
#include "lib/adns.h"
#include "lib/atoms.h"
#include "lib/bg.h"
#include "lib/cq.h"
#include "lib/crash.h"
#include "lib/crc.h"
#include "lib/dbus_util.h"
#include "lib/eval.h"
#include "lib/glib-missing.h"
#include "lib/halloc.h"
#include "lib/iso3166.h"
#include "lib/pattern.h"
#include "lib/socket.h"
#include "lib/tiger.h"
#include "lib/tigertree.h"
#include "lib/tm.h"
#include "lib/utf8.h"
#include "lib/vendors.h"
#include "lib/walloc.h"
#include "lib/watcher.h"
#include "lib/wordvec.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "if/bridge/c2ui.h"
#include "lib/override.h"

Defines

#define CORE_SOURCES
#define SLOW_UPDATE_PERIOD   20
 Update period for `main_slow_update'.
#define EXIT_GRACE   30
 Seconds to wait before exiting.
#define ATEXIT_TIMEOUT   20
 Final cleanup must not take longer.
#define LOAD_HIGH_WATERMARK   90
  amount over which we're overloaded
#define LOAD_LOW_WATERMARK   55
 lower threshold to clear condition
#define DO(fn)   do { exit_step = #fn; fn(); } while (0)
#define CASE(x)   case CAT2(G_LOG_LEVEL_,x): prefix = #x; break;
#define OPTION(name, type, summary)   { main_arg_ ## name , #name, summary, ARG_TYPE_ ## type, NULL, FALSE }

Enumerations

enum  main_arg {
  main_arg_daemonize, main_arg_exec_on_crash, main_arg_geometry, main_arg_help,
  main_arg_log_stderr, main_arg_log_stdout, main_arg_no_halloc, main_arg_no_xshm,
  main_arg_pause_on_crash, main_arg_ping, main_arg_shell, main_arg_version,
  main_arg_class, main_arg_g_fatal_warnings, main_arg_gdk_debug, main_arg_gdk_no_debug,
  main_arg_gtk_debug, main_arg_gtk_no_debug, main_arg_gtk_module, main_arg_name,
  num_main_args
}
enum  arg_type { ARG_TYPE_NONE, ARG_TYPE_TEXT, ARG_TYPE_PATH }

Functions

void gtk_gnutella_exit (gint n)
 Exit program, return status `n' to parent process.
gint reopen_log_files (void)
void sig_alarm (int n)
 Force immediate shutdown of SIGALRM reception.
void sig_hup (int n)
void sig_chld (int n)
guint32 main_get_build (void)
 Get build number.
gboolean debugging (guint t)
 Are we debugging anything at a level greater than some threshold "t"?
void gtk_gnutella_atexit (void)
 Invoked as an atexit() callback when someone does an exit().
void log_cpu_usage (tm_t *since_time, gdouble *prev_user, gdouble *prev_sys)
 Log cpu used since last time.
void gtk_gnutella_request_shutdown (void)
void sig_terminate (int n)
void search_gui_store_searches (void)
 Persist searches to disk.
void slow_main_timer (time_t now)
void icon_timer (void)
time_t check_cpu_usage (void)
 Check CPU usage.
gboolean main_timer (gpointer p)
 Main timer routine, called once per second.
gboolean scan_files_once (gpointer p)
 Scan files when the GUI is up.
void log_handler (const gchar *domain, GLogLevelFlags level, const gchar *message, gpointer user_data)
void log_init (void)
gchar underscore_to_hyphen (gchar c)
gboolean option_match (const gchar *a, const gchar *b)
 Checks whether two strings qualify as equivalent, the ASCII underscore character and the ASCII hyphen character are considered equivalent.
const gchar * option_pretty_name (const gchar *name)
 Copies the given option name to a static buffer replacing underscores with hyphens.
void usage (int exit_code)
void prehandle_arguments (char **argv)
void handle_arguments (int argc, char **argv)
int main (int argc, char **argv)

Variables

guint main_slow_update = 0
gboolean exiting = FALSE
volatile sig_atomic_t from_atexit = FALSE
volatile sig_atomic_t signal_received = 0
volatile sig_atomic_t shutdown_requested = 0
volatile sig_atomic_t sig_hup_received = 0
jmp_buf atexit_env
volatile const gchar * exit_step = "gtk_gnutella_exit"
tm_t start_time
const gchar *const log_domains []
char ** environ
struct {
   const gchar *const   name
   const gchar *const   summary
   const gchar *   arg
   gboolean   used
options []


Define Documentation

#define ATEXIT_TIMEOUT   20
 

Final cleanup must not take longer.

#define CASE  )     case CAT2(G_LOG_LEVEL_,x): prefix = #x; break;
 

#define CORE_SOURCES
 

#define DO fn   )     do { exit_step = #fn; fn(); } while (0)
 

#define EXIT_GRACE   30
 

Seconds to wait before exiting.

#define LOAD_HIGH_WATERMARK   90
 

amount over which we're overloaded

#define LOAD_LOW_WATERMARK   55
 

lower threshold to clear condition

#define OPTION name,
type,
summary   )     { main_arg_ ## name , #name, summary, ARG_TYPE_ ## type, NULL, FALSE }
 

#define SLOW_UPDATE_PERIOD   20
 

Update period for `main_slow_update'.


Enumeration Type Documentation

enum arg_type
 

Enumeration values:
ARG_TYPE_NONE 
ARG_TYPE_TEXT 
ARG_TYPE_PATH 

enum main_arg
 

Enumeration values:
main_arg_daemonize 
main_arg_exec_on_crash 
main_arg_geometry 
main_arg_help 
main_arg_log_stderr 
main_arg_log_stdout 
main_arg_no_halloc 
main_arg_no_xshm 
main_arg_pause_on_crash 
main_arg_ping 
main_arg_shell 
main_arg_version 
main_arg_class 
main_arg_g_fatal_warnings 
main_arg_gdk_debug 
main_arg_gdk_no_debug 
main_arg_gtk_debug 
main_arg_gtk_no_debug 
main_arg_gtk_module 
main_arg_name 
num_main_args 


Function Documentation

time_t check_cpu_usage void   )  [static]
 

Check CPU usage.

Returns:
current (exact) system time.

gboolean debugging guint  t  ) 
 

Are we debugging anything at a level greater than some threshold "t"?

void gtk_gnutella_atexit void   )  [static]
 

Invoked as an atexit() callback when someone does an exit().

void gtk_gnutella_exit gint  n  ) 
 

Exit program, return status `n' to parent process.

Shutdown systems, so we can track memory leaks, and wait for EXIT_GRACE seconds so that BYE messages can be sent to other nodes.

void gtk_gnutella_request_shutdown void   ) 
 

void handle_arguments int  argc,
char **  argv
[static]
 

void icon_timer void   ) 
 

void log_cpu_usage tm_t since_time,
gdouble *  prev_user,
gdouble *  prev_sys
[static]
 

Log cpu used since last time.

Parameters:
since_time time at which the measurement period started, updated
prev_user previous total user time, updated if not NULL
prev_sys previous total system time, updated if not NULL

void log_handler const gchar *  domain,
GLogLevelFlags  level,
const gchar *  message,
gpointer  user_data
[static]
 

void log_init void   )  [static]
 

int main int  argc,
char **  argv
 

guint32 main_get_build void   ) 
 

Get build number.

gboolean main_timer gpointer  p  )  [static]
 

Main timer routine, called once per second.

gboolean option_match const gchar *  a,
const gchar *  b
[static]
 

Checks whether two strings qualify as equivalent, the ASCII underscore character and the ASCII hyphen character are considered equivalent.

Returns:
whether the two strings qualify as equivalent or not.

const gchar* option_pretty_name const gchar *  name  )  [static]
 

Copies the given option name to a static buffer replacing underscores with hyphens.

Returns:
a pointer to a static buffer holding the pretty version of the option name.

void prehandle_arguments char **  argv  )  [static]
 

gint reopen_log_files void   )  [static]
 

gboolean scan_files_once gpointer  p  )  [static]
 

Scan files when the GUI is up.

void search_gui_store_searches void   ) 
 

Persist searches to disk.

void sig_alarm int  n  )  [static]
 

Force immediate shutdown of SIGALRM reception.

void sig_chld int  n  )  [static]
 

void sig_hup int  n  )  [static]
 

void sig_terminate int  n  )  [static]
 

void slow_main_timer time_t  now  )  [static]
 

gchar underscore_to_hyphen gchar  c  )  [inline, static]
 

void usage int  exit_code  )  [static]
 


Variable Documentation

const gchar* arg
 

jmp_buf atexit_env [static]
 

char** environ
 

volatile const gchar* exit_step = "gtk_gnutella_exit" [static]
 

gboolean exiting = FALSE [static]
 

volatile sig_atomic_t from_atexit = FALSE [static]
 

const gchar* const log_domains[] [static]
 

Initial value:

 {
    G_LOG_DOMAIN, "Gtk", "GLib", "Pango"
}

guint main_slow_update = 0 [static]
 

const gchar* const name
 

struct { ... } options[] [static]
 

volatile sig_atomic_t shutdown_requested = 0 [static]
 

volatile sig_atomic_t sig_hup_received = 0 [static]
 

volatile sig_atomic_t signal_received = 0 [static]
 

tm_t start_time [static]
 

const gchar* const summary
 

gboolean used
 


Generated on Sat Jun 30 17:53:28 2007 for gtk-gnutella by  doxygen 1.3.9.1