Beispiel #1
0
void check_auth_state( char_data * ch )
{
   auth_data *old_auth;

   if( !( old_auth = get_auth_name( ch->name ) ) )
      return;

   if( old_auth->state == AUTH_OFFLINE || old_auth->state == AUTH_LINK_DEAD )
   {
      old_auth->state = AUTH_ONLINE;
      save_auth_list(  );
   }
   else if( old_auth->state == AUTH_CHANGE_NAME )
   {
      ch->printf( "&R\r\nThe MUD Administrators have found the name %s\r\n"
                  "to be unacceptable. You must choose a new one.\r\n"
                  "The name you choose must be medieval and original.\r\n"
                  "No titles, descriptive words, or names close to any existing\r\n" "Immortal's name. See 'help name'.\r\n", ch->name );
   }
   else if( old_auth->state == AUTH_AUTHED )
   {
      ch->pcdata->authed_by.clear(  );
      if( !old_auth->authed_by.empty(  ) )
      {
         ch->pcdata->authed_by = old_auth->authed_by;
         old_auth->authed_by.clear(  );
      }
      else
         ch->pcdata->authed_by = "The Code";

      ch->printf( "\r\n&GThe MUD Administrators have accepted the name %s.\r\nYou are now free to roam %s.\r\n", ch->name, sysdata->mud_name.c_str(  ) );
      ch->unset_pcflag( PCFLAG_UNAUTHED );
      remove_from_auth( ch->name );
   }
}
Beispiel #2
0
void remove_from_auth( const string & name )
{
   auth_data *old_name;

   if( !( old_name = get_auth_name( name ) ) )  /* Its not old */
      return;
   else
   {
      deleteptr( old_name );
      save_auth_list(  );
   }
}
Beispiel #3
0
void add_to_auth( char_data * ch )
{
   auth_data *new_name;

   if( ( new_name = get_auth_name( ch->name ) ) != nullptr )
      return;
   else
   {
      new_name = new auth_data;
      new_name->name = ch->name;
      new_name->state = AUTH_ONLINE;   /* Just entered the game */
      authlist.push_back( new_name );
      save_auth_list(  );
   }
}
Beispiel #4
0
void char_leaving( char_data * ch, int howleft )
{
   auth_data *old_auth = NULL;

   /*
    * new auth 
    */
   old_auth = get_auth_name( ch->name );
   if( old_auth != NULL )
      if( old_auth->state == AUTH_ONLINE )
         old_auth->state = AUTH_OFFLINE;  /* Logging off */

   ch->pcdata->camp = howleft;

   if( howleft == 0 )   /* Rented at an inn */
   {
      switch ( ch->in_room->area->continent )
      {
         case ACON_ONE:
            ch->pcdata->one = ch->in_room->vnum;
            break;
         default:
            break;
      }
   }

   /*
    * Get 'em dismounted until we finish mount saving -- Blodkai, 4/97 
    */
   if( ch->position == POS_MOUNTED )
      interpret( ch, "dismount" );

   if( ch->morph )
      interpret( ch, "revert" );

   if( ch->desc )
   {
      if( ch->timer > 24 )
         update_connhistory( ch->desc, CONNTYPE_IDLE );
      else
         update_connhistory( ch->desc, CONNTYPE_QUIT );
   }

   list < obj_data * >::iterator iobj;
   for( iobj = ch->carrying.begin(  ); iobj != ch->carrying.end(  ); )
   {
      obj_data *obj = *iobj;
      ++iobj;

      inventory_scan( ch, obj );
   }
   quotes( ch );
   quitting_char = ch;
   ch->save(  );

   if( sysdata->save_pets )
   {
      list < char_data * >::iterator pet;

      for( pet = ch->pets.begin(  ); pet != ch->pets.end(  ); )
      {
         char_data *cpet = *pet;
         ++pet;

         cpet->extract( true );
      }
   }

   /*
    * Synch clandata up only when clan member quits now. --Shaddai 
    */
   if( ch->pcdata->clan )
      save_clan( ch->pcdata->clan );

   saving_char = NULL;
   ch->extract( true );

   for( int x = 0; x < MAX_WEAR; ++x )
      for( int y = 0; y < MAX_LAYERS; ++y )
         save_equipment[x][y] = NULL;
}
void HttpServer(){
	 _u8   SecType = 0;
	    _i32   retVal = -1;
	    _i32   mode = ROLE_STA;
	   /*
	     * Following function configures the device to default state by cleaning
	     * the persistent settings stored in NVMEM (viz. connection profiles &
	     * policies, power policy etc)
	     *
	     * Applications may choose to skip this step if the developer is sure
	     * that the device is in its default state at start of application
	     *
	     * Note that all profiles and persistent settings that were done on the
	     * device will be lost
	     */
	    retVal = configureSimpleLinkToDefaultState();
	    if(retVal < 0)
	    {
	        if (DEVICE_NOT_IN_STATION_MODE == retVal)
	            CLI_Write(" Failed to configure the device in its default state \n\r");

	        LOOP_FOREVER();
	    }

	    CLI_Write(" Device is configured in default state \n\r");

	    /*
	     * Assumption is that the device is configured in station mode already
	     * and it is in its default state
	     */
	    mode = sl_Start(0, 0, 0);
	    if(mode < 0)
	    {
	        LOOP_FOREVER();
	    }
	    else
	    {
	        if (ROLE_AP == mode)
	        {
	            /* If the device is in AP mode, we need to wait for this
	             * event before doing anything */
	            while(!IS_IP_ACQUIRED(g_Status)) { _SlNonOsMainLoopTask(); }
	        }
	        else
	        {
	            /* Configure CC3100 to start in AP mode */
	            retVal = sl_WlanSetMode(ROLE_AP);
	            if(retVal < 0)
	                LOOP_FOREVER();
	        }
	    }

	    /* Configure AP mode without security */
	    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID,
	               pal_Strlen(SSID_AP_MODE), (_u8 *)SSID_AP_MODE);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    SecType = SEC_TYPE_AP_MODE;
	    /* Configure the Security parameter in the AP mode */
	    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1,
	            (_u8 *)&SecType);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, pal_Strlen(PASSWORD_AP_MODE),
	            (_u8 *)PASSWORD_AP_MODE);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    /* Restart the CC3100 */
	    retVal = sl_Stop(SL_STOP_TIMEOUT);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    g_Status = 0;

	    mode = sl_Start(0, 0, 0);
	    if (ROLE_AP == mode)
	    {
	        /* If the device is in AP mode, we need to wait for this event before doing anything */
	        while(!IS_IP_ACQUIRED(g_Status)) { _SlNonOsMainLoopTask(); }
	    }
	    else
	    {
	        CLI_Write(" Device couldn't come in AP mode \n\r");
	        LOOP_FOREVER();
	    }

	    CLI_Write(" \r\n Device is configured in AP mode \n\r");

	    CLI_Write(" Waiting for client to connect\n\r");
	    /* wait for client to connect */
	    while((!IS_IP_LEASED(g_Status)) || (!IS_STA_CONNECTED(g_Status))) { _SlNonOsMainLoopTask(); }

	    CLI_Write(" Client connected\n\r");

	    /* Enable the HTTP Authentication */
	    retVal = set_authentication_check(TRUE);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    /* Get authentication parameters */
	    retVal = get_auth_name(g_auth_name);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    retVal = get_auth_password(g_auth_password);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    retVal = get_auth_realm(g_auth_realm);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    CLI_Write((_u8 *)"\r\n Authentication parameters: ");
	    CLI_Write((_u8 *)"\r\n Name = ");
	    CLI_Write(g_auth_name);
	    CLI_Write((_u8 *)"\r\n Password = "******"\r\n Realm = ");
	    CLI_Write(g_auth_realm);

	    /* Get the domain name */
	    retVal = get_domain_name(g_domain_name);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    CLI_Write((_u8 *)"\r\n\r\n Domain name = ");
	    CLI_Write(g_domain_name);

	    /* Get URN */
	    retVal = get_device_urn(g_device_urn);
	    if(retVal < 0)
	        LOOP_FOREVER();

	    CLI_Write((_u8 *)"\r\n Device URN = ");
	    CLI_Write(g_device_urn);
	    CLI_Write((_u8 *)"\r\n");

	    /* Process the async events from the NWP */
	    while(1)
	    {
	        Semaphore_pend(Semaphore_CC3100_Req, BIOS_WAIT_FOREVER);
	        _SlNonOsMainLoopTask();
	    }

}