vdr 2.6.8
svdrpdemo.c
Go to the documentation of this file.
1/*
2 * svdrpdemo.c: A plugin for the Video Disk Recorder
3 *
4 * See the README file for copyright information and how to reach the author.
5 *
6 * $Id: svdrpdemo.c 4.1 2018/04/10 13:01:07 kls Exp $
7 */
8
9#include <vdr/plugin.h>
10
11static const char *VERSION = "2.4.0";
12static const char *DESCRIPTION = "How to add SVDRP support to a plugin";
13
14class cPluginSvdrpdemo : public cPlugin {
15private:
16 // Add any member variables or functions you may need here.
17public:
18 virtual const char *Version(void) { return VERSION; }
19 virtual const char *Description(void) { return DESCRIPTION; }
20 virtual const char **SVDRPHelpPages(void);
21 virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
22 };
23
25{
26 static const char *HelpPages[] = {
27 "DATE\n"
28 " Print the current date.",
29 "TIME [ raw ]\n"
30 " Print the current time.\n"
31 " If the optional keyword 'raw' is given, the result will be the\n"
32 " raw time_t data.",
33 NULL
34 };
35 return HelpPages;
36}
37
38cString cPluginSvdrpdemo::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
39{
40 if (strcasecmp(Command, "DATE") == 0) {
41 // we use the default reply code here
42 return DateString(time(NULL));
43 }
44 else if (strcasecmp(Command, "TIME") == 0) {
45 ReplyCode = 901;
46 if (*Option) {
47 if (strcasecmp(Option, "RAW") == 0)
48 return cString::sprintf("%ld\nThis is the number of seconds since the epoch\nand a demo of a multi-line reply", time(NULL));
49 else {
50 ReplyCode = 504;
51 return cString::sprintf("Unknown option: \"%s\"", Option);
52 }
53 }
54 return TimeString(time(NULL));
55 }
56 return NULL;
57}
58
59VDRPLUGINCREATOR(cPluginSvdrpdemo); // Don't touch this!
virtual const char * Description(void)
Definition svdrpdemo.c:19
virtual const char ** SVDRPHelpPages(void)
Definition svdrpdemo.c:24
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
Definition svdrpdemo.c:38
virtual const char * Version(void)
Definition svdrpdemo.c:18
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition tools.c:1180
#define VDRPLUGINCREATOR(PluginClass)
Definition plugin.h:18
const char * HelpPages[]
Definition svdrp.c:825
static const char * VERSION
Definition svdrpdemo.c:11
static const char * DESCRIPTION
Definition svdrpdemo.c:12
cString TimeString(time_t t)
Converts the given time to a string of the form "hh:mm".
Definition tools.c:1286
cString DateString(time_t t)
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition tools.c:1266