Exemplo n.º 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"));
    }
}
Exemplo n.º 2
0
int
PMS_Ruser::encode (char *packet, int &packet_length)
{
  if (Options::get_opt (Options::DEBUGGING) != 0)
    ACE_DEBUG ((LM_DEBUG,
                "in PMS_Ruser::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 hosts that we actually see.

  for (;
       (prp = this->get_next_friend ()) != 0;
       *buf_ptr++ = '\t')
    buf_ptr = this->handle_protocol_entries (ACE_OS::strecpy (buf_ptr,
                                                              prp->get_host ()),
                                             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;
}
Exemplo n.º 3
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;
}