| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #include "connection.hh" |
|---|
| 21 | #include "lexutils.hh" |
|---|
| 22 | |
|---|
| 23 | namespace nntp |
|---|
| 24 | { |
|---|
| 25 | class mode : public connection::command |
|---|
| 26 | { |
|---|
| 27 | public: |
|---|
| 28 | mode(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 | mode::perform(connection::cb c, const std::string args[], size_t nargs) |
|---|
| 38 | const |
|---|
| 39 | { |
|---|
| 40 | switch (nargs) { |
|---|
| 41 | case 0: |
|---|
| 42 | c.send_line("501 subcommand missing"); |
|---|
| 43 | return c.dispatch(); |
|---|
| 44 | case 1: |
|---|
| 45 | if (!is_keyword(args[0])) { |
|---|
| 46 | c.send_line("501 subcommand invalid"); |
|---|
| 47 | return c.dispatch(); |
|---|
| 48 | } else { |
|---|
| 49 | std::string kw = args[0]; |
|---|
| 50 | boost::to_upper(kw); |
|---|
| 51 | if (args[0] != "READER") { |
|---|
| 52 | c.send_line |
|---|
| 53 | ("501 unrecognized subcommand"); |
|---|
| 54 | return c.dispatch(); |
|---|
| 55 | } |
|---|
| 56 | } |
|---|
| 57 | break; |
|---|
| 58 | default: |
|---|
| 59 | c.send_line("501 too many parameters"); |
|---|
| 60 | return c.dispatch(); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | if (c.authenticated()) |
|---|
| 64 | c.send_line("200 posting allowed"); |
|---|
| 65 | else |
|---|
| 66 | c.send_line("200 posting requires authentication"); |
|---|
| 67 | return c.dispatch(); |
|---|
| 68 | } |
|---|
| 69 | }; |
|---|
| 70 | namespace { |
|---|
| 71 | nntp::mode mode("mode"); |
|---|
| 72 | } |
|---|