File: ClientFinger.cc

package info (click to toggle)
postman 2.1-6
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,248 kB
  • ctags: 3,249
  • sloc: cpp: 33,376; ansic: 2,014; sh: 768; makefile: 300
file content (53 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
ClientFinger.cc
*/

#include "ClientFinger.h"
extern Language *L;

/*
example:
info@seismo.emr.ca
quake@seismo.emr.ca
*/

ClientFinger::ClientFinger (const char *aserver, int aport, const char *auser)
  {
  xstrncpy (server, CMAXIPNAME, aserver);
  xstrncpy (user, CMAXBUFFER, auser);
  fingerport = aport;
  }  

ClientFinger::~ClientFinger ()
  {
  }

bool ClientFinger::doFinger (TBuffer ErrorString, StringList *SLRes)
  {
  char buffer[1024];
  int sock;
  XSocket *socket;

  SLRes->Clear();
  sprintf (buffer, "[%.100s]", server);
  SLRes->Add (buffer);
  initStr (ErrorString);
  socket = new XSocket ();
  socket->ignore_pipe();
  sock = socket->do_client_inet (server, NULL, fingerport, 240);
  if (sock == -1) {xstrncpy (ErrorString, CMAXBUFFER, L->get (ERR_SERVERISDOWN)); return false;}
  socket->SetSock (sock);
    
  //ENVIO USER
  sprintf (buffer, "%.100s\n", user);
  if (socket->Send_TO (buffer, 3) == 0) {xstrncpy (ErrorString, CMAXBUFFER, "Socket error"); return false;}
  
  //LEO LO RECIBIDO
  while (socket->Gets (buffer, sizeof(buffer) -1))
    {
    SLRes->Add (buffer);
    }
    
  delete socket;  
  return true;
  }