int main()
{
	My_unique_ptr<BigBoss*> bestSoldiers = { new BigBoss, new SolidSnake, new LiquidSnake };
	
	conversation(bestSoldiers[0]);
	conversation(bestSoldiers[1]);
	conversation(bestSoldiers[2]);


	std::cout << " ---------------------------------------------------------------------- " << std::endl;
	



	return 0;
}
示例#2
0
int pam_sm_authenticate( pam_handle_t * pamh,
                         int flags,
                         int argc, char const ** argv )
{
   int retval = PAM_AUTH_ERR;
   char const * username = NULL;
   char const * password = NULL;

   // Parse arguments
   int argmask = _pam_parse( argc, argv );

   // Get the username
   retval = pam_get_user( pamh, &username, NULL );
   if( (retval != PAM_SUCCESS) || (!username) )
   {
      return PAM_SERVICE_ERR;
   }

   // If we've been told to use the first pass, we don't converse with
   // the user for a password.
   if( ! argmask & CPAMARG_USEFIRSTPASS )
   {
      // Converse just to be sure we have a password
      retval = conversation( pamh );
      if( retval != PAM_SUCCESS )
      {
         return PAM_CONV_ERR;
      }
   }

   // Check if we got a password.  If use_authtok wasn't specified,
   // then we've already asked once and needn't do so again.
   retval = pam_get_item( pamh, PAM_AUTHTOK, (void const **) & password );
   if( retval != PAM_SUCCESS )
   {
      return -2;
   }

   Curl curl;
   if( username != NULL && password != NULL &&
       curl.checkAuthorized( username, password ) )
   {
      return PAM_SUCCESS;
   }
   else
   {
      return PAM_AUTH_ERR;
   }

   return PAM_USER_UNKNOWN;
}
示例#3
0
int main() {
    // Initialise Arduino functionality
    init();
    // Attach USB for applicable processors
#ifdef USBCON
    USBDevice.attach();
#endif
    Serial.begin(9600);      // Serial0: communication with the PC
    Serial3.begin(9600);     // Serial3: communication with the other Arduino
    uint32_t shared_key = key_set_up();
    conversation(shared_key);
    Serial.end();
    Serial3.end();
    return 0;
}
示例#4
0
文件: main.cpp 项目: chinjao/ros_src
  void speechCallback(
		      const speech_msgs::SpeechConstPtr& speech
		      )
  {
    cout << "speech callback" << endl;
    
    //1.開始
    //2.okao内のトラッキングIDと結びついた名前(OKAO_ID)を調べる
    //3.もし、主人の名前があったら、4へ。なければ1へ(ループ)
    //4.speech内のトラッキングIDを取得
    //5.トラッキングIDとOKAO_IDを照合する
    //6.OKAO_IDに発言を記録する
    //8.主人以外の人物の記録が終わったら、1へ。終わってなければ6へ。
  
    //人物を検出しているかどうか
    cout << "human size: "<< human_last.size() <<endl;

    if(human_last.size())
      {
	bool master_is_looking = false;
	map<long long, int> tracking_to_okao;
	//発見した人物を記録し、主人を探す
	for(int i = 0; i<human_last.size(); ++i)
	  {
	    tracking_to_okao[ human_last[i].body.tracking_id ] 
	      = human_last[i].max_okao_id;
	    cout << "now looking okao_id: " << human_last[i].max_okao_id << endl; 
	    if( human_last[i].max_okao_id == MASTER )
	      master_is_looking = true;
	  }

	//主人がいるなら記録開始
	//	if( master_is_looking )
	//{
	speech_msgs::Speech sp_msg;
	float point_p = 0;

	cout<< "now looking master!" <<endl;
	int speech_okao_id;
	//string to long long
	long long speech_tracking_id = boost::lexical_cast<
	  long long>(speech->TrackingID); 
	cout << "now speech tracking_id: " << speech_tracking_id << endl;

	map< long long, int >::iterator tracking_id_find
	  = tracking_to_okao.find( speech_tracking_id );
	speech_okao_id = tracking_id_find->second;
	sp_msg.okao_id = speech_okao_id;
	if(speech->positive_point == 1){
	  point_p = 40;
	}
	else if(speech->positive_point == -1){
	  point_p = -40;
	}
	  //speech->positive_point = -20;
	cout << "point: " << speech->positive_point << endl;
	
	if(mood.count(TIDtoName(speech_okao_id)) == 0){
	  mood[TIDtoName(speech_okao_id)] = point_p;
	}
	else{
	  float point = mood[TIDtoName(speech_okao_id)];
	  point += point_p;
	  mood[TIDtoName(speech_okao_id)] = point;
	}
	window_mood[speech->hour][speech->minute][speech->second][TIDtoName(speech_okao_id)] = point_p;
	
	  
	
	zmq_positive(speech_tracking_id,mood[TIDtoName(speech_okao_id)]);
	browser(speech,speech_okao_id);
	if(speech->sentence == "おしゃべりしよう" || speech->sentence == "お話ししよう"){
	  if(conv == 0){
	    conv = 1;
	    conversation("start");
	    //cout << "お話開始" << endl; 
	    //robot_browser("いいですよ",1);
	  }
	}
	else if(speech->sentence == "おしゃべり終わり" || speech->sentence == "おしゃべり終了"){
	  if(conv == 1){
	    conv = 0;
	    conversation("end");
	    //robot_browser("終了しますね",1);
	  }
	}
	else if(conv == 1){
	  conversation(speech->sentence);
	}
	else
	  extract(speech,speech_okao_id);
	cout << "now speech okao_id: " << speech_okao_id << endl;
	cout << "all words: "<< speech->sentence <<endl;
	for( int w_id = 0 ; w_id < speech->word_num ; ++w_id )
	  {
	    if(wordcheck(speech->words[w_id].word,speech->words[w_id].part[0])){
	      WordProp wp_tmp;
	      wp_tmp.freq = 0;
	      wp_tmp.num = 0;  
	      map< string, WordProp >::iterator it_words_wp
		= words_wp.find( speech->words[ w_id ].word );
	      if( it_words_wp != words_wp.end() )
		{
		  wp_tmp = it_words_wp->second;
		}
		  
	      ++wp_tmp.freq;
	      wp_tmp.num = speech->word_num;
	      Situation st_tmp;
	      st_tmp.okao_id = speech_okao_id;

	
	      sp_msg.words.push_back( speech->words[w_id] );

	      //すべての人物をpush_backする
	      map< long long, int >::iterator it_okao 
		= tracking_to_okao.begin(); 
	      while(it_okao != tracking_to_okao.end() )
		{
		  st_tmp.people.push_back( it_okao->second ); 
		  ++it_okao;
		}
	      wp_tmp.situations.push_back( st_tmp );
		  
	      words_wp[ speech->words[ w_id ].word ] = wp_tmp; 
	    }
	  }
	//}
      }
  }
示例#5
0
PAM_EXTERN
int pam_sm_authenticate (pam_handle_t *pamh, int flags,
                         int argc, const char **argv)
{
    return conversation (pamh);
}
示例#6
0
PAM_EXTERN
int pam_sm_authenticate(pam_handle_t *pamh, int flags,
			int argc, const char **argv)
{
     const char *username;
     const char *password;
     int retval = PAM_AUTH_ERR;
    
     /* parse arguments */
     ctrl = _pam_parse(argc, argv);

     /* Get the username */
     retval = pam_get_user(pamh, &username, NULL);
     if ((retval != PAM_SUCCESS) || (!username)) {
        if (ctrl & PAM_DEBUG_ARG)
            _pam_log(LOG_DEBUG,"can not get the username");
        return PAM_SERVICE_ERR;
     }
     
     /* Converse just to be sure we have the password */
     retval = conversation(pamh);
     if (retval != PAM_SUCCESS) {
	 _pam_log(LOG_ERR, "could not obtain password for `%s'",
		  username);
	 return -2;
     }
     
     /* Get the password */
     retval = pam_get_item(pamh, PAM_AUTHTOK, (const void **)&password);
     if (retval != PAM_SUCCESS) {
	 _pam_log(LOG_ERR, "Could not retrive user's password");
	 return -2;
     }
     
     if (ctrl & PAM_DEBUG_ARG)
	 _pam_log(LOG_INFO, "Verify user `%s' with password `%s'",
		  username, password);
     
     /* Now use the username to look up password in the database file */
     retval = user_lookup(username, password);
     switch (retval) {
	 case -2:
	     /* some sort of system error. The log was already printed */
	     return PAM_SERVICE_ERR;    
	 case -1:
	     /* incorrect password */
	     _pam_log(LOG_WARNING,
		      "user `%s' denied access (incorrect password)",
		      username);
	     return PAM_AUTH_ERR;
	 case 1:
	     /* the user does not exist in the database */
	     if (ctrl & PAM_DEBUG_ARG)
		 _pam_log(LOG_NOTICE, "user `%s' not found in the database",
			  username);
	     return PAM_USER_UNKNOWN;
	 case 0:
	     /* Otherwise, the authentication looked good */
	     _pam_log(LOG_NOTICE, "user '%s' granted acces", username);
	     return PAM_SUCCESS;
	 default:
	     /* we don't know anything about this return value */
	     _pam_log(LOG_ERR,
		      "internal module error (retval = %d, user = `%s'",
		      retval, username);
	     return PAM_SERVICE_ERR;
     }

     /* should not be reached */
     return PAM_IGNORE;
}