Fixed the asn1 for facets
[yaz-moved-to-github.git] / src / sc_test.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 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 /** \brief handle that is used to stop that service should be stopped */
24 HANDLE    default_stop_event = NULL;
25
26 /** \brief stop handler which just signals "stop" */
27 static void default_sc_stop(yaz_sc_t s)
28 {
29     SetEvent(default_stop_event);
30 }
31
32 /** \brief service control main
33     This does not read argc and argv.
34     Real applications would typically do that. It is very important that
35     yaz_sc_running is called before the application starts to operate .
36 */
37 static int default_sc_main(yaz_sc_t s, int argc, char **argv)
38 {
39     default_stop_event = CreateEvent(
40         NULL,    // default security attributes
41         TRUE,    // manual reset event
42         FALSE,   // not signaled
43         NULL);   // no name
44
45     if (default_stop_event == NULL)
46     {
47         return 1;
48     }
49     yaz_sc_running(s);
50     WaitForSingleObject(default_stop_event, INFINITE);
51     return 0;
52 }
53
54 /** \brief the system main function */
55 int main(int argc, char **argv)
56 {
57     yaz_sc_t s = yaz_sc_create("yaz_sc_test", "YAZ Service Control Test");
58
59     yaz_sc_program(s, argc, argv, default_sc_main, default_sc_stop);
60
61     yaz_sc_destroy(&s);
62     exit(0);
63 }
64 /*
65  * Local variables:
66  * c-basic-offset: 4
67  * c-file-style: "Stroustrup"
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */
72