]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Sockets/WebServer/Index.c
AppPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / AppPkg / Applications / Sockets / WebServer / Index.c
CommitLineData
9f7f5161 1/**
2 @file
4684b66f 3 Generate the list of known pages.
4
bcb96695
MK
5 Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9f7f5161 7
4684b66f 8**/
9
10#include <WebServer.h>
11
12
13/**
14 Respond with the list of known pages
15
16 @param [in] SocketFD The socket's file descriptor to add to the list.
17 @param [in] pPort The WSDT_PORT structure address
18 @param [out] pbDone Address to receive the request completion status
19
20 @retval EFI_SUCCESS The request was successfully processed
21
22**/
23EFI_STATUS
24IndexPage (
25 IN int SocketFD,
26 IN WSDT_PORT * pPort,
27 OUT BOOLEAN * pbDone
28 )
29{
30 CONST DT_PAGE * pPage;
31 CONST DT_PAGE * pPageEnd;
32 EFI_STATUS Status;
33
34 DBG_ENTER ( );
35
36 //
37 // Send the index page
38 //
39 for ( ; ; ) {
40 //
41 // Send the page header
42 //
43 Status = HttpPageHeader ( SocketFD, pPort, L"Index" );
44 if ( EFI_ERROR ( Status )) {
45 break;
46 }
47
48 //
49 // Build the table header
50 //
51 Status = HttpSendAnsiString ( SocketFD,
52 pPort,
53 "<h1>UEFI Web Server</h1>\r\n"
54 "<table border=\"1\">\r\n"
55 " <tr bgcolor=\"c0c0ff\"><th>Page</th><th>Description</th></tr>\r\n" );
56 if ( EFI_ERROR ( Status )) {
57 break;
58 }
59
60 //
61 // Walk the list of pages
62 // Skip the first page
63 //
64 pPage = &mPageList[0];
65 pPageEnd = &pPage[mPageCount];
66 pPage += 1;
67 while ( pPageEnd > pPage ) {
68 //
69 // Build the table entry for this page
70 //
71 Status = HttpSendAnsiString ( SocketFD,
72 pPort,
73 "<tr><td><a target=\"_blank\" href=\"" );
74 if ( EFI_ERROR ( Status )) {
75 break;
76 }
77 Status = HttpSendUnicodeString ( SocketFD,
78 pPort,
79 &pPage->pPageName[1]);
80 if ( EFI_ERROR ( Status )) {
81 break;
82 }
83 Status = HttpSendAnsiString ( SocketFD,
84 pPort,
85 "\">" );
86 if ( EFI_ERROR ( Status )) {
87 break;
88 }
89 Status = HttpSendUnicodeString ( SocketFD,
90 pPort,
91 &pPage->pPageName[1]);
92 if ( EFI_ERROR ( Status )) {
93 break;
94 }
95 Status = HttpSendAnsiString ( SocketFD,
96 pPort,
97 "</a></td><td>" );
98 if ( EFI_ERROR ( Status )) {
99 break;
100 }
101 Status = HttpSendUnicodeString ( SocketFD,
102 pPort,
103 pPage->pDescription );
104 if ( EFI_ERROR ( Status )) {
105 break;
106 }
107 Status = HttpSendAnsiString ( SocketFD,
108 pPort,
109 "</td></tr>\r\n" );
110 if ( EFI_ERROR ( Status )) {
111 break;
112 }
113
114 //
115 // Set the next page
116 //
117 pPage += 1;
118 }
119 if ( EFI_ERROR ( Status )) {
120 break;
121 }
122
123 //
124 // Build the table trailer
125 //
126 Status = HttpSendAnsiString ( SocketFD,
127 pPort,
128 "</table>\r\n" );
129 if ( EFI_ERROR ( Status )) {
130 break;
131 }
132
133 //
134 // Send the page trailer
135 //
136 Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
137 break;
138 }
139
140 //
141 // Return the operation status
142 //
143 DBG_EXIT_STATUS ( Status );
144 return Status;
145}