1 /* example_module.c -- example module for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software. It comes without any warranty, to the extent permitted by
6 * applicable law. You can redistribute it and/or modify it under the
7 * terms of the Do What The Fuck You Want To Public License, Version 2,
8 * as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING
18 /* Do not use any vlock specific headers here unless you intend to
19 * submit your module for inclusion. */
21 /* Include this header file to make sure the types of the dependencies
22 * and hooks are correct. */
23 #include "vlock_plugin.h"
25 /* Declare dependencies. Please see PLUGINS for their meaning. Empty
26 * dependencies can be left out. */
27 const char *preceeds
[] = { "new", "all", NULL
};
28 /* const char *succeeds[]; */
29 /* const char *requires[]; */
30 /* const char *needs[]; */
31 const char *depends
[] = { "all", NULL
};
32 /* const char *conflicts[]; */
34 /* Every hook has a void** argument ctx_ptr. When they are called
35 * ctx_ptr points to the same location and *ctx_ptr is initially set to
36 * NULL. Hook functions should pass state by defining a context struct
37 * and saving the pointer to it in *ctx_ptr instead of using global
41 struct example_context
{
46 /* Do something that should happen at vlock's start here. An error in
47 * this hook aborts vlock. */
48 bool vlock_start(void **ctx_ptr
)
50 struct example_context
*ctx
= malloc(sizeof *ctx
);
58 /* Save the context for use by the other hooks. */
64 /* Hooks that are not implemented should not be defined. */
66 /* Start a screensaver type action before the password prompt after a
67 * timeout. This hook must not block! */
68 /* bool vlock_save(void **); */
70 /* Abort a screensaver type action before the password prompt after a
71 * timeout. This hook must not block! */
72 /* bool vlock_save_abort(void **); */
74 /* Do something at the end of vlock. Error returns are ignored here. */
75 bool vlock_end(void **ctx_ptr
)
77 struct example_context
*ctx
= *ctx_ptr
;
81 result
= (ctx
->a
== 23 && ctx
->b
== 42);
86 fprintf(stderr
, "vlock-example_module: Whoops!\n");