Code

Add changelog entry for jessie-security (5.4.1-6+deb8u1).
[pkg-collectd.git] / debian / patches / myplugin_api.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## myplugin_api.dpatch by Sebastian Harl <sh@tokkee.org>
3 ##
4 ## DP: Update myplugin.c to the latest collectd API.
6 @DPATCH@
8 diff a/contrib/examples/myplugin.c b/contrib/examples/myplugin.c
9 --- a/contrib/examples/myplugin.c
10 +++ b/contrib/examples/myplugin.c
11 @@ -100,14 +100,16 @@
12         vl.time       = time (NULL);
13         sstrncpy (vl.host, hostname_g, sizeof (vl.host));
14         sstrncpy (vl.plugin, "myplugin", sizeof (vl.plugin));
15 +
16 +       /* it is strongly recommended to use a type defined in the types.db file
17 +        * instead of a custom type */
18 +       sstrncpy (vl.type, "myplugin", sizeof (vl.plugin));
19         /* optionally set vl.plugin_instance and vl.type_instance to reasonable
20          * values (default: "") */
21  
22         /* dispatch the values to collectd which passes them on to all registered
23 -        * write functions - the first argument is used to lookup the data set
24 -        * definition (it is strongly recommended to use a type defined in the
25 -        * types.db file) */
26 -       plugin_dispatch_values ("myplugin", &vl);
27 +        * write functions */
28 +       plugin_dispatch_values (&vl);
29  
30         /* A return value != 0 indicates an error and the plugin will be skipped
31          * for an increasing amount of time. */
32 @@ -117,7 +119,8 @@
33  /*
34   * This function is called after values have been dispatched to collectd.
35   */
36 -static int my_write (const data_set_t *ds, const value_list_t *vl)
37 +static int my_write (const data_set_t *ds, const value_list_t *vl,
38 +               user_data_t *ud)
39  {
40         char name[1024] = "";
41         int i = 0;
42 @@ -151,7 +154,7 @@
43  /*
44   * This function is called when plugin_log () has been used.
45   */
46 -static void my_log (int severity, const char *msg)
47 +static void my_log (int severity, const char *msg, user_data_t *ud)
48  {
49         printf ("LOG: %i - %s\n", severity, msg);
50         return;
51 @@ -160,7 +163,7 @@
52  /*
53   * This function is called when plugin_dispatch_notification () has been used.
54   */
55 -static int my_notify (const notification_t *notif)
56 +static int my_notify (const notification_t *notif, user_data_t *ud)
57  {
58         char time_str[32] = "";
59         struct tm *tm = NULL;
60 @@ -210,12 +213,13 @@
61   */
62  void module_register (void)
63  {
64 -       plugin_register_log ("myplugin", my_log);
65 -       plugin_register_notification ("myplugin", my_notify);
66 +       plugin_register_log ("myplugin", my_log, /* user data */ NULL);
67 +       plugin_register_notification ("myplugin", my_notify,
68 +                       /* user data */ NULL);
69         plugin_register_data_set (&ds);
70         plugin_register_read ("myplugin", my_read);
71         plugin_register_init ("myplugin", my_init);
72 -       plugin_register_write ("myplugin", my_write);
73 +       plugin_register_write ("myplugin", my_write, /* user data */ NULL);
74         plugin_register_shutdown ("myplugin", my_shutdown);
75      return;
76  } /* void module_register (void) */