2 //=============================================================================
4 * @file http_client.cpp
6 * This is a very simple client. It accepts URLs from a prompt, and
7 * will try to fetch them. Also accepts shell escapes.
11 //=============================================================================
14 #include "ace/OS_NS_stdio.h"
15 #include "ace/OS_NS_string.h"
16 #include "ace/OS_NS_ctype.h"
17 #include "http_handler.h"
20 ACE_TMAIN (int, ACE_TCHAR
*[])
22 // Present a command line.
24 // Pass it to the HTTP_Connector.
27 // * Accept shell escape character.
31 ACE_DEBUG ((LM_DEBUG
, "* "));
33 while (ACE_OS::fgets (buf
, sizeof (buf
), stdin
) != 0)
37 // get rid of trailing '\n'
38 int len
= ACE_OS::strlen (s
);
40 if (len
> 0 && s
[len
- 1] == '\n')
43 while (ACE_OS::ace_isspace (*s
))
50 while (ACE_OS::ace_isspace (*s
));
53 if (ACE_OS::system (ACE_TEXT_CHAR_TO_TCHAR (s
)) == -1)
54 ACE_ERROR ((LM_ERROR
, ACE_TEXT (" ! Error executing: %C\n"), s
));
56 else if (ACE_OS::strncmp (s
, "http://", 7) == 0)
59 HTTP_Connector connector
;
60 connector
.connect (s
);
63 ACE_ERROR ((LM_ERROR
, ACE_TEXT (" ? I don't understand: %C\n"), s
));
65 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("* ")));
68 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\nBye!\n")));