/[projects]/smsdaemon/embedded-http/embeddedhttp.cpp
ViewVC logotype

Diff of /smsdaemon/embedded-http/embeddedhttp.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 693 by torben, Wed Apr 28 09:23:07 2010 UTC revision 694 by torben, Thu Apr 29 18:04:10 2010 UTC
# Line 45  void show_index(struct mg_connection *co Line 45  void show_index(struct mg_connection *co
45          mg_printf(conn, "%s", "Content-Type: text/html\r\n\r\n");          mg_printf(conn, "%s", "Content-Type: text/html\r\n\r\n");
46                    
47          mg_printf(conn, "%s", "<html><body><h2>smsdaemon</h2>\n");          mg_printf(conn, "%s", "<html><body><h2>smsdaemon</h2>\n");
48          mg_printf(conn, "%s", "<a href='/status'>smsdaemon status</a>\n");          mg_printf(conn, "%s", "<a href='/status'>smsdaemon status</a><br>\n");
49            mg_printf(conn, "%s", "<a href='/log'>smsdaemon log</a><br>\n");
50    
51          mg_printf(conn, "%s", "</body></html>");          mg_printf(conn, "%s", "</body></html>");
52  }  }
53    
# Line 56  static void show_404(struct mg_connectio Line 58  static void show_404(struct mg_connectio
58          mg_printf(conn, "%s", "Oops. File not found! ");          mg_printf(conn, "%s", "Oops. File not found! ");
59  }  }
60    
61    void show_log(struct mg_connection *conn, const struct mg_request_info *request_info, void *user_data) {
62            mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n");
63            mg_printf(conn, "%s", "Content-Type: text/plain\r\n\r\n");
64    
65            for (unsigned i=0; i<Logger::logBuffer.size(); i++) {
66                    mg_printf(conn, "%s", Logger::logBuffer[i].c_str() );
67            }
68    }
69    
70  void EmbeddedHttp::startServer() {  void EmbeddedHttp::startServer() {
71          std::string portStr = Common::instance()->GetConfigfile()->GetValue("smsdaemon", "httpport");          std::string portStr = Common::instance()->GetConfigfile()->GetValue("smsdaemon", "httpport");
# Line 75  void EmbeddedHttp::startServer() { Line 85  void EmbeddedHttp::startServer() {
85    
86                  mg_set_uri_callback(m_context, "/", &show_index, 0);                  mg_set_uri_callback(m_context, "/", &show_index, 0);
87                  mg_set_uri_callback(m_context, "/status", &show_status, 0);                  mg_set_uri_callback(m_context, "/status", &show_status, 0);
88                    mg_set_uri_callback(m_context, "/log", &show_log, 0);
89                  mg_set_error_callback(m_context, 404, show_404, NULL);                  mg_set_error_callback(m_context, 404, show_404, NULL);
90    
91    

Legend:
Removed from v.693  
changed lines
  Added in v.694

  ViewVC Help
Powered by ViewVC 1.1.20