Beispiel #1
0
DirectResult
direct_signals_initialize( void )
{
#ifndef ANDROID_NDK
     sigset_t mask;
     int i;
#endif
     D_DEBUG_AT( Direct_Signals, "Initializing...\n" );

     direct_recursive_mutex_init( &handlers_lock );
#ifdef ANDROID_NDK
     install_handlers();
#else
     if (direct_config->sighandler) {
          if (direct_config->sighandler_thread) {
               sigemptyset( &mask );
               for (i=0; i<NUM_SIGS_TO_HANDLE; i++)
                    sigaddset( &mask, sigs_to_handle[i] );

               pthread_sigmask( SIG_BLOCK, &mask, NULL );

               sighandler_thread = direct_thread_create( DTT_CRITICAL, handle_signals, NULL, "SigHandler" );
               D_ASSERT( sighandler_thread != NULL );
          }
          else
               install_handlers();
     }
#endif
     return DR_OK;
}
Beispiel #2
0
Q_DECL_EXPORT void
Init_plasma_applet()
{
    rb_require("korundum4");    // need to initialize the core runtime first
    init_plasma_Smoke();
    set_qtruby_embedded(true);

    binding = QtRuby::Binding(plasma_Smoke);

    smokeList << plasma_Smoke;

    QtRubyModule module = { "Plasma", resolve_classname_plasma, 0, &binding };
    qtruby_modules[plasma_Smoke] = module;

    install_handlers(Plasma_handlers);

    plasma_module = rb_define_module("Plasma");
    plasma_internal_module = rb_define_module_under(plasma_module, "Internal");

    rb_define_singleton_method(plasma_module, "method_missing", (VALUE (*) (...)) plasma_module_method_missing, -1);
    rb_define_singleton_method(plasma_module, "const_missing", (VALUE (*) (...)) plasma_module_method_missing, -1);

    rb_define_singleton_method(plasma_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    rb_require("KDE/plasma.rb");
    rb_funcall(plasma_internal_module, rb_intern("init_all_classes"), 0);
}
/* Register a cleanup function to be executed when a catchable fatal signal
   occurs.  */
void
at_fatal_signal (action_t action)
{
  static bool cleanup_initialized = false;
  if (!cleanup_initialized)
    {
      install_handlers ();
      cleanup_initialized = true;
    }

  if (actions_count == actions_allocated)
    {
      /* Extend the actions array.  Note that we cannot use xrealloc(),
	 because then the cleanup() function could access an already
	 deallocated array.  */
      actions_entry_t *old_actions = actions;
      size_t new_actions_allocated = 2 * actions_allocated;
      actions_entry_t *new_actions =
	xmalloc (new_actions_allocated * sizeof (actions_entry_t));

      memcpy (new_actions, old_actions,
	      actions_allocated * sizeof (actions_entry_t));
      actions = new_actions;
      actions_allocated = new_actions_allocated;
      /* Now we can free the old actions array.  */
      if (old_actions != static_actions)
	free (old_actions);
    }
  /* The two uses of 'volatile' in the types above (and ISO C 99 section
     5.1.2.3.(5)) ensure that we increment the actions_count only after
     the new action has been written to the memory location
     actions[actions_count].  */
  actions[actions_count].action = action;
  actions_count++;
}
Beispiel #4
0
Q_DECL_EXPORT void
Init_soprano()
{
    init_soprano_Smoke();

    binding = QtRuby::Binding(soprano_Smoke);

    smokeList << soprano_Smoke;

    QtRubyModule module = { "Soprano", resolve_classname_soprano, 0, &binding };
    qtruby_modules[soprano_Smoke] = module;

    install_handlers(Soprano_handlers);

    soprano_module = rb_define_module("Soprano");
    soprano_internal_module = rb_define_module_under(soprano_module, "Internal");

    rb_define_singleton_method(soprano_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    (void) qRegisterMetaType<Soprano::Statement>();
    (void) qRegisterMetaType<Soprano::Node>();

    rb_require("soprano/soprano.rb");
    rb_funcall(soprano_internal_module, rb_intern("init_all_classes"), 0);
}
Beispiel #5
0
DirectResult
direct_signals_initialize( void )
{
     D_DEBUG_AT( Direct_Signals, "Initializing...\n" );

     direct_recursive_mutex_init( &handlers_lock );

     install_handlers();

     return DR_OK;
}
Beispiel #6
0
void PayguideInit()
{
	/* Init variables from payguide namespace */
	payguide::namespace_init();

	ReloadConfigIfImportant();
	
	if (curl_global_init(CURL_GLOBAL_ALL)!=0)
	{
		printf("CURL init failed! Payguide shutdown.\n");
		exit(1);
	}
	
	/* Deatch from console */
	if (payguide::daemonize==1)
	{
		if (Daemonize()!=0) 
		{
			LogWrite(LOGMSG_ERROR, "Daemonize failed!");
		}
	}


	
	my_init();
	DBVeryFirstInit();
	
	OperatorsInit();
	OpenSSLInit();

	StatisticInit();
	
	/* Catching TERM signal - shut down server */
	struct sigaction sterm;
	memset (&sterm, 0, sizeof(sterm));
	sterm.sa_handler=&SigHandler;
	sigaction(SIGTERM, &sterm, NULL);
	
	/* Catching INT signal - shut down server */
	struct sigaction sint;
	memset (&sint, 0, sizeof(sint));
	sint.sa_handler=&SigHandler;
	sigaction(SIGINT, &sint, NULL);
	
	atexit (CleanUp);

	/* Init backtrace */
	#ifdef ENABLE_BACKTRACE
		open_backtrace_fd(payguide::backtrace_file.c_str());
		install_handlers() ;
	#endif
	
}
Beispiel #7
0
/* Register a cleanup function to be executed when a catchable fatal signal
   occurs.  */
void
at_fatal_signal (action_t action)
{
  static bool cleanup_initialized = false;
  if (!cleanup_initialized)
    {
      init_fatal_signals ();
      install_handlers ();
      cleanup_initialized = true;
    }

  if (actions_count == actions_allocated)
    {
      /* Extend the actions array.  Note that we cannot use xrealloc(),
         because then the cleanup() function could access an already
         deallocated array.  */
      actions_entry_t *old_actions = actions;
      size_t old_actions_allocated = actions_allocated;
      size_t new_actions_allocated = 2 * actions_allocated;
      actions_entry_t *new_actions =
        XNMALLOC (new_actions_allocated, actions_entry_t);
      size_t k;

      /* Don't use memcpy() here, because memcpy takes non-volatile arguments
         and is therefore not guaranteed to complete all memory stores before
         the next statement.  */
      for (k = 0; k < old_actions_allocated; k++)
        new_actions[k] = old_actions[k];
      actions = new_actions;
      actions_allocated = new_actions_allocated;
      /* Now we can free the old actions array.  */
      if (old_actions != static_actions)
        free (old_actions);
    }
  /* The two uses of 'volatile' in the types above (and ISO C 99 section
     5.1.2.3.(5)) ensure that we increment the actions_count only after
     the new action has been written to the memory location
     actions[actions_count].  */
  actions[actions_count].action = action;
  actions_count++;
}
Beispiel #8
0
Q_DECL_EXPORT void
Init_nepomuk()
{
    init_nepomuk_Smoke();

    binding = QtRuby::Binding(nepomuk_Smoke);

    smokeList << nepomuk_Smoke;

    QtRubyModule module = { "Nepomuk", resolve_classname_nepomuk, 0, &binding };
    qtruby_modules[nepomuk_Smoke] = module;

    install_handlers(Nepomuk_handlers);

    nepomuk_module = rb_define_module("Nepomuk");
    nepomuk_internal_module = rb_define_module_under(nepomuk_module, "Internal");

    rb_define_singleton_method(nepomuk_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    rb_require("nepomuk/nepomuk.rb");
    rb_funcall(nepomuk_internal_module, rb_intern("init_all_classes"), 0);
}
Beispiel #9
0
static void
_init(void)
{
	int i;
	acf_t f_error_addr;
	fcode_env_t *env;

	NOTICE;

	fcode_impl_count = 0;
	env = MALLOC(sizeof (fcode_env_t));
	env->table = MALLOC((MAX_FCODE + 1) * sizeof (fcode_token));
	env->base = MALLOC(dict_size);
	env->here = env->base;
	env->ds = env->ds0 = MALLOC(stack_size * sizeof (fstack_t));
	env->rs = env->rs0 = MALLOC(stack_size * sizeof (fstack_t));
	env->order = MALLOC(MAX_ORDER * sizeof (token_t));
	env->input = MALLOC(sizeof (input_typ));
	env->num_base = 0x10;

	/* Setup the initial forth environment */
	do_forth(env);
	do_definitions(env);
	install_handlers(env);

	initial_env = env;

	/*
	 * Need to define this early because it is the default for
	 * all unimpl, FCODE functions
	 */
	P1275(0x0fc, IMMEDIATE,	"ferror",		f_error);
	f_error_addr = LINK_TO_ACF(env->lastlink);
	for (i = 0; i <= MAX_FCODE; i++) {
		DEBUGF(ANY, env->table[i].usage = 0);
		SET_TOKEN(i, IMMEDIATE, "ferror", f_error_addr);
	}
	fcode_impl_count = 0;
}
Beispiel #10
0
Q_DECL_EXPORT void
Init_phonon()
{
    init_phonon_Smoke();

    binding = QtRuby::Binding(phonon_Smoke);

    smokeList << phonon_Smoke;

    QtRubyModule module = { "Phonon", resolve_classname_phonon, 0, &binding };
    qtruby_modules[phonon_Smoke] = module;

    install_handlers(Phonon_handlers);

    phonon_module = rb_define_module("Phonon");
    phonon_internal_module = rb_define_module_under(phonon_module, "Internal");

    rb_define_singleton_method(phonon_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    rb_require("phonon/phonon.rb");
    rb_funcall(phonon_internal_module, rb_intern("init_all_classes"), 0);
}
Beispiel #11
0
Q_DECL_EXPORT void
Init_qtdeclarative()
{
    init_qtdeclarative_Smoke();

    binding = QtRuby::Binding(qtdeclarative_Smoke);

    smokeList << qtdeclarative_Smoke;

    QtRubyModule module = { "QtDeclarative", resolve_classname_qtdeclarative, 0, &binding };
    qtruby_modules[qtdeclarative_Smoke] = module;

    install_handlers(QtDeclarative_handlers);

    qtdeclarative_module = rb_define_module("QtDeclarative");
    qtdeclarative_internal_module = rb_define_module_under(qtdeclarative_module, "Internal");

    rb_define_singleton_method(qtdeclarative_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    rb_require("qtdeclarative/qtdeclarative.rb");
    rb_funcall(qtdeclarative_internal_module, rb_intern("init_all_classes"), 0);
}
Beispiel #12
0
Q_DECL_EXPORT void
Init_qscintilla()
{
    init_qsci_Smoke();

    binding = QtRuby::Binding(qsci_Smoke);

    smokeList << qsci_Smoke;

    QtRubyModule module = { "Qsci", resolve_classname_qsci, 0, &binding };
    qtruby_modules[qsci_Smoke] = module;

    install_handlers(QScintilla_handlers);

    qscintilla_module = rb_define_module("Qsci");
    qscintilla_internal_module = rb_define_module_under(qscintilla_module, "Internal");

    rb_define_singleton_method(qscintilla_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);

    rb_require("qscintilla/qscintilla.rb");
    rb_funcall(qscintilla_internal_module, rb_intern("init_all_classes"), 0);
}
Beispiel #13
0
int main( int argc, const char* argv[] )
{
	/* WORKTODO ... args handling */

	int fd;
	void* region;
	char* fname = FNAME;
	unsigned offset = 0;
	unsigned length = 0x100000;
	int rc;
	unsigned fill_value = 0xdeadbeef;
	enum MODE { M_READ, M_WRITE, M_FILL, M_TEST, M_NOP } mode = M_READ;

	struct poptOption opt_table[] = {
		{ "device", 'f', POPT_ARG_STRING,  &fname, 0   },
		{ "help",   'h', POPT_ARG_NONE,         0, 'h' },
		{ "read",   'r', POPT_ARG_NONE,         0, 'r' },     
		{ "write",  'w', POPT_ARG_NONE,         0, 'w' },
		{ "nop",    'n', POPT_ARG_NONE,         0, 'n' },
		{ "fill",   'b', POPT_ARG_NONE,         0, 'f' },
		{ "offset", 'o', POPT_ARG_INT,    &offset, 'o' },
		{ "length", 'l', POPT_ARG_INT,    &length, 'l' },
		{ "value",  'v', POPT_ARG_INT,    &fill_value, 0 },
		{ "regstest", 'T', POPT_ARG_NONE,	0, 'T' },
		{ "verbose", 'V', POPT_ARG_INT,   &acq200_debug, 0 },
		{ }
	};

	poptContext opt_context;

	opt_context = poptGetContext( argv[0], argc, argv, opt_table, 0 );

	int open_mode = O_RDONLY;
	int mmap_mode = PROT_READ;

	while ( (rc = poptGetNextOpt( opt_context )) > 0 ){
		switch( rc ){
		case 'h':
			fprintf( stderr, HELP );
			return 1;
		case 'r':
			mode = M_READ;
			break;
		case 'w':
			open_mode = O_RDWR;
			mmap_mode = PROT_READ|PROT_WRITE;
			mode = M_WRITE;
			break;
		case 'n':
			mode = M_NOP;
			break;
		case 'f':
			open_mode = O_RDWR;
			mmap_mode = PROT_READ|PROT_WRITE;
			mode = M_FILL;
			break;
		case 'T':
			mode = M_TEST;
			break;
		}
	}  // processes all other opts via arg pointers


	if ( (fd = open( fname, open_mode)) < 0 ){
		fprintf( stderr, "mmap: failed to open device \"%s\" - ", fname );
		perror( "" );
		return 1;
	}

	region = mmap( NULL, length, mmap_mode, MAP_SHARED, fd, 0 );

	if ( region == (caddr_t)-1 ){
		perror( "mmap" );
		return 1;
	}

	switch( mode ){
	default:
	case M_READ:

		// spew to stdout in one big blurt

		write( 1, (char*)region+offset, length );
		break;
	case M_FILL: {
		unsigned* praw = (unsigned*)&((char*)region)[offset];
		int iwrite;
		int imax = length/sizeof(unsigned);

		for ( iwrite = 0; iwrite != imax; ++iwrite ){
			praw[iwrite] = fill_value;
		}
		break;
	}
	case M_WRITE:{

		// write to memory - read input until first of EOF or length
		// it's slow char at a time stuff but who cares?

		int iwrite;
		int cc;
		char* praw = &((char*)region)[offset];

		for ( iwrite=0; (cc = getchar()) != -1 && iwrite != length; ++iwrite ){
			praw[iwrite] = cc;
		}
		break;
	}
	case M_NOP :
		fprintf( stderr, 
			 "mmap: blocking. Hit any key to continue, q to quit\n" );
	
		while ( getchar() != 'q' ){
			char aline[128];
			FILE* fp = fopen( "/proc/self/maps", "r" );
			assert( fp );
	    
			while( fgets( aline, sizeof(aline), fp ) != NULL ) {
				fputs(aline, stderr);
			}
			fclose( fp );
		}
		break;
	case M_TEST:
		install_handlers();
//		alarm(2);
		return regsTest(region, poptGetArgs(opt_context));
		break;
	}

	return 0;
}
Beispiel #14
0
/***************************************************************************
 *
 * implementation
 *
 **************************************************************************/
int
main (int argc, char *argv[])
{
  GtkWidget *widget;
  GnomeClient *client;
  gchar *mode_string = NULL;
  gchar *cl_filter = NULL;
  gchar *cl_interface = NULL;
  gchar *cl_input_file = NULL;
  gchar *export_file_final = NULL;
  gchar *export_file_signal = NULL;
  gboolean cl_numeric = FALSE;
  glong midelay = 0;
  glong madelay = G_MAXLONG;
  gchar *version;
  gchar *cl_glade_file = NULL;
  poptContext poptcon;

  struct poptOption optionsTable[] = {
    {"diagram-only", 'd', POPT_ARG_NONE, &(pref.diagram_only), 0,
     N_("don't display any node text identification"), NULL},
    {"replay-file", 'r', POPT_ARG_STRING, &cl_input_file, 0,
     N_("replay packets from file"), N_("<file to replay>")},
    {"filter", 'f', POPT_ARG_STRING, &cl_filter, 0,
     N_("set capture filter"), N_("<capture filter>")},
    {"interface", 'i', POPT_ARG_STRING, &cl_interface, 0,
     N_("set interface to listen to"), N_("<interface name>")},
    {"final-export", 0, POPT_ARG_STRING, &export_file_final, 0,
     N_("export to named file at end of replay"), N_("<file to export to>")},
    {"signal-export", 0, POPT_ARG_STRING, &export_file_signal, 0,
     N_("export to named file on receiving USR1"), N_("<file to export to>")},
    {"stationary", 's', POPT_ARG_NONE, &(pref.stationary), 0,  
     N_("don't move nodes around (deprecated)"), NULL}, 
    {"node-limit", 'l', POPT_ARG_INT, &(appdata.node_limit), 0,
     N_("limits nodes displayed"), N_("<number of nodes>")},
    {"mode", 'm', POPT_ARG_STRING, &mode_string, 0,
     N_("mode of operation"), N_("<link|ip|tcp>")},
    {"numeric", 'n', POPT_ARG_NONE, &cl_numeric, 0,
     N_("don't convert addresses to names"), NULL},
    {"quiet", 'q', POPT_ARG_NONE, &quiet, 0,
     N_("Disable informational messages"), NULL},
    {"min-delay", 0, POPT_ARG_LONG, &midelay,  0,
     N_("minimum packet delay in ms for reading capture files [cli only]"),
      N_("<delay>")},
    {"max-delay", 0, POPT_ARG_LONG, &madelay,  0,
     N_("maximum packet delay in ms for reading capture files [cli only]"),
      N_("<delay>")},
    {"glade-file", 0, POPT_ARG_STRING, &(cl_glade_file), 0,
     N_("uses the named libglade file for widgets"), N_("<glade file>")},

    POPT_AUTOHELP {NULL, 0, 0, NULL, 0, NULL, NULL}
  };

#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset(PACKAGE, "UTF-8"); /* force UTF-8 conversion */
  textdomain (PACKAGE);
#endif

  /* We set the window icon to use */
  if (!getenv ("GNOME_DESKTOP_ICON"))
    putenv ("GNOME_DESKTOP_ICON=" PIXMAPS_DIR "/etherape.png");

#ifdef PACKAGE_SCM_REV
  /* We initiate the application and read command line options */
  version = g_strdup_printf("%s (hg id %s)", VERSION, 
                            (*PACKAGE_SCM_REV) ? PACKAGE_SCM_REV : 
                              _("-unknown-"));
#else
  version = g_strdup(VERSION);
#endif
  gnome_program_init ("EtherApe", version, 
                      LIBGNOMEUI_MODULE, argc, argv,
		      GNOME_PARAM_POPT_TABLE, optionsTable, GNOME_PARAM_NONE);
  g_free(version);

  appdata_init(&appdata);

  /* We obtain application parameters 
   * First, absolute defaults
   * Second, values saved in the config file
   * Third, whatever given in the command line */
  init_config(&pref);

  set_debug_level();

  /* Config file */
  load_config();

  /* Command line */
  cl_numeric = !pref.name_res;
  poptcon =
    poptGetContext ("Etherape", argc, (const char **) argv, optionsTable, 0);
  while (poptGetNextOpt (poptcon) > 0);

  if (cl_interface)
    {
      if (appdata.interface)
	g_free (appdata.interface);
      appdata.interface = g_strdup (cl_interface);
    }

  if (export_file_final)
    {
      if (appdata.export_file_final)
	g_free (appdata.export_file_final);
      appdata.export_file_final = g_strdup (export_file_final);
    }
  if (export_file_signal)
    {
      if (appdata.export_file_signal)
	g_free (appdata.export_file_signal);
      appdata.export_file_signal = g_strdup (export_file_signal);
    }

  pref.name_res = !cl_numeric;

  if (cl_input_file)
    {
      if (appdata.input_file)
	g_free (appdata.input_file);
      appdata.input_file = g_strdup (cl_input_file);
    }

  /* Find mode of operation */
  if (mode_string)
    {
      if (strstr (mode_string, "link"))
	appdata.mode = LINK6;
      else if (strstr (mode_string, "ip"))
	appdata.mode = IP;
      else if (strstr (mode_string, "tcp"))
	appdata.mode = TCP;
      else
	g_warning (_
		   ("Unrecognized mode. Do etherape --help for a list of modes"));
      g_free(pref.filter);
      pref.filter = get_default_filter(appdata.mode);
    }

  if (cl_filter)
    {
      if (pref.filter)
	g_free (pref.filter);
      pref.filter = g_strdup (cl_filter);
    }

  if (midelay >= 0 && midelay <= G_MAXLONG)
    {
       appdata.min_delay = midelay;
       if (appdata.min_delay != 0)
         g_message("Minimum delay set to %lu ms", appdata.min_delay);
    }
  else
      g_message("Invalid minimum delay %ld, ignored", midelay);
  
  if (madelay >= 0 && madelay <= G_MAXLONG)
    {
      if (madelay < appdata.min_delay)
        {
          g_message("Maximum delay must be less of minimum delay");
          appdata.max_delay = appdata.min_delay;
        }
      else
        appdata.max_delay = madelay;
      if (appdata.max_delay != G_MAXLONG)
        g_message("Maximum delay set to %lu ms", appdata.max_delay);
    }
  else
      g_message("Invalid maximum delay %ld, ignored", madelay);
  
  /* Glade */
  glade_gnome_init ();
  glade_require("gnome");
  glade_require("canvas");
  if (!appdata_init_glade(cl_glade_file))
    return 1;

  /* prepare decoders */
  services_init();
  
  /* Sets controls to the values of variables and connects signals */
  init_diagram (appdata.xml);

  /* Session handling */
  client = gnome_master_client ();
  g_signal_connect (G_OBJECT (client), "save_yourself",
		    GTK_SIGNAL_FUNC (save_session), argv[0]);
  g_signal_connect (G_OBJECT (client), "die",
		    GTK_SIGNAL_FUNC (session_die), NULL);
  gtk_widget_show (appdata.app1);

  install_handlers();

  /* With this we force an update of the diagram every x ms 
   * Data in the diagram is updated, and then the canvas redraws itself when
   * the gtk loop is idle. If the CPU can't handle the set refresh_period,
   * then it will just do a best effort */

  widget = glade_xml_get_widget (appdata.xml, "canvas1");
  destroying_idle (widget);

  /* This other timeout makes sure that the info windows are updated */
  g_timeout_add (500, (GtkFunction) update_info_windows, NULL);

  /* another timeout to handle IP-cache timeouts */
  g_timeout_add (10000, (GtkFunction) ipcache_tick, NULL);

  init_menus ();
  
  gui_start_capture ();

  /* MAIN LOOP */
  gtk_main ();

  free_static_data();
  return 0;
}				/* main */