~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to plugin_event.c

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 750.
  • Revision ID: siretart@tauware.de-20110427172415-6n4aptmvmz0eztvm
Tags: upstream-0.11.0~svn1143
ImportĀ upstreamĀ versionĀ 0.11.0~svn1143

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: plugin_event.c -1   $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/plugin_event.c $
 
3
 *
 
4
 * plugin template
 
5
 *
 
6
 * Copyright (C) 2003 Ed Martin <edman007@edman007.com>
 
7
 * Copyright (C) 2004, 2005, 2006, 2007, 2008 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 
8
 *
 
9
 * This file is part of LCD4Linux.
 
10
 *
 
11
 * LCD4Linux is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2, or (at your option)
 
14
 * any later version.
 
15
 *
 
16
 * LCD4Linux is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; if not, write to the Free Software
 
23
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
24
 *
 
25
 */
 
26
 
 
27
/* 
 
28
 * exported functions:
 
29
 *
 
30
 * int plugin_init_event (void)
 
31
 *  adds various functions
 
32
 *
 
33
 */
 
34
 
 
35
 
 
36
/* define the include files you need */
 
37
#include "config.h"
 
38
 
 
39
#include <stdlib.h>
 
40
#include <string.h>
 
41
#include <ctype.h>
 
42
 
 
43
/* these should always be included */
 
44
#include "debug.h"
 
45
#include "plugin.h"
 
46
#include "event.h"
 
47
 
 
48
#ifdef WITH_DMALLOC
 
49
#include <dmalloc.h>
 
50
#endif
 
51
 
 
52
 
 
53
 
 
54
/* function 'trigger' */
 
55
/* takes one argument, a string */
 
56
/* triggers the event */
 
57
 
 
58
static void my_trigger(RESULT * result, RESULT * arg1)
 
59
{
 
60
    char *param;
 
61
 
 
62
    /* Get Parameter */
 
63
    /* R2N stands for 'Result to Number' */
 
64
    param = R2S(arg1);
 
65
    named_event_trigger(param);
 
66
 
 
67
    char *value = "";
 
68
 
 
69
    /* store result */
 
70
    /* when called with R_NUMBER, it assumes the */
 
71
    /* next parameter to be a pointer to double */
 
72
    SetResult(&result, R_NUMBER, &value);
 
73
}
 
74
 
 
75
 
 
76
/* plugin initialization */
 
77
/* MUST NOT be declared 'static'! */
 
78
int plugin_init_event(void)
 
79
{
 
80
 
 
81
    /* register all our cool functions */
 
82
    /* the second parameter is the number of arguments */
 
83
    /* -1 stands for variable argument list */
 
84
    AddFunction("event::trigger", 1, my_trigger);
 
85
 
 
86
 
 
87
    return 0;
 
88
}
 
89
 
 
90
void plugin_exit_event(void)
 
91
{
 
92
    /* free any allocated memory */
 
93
    /* close filedescriptors */
 
94
}