1 #include "ace/OS_NS_string.h"
5 #include "Command_Processor.h"
6 #include "URL_Visitor.h"
13 URL_Command::URL_Command (URL
*url
)
19 URL_Command::execute ()
21 ACE_CString check_string
22 (ACE_TEXT_ALWAYS_CHAR (this->url_
->url_addr ().get_path_name ()));
23 if (check_string
.find ("news:") != ACE_CString::npos
)
26 if (check_string
.find (".cgi") != ACE_CString::npos
)
29 if (check_string
.find ("mailto") != ACE_CString::npos
)
32 if (check_string
.find (".gif") != ACE_CString::npos
)
35 if (check_string
.find (".pdf") != ACE_CString::npos
)
38 if (check_string
.find (".map") != ACE_CString::npos
)
41 if (check_string
.find (".bmp") != ACE_CString::npos
)
44 if (check_string
.find (".jpg") != ACE_CString::npos
)
47 if (this->url_
->accept (OPTIONS::instance ()->visitor ()) !=0)
50 "Coudnt accept url\n"));
57 URL_Command::destroy ()
62 Command_Processor::Command_Processor ()
66 Command_Processor::~Command_Processor ()
71 Command_Processor::destroy ()
78 Command_Processor::execute ()
81 while (this->url_queue_
.is_empty () != 1)
83 if (this->url_queue_
.dequeue_head (command
) != 0)
84 ACE_ERROR_RETURN ((LM_ERROR
,
85 "%p\n", "dequeue_head"),
87 URL_Command
*url_command
= dynamic_cast<URL_Command
*> (command
);
88 Auto_Destroyer
<URL_Command
> url_command_ptr (url_command
);
89 if (url_command_ptr
->execute () != 0)
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 "%p\n", "Couldnt execute command"),
98 Command_Processor::insert (Command
*command
)
100 // According to the order specified the commands are removed from the queue.
101 if (this->url_queue_
.is_full() != 1)
103 if (ACE_OS::strcmp (OPTIONS::instance ()->order (), ACE_TEXT ("FIFO")) == 0)
105 if (this->url_queue_
.enqueue_tail (command
) !=0)
106 ACE_ERROR_RETURN ((LM_ERROR
,
107 ACE_TEXT ("%p\n"), ACE_TEXT ("enqueue_tail")),
110 if (ACE_OS::strcmp (OPTIONS::instance ()->order (), ACE_TEXT ("LIFO")) == 0)
112 if (this->url_queue_
.enqueue_head (command
) !=0)
113 ACE_ERROR_RETURN ((LM_ERROR
,
114 ACE_TEXT ("%p\n"), ACE_TEXT ("enqueue_head")),
121 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, Options
, ACE_Null_Mutex
);