vdr
1.7.27
|
00001 /* 00002 * svdrpdemo.c: A plugin for the Video Disk Recorder 00003 * 00004 * See the README file for copyright information and how to reach the author. 00005 * 00006 * $Id: svdrpdemo.c 2.0 2007/08/15 13:19:57 kls Exp $ 00007 */ 00008 00009 #include <vdr/plugin.h> 00010 00011 static const char *VERSION = "0.0.3"; 00012 static const char *DESCRIPTION = "How to add SVDRP support to a plugin"; 00013 00014 class cPluginSvdrpdemo : public cPlugin { 00015 private: 00016 // Add any member variables or functions you may need here. 00017 public: 00018 virtual const char *Version(void) { return VERSION; } 00019 virtual const char *Description(void) { return DESCRIPTION; } 00020 virtual const char **SVDRPHelpPages(void); 00021 virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode); 00022 }; 00023 00024 const char **cPluginSvdrpdemo::SVDRPHelpPages(void) 00025 { 00026 static const char *HelpPages[] = { 00027 "DATE\n" 00028 " Print the current date.", 00029 "TIME [ raw ]\n" 00030 " Print the current time.\n" 00031 " If the optional keyword 'raw' is given, the result will be the\n" 00032 " raw time_t data.", 00033 NULL 00034 }; 00035 return HelpPages; 00036 } 00037 00038 cString cPluginSvdrpdemo::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) 00039 { 00040 if (strcasecmp(Command, "DATE") == 0) { 00041 // we use the default reply code here 00042 return DateString(time(NULL)); 00043 } 00044 else if (strcasecmp(Command, "TIME") == 0) { 00045 ReplyCode = 901; 00046 if (*Option) { 00047 if (strcasecmp(Option, "RAW") == 0) 00048 return cString::sprintf("%ld\nThis is the number of seconds since the epoch\nand a demo of a multi-line reply", time(NULL)); 00049 else { 00050 ReplyCode = 504; 00051 return cString::sprintf("Unknown option: \"%s\"", Option); 00052 } 00053 } 00054 return TimeString(time(NULL)); 00055 } 00056 return NULL; 00057 } 00058 00059 VDRPLUGINCREATOR(cPluginSvdrpdemo); // Don't touch this!