Added a few comments. Source in ztest also analyzed by Doxygen.
[yaz-moved-to-github.git] / src / sc_test.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2008 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /**
7  * \file sc_test.c
8  * \brief Small test for the Windows Service Control utility
9  */
10
11 #ifdef WIN32
12 #include <windows.h>
13 #include <tchar.h>
14 #include <direct.h>
15 #endif
16
17 #include <stdio.h>
18 #include <string.h>
19 #include <yaz/xmalloc.h>
20 #include <yaz/log.h>
21 #include <yaz/sc.h>
22
23 HANDLE    default_stop_event = NULL;
24 static void default_sc_stop(yaz_sc_t s)
25 {
26     SetEvent(default_stop_event);
27 }
28
29 static int default_sc_main(yaz_sc_t s, int argc, char **argv)
30 {
31     default_stop_event = CreateEvent(
32         NULL,    // default security attributes
33         TRUE,    // manual reset event
34         FALSE,   // not signaled
35         NULL);   // no name
36
37     if (default_stop_event == NULL)
38     {
39         return 1;
40     }
41     yaz_sc_running(s);
42     WaitForSingleObject(default_stop_event, INFINITE);
43     return 0;
44 }
45
46
47 int main(int argc, char **argv)
48 {
49     yaz_sc_t s = yaz_sc_create("yaz_sc_test", "YAZ Service Control Test");
50
51     yaz_sc_program(s, argc, argv, default_sc_main, default_sc_stop);
52
53     yaz_sc_destroy(&s);
54     exit(0);
55 }
56 /*
57  * Local variables:
58  * c-basic-offset: 4
59  * indent-tabs-mode: nil
60  * End:
61  * vim: shiftwidth=4 tabstop=8 expandtab
62  */
63