]> git.neil.brown.name Git - susman.git/blob - watch_test.c
wakealarmd: cope with delta between system time and RTC time.
[susman.git] / watch_test.c
1
2 /* Test watching for suspend notifications
3  *
4  * Copyright (C) 2011 Neil Brown <neilb@suse.de>
5  *
6  *    This program is free software; you can redistribute it and/or modify
7  *    it under the terms of the GNU General Public License as published by
8  *    the Free Software Foundation; either version 2 of the License, or
9  *    (at your option) any later version.
10  *
11  *    This program is distributed in the hope that it will be useful,
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *    GNU General Public License for more details.
15  *
16  *    You should have received a copy of the GNU General Public License along
17  *    with this program; if not, write to the Free Software Foundation, Inc.,
18  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 #include <stdlib.h>
21 #include <event.h>
22 #include <stdio.h>
23 #include "libsus.h"
24
25 static int suspend(void *m)
26 {
27         char *msg = m;
28         printf("Suspend: %s\n", msg);
29         printf("Hang on while I tie my shoe laces...\n");
30         sleep(3);
31         printf("... OK, Done\n");
32         return 1;
33 }
34
35 static void resume(void *m)
36 {
37         char *msg = m;
38         printf("Resume: %s\n", msg);
39 }
40
41
42 main(int argc, char *argv[])
43 {
44
45         event_init();
46
47         suspend_watch(suspend, resume, "I saw that");
48
49         event_loop(0);
50         exit(0);
51 }