示例#1
0
void
PMC_Ruser::process (void)
{
    const char *(Drwho_Node::*get_name)(void);

    if (Options::get_opt (Options::PRINT_LOGIN_NAME))
        get_name = &Drwho_Node::get_login_name;
    else
        get_name = &Drwho_Node::get_real_name;

    for (Protocol_Record *prp;
            (prp = this->Protocol_Manager::get_each_friend ()) != 0;
        )
    {
        ACE_DEBUG ((LM_DEBUG,
                    "%-*s ",
                    this->max_key_length,
                    prp->get_host ()));

        for (Drwho_Node *np = prp->get_drwho_list (); ;)
        {
            ACE_DEBUG ((LM_DEBUG,
                        "%s",
                        (np->*get_name) ()));

            if (np->get_inactive_count () != 0)
            {
                if (np->get_active_count () != 0)
                    ACE_DEBUG ((LM_DEBUG,
                                "*(%d)",
                                np->get_active_count ()));
            }
            else if (np->get_active_count () > 1)
                ACE_DEBUG ((LM_DEBUG,
                            "*(%d)",
                            np->get_active_count ()));
            else if (np->get_active_count () == 1)
                ACE_DEBUG ((LM_DEBUG,
                            "*"));

            np = np->next_;
            if (np == 0)
                break;
            else if (Options::get_opt (Options::PRINT_LOGIN_NAME))
                ACE_DEBUG ((LM_DEBUG,
                            " "));
            else
                ACE_DEBUG ((LM_DEBUG,
                            ", "));
        }

        ACE_DEBUG ((LM_DEBUG,
                    "\n"));
    }
}
示例#2
0
void
PMC_Usr::process (void)
{
  Protocol_Record *prp = this->get_each_friend ();
  Drwho_Node *np  = prp->get_drwho_list ();

  if (np == 0)
    ACE_DEBUG ((LM_DEBUG,
                "<unknown>"));
  else
    {
      // First try to get a login session that is active...

      for (; np != 0; np = np->next_)
	if (np->active_count_ > 0)
	  {
	    ACE_DEBUG ((LM_DEBUG,
                        "%s ",
                        np->get_host_name ()));

	    if (Options::get_opt (Options::USE_VERBOSE_FORMAT) == 0)
	      return;
	  }

      for (np = prp->get_drwho_list ();
           np != 0;
           np = np->next_)
	if (np->active_count_ == 0)
	  {
	    ACE_DEBUG ((LM_DEBUG,
                        "%s ",
                        np->get_host_name ()));

	    if (Options::get_opt (Options::USE_VERBOSE_FORMAT) == 0)
	      return;
	  }
    }
}
示例#3
0
int
RWho_DB_Manager::get_next_user (Protocol_Record &protocol_record)
{
  // Get the next host file if necessary
  if (this->current_user >= this->number_of_users
      && this->get_next_host () == 0)
    return 0;

  protocol_record.set_login (this->host_data.wd_we[current_user].we_utmp.out_name);
  Drwho_Node *current_node = protocol_record.get_drwho_list ();
  current_node->set_host_name (this->host_data.wd_hostname);
  current_node->set_idle_time (this->host_data.wd_we[current_user].we_idle);
  this->current_user++;

  return 1;
}
示例#4
0
char *
PMC_Ruser::handle_protocol_entries (const char *cp,
                                    const char *host_name,
                                    const char *)
{
    static Protocol_Record protocol_record (1);
    Drwho_Node *current_node = protocol_record.get_drwho_list ();

    protocol_record.set_host (host_name);
    current_node->set_inactive_count (atoi (cp));
    current_node->set_active_count (atoi (cp = ACE_OS::strchr (cp, ' ') + 1));
    current_node->set_login_name (cp = ACE_OS::strchr (cp, ' ') + 1);
    current_node->set_real_name (cp = ACE_OS::strchr (cp, '\0') + 1);

    this->insert_protocol_info (protocol_record);

    return (char *) ACE::strend (cp);
}
示例#5
0
int
PMS_All::encode (char *packet, int &packet_length)
{
  if (Options::get_opt (Options::DEBUGGING) != 0)
    ACE_DEBUG ((LM_DEBUG,
                "in PMS_All::encode"));

  Protocol_Record *prp;
  char *buf_ptr = packet;

  ACE_OS::sprintf (buf_ptr,
                   "Users   %d",
                   this->get_total_users ());
  buf_ptr += ACE_OS::strlen (buf_ptr) + 1;

  // We only send back info on friends that we actually see logged in.

  for (;
       (prp = this->get_next_friend ()) != 0;
       *buf_ptr++ = '\t')
    buf_ptr = 
      this->handle_protocol_entries (ACE_OS::strecpy 
                                       (ACE_OS::strecpy (buf_ptr,
                                                         prp->get_login ()),
                                        prp->get_real ()),
                                     prp->get_drwho_list ());

  *buf_ptr++ = '\n';
  packet_length = buf_ptr - packet;

  if (Options::get_opt (Options::DEBUGGING) != 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "packet_length = %d\n",
                  packet_length));
      ACE_OS::write (ACE_STDERR, packet, packet_length);
      ACE_DEBUG ((LM_DEBUG,
                  "\n"));
    }
  return 1;
}
示例#6
0
int
PMS_Usr::encode (char *packet, int &packet_length)
{
  if (Options::get_opt (Options::DEBUGGING) != 0)
    ACE_DEBUG ((LM_DEBUG,
                "in PMS_Usr::encode"));

  char *buf_ptr = packet;

  // We only send back info on friend that is actually logged in.

  Protocol_Record *prp = this->get_next_friend ();

  if (prp)
    {
      buf_ptr = this->handle_protocol_entries (ACE_OS::strecpy (buf_ptr,
                                                                prp->get_login ()),
                                               prp->get_drwho_list ());
      *buf_ptr++ = '\t';
    }

  *buf_ptr++ = '\n';
  packet_length = buf_ptr - packet;

  if (Options::get_opt (Options::DEBUGGING) != 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "packet_length = %d\n",
                  packet_length));
      ACE_OS::write (ACE_STDERR, packet, packet_length);
      ACE_DEBUG ((LM_DEBUG,
                  "\n"));
    }

  return 1;
}
示例#7
0
void
PM_Client::process (void)
{
  const char *(Protocol_Record::*get_name)(void);

  if (Options::get_opt (Options::PRINT_LOGIN_NAME))
    get_name = &Protocol_Record::get_login;
  else
    get_name = &Protocol_Record::get_real;

  int active_friends = 0;
  int users = this->Protocol_Manager::get_total_users ();

  ACE_DEBUG ((LM_DEBUG,
              "------------------------\n"));

  if (Options::get_opt (Options::PRINT_LOGIN_NAME))
    this->max_key_length = MAXUSERIDNAMELEN;

  // Goes through the queue of all the logged in friends and prints
  // out the associated information.

  for (Protocol_Record *prp = this->Protocol_Manager::get_each_friend ();
       prp != 0;
       prp = this->Protocol_Manager::get_each_friend ())
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%c%-*s [", (prp->is_active_ != 0 ? '*' : ' '),
                  this->max_key_length,
                  (prp->*get_name) ()));

      for (Drwho_Node *np = prp->get_drwho_list (); ;)
        {
          ACE_DEBUG ((LM_DEBUG,
                      np->get_host_name (),
                      stdout));

          active_friends += np->get_active_count ();

          if (np->get_inactive_count () != 0)
            {
              if (np->get_active_count () != 0)
                ACE_DEBUG ((LM_DEBUG,
                            "*(%d)",
                            np->get_active_count ()));
            }
          else if (np->get_active_count () > 1)
            ACE_DEBUG ((LM_DEBUG,
                        "*(%d)",
                        np->get_active_count ()));
          else if (np->get_active_count () == 1)
            ACE_DEBUG ((LM_DEBUG,
                        "*"));

          np = np->next_;
          if (np == 0)
            break;
          else
            ACE_DEBUG ((LM_DEBUG,
                        " "));
        }

      ACE_DEBUG ((LM_DEBUG,
                  "]\n"));
    }

  ACE_DEBUG ((LM_DEBUG,
              "------------------------\n"));
  ACE_DEBUG ((LM_DEBUG,
              "friends: %d\tusers: %d\n",
              active_friends,
              users));
}
示例#8
0
Protocol_Record *
SL_Server::get_each_entry (void)
{
  Protocol_Record *prp = Single_Lookup::get_each_entry ();
  return prp->get_drwho_list () == 0 ? 0 : prp;
}