Beispiel #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"));
    }
}
Protocol_Record *
PMC_Flo::insert_protocol_info (Protocol_Record &protocol_record)
{
  Protocol_Record *prp = PM_Client::insert_protocol_info (protocol_record);
  int length = ACE_OS::strlen (prp->get_real ());

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

  return prp;
}
Beispiel #3
0
Protocol_Record *
PMS_All::insert_protocol_info (Protocol_Record &protocol_record)
{
  Protocol_Record *prp = PM_Server::insert_protocol_info (protocol_record);
  passwd *pwent = ACE_OS::getpwnam (prp->get_login ());
  char *cp = (char *) ACE_OS::strchr (prp->set_real
                                      (pwent == 0
                                       ? prp->get_login () :
                                       ACE::strnew (pwent->pw_gecos)),
                                      ',');
  if (cp != 0)
    *cp = '\0';

  return prp;
}
Beispiel #4
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;
}
Beispiel #5
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);
}
int
PMC_Flo::encode (char *packet, int &packet_length)
{
  if (Options::get_opt (Options::DEBUG) != 0)
    ACE_DEBUG ((LM_DEBUG,
                "in PMC_Flo::encode"));

  ACE_NEW_RETURN (this->ss,
                  BS_Client,
                  -1);

  SET_PACKET_TYPE (packet, Options::PROTO_FLO);
  char *buf_ptr = SKIP_PACKET_TYPE (packet);

  sprintf (buf_ptr,
           "%d",
           this->friend_count ());

  buf_ptr += MAXUSERIDNAMELEN;

  // Iterate through all the friends, copying them into the packet
  // buffer.

  for (Protocol_Record *prp; (prp = this->get_next_friend ()) != 0; )
    buf_ptr = ACE_OS::strecpy (buf_ptr,
                               prp->get_login ());

  packet_length = buf_ptr - packet;

  if (Options::get_opt (Options::DEBUG) != 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;
}
Beispiel #7
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;
}
Beispiel #8
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;
	  }
    }
}
Beispiel #9
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;
}
Beispiel #10
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;
}
Beispiel #11
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));
}
Beispiel #12
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;
}