root/nntp/capabilities.cc
| Revision 868b365c127bbf4f0b52f22da03e32a94a4f6653, 2.3 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 3 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | |
| 3 | Copyright © 2009 Antti-Juhani Kaijanaho |
| 4 | |
| 5 | Alue is free software: you can redistribute it and/or modify it |
| 6 | under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | Alue is distributed in the hope that it will be useful, but |
| 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with Alue. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #include "connection.hh" |
| 21 | #include "lexutils.hh" |
| 22 | |
| 23 | namespace nntp |
| 24 | { |
| 25 | class capabilities : public connection::command |
| 26 | { |
| 27 | public: |
| 28 | capabilities(const char *s) { |
| 29 | connection::register_command(s, this); |
| 30 | } |
| 31 | |
| 32 | connection::continuation::ptr |
| 33 | perform(connection::cb, const std::string[], size_t) const; |
| 34 | }; |
| 35 | |
| 36 | connection::continuation::ptr |
| 37 | capabilities::perform(connection::cb c, |
| 38 | const std::string args[], size_t nargs) const |
| 39 | { |
| 40 | // RFC 3977 requires that this be checked ("MUST") |
| 41 | switch (nargs) { |
| 42 | case 0: |
| 43 | break; |
| 44 | case 1: |
| 45 | if (is_keyword(args[0])) break; |
| 46 | /* passthrough */ |
| 47 | default: |
| 48 | c.send_line("501 syntax error"); |
| 49 | return c.dispatch(); |
| 50 | } |
| 51 | |
| 52 | c.capabilities_used() = true; |
| 53 | c.send_line("101 CAPABILITIES list follows"); |
| 54 | c.send_line("VERSION 2"); |
| 55 | c.send_line("IMPLEMENTATION alue/0"); |
| 56 | for (connection::command_iterator it = c.cmds_begin(); |
| 57 | it != c.cmds_end(); it++) { |
| 58 | it->second->write_capability_line(c); |
| 59 | } |
| 60 | c.send_line("."); |
| 61 | return c.dispatch(); |
| 62 | } |
| 63 | |
| 64 | }; |
| 65 | namespace { |
| 66 | nntp::capabilities capabilities("capabilities"); |
| 67 | } |
Note: See TracBrowser
for help on using the browser.
