summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/Caching/http_client.cpp
blob: 9238ace3194a6a6b1b8264617ae0f88595667f44 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// $Id$

// ============================================================================
//
// = LIBRARY
//    apps/JAWS/clients/Caching
// 
// = FILENAME
//    http_client.cpp
//
// = DESCRIPTION
//    This is a very simple client.  It accepts URLs from a prompt, and
//    will try to fetch them.  Also accepts shell escapes.
//
// = AUTHOR
//    James Hu
// 
// ============================================================================

#include "http_handler.h"

ACE_RCSID(Caching, http_client, "$Id$")

int
main (int, char *[])
{
  // Present a command line.
  // * Accept a URL.
  //     Pass it to the HTTP_Connector.
  //     Connect.
  //     Report status.
  // * Accept shell escape character.

  char buf[BUFSIZ];

  ACE_DEBUG ((LM_DEBUG, "* "));

  while (ACE_OS::fgets (buf, sizeof (buf), stdin) != NULL)
    {
      char *s = buf;

      while (isspace (*s))
        s++;

      if (*s == '!')
        {
          do 
	    s++; 
	  while (isspace (*s));

          // Shell command.
          if (ACE_OS::system (s) == -1)
            ACE_ERROR ((LM_ERROR, " ! Error executing: %s\n", s));
        }
      else if (ACE_OS::strncmp (s, "http://", 7) == 0)
        {
          // URL
          HTTP_Connector connector;
          connector.connect (s);
        }
      else
        ACE_ERROR ((LM_ERROR, " ? I don't understand: %s\n", s));

      ACE_ERROR ((LM_ERROR, "* "));
    }

  ACE_DEBUG ((LM_DEBUG, "\nBye!\n"));

  return 0;
}