unbound 0.1
w_inst.c File Reference

Contains install and remove functions that manipulate the windows services API and windows registry. More...

#include "config.h"
#include "winrc/w_inst.h"
#include "winrc/win_svc.h"

Functions

void wsvc_err2str (char *str, size_t len, const char *fixed, DWORD err)
 Convert windows GetLastError() value to a neat string.
static void fatal_win (FILE *out, const char *str)
 exit with windows error
static void event_reg_install (FILE *out, const char *pathname)
 install registry entries for eventlog
static void event_reg_remove (FILE *out)
 remove registry entries for eventlog
static void quote_it (FILE *out, char *str, size_t maxlen)
 put quotes around string.
static void change (FILE *out, char *path, size_t max, const char *from, const char *to)
 change suffix
void wsvc_install (FILE *out, const char *rename)
 Install service in servicecontrolmanager, setup registry.
void wsvc_remove (FILE *out)
 Remove installed service from servicecontrolmanager, registry entries.
void wsvc_rc_start (FILE *out)
 Start the service from servicecontrolmanager, tells OS to start daemon.
void wsvc_rc_stop (FILE *out)
 Stop the service from servicecontrolmanager, tells OS to stop daemon.

Detailed Description

Contains install and remove functions that manipulate the windows services API and windows registry.

Function Documentation

◆ wsvc_err2str()

void wsvc_err2str ( char * str,
size_t len,
const char * fixed,
DWORD err )

Convert windows GetLastError() value to a neat string.

Parameters
strdestination buffer
lenlength of dest buffer
fixedfixed text to prepend to string.
errthe GetLastError() value.

References wsvc_err2str().

Referenced by fatal_win(), reportev(), and wsvc_err2str().

◆ fatal_win()

void fatal_win ( FILE * out,
const char * str )
static

◆ event_reg_install()

void event_reg_install ( FILE * out,
const char * pathname )
static

install registry entries for eventlog

References event_reg_install(), fatal_win(), and SERVICE_NAME.

Referenced by event_reg_install(), and wsvc_install().

◆ event_reg_remove()

void event_reg_remove ( FILE * out)
static

remove registry entries for eventlog

References event_reg_remove(), fatal_win(), and SERVICE_NAME.

Referenced by event_reg_remove(), and wsvc_remove().

◆ quote_it()

void quote_it ( FILE * out,
char * str,
size_t maxlen )
static

put quotes around string.

Needs one space in front

Parameters
outdebugfile
strto be quoted.
maxlenmax length of the string buffer.

References quote_it().

Referenced by quote_it(), and wsvc_install().

◆ change()

void change ( FILE * out,
char * path,
size_t max,
const char * from,
const char * to )
static

change suffix

References change().

Referenced by change(), and wsvc_install().

◆ wsvc_install()

void wsvc_install ( FILE * out,
const char * rename )

Install service in servicecontrolmanager, setup registry.

Parameters
outdebug output printed here (errors). or NULL.
renameif nonNULL this executable is not unbound.exe but this name.

References change(), event_reg_install(), fatal_win(), quote_it(), SERVICE_NAME, and wsvc_install().

Referenced by main(), wsvc_command_option(), and wsvc_install().

◆ wsvc_remove()

void wsvc_remove ( FILE * out)

Remove installed service from servicecontrolmanager, registry entries.

Parameters
outdebug output printed here (errors). or NULL.

References event_reg_remove(), fatal_win(), SERVICE_NAME, and wsvc_remove().

Referenced by main(), wsvc_command_option(), and wsvc_remove().

◆ wsvc_rc_start()

void wsvc_rc_start ( FILE * out)

Start the service from servicecontrolmanager, tells OS to start daemon.

Parameters
outdebug output printed here (errors). or NULL.

References fatal_win(), SERVICE_NAME, and wsvc_rc_start().

Referenced by main(), wsvc_command_option(), and wsvc_rc_start().

◆ wsvc_rc_stop()

void wsvc_rc_stop ( FILE * out)

Stop the service from servicecontrolmanager, tells OS to stop daemon.

Parameters
outdebug output printed here (errors). or NULL.

References fatal_win(), SERVICE_NAME, and wsvc_rc_stop().

Referenced by main(), wsvc_command_option(), and wsvc_rc_stop().