summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMidas <vdrportal_midas@gmx.de>2011-08-06 00:27:35 +0200
committerMidas <vdrportal_midas@gmx.de>2011-08-06 00:27:35 +0200
commit07360b23579d0f824511ef144ae831a6a07cbf5a (patch)
tree5453d5ccad159aa21068da2595b6ec3d8eca900d
parent96ae377c7d1e1ba701e1e7388c29bbf88f87280b (diff)
downloadvdr-plugin-sleeptimer-07360b23579d0f824511ef144ae831a6a07cbf5a.tar.gz
vdr-plugin-sleeptimer-07360b23579d0f824511ef144ae831a6a07cbf5a.tar.bz2
Changed command line parsing. Untested.
-rw-r--r--sleeptimer.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/sleeptimer.c b/sleeptimer.c
index e8755d5..2189920 100644
--- a/sleeptimer.c
+++ b/sleeptimer.c
@@ -6,10 +6,11 @@
* $Id$
*/
+#include <getopt.h>
+
#include <vdr/plugin.h>
#include <vdr/interface.h>
#include <vdr/device.h>
-#include <vdr/status.h>
#if VDRVERSNUM < 10507
#include "i18n.h"
@@ -19,7 +20,7 @@
#define COMMANDLENGTH 512
#endif
-static const char *VERSION = "0.8.2";
+static const char *VERSION = "0.8.3-WIP201108060024";
static const char *DESCRIPTION = "Sleeptimer for VDR";
static const char *MAINMENUENTRY = tr("Sleeptimer");
@@ -161,18 +162,27 @@ const char *cPluginSleeptimer::CommandLineHelp(void)
return " -e command shutdown command (default: /sbin/poweroff)\n";
}
-bool cPluginSleeptimer::ProcessArgs(int argc, char *argv[])
+bool cPluginSleeptimer::ProcessArgs (int argc, char *argv[])
{
- // Implement command line argument processing here if applicable.
- int c;
- while((c = getopt(argc, argv, "e:")) != -1 ) {
- switch(c) {
- case 'e':
- strncpy(cli_command, optarg, sizeof(cli_command) - 1);
- break;
- default: return false;
- }
- }
+ static const char short_options[] = "e:";
+
+ static const struct option long_options[] =
+ {
+ { "execute", optional_argument, NULL, 'e' },
+ {NULL}
+ };
+
+ int c=0;
+ while ((c = getopt_long(argc,argv,short_options,long_options,NULL))!=-1)
+ {
+ switch (c)
+ {
+ case 'e':
+ strncpy(cli_command, optarg, sizeof(cli_command) - 1);
+ break;
+ default: return false;
+ }
+ }
return true;
}