forked from xaxaxa/workspace
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest1.cppsp
More file actions
156 lines (147 loc) · 3.08 KB
/
test1.cppsp
File metadata and controls
156 lines (147 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<%#
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
* */
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <stdexcept>
#include <cppsp/common.H>
#include <delegate.H>
#include <dirent.h>
int aaaaa=0;
%>
<%@ class p %>
<%#
void listDir(string dir,const function<void(dirent&)>& cb)
{
//cout << "scanning " << dir << endl;
DIR* d=opendir(dir.c_str());
if(d==NULL) {
throw runtime_error(strerror(errno));
return;
}
int len = offsetof(dirent, d_name) + pathconf(dir.c_str(), _PC_NAME_MAX) + 1;
char ent[len];
dirent* ent1=(dirent*)ent;
while(readdir_r(d, (dirent*)ent, &ent1)==0 && ent1!=NULL) {
if(strcmp(ent1->d_name, ".")==0 || strcmp(ent1->d_name, "..")==0)
continue;
cb(*ent1);
}
closedir(d);
}
%>
<%$
string asdf() {
return "zzz";
}
void doInit() {
//initCB();
//throw runtime_error("aaaaaa");
auto res=loadNestedPage("1.cppsp");
if(res) cb1(res(),nullptr);
else res.wait({&p::cb1,this});
}
Page* p=NULL;
void cb1(Page* p, exception* ex) {
if(ex!=NULL) {
cancelLoad(ex);
return;
}
this->p=p;
initCB();
}
/*
CP::Timer t;
bool added=false;
void finalize() {
if(!added)poll->add(t);
added=true;
t.setInterval(500);
printf("setInterval: handle=%i\n",t.handle);
t.setCallback({&p::timercb,this});
}
void timercb(int count) {
printf("timercb\n");
t.setInterval(0);
render(response->output);
flush();
//finalizeCB();
}*/
%>
<html>
<head>
<title>fgdhjf</title>
</head>
<body>
<table border="1">
<tr>
<td>UID: </td>
<td><%=getuid()%></td>
</tr>
<tr>
<td>GID: </td>
<td><%=getgid()%></td>
</tr>
</table>
headers:
<table border="1">
<%
for(auto it=request->headers.begin();it!=request->headers.end();it++) {
%>
<tr>
<td><%htmlEscape((*it).name,output);%></td>
<td><%htmlEscape((*it).value,output);%></td>
</tr>
<%
}
%>
</table>
<form method="post" action="1.cppsp?a=1111111&b=222222">
<input type="text" name="input1" /><br />
<input type="text" name="input2" />
<input type="submit" value="click here" />
</form>
<%="ddd"%>
s
gsjdhkh
test1
<%
for(int i=0;i<10;i++) {
%>
gfdsgsfdgdsf<br />
<%
}
//throw runtime_error("aaaaa");
%>
<%=(++aaaaa)%><br />
<%=mapPath("fdshjk/")%>
<br />=============================<br />
<table border="1">
<%
/*listDir(server->mapPath("/"), [&](dirent& d) {
%>
<tr>
<td><%=htmlEscape(d.d_name)%></td>
</tr>
<%
});*/
%>
</table>
<!--#include file="100.html" -->
<%
p->render(output);
p->release();
%>
</body>
</html>