Main Page | Modules | Alphabetical List | Data Structures | 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 <setjmp.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/geo_ip.h"
#include "core/gmsg.h"
#include "core/gnet_stats.h"
#include "core/gnutella.h"
#include "core/guid.h"
#include "core/gwcache.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/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/sockets.h"
#include "core/sq.h"
#include "core/tsync.h"
#include "core/tx.h"
#include "core/uhc.h"
#include "core/upload_stats.h"
#include "core/verify.h"
#include "core/version.h"
#include "core/vmsg.h"
#include "core/whitelist.h"
#include "lib/adns.h"
#include "lib/atoms.h"
#include "lib/bg.h"
#include "lib/cq.h"
#include "lib/crc.h"
#include "lib/dbus_util.h"
#include "lib/eval.h"
#include "lib/glib-missing.h"
#include "lib/iso3166.h"
#include "lib/pattern.h"
#include "lib/tiger.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' */
 Update period for `main_slow_update'.

#define EXIT_GRACE   30 /**< Seconds to wait before exiting */
 Seconds to wait before exiting.

#define ATEXIT_TIMEOUT   20 /**< Final cleanup must not take longer */
 Final cleanup must not take longer.

#define LOAD_HIGH_WATERMARK   90 /**< % amount over which we're overloaded */
  amount over which we're overloaded

#define LOAD_LOW_WATERMARK   55 /**< lower threshold to clear condition */
 lower threshold to clear condition

#define DO(fn)   do { exit_step = STRINGIFY(fn); fn(); } while (0)
#define CASE(x)   case CAT2(G_LOG_LEVEL_,x): prefix = STRINGIFY(x); break;

Functions

 RCSID ("$Id:main.c, v 1.264 2005/11/29 22:14:55 rmanfredi Exp $")
void gtk_gnutella_exit (gint n)
 Exit program, return status `n' to parent process.

void sig_alarm (int n)
 Force immediate shutdown of SIGALRM reception.

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 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)
void close_fds (gint fd)
 Closes all file descriptors greater or equal to ``fd''.

void assertion_init (void)
int main (int argc, char **argv)

Variables

guint main_slow_update = 0
gboolean exiting = FALSE
gboolean from_atexit = FALSE
gint signal_received = 0
jmp_buf atexit_env
volatile gchar * exit_step = "gtk_gnutella_exit"
tm_t start_time
const gchar *const  log_domains []
char ** environ


Define Documentation

#define ATEXIT_TIMEOUT   20 /**< Final cleanup must not take longer */
 

Final cleanup must not take longer.

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

#define CORE_SOURCES
 

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

#define EXIT_GRACE   30 /**< Seconds to wait before exiting */
 

Seconds to wait before exiting.

#define LOAD_HIGH_WATERMARK   90 /**< % amount over which we're overloaded */
 

amount over which we're overloaded

#define LOAD_LOW_WATERMARK   55 /**< lower threshold to clear condition */
 

lower threshold to clear condition

#define SLOW_UPDATE_PERIOD   20 /**< Update period for `main_slow_update' */
 

Update period for `main_slow_update'.


Function Documentation

void assertion_init void   )  [static]
 

time_t check_cpu_usage void   )  [static]
 

Check CPU usage.

Returns:
current (exact) system time.

void close_fds gint  fd  )  [static]
 

Closes all file descriptors greater or equal to ``fd''.

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 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
 

gboolean main_timer gpointer  p  )  [static]
 

Main timer routine, called once per second.

RCSID "$Id:main.  c,
v 1.264 2005/11/29 22:14:55 rmanfredi Exp $" 
 

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_terminate int  n  )  [static]
 

void slow_main_timer time_t  now  )  [static]
 


Variable Documentation

jmp_buf atexit_env [static]
 

char** environ
 

volatile gchar* exit_step = "gtk_gnutella_exit" [static]
 

gboolean exiting = FALSE [static]
 

gboolean from_atexit = FALSE [static]
 

const gchar* const log_domains[] [static]
 

Initial value:

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

guint main_slow_update = 0 [static]
 

gint signal_received = 0 [static]
 

tm_t start_time [static]
 


Generated on Sun Feb 12 10:50:04 2006 for Gtk-Gnutella by doxygen 1.3.6