started docs
This commit is contained in:
@@ -85,17 +85,6 @@ String join(StringList l, String delim)
|
||||
return(result);
|
||||
}
|
||||
|
||||
StringList filter(StringList items, std::function<bool (String)> f)
|
||||
{
|
||||
StringList new_items;
|
||||
for(auto item : items)
|
||||
{
|
||||
if(f(item))
|
||||
new_items.push_back(item);
|
||||
}
|
||||
return(new_items);
|
||||
}
|
||||
|
||||
String html_escape(String s)
|
||||
{
|
||||
String result;
|
||||
|
||||
+22
-6
@@ -8,18 +8,34 @@ StringList split(String str, String delim = "\n");
|
||||
String join(StringList l, String delim = "\n");
|
||||
String nibble(String& haystack, String delim);
|
||||
void json_consume_space(String s, u32& i);
|
||||
StringList filter(StringList items, std::function<bool (String)> f);
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> filter(std::vector<T> items, std::function<bool (T)> f)
|
||||
{
|
||||
std::vector<T> new_items;
|
||||
for(auto item : items)
|
||||
{
|
||||
if(f(item))
|
||||
new_items.push_back(item);
|
||||
}
|
||||
return(new_items);
|
||||
}
|
||||
|
||||
template <class ...Args>
|
||||
String first(Args... args)
|
||||
{
|
||||
std::vector<String> vec = {args...};
|
||||
for(auto s : vec)
|
||||
if(trim(s) != "")
|
||||
return(s);
|
||||
return("");
|
||||
}
|
||||
|
||||
String html_escape(String s);
|
||||
String html_escape(u64 a);
|
||||
String html_escape(f64 a);
|
||||
|
||||
String json_encode(DTree t);
|
||||
String json_decode_String(String s, u32& i, char termination_char = '"');
|
||||
String json_decode_keyword(String s, u32& i);
|
||||
String json_decode_number(String s, u32& i);
|
||||
DTree json_decode_value(String s, u32& i);
|
||||
DTree json_decode_map(String s, u32& i);
|
||||
DTree json_decode(String s);
|
||||
|
||||
String var_dump(StringMap map, String prefix = "", String postfix = "\n");
|
||||
|
||||
+1
-1
@@ -257,7 +257,7 @@ unsigned char c;
|
||||
/* ================ end of sha1.c ================ */
|
||||
|
||||
String
|
||||
hash_sha1(String s, bool as_binary)
|
||||
sha1(String s, bool as_binary)
|
||||
{
|
||||
unsigned char v[20];
|
||||
SHA1_CTX ctx;
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ By Steve Reid <steve@edmweb.com>
|
||||
*/
|
||||
|
||||
|
||||
String hash_sha1(String s, bool as_binary = false);
|
||||
String sha1(String s, bool as_binary = false);
|
||||
|
||||
+4
-1
@@ -438,4 +438,7 @@ void on_child_exit(int sig)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringList ls(String dir)
|
||||
{
|
||||
return(split(trim(shell_exec("ls -1 "+shell_escape(dir))), "\n"));
|
||||
}
|
||||
|
||||
+2
-1
@@ -13,7 +13,7 @@ void set_cwd(String path);
|
||||
time_t file_mtime(String file_name);
|
||||
void unlink(String file_name);
|
||||
String expand_path(String path);
|
||||
void on_segfault(int sig);
|
||||
StringList ls(String dir);
|
||||
|
||||
f64 microtime();
|
||||
u64 time();
|
||||
@@ -38,3 +38,4 @@ StringMap memcache_get_multiple(u64 connection, StringList keys);
|
||||
pid_t parent_pid = 0;
|
||||
pid_t my_pid = 0;
|
||||
|
||||
void on_segfault(int sig);
|
||||
|
||||
@@ -195,6 +195,7 @@ struct ServerState {
|
||||
|
||||
std::map<String, SharedUnit*> units;
|
||||
ServerSettings config;
|
||||
u32 request_count = 0;
|
||||
|
||||
};
|
||||
|
||||
@@ -289,3 +290,4 @@ void print(Ts... args)
|
||||
{
|
||||
((*context->ob << args), ...);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,10 +41,11 @@ int handle_complete(FastCGIRequest& request) {
|
||||
// printf("(i) request handle\n");
|
||||
|
||||
context = &request;
|
||||
server_state.request_count += 1;
|
||||
request.server = &server_state;
|
||||
request.stats.time_start = microtime();
|
||||
request.header["Content-Type"] = context->server->config.CONTENT_TYPE;
|
||||
request.get = parse_query(request.params["QUERY_String"]);
|
||||
request.get = parse_query(request.params["QUERY_STRING"]);
|
||||
request.random_index = 0;
|
||||
request.random_seed = noise64(*reinterpret_cast<u64*>(&request.stats.time_start));
|
||||
request.ob_start();
|
||||
|
||||
Reference in New Issue
Block a user