2 * Copyright (c) 1995-1999, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * NT server based on threads by
7 * Chas Woodfield, Fretwell Downing Datasystems.
10 * Revision 1.60 2000-03-14 09:06:11 adam
11 * Added POSIX threads support for frontend server.
13 * Revision 1.59 1999/11/30 13:47:12 adam
14 * Improved installation. Moved header files to include/yaz.
16 * Revision 1.58 1999/08/27 09:40:32 adam
17 * Renamed logf function to yaz_log. Removed VC++ project files.
19 * Revision 1.57 1999/07/06 12:17:15 adam
20 * Added option -1 that runs server once (for profiling purposes).
22 * Revision 1.56 1999/06/10 11:45:30 adam
23 * Added bend_start, bend_stop handlers and removed pre_init.
24 * Handlers bend_start/bend_stop are called when service/daemon is
27 * Revision 1.55 1999/06/10 09:18:54 adam
28 * Modified so that pre_init is called when service/server is started.
30 * Revision 1.54 1999/04/16 14:45:55 adam
31 * Added interface for tcpd wrapper for access control.
33 * Revision 1.53 1999/02/02 13:57:39 adam
34 * Uses preprocessor define WIN32 instead of WINDOWS to build code
35 * for Microsoft WIN32.
37 * Revision 1.52 1998/08/21 14:13:34 adam
38 * Added GNU Configure script to build Makefiles.
40 * Revision 1.51 1998/07/07 15:51:03 adam
41 * Changed server so that it stops if bind fails - "address already in
42 * use" typically causes this.
44 * Revision 1.50 1998/06/22 11:32:39 adam
45 * Added 'conditional cs_listen' feature.
47 * Revision 1.49 1998/02/27 14:04:55 adam
48 * Fixed bug in statserv_remove.
50 * Revision 1.48 1998/02/11 11:53:36 adam
51 * Changed code so that it compiles as C++.
53 * Revision 1.47 1998/02/10 10:28:57 adam
54 * Added app_name, service_dependencies, service_display_name and
55 * options_func. options_func allows us to specify a different function
56 * to interogate the command line arguments. The other members allow us
57 * to pass the full service details accross to the service manager (CW).
60 * Revision 1.46 1998/01/30 15:24:57 adam
61 * Fixed bug in inetd code. The server listened on tcp:@:9999 even
62 * though it was started in inetd mode.
64 * Revision 1.45 1998/01/29 13:30:23 adam
65 * Better event handle system for NT/Unix.
67 * Revision 1.44 1997/11/07 13:31:52 adam
68 * Added NT Service name part of statserv_options_block. Moved NT
69 * service utility to server library.
71 * Revision 1.43 1997/10/31 12:20:09 adam
72 * Improved memory debugging for xmalloc/nmem.c. References to NMEM
73 * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
74 * Bug fix: missing fclose in data1_read_espec1.
76 * Revision 1.42 1997/10/27 14:03:02 adam
77 * Added new member to statserver_options_block, pre_init, which
78 * specifies a callback to be invoked after command line parsing and
79 * before the server listens for the first time.
81 * Revision 1.41 1997/09/29 07:19:32 adam
82 * Server library uses nmem_init/nmem_exit. The log prefix no longer
83 * includes leading path on NT.
85 * Revision 1.40 1997/09/17 12:10:41 adam
88 * Revision 1.39 1997/09/09 10:10:19 adam
89 * Another MSV5.0 port. Changed projects to include proper
90 * library/include paths.
91 * Server starts server in test-mode when no options are given.
93 * Revision 1.38 1997/09/04 14:19:14 adam
96 * Revision 1.37 1997/09/01 08:53:01 adam
97 * New windows NT/95 port using MSV5.0. The test server 'ztest' was
98 * moved a separate directory. MSV5.0 project server.dsp created.
99 * As an option, the server can now operate as an NT service.
101 * Revision 1.36 1996/07/06 19:58:36 quinn
102 * System headerfiles gathered in yconfig
104 * Revision 1.35 1996/05/29 10:03:28 quinn
107 * Revision 1.34 1996/02/21 13:12:07 quinn
108 * *** empty log message ***
110 * Revision 1.33 1996/02/10 12:23:49 quinn
111 * Enable inetd operations fro TCP/IP stack
113 * Revision 1.32 1996/01/19 15:41:52 quinn
114 * *** empty log message ***
116 * Revision 1.31 1995/11/17 11:09:39 adam
117 * Added new option '-c' to specify configuration name in control block.
119 * Revision 1.30 1995/11/01 13:54:59 quinn
122 * Revision 1.29 1995/10/30 12:41:29 quinn
123 * Added hostname lookup for server.
125 * Revision 1.28 1995/09/29 17:12:30 quinn
128 * Revision 1.27 1995/09/27 15:03:02 quinn
129 * Modified function heads & prototypes.
131 * Revision 1.26 1995/08/29 14:44:51 quinn
134 * Revision 1.25 1995/08/29 11:18:02 quinn
135 * Added code to receive close
137 * Revision 1.24 1995/06/16 10:31:39 quinn
138 * Added session timeout.
140 * Revision 1.23 1995/06/15 12:30:48 quinn
143 * Revision 1.22 1995/06/15 07:45:17 quinn
146 * Revision 1.21 1995/06/06 08:15:40 quinn
149 * Revision 1.20 1995/05/29 08:12:09 quinn
152 * Revision 1.19 1995/05/16 09:37:27 quinn
155 * Revision 1.18 1995/05/16 08:51:09 quinn
156 * License, documentation, and memory fixes
158 * Revision 1.17 1995/05/15 11:56:42 quinn
159 * Asynchronous facilities. Restructuring of seshigh code.
161 * Revision 1.16 1995/04/10 10:23:40 quinn
162 * Some work to add scan and other things.
164 * Revision 1.15 1995/03/31 10:16:51 quinn
167 * Revision 1.14 1995/03/31 09:18:58 quinn
170 * Revision 1.13 1995/03/30 16:08:39 quinn
173 * Revision 1.12 1995/03/30 13:29:02 quinn
176 * Revision 1.11 1995/03/30 12:18:17 quinn
179 * Revision 1.10 1995/03/29 15:40:16 quinn
180 * Ongoing work. Statserv is now dynamic by default
182 * Revision 1.9 1995/03/27 08:34:30 quinn
183 * Added dynamic server functionality.
184 * Released bindings to session.c (is now redundant)
186 * Revision 1.8 1995/03/20 09:46:26 quinn
189 * Revision 1.7 1995/03/16 13:29:04 quinn
190 * Partitioned server.
192 * Revision 1.6 1995/03/15 15:18:52 quinn
193 * Little changes to better support nonblocking I/O
196 * Revision 1.5 1995/03/15 08:37:45 quinn
197 * Now we're pretty much set for nonblocking I/O.
199 * Revision 1.4 1995/03/14 16:59:48 quinn
202 * Revision 1.3 1995/03/14 11:30:15 quinn
205 * Revision 1.2 1995/03/14 10:28:03 quinn
206 * More work on demo server.
208 * Revision 1.1 1995/03/10 18:22:45 quinn
209 * The rudiments of an asynchronous server.
231 #include <yaz/comstack.h>
232 #include <yaz/tcpip.h>
233 #include <yaz/options.h>
235 #include <yaz/xmosi.h>
240 #include <yaz/statserv.h>
242 static IOCHAN pListener = NULL;
244 static char *me = "statserver";
248 int check_options(int argc, char **argv);
249 statserv_options_block control_block = {
250 1, /* dynamic mode */
251 0, /* threaded mode */
252 0, /* one shot (single session) */
253 LOG_DEFAULT_LEVEL, /* log level */
255 "", /* diagnostic output to stderr */
256 "tcp:@:9999", /* default listener port */
257 PROTO_Z3950, /* default application protocol */
258 60, /* idle timeout (minutes) */
259 1024*1024, /* maximum PDU size (approx.) to allow */
260 "default-config", /* configuration name to pass to backend */
261 "", /* set user id */
262 0, /* bend_start handler */
263 0, /* bend_stop handler */
264 check_options, /* Default routine, for checking the run-time arguments */
267 0 /* default value for inet deamon */
270 ,"Z39.50 Server", /* NT Service Name */
271 "Server", /* NT application Name */
272 "", /* NT Service Dependencies */
273 "Z39.50 Server" /* NT Service Display Name */
278 * handle incoming connect requests.
279 * The dynamic mode is a bit tricky mostly because we want to avoid
280 * doing all of the listening and accepting in the parent - it's
285 typedef struct _ThreadList ThreadList;
294 static ThreadList *pFirstThread;
295 static CRITICAL_SECTION Thread_CritSect;
296 static BOOL bInitialized = FALSE;
298 static void ThreadList_Initialize()
300 /* Initialize the critical Sections */
301 InitializeCriticalSection(&Thread_CritSect);
303 /* Set the first thraed */
306 /* we have been initialized */
310 static void statserv_add(HANDLE hThread, IOCHAN pIOChannel)
312 /* Only one thread can go through this section at a time */
313 EnterCriticalSection(&Thread_CritSect);
316 /* Lets create our new object */
317 ThreadList *pNewThread = (ThreadList *)malloc(sizeof(ThreadList));
318 pNewThread->hThread = hThread;
319 pNewThread->pIOChannel = pIOChannel;
320 pNewThread->pNext = pFirstThread;
321 pFirstThread = pNewThread;
323 /* Lets let somebody else create a new object now */
324 LeaveCriticalSection(&Thread_CritSect);
328 void statserv_remove(IOCHAN pIOChannel)
330 /* Only one thread can go through this section at a time */
331 EnterCriticalSection(&Thread_CritSect);
334 ThreadList *pCurrentThread = pFirstThread;
335 ThreadList *pNextThread;
336 ThreadList *pPrevThread =NULL;
338 /* Step through alll the threads */
339 for (; pCurrentThread != NULL; pCurrentThread = pNextThread)
341 /* We only need to compare on the IO Channel */
342 if (pCurrentThread->pIOChannel == pIOChannel)
344 /* We have found the thread we want to delete */
345 /* First of all reset the next pointers */
346 if (pPrevThread == NULL)
347 pFirstThread = pCurrentThread->pNext;
349 pPrevThread->pNext = pCurrentThread->pNext;
351 /* All we need todo now is delete the memory */
352 free(pCurrentThread);
354 /* No need to look at any more threads */
359 /* We need to look at another thread */
360 pNextThread = pCurrentThread->pNext;
361 pPrevThread = pCurrentThread;
365 /* Lets let somebody else remove an object now */
366 LeaveCriticalSection(&Thread_CritSect);
370 void statserv_closedown()
372 /* Shouldn't do anything if we are not initialized */
376 HANDLE *pThreadHandles = NULL;
378 /* We need to stop threads adding and removing while we */
379 /* start the closedown process */
380 EnterCriticalSection(&Thread_CritSect);
383 /* We have exclusive access to the thread stuff now */
384 /* Y didn't i use a semaphore - Oh well never mind */
385 ThreadList *pCurrentThread = pFirstThread;
387 /* Before we do anything else, we need to shutdown the listener */
388 if (pListener != NULL)
389 iochan_destroy(pListener);
391 for (; pCurrentThread != NULL; pCurrentThread = pCurrentThread->pNext)
393 /* Just destroy the IOCHAN, that should do the trick */
394 iochan_destroy(pCurrentThread->pIOChannel);
396 /* Keep a running count of our handles */
402 HANDLE *pCurrentHandle ;
404 /* Allocate the thread handle array */
405 pThreadHandles = (HANDLE *)malloc(sizeof(HANDLE) * iHandles);
406 pCurrentHandle = pThreadHandles;
408 for (pCurrentThread = pFirstThread;
409 pCurrentThread != NULL;
410 pCurrentThread = pCurrentThread->pNext, pCurrentHandle++)
412 /* Just the handle */
413 *pCurrentHandle = pCurrentThread->hThread;
417 /* We can now leave the critical section */
418 LeaveCriticalSection(&Thread_CritSect);
421 /* Now we can really do something */
424 /* This will now wait, until all the threads close */
425 WaitForMultipleObjects(iHandles, pThreadHandles, TRUE, INFINITE);
427 /* Free the memory we allocated for the handle array */
428 free(pThreadHandles);
431 if (control_block.bend_stop)
432 (*control_block.bend_stop)(&control_block);
433 /* No longer require the critical section, since all threads are dead */
434 DeleteCriticalSection(&Thread_CritSect);
438 int __stdcall event_loop_thread (IOCHAN iochan)
440 return event_loop (&iochan);
443 static void listener(IOCHAN h, int event)
445 COMSTACK line = (COMSTACK) iochan_getdata(h);
450 if (event == EVENT_INPUT)
452 if ((res = cs_listen(line, 0, 0)) < 0)
454 yaz_log(LOG_FATAL, "cs_listen failed");
459 yaz_log(LOG_DEBUG, "listen ok");
460 iochan_setevent(h, EVENT_OUTPUT);
461 iochan_setflags(h, EVENT_OUTPUT | EVENT_EXCEPT); /* set up for acpt */
463 else if (event == EVENT_OUTPUT)
470 if (!(new_line = cs_accept(line)))
472 yaz_log(LOG_FATAL, "Accept failed.");
473 iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
476 yaz_log(LOG_DEBUG, "Accept ok");
478 if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session,
481 yaz_log(LOG_FATAL, "Failed to create iochan");
486 yaz_log(LOG_DEBUG, "Creating association");
487 if (!(newas = create_association(new_chan, new_line)))
489 yaz_log(LOG_FATAL, "Failed to create new assoc.");
493 yaz_log(LOG_DEBUG, "Setting timeout %d", control_block.idle_timeout);
494 iochan_setdata(new_chan, newas);
495 iochan_settimeout(new_chan, control_block.idle_timeout * 60);
497 yaz_log(LOG_DEBUG, "Determining client address");
498 a = cs_addrstr(new_line);
499 yaz_log(LOG_LOG, "Accepted connection from %s", a ? a : "[Unknown]");
501 /* Now what we need todo is create a new thread with this iochan as
503 /* if (CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)event_loop_thread,
504 new_chan, 0, &ThreadId) == NULL) */
505 /* Somehow, somewhere we need to store this thread id, otherwise we
506 won't be able to close cleanly */
507 NewHandle = (HANDLE)_beginthreadex(NULL, 0, event_loop_thread,
508 new_chan, 0, &ThreadId);
509 if (NewHandle == (HANDLE)-1)
512 yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to create new thread.");
516 /* We successfully created the thread, so add it to the list */
517 statserv_add(NewHandle, new_chan);
519 yaz_log(LOG_DEBUG, "Created new thread, iochan %p", new_chan);
520 iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
524 yaz_log(LOG_FATAL, "Bad event on listener.");
532 /* To save having an #ifdef in event_loop we need to define this empty function */
533 void statserv_remove(IOCHAN pIOChannel)
537 void statserv_closedown()
540 for (p = pListener; p; p = p->next)
544 static void *new_session (void *vp);
546 static void listener(IOCHAN h, int event)
548 COMSTACK line = (COMSTACK) iochan_getdata(h);
550 static int child = 0;
553 if (event == EVENT_INPUT)
555 if (control_block.dynamic && !child)
561 yaz_log(LOG_FATAL|LOG_ERRNO, "pipe");
565 if ((res = fork()) < 0)
567 yaz_log(LOG_FATAL|LOG_ERRNO, "fork");
571 else if (res == 0) /* child */
578 for (pp = pListener; pp; pp = iochan_getnext(pp))
582 COMSTACK l = (COMSTACK)iochan_getdata(pp);
587 sprintf(nbuf, "%s(%d)", me, getpid());
588 log_init(control_block.loglevel, nbuf, 0);
593 /* wait for child to take the call */
599 if ((res = read(hand[0], dummy, 1)) < 0 && errno != EINTR)
601 yaz_log(LOG_FATAL|LOG_ERRNO, "handshake read");
607 yaz_log(LOG_DEBUG, "P: Child has taken the call");
612 if ((res = cs_listen_check(line, 0, 0, control_block.check_ip,
613 control_block.daemon_name)) < 0)
615 yaz_log(LOG_WARN, "cs_listen failed");
620 yaz_log(LOG_DEBUG, "listen ok");
621 iochan_setevent(h, EVENT_OUTPUT);
622 iochan_setflags(h, EVENT_OUTPUT | EVENT_EXCEPT); /* set up for acpt */
624 /* in dynamic mode, only the child ever comes down here */
625 else if (event == EVENT_OUTPUT)
629 if (!(new_line = cs_accept(line)))
631 yaz_log(LOG_FATAL, "Accept failed.");
632 iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
635 yaz_log(LOG_DEBUG, "accept ok");
636 if (control_block.dynamic)
639 /* close our half of the listener socket */
640 for (pp = pListener; pp; pp = iochan_getnext(pp))
642 COMSTACK l = (COMSTACK)iochan_getdata(pp);
647 yaz_log(LOG_DEBUG, "Releasing parent");
651 iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
654 if (control_block.threads)
656 pthread_t child_thread;
657 pthread_create (&child_thread, 0, new_session, new_line);
658 pthread_detach (child_thread);
661 new_session(new_line);
663 new_session(new_line);
668 yaz_log(LOG_FATAL, "Bad event on listener.");
674 static void *new_session (void *vp)
679 COMSTACK new_line = (COMSTACK) vp;
680 if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session,
683 yaz_log(LOG_FATAL, "Failed to create iochan");
686 if (!(newas = create_association(new_chan, new_line)))
688 yaz_log(LOG_FATAL, "Failed to create new assoc.");
691 iochan_setdata(new_chan, newas);
692 iochan_settimeout(new_chan, control_block.idle_timeout * 60);
693 a = cs_addrstr(new_line);
694 yaz_log(LOG_LOG, "Accepted connection from %s", a ? a : "[Unknown]");
695 if (control_block.threads)
697 event_loop(&new_chan);
701 new_chan->next = pListener;
702 pListener = new_chan;
709 static void inetd_connection(int what)
716 if ((line = cs_createbysocket(0, tcpip_type, 0, what)))
718 if ((chan = iochan_create(cs_fileno(line), ir_session, EVENT_INPUT)))
720 if ((assoc = create_association(chan, line)))
722 iochan_setdata(chan, assoc);
723 iochan_settimeout(chan, control_block.idle_timeout * 60);
724 addr = cs_addrstr(line);
725 yaz_log(LOG_LOG, "Inetd association from %s", addr ? addr : "[UNKNOWN]");
729 yaz_log(LOG_FATAL, "Failed to create association structure");
731 chan->next = pListener;
736 yaz_log(LOG_FATAL, "Failed to create iochan");
741 yaz_log(LOG_ERRNO|LOG_FATAL, "Failed to create comstack on socket 0");
746 * Set up a listening endpoint, and give it to the event-handler.
748 static void add_listener(char *where, int what)
752 char mode[100], addr[100];
756 if (!where || sscanf(where, "%[^:]:%s", mode, addr) != 2)
758 yaz_log (LOG_WARN, "%s: Address format: ('tcp'|'osi')':'<address>", me);
761 if (!strcmp(mode, "tcp"))
763 else if (!strcmp(mode, "osi"))
768 yaz_log (LOG_WARN, "OSI Transport not allowed by configuration.");
774 yaz_log (LOG_WARN, "You must specify either 'osi:' or 'tcp:'");
777 yaz_log(LOG_LOG, "Adding %s %s listener on %s",
778 control_block.dynamic ? "dynamic" :
779 (control_block.threads ? "threaded" : "static"),
780 what == PROTO_SR ? "SR" : "Z3950", where);
781 if (!(l = cs_create(type, 0, what)))
783 yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to create listener");
786 ap = cs_straddr (l, addr);
789 fprintf(stderr, "Address resolution failed.\n");
793 if (cs_bind(l, ap, CS_SERVER) < 0)
795 yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", where);
799 if (!(lst = iochan_create(cs_fileno(l), listener, EVENT_INPUT |
802 yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to create IOCHAN-type");
806 iochan_setdata(lst, l);
808 /* Ensure our listener chain is setup properly */
809 lst->next = pListener;
814 /* For windows we don't need to catch the signals */
815 static void catchchld(int num)
817 while (waitpid(-1, 0, WNOHANG) > 0)
819 signal(SIGCHLD, catchchld);
823 statserv_options_block *statserv_getcontrol(void)
825 static statserv_options_block cb;
827 memcpy(&cb, &control_block, sizeof(cb));
831 void statserv_setcontrol(statserv_options_block *block)
833 memcpy(&control_block, block, sizeof(*block));
836 int statserv_start(int argc, char **argv)
842 /* We need to initialize the thread list */
843 ThreadList_Initialize();
847 if ((me = strrchr (argv[0], '\\')))
854 if (control_block.options_func(argc, argv))
857 if (control_block.bend_start)
858 (*control_block.bend_start)(&control_block);
860 if (control_block.inetd)
861 inetd_connection(control_block.default_proto);
864 if (control_block.dynamic)
865 signal(SIGCHLD, catchchld);
867 if (*control_block.setuid)
871 if (!(pw = getpwnam(control_block.setuid)))
873 yaz_log(LOG_FATAL, "%s: Unknown user", control_block.setuid);
876 if (setuid(pw->pw_uid) < 0)
878 yaz_log(LOG_FATAL|LOG_ERRNO, "setuid");
884 if ((pListener == NULL) && *control_block.default_listen)
885 add_listener(control_block.default_listen,
886 control_block.default_proto);
888 if (pListener == NULL)
892 yaz_log(LOG_LOG, "Entering event loop.");
893 ret = event_loop(&pListener);
899 int check_options(int argc, char **argv)
904 while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:", argv, argc, &arg)) != -2)
909 add_listener(arg, control_block.default_proto);
912 control_block.one_shot = 1;
913 control_block.dynamic = 0;
916 control_block.default_proto = PROTO_Z3950;
919 control_block.default_proto = PROTO_SR;
922 control_block.dynamic = 0;
926 control_block.dynamic = 0;
927 control_block.threads = 1;
929 fprintf(stderr, "%s: Threaded mode not available.\n", me);
933 strcpy(control_block.logfile, arg ? arg : "");
934 log_init(control_block.loglevel, me, control_block.logfile);
937 control_block.loglevel = log_mask_str(arg);
938 log_init(control_block.loglevel, me, control_block.logfile);
941 strcpy(control_block.apdufile, arg ? arg : "");
944 strcpy(control_block.setuid, arg ? arg : "");
947 strcpy(control_block.configname, arg ? arg : "");
950 strcpy(control_block.daemon_name, arg ? arg : "");
953 if (!arg || !(r = atoi(arg)))
955 fprintf(stderr, "%s: Specify positive timeout for -t.\n", me);
958 control_block.idle_timeout = r;
961 if (!arg || !(r = atoi(arg)))
963 fprintf(stderr, "%s: Specify positive size for -k.\n", me);
966 control_block.maxrecordsize = r * 1024;
969 control_block.inetd = 1;
979 fprintf(stderr, "Usage: %s [ -a <pdufile> -v <loglevel>"
980 " -l <logfile> -u <user> -c <config> -t <minutes>"
981 " -k <kilobytes> -d <daemon>"
982 " -zsiST -w <directory> <listender-addr>... ]\n", me);
996 static Args ArgDetails;
998 /* name of the executable */
999 #define SZAPPNAME "server"
1001 /* list of service dependencies - "dep1\0dep2\0\0" */
1002 #define SZDEPENDENCIES ""
1004 int statserv_main(int argc, char **argv)
1006 statserv_options_block *cb = statserv_getcontrol();
1008 /* Lets setup the Arg structure */
1009 ArgDetails.argc = argc;
1010 ArgDetails.argv = argv;
1012 /* Now setup the service with the service controller */
1013 SetupService(argc, argv, &ArgDetails, SZAPPNAME,
1014 cb->service_name, /* internal service name */
1015 cb->service_name, /* displayed name of the service */
1020 int StartAppService(void *pHandle, int argc, char **argv)
1022 /* Initializes the App */
1026 void RunAppService(void *pHandle)
1028 Args *pArgs = (Args *)pHandle;
1030 /* Starts the app running */
1031 statserv_start(pArgs->argc, pArgs->argv);
1034 void StopAppService(void *pHandle)
1037 statserv_closedown();
1040 int statserv_main(int argc, char **argv)
1042 int ret = statserv_start (argc, argv);
1043 statserv_closedown ();