summaryrefslogtreecommitdiff
path: root/PLUGINS/src/svdrpdemo/svdrpdemo.c
blob: 5e222bedf23d63734343dbcc2438a515bece0c71 (plain)
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
/*
 * svdrpdemo.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: svdrpdemo.c 3.1 2014/01/01 13:29:54 kls Exp $
 */

#include <vdr/plugin.h>

static const char *VERSION        = "2.1.1";
static const char *DESCRIPTION    = "How to add SVDRP support to a plugin";

class cPluginSvdrpdemo : public cPlugin {
private:
  // Add any member variables or functions you may need here.
public:
  virtual const char *Version(void) { return VERSION; }
  virtual const char *Description(void) { return DESCRIPTION; }
  virtual const char **SVDRPHelpPages(void);
  virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
  };

const char **cPluginSvdrpdemo::SVDRPHelpPages(void)
{
  static const char *HelpPages[] = {
    "DATE\n"
    "    Print the current date.",
    "TIME [ raw ]\n"
    "    Print the current time.\n"
    "    If the optional keyword 'raw' is given, the result will be the\n"
    "    raw time_t data.",
    NULL
    };
  return HelpPages;
}

cString cPluginSvdrpdemo::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{
  if (strcasecmp(Command, "DATE") == 0) {
     // we use the default reply code here
     return DateString(time(NULL));
     }
  else if (strcasecmp(Command, "TIME") == 0) {
     ReplyCode = 901;
     if (*Option) {
        if (strcasecmp(Option, "RAW") == 0)
           return cString::sprintf("%ld\nThis is the number of seconds since the epoch\nand a demo of a multi-line reply", time(NULL));
        else {
           ReplyCode = 504;
           return cString::sprintf("Unknown option: \"%s\"", Option);
           }
        }
     return TimeString(time(NULL));
     }
  return NULL;
}

VDRPLUGINCREATOR(cPluginSvdrpdemo); // Don't touch this!