1 /*
2 *
3 * Copyright (c) 2003 The Regents of the University of California. All
4 * rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * - Neither the name of the University nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 */
30
31 #include "fusdd_net_i.h"
32
33 #include <libmisc/misc.h>
34 #include <libmisc/elog.h>
35 #include <libmisc/misc_network.h>
36 #include <libmisc/queue.h>
37 #include <emrun/emrun.h>
38 #include <fusd.h>
39
40 #define __GNU_SOURCE
41 #include <getopt.h>
42
43 /*
44 * FUSDd_net.c
45 *
46 * Remote device support for FUSD
47 *
48 * This version is intended to be launched from emrun
49 *
50 */
51
52 /* global state variable */
53 struct fusdnet state = {};
54
55
56 void nlog(int loglevel, char *fmt, ...)
57 {
58 va_list ap;
59 va_start(ap, fmt);
60 elog(loglevel, fmt, ap);
61 va_end(ap);
62 }
63
64
65 /*
66 * Startup
67 */
68
69 static void fusdnet_shutdown(void *data)
70 {
71 elog(LOG_NOTICE, "fusdnet_server shutting down...");
72 exit(0);
73 }
74
75 int main(int argc, char **argv)
76 {
77 /* generic init */
78 misc_init(&argc, argv, CVSTAG);
79
80 /* intialize the server and client sides */
81 fusdnet_status_init(&state);
82 fusdnet_server_init(&state);
83
84 /* connect to emrun */
85 emrun_opts_t emrun_opts = {
86 shutdown: fusdnet_shutdown, /* this function implements our shutdown handler */
87 data: &state /* this pointer will be passed to our shutdown handler */
88 };
89 emrun_init(&emrun_opts);
90
91 /* event loop */
92 g_main();
93 elog(LOG_ERR,"Irregular termination!\n");
94 return 1;
95 }
96
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.