diff options
Diffstat (limited to 'src/serv/direct.cc')
| -rw-r--r-- | src/serv/direct.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/serv/direct.cc b/src/serv/direct.cc new file mode 100644 index 0000000..1e7c2d6 --- /dev/null +++ b/src/serv/direct.cc | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | /************************************************************************* | ||
| 2 | * | ||
| 3 | * HTCd - Copyright (C) 1998-2006 Henrik Rydberg | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <serv/htcd.h> | ||
| 21 | #include <mt/dates.h> | ||
| 22 | |||
| 23 | const mstring log_cmd="\\group:\\user.id"; | ||
| 24 | |||
| 25 | TOK_IMPL(error) { | ||
| 26 | throw("htc: 'error' no longer supported"); | ||
| 27 | } | ||
| 28 | |||
| 29 | TOK_IMPL(log) { | ||
| 30 | htcd_req* htc=Reqd(env); | ||
| 31 | MLOCK(htc->htcd()->mutex); | ||
| 32 | fp_stream& tlog=htc->htcd()->errlog; | ||
| 33 | tlog<<"["<<time(0)<<"]["<<htc->tcp->node.ip<<"][" | ||
| 34 | <<htc->tcp->node.name<<":"<<htc->tcp->port<<"][" | ||
| 35 | <<htc->group<<":"<<htc->user.uid()<<"] "; | ||
| 36 | env.parg(tlog,0); | ||
| 37 | tlog<<"\n"; | ||
| 38 | tlog.flush(); | ||
| 39 | } | ||
| 40 | |||
| 41 | TOK_IMPL(output) { | ||
| 42 | env.parg(*Reqd(env)->output,0); | ||
| 43 | } | ||
| 44 | |||
| 45 | void envAddDirect(tokmap& T) | ||
| 46 | { | ||
| 47 | TOK_ADD(output,"r",tok_t::PUBLIC, | ||
| 48 | "%Redirect to output stream\n" | ||
| 49 | "%Syntax: \\output{body}\n" | ||
| 50 | "%\n" | ||
| 51 | "%Normally used on server-level, when output refers\n" | ||
| 52 | "%to a socket.\n" | ||
| 53 | ); | ||
| 54 | |||
| 55 | TOK_ADD(error,"r",tok_t::SYSONLY, | ||
| 56 | "%Redirect to error stream\n" | ||
| 57 | "%Syntax: \\error{body}\n" | ||
| 58 | "%\n" | ||
| 59 | "%Normally used for debugging and loggin of errors.\n" | ||
| 60 | ); | ||
| 61 | |||
| 62 | TOK_ADD(log,"r",tok_t::SYSONLY, | ||
| 63 | "%Message log\n" | ||
| 64 | "%Syntax: \\log{msg}\n" | ||
| 65 | "%\n" | ||
| 66 | "%Outputs to log stream a single line with pre-set information:\n" | ||
| 67 | "%\n" | ||
| 68 | "%IP address\n" | ||
| 69 | "%Time\n" | ||
| 70 | "%Request\n" | ||
| 71 | "%Response\n" | ||
| 72 | ); | ||
| 73 | } | ||
