]>
Commit | Line | Data |
---|---|---|
4684b66f | 1 | /*++ |
2 | This file contains an 'Intel UEFI Application' and is | |
3 | licensed for Intel CPUs and chipsets under the terms of your | |
4 | license agreement with Intel or your vendor. This file may | |
5 | be modified by the user, subject to additional terms of the | |
6 | license agreement | |
7 | --*/ | |
8 | /*++ | |
9 | ||
10 | Copyright (c) 2011 Intel Corporation. All rights reserved | |
11 | This software and associated documentation (if any) is furnished | |
12 | under a license and may only be used or copied in accordance | |
13 | with the terms of the license. Except as permitted by such | |
14 | license, no part of this software or documentation may be | |
15 | reproduced, stored in a retrieval system, or transmitted in any | |
16 | form or by any means without the express written consent of | |
17 | Intel Corporation. | |
18 | ||
19 | --*/ | |
20 | ||
21 | /** @file | |
22 | Generate the list of known pages. | |
23 | ||
24 | **/ | |
25 | ||
26 | #include <WebServer.h> | |
27 | ||
28 | ||
29 | /** | |
30 | Respond with the list of known pages | |
31 | ||
32 | @param [in] SocketFD The socket's file descriptor to add to the list. | |
33 | @param [in] pPort The WSDT_PORT structure address | |
34 | @param [out] pbDone Address to receive the request completion status | |
35 | ||
36 | @retval EFI_SUCCESS The request was successfully processed | |
37 | ||
38 | **/ | |
39 | EFI_STATUS | |
40 | IndexPage ( | |
41 | IN int SocketFD, | |
42 | IN WSDT_PORT * pPort, | |
43 | OUT BOOLEAN * pbDone | |
44 | ) | |
45 | { | |
46 | CONST DT_PAGE * pPage; | |
47 | CONST DT_PAGE * pPageEnd; | |
48 | EFI_STATUS Status; | |
49 | ||
50 | DBG_ENTER ( ); | |
51 | ||
52 | // | |
53 | // Send the index page | |
54 | // | |
55 | for ( ; ; ) { | |
56 | // | |
57 | // Send the page header | |
58 | // | |
59 | Status = HttpPageHeader ( SocketFD, pPort, L"Index" ); | |
60 | if ( EFI_ERROR ( Status )) { | |
61 | break; | |
62 | } | |
63 | ||
64 | // | |
65 | // Build the table header | |
66 | // | |
67 | Status = HttpSendAnsiString ( SocketFD, | |
68 | pPort, | |
69 | "<h1>UEFI Web Server</h1>\r\n" | |
70 | "<table border=\"1\">\r\n" | |
71 | " <tr bgcolor=\"c0c0ff\"><th>Page</th><th>Description</th></tr>\r\n" ); | |
72 | if ( EFI_ERROR ( Status )) { | |
73 | break; | |
74 | } | |
75 | ||
76 | // | |
77 | // Walk the list of pages | |
78 | // Skip the first page | |
79 | // | |
80 | pPage = &mPageList[0]; | |
81 | pPageEnd = &pPage[mPageCount]; | |
82 | pPage += 1; | |
83 | while ( pPageEnd > pPage ) { | |
84 | // | |
85 | // Build the table entry for this page | |
86 | // | |
87 | Status = HttpSendAnsiString ( SocketFD, | |
88 | pPort, | |
89 | "<tr><td><a target=\"_blank\" href=\"" ); | |
90 | if ( EFI_ERROR ( Status )) { | |
91 | break; | |
92 | } | |
93 | Status = HttpSendUnicodeString ( SocketFD, | |
94 | pPort, | |
95 | &pPage->pPageName[1]); | |
96 | if ( EFI_ERROR ( Status )) { | |
97 | break; | |
98 | } | |
99 | Status = HttpSendAnsiString ( SocketFD, | |
100 | pPort, | |
101 | "\">" ); | |
102 | if ( EFI_ERROR ( Status )) { | |
103 | break; | |
104 | } | |
105 | Status = HttpSendUnicodeString ( SocketFD, | |
106 | pPort, | |
107 | &pPage->pPageName[1]); | |
108 | if ( EFI_ERROR ( Status )) { | |
109 | break; | |
110 | } | |
111 | Status = HttpSendAnsiString ( SocketFD, | |
112 | pPort, | |
113 | "</a></td><td>" ); | |
114 | if ( EFI_ERROR ( Status )) { | |
115 | break; | |
116 | } | |
117 | Status = HttpSendUnicodeString ( SocketFD, | |
118 | pPort, | |
119 | pPage->pDescription ); | |
120 | if ( EFI_ERROR ( Status )) { | |
121 | break; | |
122 | } | |
123 | Status = HttpSendAnsiString ( SocketFD, | |
124 | pPort, | |
125 | "</td></tr>\r\n" ); | |
126 | if ( EFI_ERROR ( Status )) { | |
127 | break; | |
128 | } | |
129 | ||
130 | // | |
131 | // Set the next page | |
132 | // | |
133 | pPage += 1; | |
134 | } | |
135 | if ( EFI_ERROR ( Status )) { | |
136 | break; | |
137 | } | |
138 | ||
139 | // | |
140 | // Build the table trailer | |
141 | // | |
142 | Status = HttpSendAnsiString ( SocketFD, | |
143 | pPort, | |
144 | "</table>\r\n" ); | |
145 | if ( EFI_ERROR ( Status )) { | |
146 | break; | |
147 | } | |
148 | ||
149 | // | |
150 | // Send the page trailer | |
151 | // | |
152 | Status = HttpPageTrailer ( SocketFD, pPort, pbDone ); | |
153 | break; | |
154 | } | |
155 | ||
156 | // | |
157 | // Return the operation status | |
158 | // | |
159 | DBG_EXIT_STATUS ( Status ); | |
160 | return Status; | |
161 | } |