Exemplo n.º 1
0
Protocol_Record *
PMS_Ruser::insert_protocol_info (Protocol_Record &protocol_record)
{
  Drwho_Node *current_node = protocol_record.get_drwho_list ();
  Protocol_Record *prp = this->ss->insert (current_node->get_host_name (),
                                           MAXHOSTNAMELEN);
  Drwho_Node *np = this->get_drwho_node (ACE::strnnew (protocol_record.get_login (),
                                                       MAXUSERIDNAMELEN),
                                         prp->drwho_list_);

  if (Options::get_opt (Options::PRINT_LOGIN_NAME))
    np->set_real_name ("");
  else
    {
      passwd *pwent = ACE_OS::getpwnam (np->get_login_name ());
      char *cp =
        (char *) ACE_OS::strchr (np->set_real_name (pwent == 0
                                                    ? np->get_login_name ()
                                                    : ACE::strnew (pwent->pw_gecos)),
                                 ',');
      if (cp != 0)
        *cp = '\0';
    }

  if (current_node->get_idle_time () >= MAX_USER_TIMEOUT)
    np->inactive_count_++;
  else
    np->active_count_++;

  return prp;
}
Exemplo n.º 2
0
Protocol_Record *
PM_Client::insert_protocol_info (Protocol_Record &protocol_record)
{
  Protocol_Record *prp = this->ss->insert (protocol_record.get_login ());
  Drwho_Node *current_node = protocol_record.get_drwho_list ();
  Drwho_Node *np = this->get_drwho_node (ACE::strnew (current_node->get_host_name ()),
                                         prp->drwho_list_);

  // Update the active and inactive counts.

  if (np->get_active_count () < current_node->get_active_count ())
    {
      np->set_active_count (current_node->get_active_count ());
      prp->is_active_ = 1;
    }

  if (np->get_inactive_count () < current_node->get_inactive_count())
    np->set_inactive_count (current_node->get_inactive_count ());

  return prp;
}
Exemplo n.º 3
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"));
    }
}
Exemplo n.º 4
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;
	  }
    }
}
Exemplo n.º 5
0
Protocol_Record *
PMC_Ruser::insert_protocol_info (Protocol_Record &protocol_record)
{
    Protocol_Record *prp = this->ss->insert (protocol_record.get_host (),
                           MAXHOSTNAMELEN);
    Drwho_Node *current_node = protocol_record.get_drwho_list ();
    Drwho_Node *np = this->get_drwho_node (ACE::strnnew (current_node->get_login_name (),
                                           MAXUSERIDNAMELEN),
                                           prp->drwho_list_);
    int length = ACE_OS::strlen (prp->get_host ());

    np->set_real_name (ACE::strnew (current_node->get_real_name ()));

    if (np->get_active_count () < current_node->get_active_count ())
        np->set_active_count (current_node->get_active_count ());
    if (np->get_inactive_count () < current_node->get_inactive_count())
        np->set_inactive_count (current_node->get_inactive_count ());

    if (length > this->max_key_length)
        this->max_key_length = length;

    return prp;
}
Exemplo n.º 6
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));
}