YAZ  5.34.0
Data Structures | Functions
sc.c File Reference

Windows Service Control. More...

#include <stdio.h>
#include <string.h>
#include <yaz/xmalloc.h>
#include <yaz/log.h>
#include <yaz/sc.h>
#include <yaz/wrbuf.h>

Go to the source code of this file.

Data Structures

struct  sc_s
 

Functions

yaz_sc_t yaz_sc_create (const char *service_name, const char *display_name)
 creates service handle More...
 
void yaz_sc_running (yaz_sc_t s)
 signals that sc_main applicatio starts running More...
 
int yaz_sc_program (yaz_sc_t s, int argc, char **argv, int(*sc_main)(yaz_sc_t s, int argc, char **argv), void(*sc_stop)(yaz_sc_t s))
 registers service controlled program More...
 
void yaz_sc_destroy (yaz_sc_t *s)
 frees service control handle More...
 

Detailed Description

Windows Service Control.

Definition in file sc.c.

Function Documentation

◆ yaz_sc_create()

yaz_sc_t yaz_sc_create ( const char *  service_name,
const char *  display_name 
)

creates service handle

Parameters
service_nameService Name
display_nameDisplay Name
Returns
service control handle

This function does not activate the service. Only creates handle.

Definition at line 44 of file sc.c.

References sc_s::display_name, sc_s::install_flag, sc_s::remove_flag, sc_s::run_flag, sc_s::sc_main, sc_s::sc_stop, sc_s::service_name, sc_s::start_flag, xmalloc, and xstrdup.

Referenced by statserv_main().

◆ yaz_sc_destroy()

void yaz_sc_destroy ( yaz_sc_t s)

frees service control handle

Parameters
sservice control handle

Definition at line 371 of file sc.c.

References xfree.

Referenced by statserv_main().

◆ yaz_sc_program()

int yaz_sc_program ( yaz_sc_t  s,
int  argc,
char **  argv,
int(*)(yaz_sc_t s, int argc, char **argv)  sc_main,
void(*)(yaz_sc_t s)  sc_stop 
)

registers service controlled program

Parameters
sservice control handle
argcargc as given from main
argvargv as given from main
sc_mainservice main function
sc_stopservice stop function
Returns
sc_main return value

sc_main is the main program of the application. It should initialize the application.. Function yaz_sc_running MUST be called before the application operates (after initialization)

Definition at line 233 of file sc.c.

References sc_s::argc, sc_s::argv, sc_s::display_name, sc_s::install_flag, sc_s::remove_flag, sc_s::run_flag, sc_s::sc_main, sc_s::sc_stop, sc_s::service_name, sc_s::start_flag, wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), wrbuf_puts(), yaz_log(), YLOG_ERRNO, YLOG_FATAL, and YLOG_LOG.

Referenced by statserv_main().

◆ yaz_sc_running()

void yaz_sc_running ( yaz_sc_t  s)

signals that sc_main applicatio starts running

Parameters
sservice control handle

Definition at line 226 of file sc.c.

Referenced by statserv_sc_main().