Minor fixups to the documentation and preprocessor tokens.
[pub/USBasp.git] / Projects / Webserver / Lib / HTTPServerApp.c
index 7d29272..4c12271 100644 (file)
@@ -43,8 +43,8 @@
 char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
                                "Server: LUFA RNDIS\r\n"\r
                                "Connection: close\r\n"\r
-                                                          "MIME-version: 1.0\r\n"\r
-                                                          "Content-Type: ";\r
+                               "MIME-version: 1.0\r\n"\r
+                               "Content-Type: ";\r
 \r
 /** HTTP server response header, for transmission before a resource not found error. This indicates to the host that the given\r
  *  given URL is invalid, and gives extra error information.\r
@@ -52,14 +52,14 @@ char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"
 char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
                                "Server: LUFA RNDIS\r\n"\r
                                "Connection: close\r\n"\r
-                                                          "MIME-version: 1.0\r\n"\r
-                                                          "Content-Type: text/plain\r\n\r\n"\r
-                                                          "Error 404: File Not Found";\r
+                               "MIME-version: 1.0\r\n"\r
+                               "Content-Type: text/plain\r\n\r\n"\r
+                               "Error 404: File Not Found";\r
 \r
 /** Default MIME type sent if no other MIME type can be determined */\r
 char PROGMEM DefaultMIMEType[] = "text/plain";\r
 \r
-/** List of MIME types for each supported file extension - must be terminated with \ref END_OF_MIME_LIST entry. */\r
+/** List of MIME types for each supported file extension. */\r
 MIME_Type_t PROGMEM MIMETypes[] =\r
        {\r
                {.Extension = "htm", .MIMEType = "text/html"},\r
@@ -67,9 +67,9 @@ MIME_Type_t PROGMEM MIMETypes[] =
                {.Extension = "gif", .MIMEType = "image/gif"},\r
                {.Extension = "bmp", .MIMEType = "image/bmp"},\r
                {.Extension = "png", .MIMEType = "image/png"},\r
+               {.Extension = "ico", .MIMEType = "image/x-icon"},\r
                {.Extension = "exe", .MIMEType = "application/octet-stream"},\r
                {.Extension = "gz",  .MIMEType = "application/x-gzip"},\r
-               {.Extension = "ico", .MIMEType = "image/x-icon"},\r
                {.Extension = "zip", .MIMEType = "application/zip"},\r
                {.Extension = "pdf", .MIMEType = "application/pdf"},\r
        };\r
@@ -97,12 +97,9 @@ void WebserverApp_Callback(void)
 \r
        if (uip_aborted() || uip_timedout() || uip_closed())\r
        {\r
-               /* Connection is being terminated for some reason - close file handle if open */\r
-               if (AppState->FileOpen)\r
-               {\r
-                       f_close(&AppState->FileHandle);\r
-                       AppState->FileOpen = false;\r
-               }\r
+               /* Connection is being terminated for some reason - close file handle */\r
+               f_close(&AppState->FileHandle);\r
+               AppState->FileOpen = false;\r
                \r
                /* Lock to the closed state so that no further processing will occur on the connection */\r
                AppState->CurrentState  = WEBSERVER_STATE_Closed;\r
@@ -128,7 +125,7 @@ void WebserverApp_Callback(void)
                AppState->CurrentState = AppState->NextState;\r
        }\r
 \r
-       if (uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() || uip_poll())\r
+       if (uip_rexmit() || uip_acked() || uip_newdata() || uip_connected() || uip_poll())\r
        {\r
                switch (AppState->CurrentState)\r
                {\r
@@ -159,7 +156,7 @@ void WebserverApp_Callback(void)
 static void Webserver_OpenRequestedFile(void)\r
 {\r
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
-       char*                     AppData     = (char*)uip_appdata;\r
+       char*               const AppData     = (char*)uip_appdata;\r
        \r
        /* No HTTP header received from the client, abort processing */\r
        if (!(uip_newdata()))\r
@@ -199,12 +196,12 @@ static void Webserver_OpenRequestedFile(void)
 static void Webserver_SendResponseHeader(void)\r
 {\r
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
-       char*                     AppData     = (char*)uip_appdata;\r
+       char*               const AppData     = (char*)uip_appdata;\r
 \r
        char*    HeaderToSend;\r
        uint16_t HeaderLength;\r
 \r
-       /* Determine what HTTP header should be sent to the client */\r
+       /* Determine which HTTP header should be sent to the client */\r
        if (AppState->FileOpen)\r
        {\r
                HeaderToSend = HTTP200Header;\r
@@ -216,6 +213,7 @@ static void Webserver_SendResponseHeader(void)
                AppState->NextState = WEBSERVER_STATE_Closing;\r
        }\r
 \r
+       /* Copy over the HTTP response header and send it to the receiving client */\r
        HeaderLength = strlen_P(HeaderToSend);\r
        strncpy_P(AppData, HeaderToSend, HeaderLength);\r
        uip_send(AppData, HeaderLength);\r
@@ -227,7 +225,7 @@ static void Webserver_SendResponseHeader(void)
 static void Webserver_SendMIMETypeHeader(void)\r
 {\r
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
-       char*                     AppData     = (char*)uip_appdata;\r
+       char*               const AppData     = (char*)uip_appdata;\r
 \r
        char*    Extension        = strpbrk(AppState->FileName, ".");\r
        uint16_t MIMEHeaderLength = 0;\r
@@ -272,7 +270,7 @@ static void Webserver_SendMIMETypeHeader(void)
 static void Webserver_SendData(void)\r
 {\r
        uip_tcp_appstate_t* const AppState    = &uip_conn->appstate;\r
-       char*                     AppData     = (char*)uip_appdata;\r
+       char*               const AppData     = (char*)uip_appdata;\r
 \r
        /* Must determine the maximum segment size to determine maximum file chunk size */\r
        uint16_t MaxSegmentSize = uip_mss();\r