コード例 #1
0
ファイル: acct_init.c プロジェクト: Firstyear/ds
int
acct_postop_init( Slapi_PBlock *pb )
{
	void *plugin_id = get_identity();

	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
				SLAPI_PLUGIN_VERSION_01 ) != 0 ||
		slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
					(void *)&post_plugin_desc ) != 0 ) {
			slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME,
						"acct_postop_init - Failed to set plugin version or name\n" );
			return( CALLBACK_ERR );
	}


	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_POST_BIND_FN, (void *)acct_bind_postop ) != 0 ||
	     slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN, (void *) acct_post_op) != 0 ||
		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *) acct_post_op) != 0)
	{
		slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME,
				"acct_postop_init - Failed to set plugin callback function\n" );
		return( CALLBACK_ERR );
	}

	if( slapi_pblock_get( pb, SLAPI_PLUGIN_IDENTITY, &plugin_id ) != 0 ) {
		slapi_log_err(SLAPI_LOG_ERR, POST_PLUGIN_NAME,
				"acct_postop_init - Failed to get plugin identity\n" );
		return( CALLBACK_ERR );
	}

	return( CALLBACK_OK );
}
コード例 #2
0
void NewIdentityDialog::onUserNameChanged( const QString& name )
{
   if( name != QString() )
   {
      auto pro = bts::application::instance()->get_profile();
      auto keys = pro->get_keychain();

      auto trim_name = fc::trim(name.toUtf8().constData());
      auto ident_key = keys.get_identity_key( trim_name );
      auto key_addr  = /*bts::*/public_key_address( ident_key.get_public_key() );
      ui->publickey->setText( std::string(key_addr).c_str() );

      // make sure the key is unique..
      try {
          bts::addressbook::wallet_identity cur_ident = pro->get_identity( trim_name );
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
          ui->status_label->setText( tr( "Status: You have already created this identity." ) );
      } 
      catch ( fc::key_not_found_exception& e )
      {
          ui->status_label->setText( tr( "Status: Unknown" ) );
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(true);
      }
   }
   else
   {
      ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
   }
}
コード例 #3
0
static void simple(void) {
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	LinphonePresenceModel *pauline_presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityDinner, NULL);
	LinphoneFriend* f = linphone_core_create_friend_with_address(marie->lc, get_identity(pauline));
	LinphonePresenceActivity *activity = NULL;

	lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 40);
	linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
	linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL);
	enable_publish(pauline, TRUE);

	linphone_friend_enable_subscribes(f, TRUE);
	linphone_friend_set_inc_subscribe_policy(f,LinphoneSPAccept); /* Accept incoming subscription request for this friend*/
	linphone_core_add_friend(marie->lc, f);

	linphone_core_set_presence_model(pauline->lc, pauline_presence);

	BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityDinner,1));
	activity = linphone_presence_model_get_activity(linphone_friend_get_presence_model(f));
	if (BC_ASSERT_PTR_NOT_NULL(activity)) {
		BC_ASSERT_EQUAL(linphone_presence_activity_get_type(activity), LinphonePresenceActivityDinner, int, "%d");
	}

	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
コード例 #4
0
ファイル: t_vertex_sse.c プロジェクト: DirectFB/mesa
static void emit_load4f_1( struct x86_program *p, 
			   struct x86_reg dest,
			   struct x86_reg arg0 )
{
   /* Pull in low word, then swizzle in identity */
   sse_movss(&p->func, dest, arg0);
   sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
}
コード例 #5
0
ファイル: t_vertex_sse.c プロジェクト: DirectFB/mesa
static void emit_load4f_2( struct x86_program *p, 
			   struct x86_reg dest,
			   struct x86_reg arg0 )
{
   /* Initialize from identity, then pull in low two words:
    */
   sse_movups(&p->func, dest, get_identity(p));
   sse_movlps(&p->func, dest, arg0);
}
コード例 #6
0
ファイル: gvpectrl.C プロジェクト: TradeHill2011/gvpe
static void
usage (int status)
{
  if (status != 0)
    fprintf (stderr, _("Try `%s --help\' for more information.\n"), get_identity ());
  else
    {
      printf (_("Usage: %s [option]...\n\n"), get_identity ());
      printf (_
              ("  -c, --config=DIR           Read configuration options from DIR.\n"
               "  -k, --kill[=SIGNAL]        Attempt to kill a running gvpe and exit.\n"
               "  -g, --generate-keys        Generate public/private RSA keypair.\n"
               "  -s, --show-config          Display the configuration information.\n"
               "  -q, --quiet                Be quite quiet.\n"
               "      --help                 Display this help and exit.\n"
               "      --version              Output version information and exit.\n\n"));
      printf (_("Report bugs to <*****@*****.**>.\n"));
    }

  exit (status);
}
コード例 #7
0
ファイル: pool.c プロジェクト: FancyFon/strongswan
static bool add_address(u_int pool_id, char *address_str, int *family)
{
	host_t *address;
	int user_id = 0;

	char *pos_eq = strchr(address_str, '=');
	if (pos_eq != NULL)
	{
		identification_t *id = identification_create_from_string(pos_eq + 1);
		user_id = get_identity(id);
		id->destroy(id);

		if (user_id == 0)
		{
			return FALSE;
		}
		*pos_eq = '\0';
	}

	address = host_create_from_string(address_str, 0);
	if (address == NULL)
	{
		fprintf(stderr, "invalid address '%s'.\n", address_str);
		return FALSE;
	}
	if (family && *family != AF_UNSPEC &&
		*family != address->get_family(address))
	{
		fprintf(stderr, "invalid address family '%s'.\n", address_str);
		address->destroy(address);
		return FALSE;
	}

	if (db->execute(db, NULL,
			"INSERT INTO addresses "
			"(pool, address, identity, acquired, released) "
			"VALUES (?, ?, ?, ?, ?)",
			DB_UINT, pool_id, DB_BLOB, address->get_address(address),
			DB_UINT, user_id, DB_UINT, 0, DB_UINT, 1) != 1)
	{
		fprintf(stderr, "inserting address '%s' failed.\n", address_str);
		address->destroy(address);
		return FALSE;
	}
	if (family)
	{
		*family = address->get_family(address);
	}
	address->destroy(address);

	return TRUE;
}
コード例 #8
0
ファイル: gvpectrl.C プロジェクト: TradeHill2011/gvpe
int
main (int argc, char **argv, char **envp)
{
  set_identity (argv[0]);
  log_to (LOGTO_STDERR);

  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  parse_options (argc, argv, envp);

  if (show_version)
    {
      printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (),
              VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
      printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
      printf (_
              ("Copyright (C) 2003-2008 Marc Lehmann <*****@*****.**> and others.\n"
               "See the AUTHORS file for a complete list.\n\n"
               "vpe comes with ABSOLUTELY NO WARRANTY.  This is free software,\n"
               "and you are welcome to redistribute it under certain conditions;\n"
               "see the file COPYING for details.\n"));

      return 0;
    }

  if (show_help)
    usage (0);

  {
    configuration_parser (conf, false, 0, 0);
  }

  if (generate_keys)
    {
      RAND_load_file ("/dev/urandom", 1024);
      exit (keygen (generate_keys));
    }

  if (kill_gvpe)
    exit (kill_other (kill_gvpe));

  if (show_config)
    {
      conf.print ();
      exit (EXIT_SUCCESS);
    }

  usage (1);
}
コード例 #9
0
void NewIdentityDialog::onUserNameChanged( const QString& name )
{
   if( name.trimmed() != QString() )
   {
      auto pro = bts::application::instance()->get_profile();
      auto keys = pro->get_keychain();

      auto trim_name = fc::trim(name.toUtf8().constData());
      auto ident_key = keys.get_identity_key( trim_name );
      auto key_addr  = /*bts::*/public_key_address( ident_key.get_public_key() );
      ui->publickey->setText( std::string(key_addr).c_str() );

      // make sure the key is unique..
      try {
          bts::addressbook::wallet_identity cur_ident = pro->get_identity( trim_name );
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
          ui->status_label->setStyleSheet("QLabel { color : red; }");
          if (cur_ident.dac_id_string == trim_name)
              ui->status_label->setText( tr( "Status: You have already created this identity." ) );
          else
              ui->status_label->setText( tr( "Status: You have already created a similar id." ) );
      } 
      catch ( fc::key_not_found_exception& )
      {
          fc::optional<bts::bitname::name_record> current_record = bts::application::instance()->lookup_name(trim_name);
          if(current_record)
          {
             ui->status_label->setStyleSheet("QLabel { color : red; }");
             ui->status_label->setText(tr("Status: This Keyhotee ID was already registered by someone else."));
             ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
          }
          else
          {
             ui->status_label->setStyleSheet("QLabel { color : black; }");
             ui->status_label->setText( tr( "Status: Unknown" ) );
             ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(true);
          }
      }
      catch ( fc::assert_exception& )
      {
          ui->status_label->setStyleSheet("QLabel { color : red; }");
          ui->status_label->setText(tr("Status: Invalid ID. This ID cannot be registered."));
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
      }
   }
   else
   {
      ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
   }
}
コード例 #10
0
static void test_presence_list_subscribe_before_publish(void) {
	LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
	LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	const char *rls_uri = "sip:[email protected]";
	LinphoneFriendList *lfl;
	LinphoneFriend *lf;
	const char *pauline_identity;
	MSList* lcs = NULL;
	int dummy = 0;

	pauline_identity = get_identity(pauline);

	linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL));

	lfl = linphone_core_create_friend_list(laure->lc);
	linphone_friend_list_set_rls_uri(lfl, rls_uri);
	lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
	linphone_friend_list_add_friend(lfl, lf);
	lf = linphone_core_create_friend_with_address(laure->lc, "sip:[email protected]");
	linphone_friend_list_add_friend(lfl, lf);
	linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc));
	linphone_core_add_friend_list(laure->lc, lfl);
	linphone_friend_list_unref(lfl);
	linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL));
	linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE);

	lcs = ms_list_append(lcs, laure->lc);
	lcs = ms_list_append(lcs, pauline->lc);

	wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */

	enable_publish(pauline, TRUE);
	wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000);
	BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
	BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
	BC_ASSERT_TRUE(lf->presence_received);
	BC_ASSERT_TRUE(lf->subscribe_active);
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:[email protected]");
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
	BC_ASSERT_FALSE(lf->presence_received);
	BC_ASSERT_TRUE(lf->subscribe_active);

	enable_publish(laure, FALSE);
	enable_publish(pauline, FALSE);

	linphone_core_manager_destroy(laure);
	linphone_core_manager_destroy(pauline);
}
コード例 #11
0
ファイル: display.c プロジェクト: apinkney97/JSReflow
void
init_display (bitmap_font_type f)
{
    string server_identity;

    /* Do nothing unless the user wants us to.  */
    if (!wants_display) return;

    server_identity = get_identity ();

#ifndef STANDALONE_SERVER
    {   /* Fork our server.  This is the production case.  */
        unsigned design_size;

        int pid = fork ();
        switch (pid)
        {
        case -1:
            FATAL_PERROR ("fork");

        case 0:
        {   /* We are the child, i.e., the server.  Convert the design size,
               which we have in points, to pixels.  `start_server' never
               returns, because it waits forever for events.  */
            design_size = (BITMAP_FONT_DESIGN_SIZE (f) * atof (dpi)
                           / POINTS_PER_INCH);

            start_server (design_size, server_identity);
            FATAL ("init_display: start_server returned");
        }

        default:
            /* We are the parent, i.e., the main process.
               Continue outside the switch.  */
            ;
        }
    }
#endif /* not STANDALONE_SERVER */

    /* Assign to the globals so that our other routines can send messages.  */
    get_server_info (&server_window, &display, server_identity);

    /* Register our message atoms with the X server.  */
    foserver_exit_atom = XInternAtom (display, FOSERVER_EXIT_ATOM, False);
    foserver_update_pixmap_atom
        = XInternAtom (display, FOSERVER_UPDATE_PIXMAP_ATOM, False);

}
コード例 #12
0
ファイル: t_vertex_sse.c プロジェクト: DirectFB/mesa
static void emit_load4f_3( struct x86_program *p, 
			   struct x86_reg dest,
			   struct x86_reg arg0 )
{
   /* Have to jump through some hoops:
    *
    * c 0 0 0
    * c 0 0 1
    * 0 0 c 1
    * a b c 1
    */
   sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
   sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
   sse_shufps(&p->func, dest, dest, SHUF(Y,Z,X,W) );
   sse_movlps(&p->func, dest, arg0);
}
コード例 #13
0
ファイル: agent.hpp プロジェクト: alamaison/ssh2-cpp
/**
 * Exception wrapper around libssh2_agent_get_identity.
 *
 * Returns 1 when reached end of keys.
 */
inline int get_identity(
    LIBSSH2_AGENT* agent, LIBSSH2_SESSION* session,
    libssh2_agent_publickey** out, libssh2_agent_publickey* previous)
{
    boost::system::error_code ec;
    std::string message;

    int rc = get_identity(agent, session, out, previous, ec, message);

    if (ec)
    {
        SSH_DETAIL_THROW_API_ERROR_CODE(
            ec, message, "libssh2_agent_get_identity");
    }

    return rc;
}
コード例 #14
0
ファイル: acct_init.c プロジェクト: Firstyear/ds
/*
  Plugin startup function, when this is called any other plugins should
  already be initialized, so it's safe to e.g. perform internal searches,
  which is needed to retrieve the plugin configuration
*/
int
acct_policy_start( Slapi_PBlock *pb )
{
	acctPluginCfg *cfg;
	void *plugin_id = get_identity();
	Slapi_DN *plugindn = NULL;
	char *config_area = NULL;

	if(slapi_plugin_running(pb)){
		return 0;
	}

	slapi_pblock_get(pb, SLAPI_TARGET_SDN, &plugindn);
	acct_policy_set_plugin_sdn(slapi_sdn_dup(plugindn));

	/* Set the alternate config area if one is defined. */
	slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_AREA, &config_area);
	if (config_area) {
		acct_policy_set_config_area(slapi_sdn_new_normdn_byval(config_area));
	}

	if(config_rwlock == NULL){
		if((config_rwlock = slapi_new_rwlock()) == NULL){
			return( CALLBACK_ERR );
		}
	}

	/* Load plugin configuration */
	if( acct_policy_load_config_startup( pb, plugin_id ) ) {
		slapi_log_err(SLAPI_LOG_ERR, PLUGIN_NAME,
			"acct_policy_start failed to load configuration\n" );
		return( CALLBACK_ERR );
	}

	/* Show the configuration */
	cfg = get_config();
	slapi_log_err(SLAPI_LOG_PLUGIN, PLUGIN_NAME, "acct_policy_start - config: "
		"stateAttrName=%s altStateAttrName=%s specAttrName=%s limitAttrName=%s "
		"alwaysRecordLogin=%d\n",
		cfg->state_attr_name, cfg->alt_state_attr_name?cfg->alt_state_attr_name:"not configured", cfg->spec_attr_name,
		cfg->limit_attr_name, cfg->always_record_login);

	return( CALLBACK_OK );
}
コード例 #15
0
/*	-----------------------------------------------------------------	*/
int stop_ec2_provisioning( struct amazonEc2 * pptr )
{
	struct	ec2_subscription * subptr = (struct ec2_subscription *) 0;
	char 	reference[2024];
	int     status = 0;
	char srcdir[1024];
	char * response;
	char * token;
	char sendstr[1024]=" ";
	char strtmp[1024]=" ";
	listcc	categoryAtr;
	PyObject    *pName=NULL, *pModule=NULL, *pDict=NULL, *pFunc=NULL,*result=NULL;
	PyThreadState* pythr=NULL;

	/* ------------------------ */
	/* prepare the subscription */
	/* ------------------------ */
	if (!( pptr ))
		return(118);
	else if ( pptr->state == _OCCI_IDLE )
		return(0);
	else if (!(subptr = use_ec2_configuration( get_default_agent(),default_tls(),pptr->profile )))
		return(118);
	else	sprintf(reference,"%s/%s/%s",get_identity(),_CORDS_EC2,pptr->id);

	/* ------------------------------------------- */
	/* perform pre-release actions for destruction */
	/* ------------------------------------------- */
	if ( use_cosacs_agent( pptr->agent ) )
	{
		if ( cosacs_test_interface( pptr->hostname, _COSACS_STOP_TIMEOUT, _COSACS_STOP_RETRY ) )
		{
			cosacs_metadata_instructions( 
				pptr->hostname, _CORDS_RELEASE,
				reference, default_publisher(), pptr->account );
		}
	}
		
	if(!(strValid(pptr->id))) strcpy(sendstr," ");
	else strcpy(sendstr,pptr->id);

	if(!(strValid(pptr->name))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->name,',');

	if(!(strValid(pptr->flavor))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->flavor,',');
	
	if(!(strValid(pptr->image))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->image,',');
	
	if(!(strValid(pptr->original))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->original,',');
	
	if(!(strValid(pptr->profile))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->profile,',');

	if(!(strValid(pptr->node))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->node,',');
	
	if(!(strValid(pptr->price))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->price,',');

	if(!(strValid(pptr->account))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->account,',');

	if(!(strValid(pptr->number))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->number,',');

	if(!(strValid(pptr->rootpass))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->rootpass,',');

	if(!(strValid(pptr->reference))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->reference,',');

	if(!(strValid(pptr->network))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->network,',');

	if(!(strValid(pptr->access))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->access,',');

	if(!(strValid(pptr->accessip))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->accessip,',');

	if(!(strValid(pptr->keypair))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->keypair,',');

	if(!(strValid(pptr->placementgroup))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->placementgroup,',');

	if(!(strValid(pptr->publicaddr))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->publicaddr,',');

	 if(!(strValid(pptr->privateaddr))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->privateaddr,',');

	 if(!(strValid(pptr->firewall))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->firewall,',');

	if(!(strValid(pptr->group))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->group,',');

	if(!(strValid(pptr->zone))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->zone,',');

	if(!(strValid(pptr->hostname))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->hostname,',');

	if(!(strValid(pptr->workload))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->workload,',');

	if(!(strValid(pptr->agent))){
		strcpy(strtmp," ");
		strConcat(sendstr,strtmp,',');
	}
	else strConcat(sendstr,pptr->agent,',');

	sprintf(strtmp,"%d",pptr->when);
	if(strValid(strcmp)) strConcat(sendstr,strtmp,',');
	else strConcat(sendstr," ",',');
	
	sprintf(strtmp,"%d",pptr->state);
	if(strValid(strtmp)) strConcat(sendstr,strtmp,',');
	else strConcat(sendstr," ",',');	

	//           python interface
	sprintf(srcdir,"%s/pyaccords/pysrc",PYPATH);
	pythr = Py_NewInterpreter();
	python_path(srcdir);
	pName = PyString_FromString("amazonEc2Act");
	if(pName == NULL) printf("erro: in amazonEc2Act.py no such file name\n");
	else pModule = PyImport_Import(pName);
	if(pModule == NULL) printf("error: failed to load amazonEc2Act module\n");
	else pDict = PyModule_GetDict(pModule);
	if(pDict == NULL) printf("error: failed to load dict name in amazonEc2Act module\n");
	else pFunc = PyDict_GetItemString(pDict,"stop");
	if(pFunc == NULL) printf("error: failed to load start function in amazonEc2Act module\n");
	else result=PyObject_CallFunction(pFunc,"ssss",subptr->accesskey,subptr->secretkey,subptr->zone,sendstr);
	
	if (!result || PyErr_Occurred())
        {
       		PyErr_Print();
       		return (0);
       	}

	response=allocate_string(PyString_AsString( result ));
	Py_DECREF(pModule);
	Py_DECREF(pName);
	Py_EndInterpreter(pythr);

	resetListe(&categoryAtr);
	token= strtok(response,",");
	for(; token != NULL ;)
	{
		addBacke(&categoryAtr,token);
		token=strtok(NULL, ",");
	}
	elemm *pelem = categoryAtr.first;
	if(pelem){
		pptr->id = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->name = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->flavor = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->image = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->original = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->profile = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->node = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->price = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->account = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->number = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->rootpass = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->reference = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->network = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->access = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->accessip = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->keypair = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->placementgroup = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->publicaddr = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->privateaddr = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->firewall = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->group = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->zone = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->hostname = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->workload = pelem->value;
		pelem = pelem->next;
	}
        if(pelem){
		pptr->agent = pelem->value;
		pelem = pelem->next;
	}
	if(pelem){
		pptr->when = atoi(pelem->value);
		pelem = pelem->next;
	}
	if(pelem){
		pptr->state = atoi(pelem->value);
	}

	return status;

}
コード例 #16
0
static void test_presence_list_base(bool_t enable_compression) {
	LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
	LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	const char *rls_uri = "sip:[email protected]";
	LinphoneFriendList *lfl;
	LinphoneFriend *lf;
	const char *laure_identity;
	const char *marie_identity;
	const char *pauline_identity;
	MSList* lcs = NULL;

	laure_identity = get_identity(laure);
	marie_identity = get_identity(marie);
	pauline_identity = get_identity(pauline);
	enable_publish(marie, TRUE);
	enable_publish(pauline, TRUE);
	enable_publish(laure, TRUE);
	enable_deflate_content_encoding(marie, enable_compression);
	enable_deflate_content_encoding(pauline, enable_compression);
	enable_deflate_content_encoding(laure, enable_compression);

	linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityBusy, NULL));
	linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL));

	lfl = linphone_core_create_friend_list(laure->lc);
	linphone_friend_list_set_rls_uri(lfl, rls_uri);
	lf = linphone_core_create_friend_with_address(laure->lc, marie_identity);
	linphone_friend_list_add_friend(lfl, lf);
	linphone_friend_unref(lf);
	lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
	linphone_friend_list_add_friend(lfl, lf);
	linphone_friend_unref(lf);
	lf = linphone_core_create_friend_with_address(laure->lc, "sip:[email protected]");
	linphone_friend_list_add_friend(lfl, lf);
	linphone_friend_unref(lf);
	linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc));
	linphone_core_add_friend_list(laure->lc, lfl);
	linphone_friend_list_unref(lfl);
	linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL));

	lcs = ms_list_append(lcs, laure->lc);
	lcs = ms_list_append(lcs, marie->lc);
	lcs = ms_list_append(lcs, pauline->lc);

	wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 4000);
	BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
	BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d");
	if (!BC_ASSERT_TRUE(lf->presence_received)) goto end;
	if (!BC_ASSERT_TRUE(lf->subscribe_active)) goto end;
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
	if (!BC_ASSERT_TRUE(lf->presence_received)) goto end;
	if (!BC_ASSERT_TRUE(lf->subscribe_active)) goto end;
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:[email protected]");
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
	BC_ASSERT_FALSE(lf->presence_received);
	if (!BC_ASSERT_TRUE(lf->subscribe_active)) goto end;

	lfl = linphone_core_create_friend_list(marie->lc);
	linphone_friend_list_set_rls_uri(lfl, rls_uri);
	lf = linphone_core_create_friend_with_address(marie->lc, laure_identity);
	linphone_friend_list_add_friend(lfl, lf);
	linphone_friend_unref(lf);
	linphone_core_remove_friend_list(marie->lc, linphone_core_get_default_friend_list(marie->lc));
	linphone_core_add_friend_list(marie->lc, lfl);
	linphone_friend_list_unref(lfl);
	linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc), NULL, FALSE);

	wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 4000);
	BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
	BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(marie->lc)->expected_notification_version, 1, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
	if (!BC_ASSERT_TRUE(lf->presence_received)) goto end;
	if (!BC_ASSERT_TRUE(lf->subscribe_active)) goto end;

	lfl = linphone_core_create_friend_list(pauline->lc);
	linphone_friend_list_set_rls_uri(lfl, rls_uri);
	lf = linphone_core_create_friend_with_address(pauline->lc, marie_identity);
	linphone_friend_list_add_friend(lfl, lf);
	linphone_friend_unref(lf);
	linphone_core_remove_friend_list(pauline->lc, linphone_core_get_default_friend_list(pauline->lc));
	linphone_core_add_friend_list(pauline->lc, lfl);
	linphone_friend_list_unref(lfl);
	linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc), NULL, FALSE);

	wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000);
	BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
	BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 1, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d");
	if (!BC_ASSERT_TRUE(lf->presence_received)) goto end;
	if (!BC_ASSERT_TRUE(lf->subscribe_active)) goto end;

	linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityOnThePhone, NULL));

	wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 4, 4000);
	/* The number of PresenceReceived events can be 3 or 4 here. TODO: ideally it should always be 3. */
	BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 3, int, "%d");
	BC_ASSERT_LOWER(laure->stat.number_of_NotifyPresenceReceived, 4, int, "%d");
	BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 2, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d");

	wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 2, 4000);
	BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
	BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 2, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d");

	ms_message("Disabling publish");
	enable_publish(laure, FALSE);
	enable_publish(marie, FALSE);
	enable_publish(pauline, FALSE);


	reset_counters(&pauline->stat);
	reset_counters(&laure->stat);
	reset_counters(&marie->stat);

	/*keep in ming long terme presence*/

	if (!BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOnline, 1, 4000)))
		goto end;
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
	/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
					, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");


	if (!BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphonePresenceActivityOnline, 2, 4000))) goto end;
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
	/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
					, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/

	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
	/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
					, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/


	if (!BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphonePresenceActivityOnline, 1, 4000))) goto end;
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
	/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
					, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/

end:
	linphone_core_manager_destroy(laure);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
コード例 #17
0
static void test_presence_list_subscribe_with_error(bool_t io_error) {
	LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc");
	LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
	const char *rls_uri = "sip:[email protected]";
	LinphoneFriendList *lfl;
	LinphoneFriend *lf;
	const char *pauline_identity;
	MSList* lcs = NULL;
	int dummy = 0;
	lp_config_set_int(laure->lc->config, "sip", "rls_presence_expires", 5);


	pauline_identity = get_identity(pauline);

	linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL));

	lfl = linphone_core_create_friend_list(laure->lc);
	linphone_friend_list_set_rls_uri(lfl, rls_uri);
	lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
	linphone_friend_list_add_friend(lfl, lf);
	lf = linphone_core_create_friend_with_address(laure->lc, "sip:[email protected]");
	linphone_friend_list_add_friend(lfl, lf);
	linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc));
	linphone_core_add_friend_list(laure->lc, lfl);
	linphone_friend_list_unref(lfl);
	linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL));
	linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE);
	lcs = ms_list_append(lcs, laure->lc);
	lcs = ms_list_append(lcs, pauline->lc);

	wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */

	enable_publish(pauline, TRUE);
	BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 1, 6000));
	BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
	BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
	BC_ASSERT_TRUE(lf->presence_received);
	BC_ASSERT_TRUE(lf->subscribe_active);
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:[email protected]");
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
	BC_ASSERT_FALSE(lf->presence_received);
	BC_ASSERT_TRUE(lf->subscribe_active);

	BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 2, 6000));
	if (io_error) {
		ms_message("Simulating socket error");
		sal_set_recv_error(laure->lc->sal, -1);
		wait_for_list(lcs, &dummy, 1, 500); /* just time for socket to be closed */
	} else {
		ms_message("Simulating in/out packets losses");
		sal_set_send_error(laure->lc->sal,1500); /*make sure no refresh is sent, trash the message without generating error*/
		sal_set_recv_error(laure->lc->sal, 1500); /*make sure server notify to close the dialog is also ignored*/
		wait_for_list(lcs, &dummy, 1, 5000); /* Wait a little bit for the subscribe to happen */
	}
	/*restart normal behavior*/
	sal_set_send_error(laure->lc->sal,0);
	sal_set_recv_error(laure->lc->sal, 1);

	BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 3, 6000)); /* give time for subscription to recover to avoid to receive 491 Request pending*/

	linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL));

	BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityAway, 1, 6000));
	lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
	BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d");

	linphone_core_manager_destroy(laure);
	linphone_core_manager_destroy(pauline);
}
コード例 #18
0
void NewIdentityDialog::onSave()
{
  //store new identity in profile
  auto app = bts::application::instance();
  auto profile = app->get_profile();
  auto trimmed_dac_id = ui->username->text().trimmed();
  fc::string dac_id = trimmed_dac_id.toStdString();

  // make sure the key is unique..
  try {
      bts::addressbook::wallet_identity cur_ident = profile->get_identity( dac_id );
      ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
      ui->status_label->setStyleSheet("QLabel { color : red; }");
      ui->publickey->setText( "" );
      if (cur_ident.dac_id_string == dac_id)
          ui->status_label->setText( tr( "Status: You have already created this identity." ) );
      else
          ui->status_label->setText( tr( "Status: You have already created a similar id." ) );
      return;
  }
  catch ( fc::key_not_found_exception& )
  {
      fc::optional<bts::bitname::name_record> current_record = bts::application::instance()->lookup_name(dac_id);
      if(current_record)
      {
          ui->status_label->setStyleSheet("QLabel { color : red; }");
          ui->status_label->setText(tr("Status: This Keyhotee ID was already registered by someone else."));
          ui->publickey->setText( "" );
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
          return;
      }
  }


  bts::addressbook::wallet_identity ident;
  ident.first_name = fc::trim( ui->firstname->text().toUtf8().constData() );
  ident.last_name = fc::trim( ui->lastname->text().toUtf8().constData() );
  ident.mining_effort = ui->register_checkbox->isChecked() ? 25.0 : 0.0;
  ident.wallet_ident = dac_id;
  ident.set_dac_id( dac_id );
  auto priv_key = profile->get_keychain().get_identity_key(dac_id);
  ident.public_key = priv_key.get_public_key();
  profile->store_identity( ident );
  /// notify identity observers
  IdentityObservable::getInstance().notify();
  try 
  {
    app->mine_name(dac_id,
              profile->get_keychain().get_identity_key(dac_id).get_public_key(),
              ident.mining_effort);
  }
  catch ( const fc::exception& e )
  {
    wlog( "${e}", ("e",e.to_detail_string()) );
  }

  //store contact for new identity
  bts::addressbook::wallet_contact myself;
  //copy common fields from new identity into contact
  static_cast<bts::addressbook::contact&>(myself) = ident;
  //fill in remaining fields for contact
  myself.first_name = ident.first_name;
  myself.last_name = ident.last_name;
#ifdef ALPHA_RELEASE
  //just store the founder code here so we can access it over in ContactView temporarily for alpha release
  myself.notes = ui->founder_code->text().toStdString();
#endif
  TKeyhoteeApplication::getInstance()->getMainWindow()->getAddressBookModel()->storeContact( Contact(myself) );

  app->add_receive_key(priv_key);

	//re-connect to mail server to send an updated sync_time (get past mail for identities) if history should be downloaded
	int days_in_past_to_fetch = ui->downloadHistory->currentData().toInt();
  if (days_in_past_to_fetch != 0)
  {
    fc::time_point sync_time;
    if (days_in_past_to_fetch != -1)
      sync_time = fc::time_point::now() - fc::days(days_in_past_to_fetch);
    //if requested sync time further in the past than last sync time, change last_sync_time
    if (sync_time < profile->get_last_sync_time())
      profile->set_last_sync_time(sync_time);
    app->connect_to_network();
  }
  emit identityadded();

}
コード例 #19
0
/**
 * Main function that will be run.
 *
 * @param cls closure
 * @param args remaining command-line arguments
 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
 * @param c configuration
 */
static void
run (void *cls, char *const *args, const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *c)
{
    char *dbfile;
    struct WhiteListRow *wl_head;
    struct WhiteListRow *wl_entry;
    struct GNUNET_PeerIdentity identity;
    struct GNUNET_ATS_Properties prop;
    struct GNUNET_TIME_Relative delay;
    unsigned long long pid;
    unsigned int nrows;
    int ret;

    if (GNUNET_OK !=
            GNUNET_CONFIGURATION_get_value_number (c, "TESTBED",
                    "PEERID", &pid))
    {
        GNUNET_break (0);
        return;
    }
    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "TESTBED-UNDERLAY",
            "DBFILE",
            &dbfile))
    {
        GNUNET_break (0);
        return;
    }
    if (SQLITE_OK != (ret = sqlite3_open_v2 (dbfile, &db, SQLITE_OPEN_READONLY, NULL)))
    {
        if (NULL != db)
        {
            LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_open_v2");
            GNUNET_break (SQLITE_OK == sqlite3_close (db));
        }
        else
            LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot open sqlite file %s\n", dbfile);
        GNUNET_free (dbfile);
        return;
    }
    DEBUG ("Opened database %s\n", dbfile);
    GNUNET_free (dbfile);
    dbfile = NULL;
    wl_head = NULL;
    if (GNUNET_OK != load_keys (c))
        goto close_db;

    transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL);
    if (NULL == transport)
    {
        GNUNET_break (0);
        return;
    }
    /* read and process whitelist */
    nrows = 0;
    wl_head = NULL;
    nrows = db_read_whitelist (db, pid, &wl_head);
    if ((GNUNET_SYSERR == nrows) || (0 == nrows))
    {
        GNUNET_TRANSPORT_disconnect (transport);
        goto close_db;
    }
    map = GNUNET_CONTAINER_multipeermap_create (nrows, GNUNET_NO);
    while (NULL != (wl_entry = wl_head))
    {
        wl_head = wl_entry->next;
        delay.rel_value_us = wl_entry->latency;
        memset (&prop, 0, sizeof (prop));
        GNUNET_assert (GNUNET_OK == get_identity (wl_entry->id, &identity));
        GNUNET_break (GNUNET_OK ==
                      GNUNET_CONTAINER_multipeermap_put (map, &identity, &identity,
                              GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
        DEBUG ("Setting %u ms latency to peer `%s'\n",
               wl_entry->latency,
               GNUNET_i2s (&identity));
        GNUNET_TRANSPORT_set_traffic_metric (transport,
                                             &identity,
                                             &prop,
                                             delay,
                                             delay);
        GNUNET_free (wl_entry);
    }
    bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL);
    shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                    &do_shutdown, NULL);

close_db:
    GNUNET_break (SQLITE_OK == sqlite3_close (db));
    return;
}
コード例 #20
0
/**
 * ipsec pool --addattr <type> - add attribute entry
 */
void add_attr(char *name, char *pool, char *identity,
			  char *value, value_type_t value_type)
{
	configuration_attribute_type_t type, type_ip6;
	u_int pool_id = 0, identity_id = 0;
	char id_pool_str[128] = "";
	chunk_t blob;
	bool success;

	if (pool)
	{
		pool_id = get_attr_pool(pool);
		if (pool_id == 0)
		{
			exit(EXIT_FAILURE);
		}

		if (identity)
		{
			identification_t *id;

			id = identification_create_from_string(identity);
			identity_id = get_identity(id);
			id->destroy(id);
			if (identity_id == 0)
			{
				exit(EXIT_FAILURE);
			}
			snprintf(id_pool_str, sizeof(id_pool_str),
					 " for '%s' in pool '%s'", identity, pool);
		}
		else
		{
			snprintf(id_pool_str, sizeof(id_pool_str), " in pool '%s'", pool);
		}
	}

	if (value_type == VALUE_NONE)
	{
		fprintf(stderr, "the value of the %s attribute is missing.\n", name);
		usage();
	}
	if (!parse_attributes(name, value, &value_type, &type, &type_ip6, &blob))
	{
		exit(EXIT_FAILURE);
	}

	success = db->execute(db, NULL,
				"INSERT INTO attributes (identity, pool, type, value) "
				"VALUES (?, ?, ?, ?)", DB_UINT, identity_id, DB_UINT, pool_id,
				DB_INT, type, DB_BLOB, blob) == 1;
	free(blob.ptr);

	if (success)
	{
		printf("added %s attribute (%N)%s.\n", name,
			   configuration_attribute_type_names, type, id_pool_str);
	}
	else
	{
		fprintf(stderr, "adding %s attribute (%N)%s failed.\n", name,
						configuration_attribute_type_names, type, id_pool_str);
	}
}
コード例 #21
0
/**
 * ipsec pool --delattr <type> - delete attribute entry
 */
void del_attr(char *name, char *pool, char *identity,
			  char *value, value_type_t value_type)
{
	configuration_attribute_type_t type, type_ip6, type_db;
	u_int pool_id = 0, identity_id = 0;
	char id_pool_str[128] = "";
	chunk_t blob, blob_db;
	u_int id;
	enumerator_t *query;
	bool found = FALSE;

	if (pool)
	{
		pool_id = get_attr_pool(pool);
		if (pool_id == 0)
		{
			exit(EXIT_FAILURE);
		}

		if (identity)
		{
			identification_t *id;

			id = identification_create_from_string(identity);
			identity_id = get_identity(id);
			id->destroy(id);
			if (identity_id == 0)
			{
				exit(EXIT_FAILURE);
			}
			snprintf(id_pool_str, sizeof(id_pool_str),
					 " for '%s' in pool '%s'", identity, pool);
		}
		else
		{
			snprintf(id_pool_str, sizeof(id_pool_str), " in pool '%s'", pool);
		}
	}

	if (!parse_attributes(name, value, &value_type, &type, &type_ip6, &blob))
	{
		exit(EXIT_FAILURE);
	}

	if (blob.len > 0)
	{
		query = db->query(db,
					"SELECT id, type, value FROM attributes "
					"WHERE identity = ? AND pool = ? AND type = ? AND value = ?",
					DB_UINT, identity_id, DB_UINT, pool_id, DB_INT, type,
					DB_BLOB, blob, DB_UINT, DB_INT, DB_BLOB);
	}
	else if (type_ip6 == 0)
	{
		query = db->query(db,
					"SELECT id, type, value FROM attributes "
					"WHERE identity = ? AND pool = ? AND type = ?",
					DB_UINT, identity_id, DB_UINT, pool_id, DB_INT, type,
					DB_UINT, DB_INT, DB_BLOB);
	}
	else
	{
		query = db->query(db,
					"SELECT id, type, value FROM attributes "
					"WHERE identity = ? AND pool = ? AND (type = ? OR type = ?)",
					DB_UINT, identity_id, DB_UINT, pool_id, DB_INT, type,
					DB_INT, type_ip6, DB_UINT, DB_INT, DB_BLOB);
	}

	if (!query)
	{
		fprintf(stderr, "deleting '%s' attribute (%N)%s failed.\n",
				name, configuration_attribute_type_names, type, id_pool_str);
		free(blob.ptr);
		exit(EXIT_FAILURE);
	}

	while (query->enumerate(query, &id, &type_db, &blob_db))
	{
		host_t *server = NULL;

		found = TRUE;

		if (value_type == VALUE_ADDR)
		{
			int family = (type_db == type_ip6) ? AF_INET6 : AF_INET;

			server = host_create_from_chunk(family, blob_db, 0);
		}

		if (db->execute(db, NULL,
					"DELETE FROM attributes WHERE id = ?",
					 DB_UINT, id) != 1)
		{
			if (server)
			{
				fprintf(stderr, "deleting %s server %H%s failed\n",
						name, server, id_pool_str);
				server->destroy(server);
			}
			else if (value_type == VALUE_STRING)
			{
				fprintf(stderr, "deleting %s attribute (%N) with value '%.*s'%s failed.\n",
								name, configuration_attribute_type_names, type,
								(int)blob_db.len, blob_db.ptr, id_pool_str);
			}

			else
			{
				fprintf(stderr, "deleting %s attribute (%N) with value %#B%s failed.\n",
								name, configuration_attribute_type_names, type,
								&blob_db, id_pool_str);
			}
			query->destroy(query);
			free(blob.ptr);
			exit(EXIT_FAILURE);
		}
		if (server)
		{
			printf("deleted %s server %H%s\n", name, server, id_pool_str);
			server->destroy(server);
		}
		else if (value_type == VALUE_STRING)
		{
			printf("deleted %s attribute (%N) with value '%.*s'%s.\n",
				   name, configuration_attribute_type_names, type,
				   (int)blob_db.len, blob_db.ptr, id_pool_str);
		}
		else
		{
			printf("deleted %s attribute (%N) with value %#B%s.\n",
				   name, configuration_attribute_type_names, type,
				   &blob_db, id_pool_str);
		}
	}
	query->destroy(query);

	if (!found)
	{
		if (blob.len == 0)
		{
			if (type_ip6 == 0)
			{
				fprintf(stderr, "no %s attribute (%N) was found%s.\n", name,
						configuration_attribute_type_names, type, id_pool_str);
			}
			else
			{
				fprintf(stderr, "no %s attribute%s was found.\n",
						name, id_pool_str);
			}
		}
		else
		{
			if (value_type == VALUE_ADDR)
			{
				host_t *server = host_create_from_chunk(AF_UNSPEC, blob, 0);

				fprintf(stderr, "the %s server %H%s was not found.\n", name,
								 server, id_pool_str);
				server->destroy(server);
			}
			else
			{
				fprintf(stderr, "the %s attribute (%N) with value '%.*s'%s "
								"was not found.\n", name,
								 configuration_attribute_type_names, type,
								 (int)blob.len, blob.ptr, id_pool_str);
			}
		}
	}
	free(blob.ptr);
}
コード例 #22
0
ファイル: t_vertex_sse.c プロジェクト: DirectFB/mesa
/* Lots of hardcoding
 *
 * EAX -- pointer to current output vertex
 * ECX -- pointer to current attribute 
 * 
 */
static GLboolean build_vertex_emit( struct x86_program *p )
{
   struct gl_context *ctx = p->ctx;
   TNLcontext *tnl = TNL_CONTEXT(ctx);
   struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
   GLuint j = 0;

   struct x86_reg vertexEAX = x86_make_reg(file_REG32, reg_AX);
   struct x86_reg srcECX = x86_make_reg(file_REG32, reg_CX);
   struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP);
   struct x86_reg vtxESI = x86_make_reg(file_REG32, reg_SI);
   struct x86_reg temp = x86_make_reg(file_XMM, 0);
   struct x86_reg vp0 = x86_make_reg(file_XMM, 1);
   struct x86_reg vp1 = x86_make_reg(file_XMM, 2);
   struct x86_reg temp2 = x86_make_reg(file_XMM, 3);
   GLubyte *fixup, *label;

   /* Push a few regs?
    */
   x86_push(&p->func, countEBP);
   x86_push(&p->func, vtxESI);


   /* Get vertex count, compare to zero
    */
   x86_xor(&p->func, srcECX, srcECX);
   x86_mov(&p->func, countEBP, x86_fn_arg(&p->func, 2));
   x86_cmp(&p->func, countEBP, srcECX);
   fixup = x86_jcc_forward(&p->func, cc_E);

   /* Initialize destination register. 
    */
   x86_mov(&p->func, vertexEAX, x86_fn_arg(&p->func, 3));

   /* Dereference ctx to get tnl, then vtx:
    */
   x86_mov(&p->func, vtxESI, x86_fn_arg(&p->func, 1));
   x86_mov(&p->func, vtxESI, x86_make_disp(vtxESI, get_offset(ctx, &ctx->swtnl_context)));
   vtxESI = x86_make_disp(vtxESI, get_offset(tnl, &tnl->clipspace));

   
   /* Possibly load vp0, vp1 for viewport calcs:
    */
   if (vtx->need_viewport) {
      sse_movups(&p->func, vp0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_scale[0])));
      sse_movups(&p->func, vp1, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_xlate[0])));
   }

   /* always load, needed or not:
    */
   sse_movups(&p->func, p->chan0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->chan_scale[0])));
   sse_movups(&p->func, p->identity, x86_make_disp(vtxESI, get_offset(vtx, &vtx->identity[0])));

   /* Note address for loop jump */
   label = x86_get_label(&p->func);

   /* Emit code for each of the attributes.  Currently routes
    * everything through SSE registers, even when it might be more
    * efficient to stick with regular old x86.  No optimization or
    * other tricks - enough new ground to cover here just getting
    * things working.
    */
   while (j < vtx->attr_count) {
      struct tnl_clipspace_attr *a = &vtx->attr[j];
      struct x86_reg dest = x86_make_disp(vertexEAX, a->vertoffset);

      /* Now, load an XMM reg from src, perhaps transform, then save.
       * Could be shortcircuited in specific cases:
       */
      switch (a->format) {
      case EMIT_1F:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
	 emit_store(p, dest, 1, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_2F:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
	 emit_store(p, dest, 2, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_3F:
	 /* Potentially the worst case - hardcode 2+1 copying:
	  */
	 if (0) {
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
	    emit_store(p, dest, 3, temp);
	    update_src_ptr(p, srcECX, vtxESI, a);
	 }
	 else {
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
	    emit_store(p, dest, 2, temp);
	    if (a->inputsize > 2) {
	       emit_load(p, temp, 1, x86_make_disp(srcECX, 8), 1);
	       emit_store(p, x86_make_disp(dest,8), 1, temp);
	    }
	    else {
	       sse_movss(&p->func, x86_make_disp(dest,8), get_identity(p));
	    }
	    update_src_ptr(p, srcECX, vtxESI, a);
	 }
	 break;
      case EMIT_4F:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 emit_store(p, dest, 4, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_2F_VIEWPORT: 
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
	 sse_mulps(&p->func, temp, vp0);
	 sse_addps(&p->func, temp, vp1);
	 emit_store(p, dest, 2, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_3F_VIEWPORT: 
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
	 sse_mulps(&p->func, temp, vp0);
	 sse_addps(&p->func, temp, vp1);
	 emit_store(p, dest, 3, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_4F_VIEWPORT: 
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 sse_mulps(&p->func, temp, vp0);
	 sse_addps(&p->func, temp, vp1);
	 emit_store(p, dest, 4, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_3F_XYW:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 sse_shufps(&p->func, temp, temp, SHUF(X,Y,W,Z));
	 emit_store(p, dest, 3, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;

      case EMIT_1UB_1F:	 
	 /* Test for PAD3 + 1UB:
	  */
	 if (j > 0 &&
	     a[-1].vertoffset + a[-1].vertattrsize <= a->vertoffset - 3)
	 {
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
	    sse_shufps(&p->func, temp, temp, SHUF(X,X,X,X));
	    emit_pack_store_4ub(p, x86_make_disp(dest, -3), temp); /* overkill! */
	    update_src_ptr(p, srcECX, vtxESI, a);
	 }
	 else {
	    printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize );
	    return GL_FALSE;
	 }
	 break;
      case EMIT_3UB_3F_RGB:
      case EMIT_3UB_3F_BGR:
	 /* Test for 3UB + PAD1:
	  */
	 if (j == vtx->attr_count - 1 ||
	     a[1].vertoffset >= a->vertoffset + 4) {
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
	    if (a->format == EMIT_3UB_3F_BGR)
	       sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
	    emit_pack_store_4ub(p, dest, temp);
	    update_src_ptr(p, srcECX, vtxESI, a);
	 }
	 /* Test for 3UB + 1UB:
	  */
	 else if (j < vtx->attr_count - 1 &&
		  a[1].format == EMIT_1UB_1F &&
		  a[1].vertoffset == a->vertoffset + 3) {
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
	    update_src_ptr(p, srcECX, vtxESI, a);

	    /* Make room for incoming value:
	     */
	    sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));

	    get_src_ptr(p, srcECX, vtxESI, &a[1]);
	    emit_load(p, temp2, 1, x86_deref(srcECX), a[1].inputsize);
	    sse_movss(&p->func, temp, temp2);
	    update_src_ptr(p, srcECX, vtxESI, &a[1]);

	    /* Rearrange and possibly do BGR conversion:
	     */
	    if (a->format == EMIT_3UB_3F_BGR)
	       sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
	    else
	       sse_shufps(&p->func, temp, temp, SHUF(Y,Z,W,X));

	    emit_pack_store_4ub(p, dest, temp);
	    j++;		/* NOTE: two attrs consumed */
	 }
	 else {
	    printf("Can't emit 3ub\n");
	    return GL_FALSE;	/* add this later */
	 }
	 break;

      case EMIT_4UB_4F_RGBA:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 emit_pack_store_4ub(p, dest, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_4UB_4F_BGRA:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
	 emit_pack_store_4ub(p, dest, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_4UB_4F_ARGB:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
	 emit_pack_store_4ub(p, dest, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_4UB_4F_ABGR:
	 get_src_ptr(p, srcECX, vtxESI, a);
	 emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	 sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
	 emit_pack_store_4ub(p, dest, temp);
	 update_src_ptr(p, srcECX, vtxESI, a);
	 break;
      case EMIT_4CHAN_4F_RGBA:
	 switch (CHAN_TYPE) {
	 case GL_UNSIGNED_BYTE:
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	    emit_pack_store_4ub(p, dest, temp);
	    update_src_ptr(p, srcECX, vtxESI, a);
	    break;
	 case GL_FLOAT:
	    get_src_ptr(p, srcECX, vtxESI, a);
	    emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
	    emit_store(p, dest, 4, temp);
	    update_src_ptr(p, srcECX, vtxESI, a);
	    break;
	 case GL_UNSIGNED_SHORT:
	 default:
	    printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE));
	    return GL_FALSE;
	 }
	 break;
      default:
	 printf("unknown a[%d].format %d\n", j, a->format);
	 return GL_FALSE;	/* catch any new opcodes */
      }
      
      /* Increment j by at least 1 - may have been incremented above also:
       */
      j++;
   }

   /* Next vertex:
    */
   x86_lea(&p->func, vertexEAX, x86_make_disp(vertexEAX, vtx->vertex_size));

   /* decr count, loop if not zero
    */
   x86_dec(&p->func, countEBP);
   x86_test(&p->func, countEBP, countEBP); 
   x86_jcc(&p->func, cc_NZ, label);

   /* Exit mmx state?
    */
   if (p->func.need_emms)
      mmx_emms(&p->func);

   /* Land forward jump here:
    */
   x86_fixup_fwd_jump(&p->func, fixup);

   /* Pop regs and return
    */
   x86_pop(&p->func, x86_get_base_reg(vtxESI));
   x86_pop(&p->func, countEBP);
   x86_ret(&p->func);

   assert(!vtx->emit);
   vtx->emit = (tnl_emit_func)x86_get_func(&p->func);

   assert( (char *) p->func.csr - (char *) p->func.store <= MAX_SSE_CODE_SIZE );
   return GL_TRUE;
}