1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-30 07:56:36 +02:00

unreal service utility changes and win32 resolver fixes

This commit is contained in:
codemastr
2002-08-23 21:26:02 +00:00
parent 0f9fd774f4
commit b2efdf1fe4
3 changed files with 72 additions and 11 deletions
+7
View File
@@ -1523,3 +1523,10 @@ seen. gmtime warning still there
- Stripped the docs. 100kb down, but a reformat in something other than MS
word would really really help.
- Changed version to beta12
- Add config option to the unreal service utility options are:
unreal config startup auto|manual
auto starts the service when the pc boots, manual requires you to run Unreal manually
unreal config crashrestart delay (2k/XP only)
specifies how long to wait after a crash to restart Unreal (in minutes). If no delay is
specified, no action is taken when a crash occurs
- Made some changes to the win32 resolver, hopefully this will fix the crash bugs
-5
View File
@@ -445,12 +445,8 @@ struct hostent *gethost_byname(char *name, Link *lp)
#endif
if (!lp)
return NULL;
#ifndef _WIN32
(void)do_query_name(lp, name, NULL);
return NULL;
#else
return gethostbyname(name);
#endif
}
struct hostent *gethost_byaddr(char *addr, Link *lp)
@@ -472,7 +468,6 @@ struct hostent *gethost_byaddr(char *addr, Link *lp)
static int do_query_name(Link *lp, char *name, ResRQ *rptr)
{
//#ifndef _WIN32
char hname[HOSTLEN + 1];
int len;
+65 -6
View File
@@ -20,10 +20,14 @@
#include <windows.h>
#include <string.h>
#include <stdio.h>
static OSVERSIONINFO VerInfo;
#define IRCD_SERVICE_CONTROL_REHASH 128
void show_usage() {
fprintf(stderr, "unreal start|stop|rehash|restart|install|uninstall");
fprintf(stderr, "unreal start|stop|rehash|restart|install|uninstall|config <option> <value>");
fprintf(stderr, "\nValid config options:\nstartup auto|manual\n");
if (VerInfo.dwMajorVersion == 5)
fprintf(stderr, "crashrestart delay\n");
}
char *show_error(DWORD code) {
@@ -34,15 +38,13 @@ char *show_error(DWORD code) {
int main(int argc, char *argv[]) {
OSVERSIONINFO VerInfo;
char *bslash;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&VerInfo);
if (argc < 2) {
show_usage();
return -1;
}
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&VerInfo);
}
if (!stricmp(argv[1], "install")) {
SC_HANDLE hService, hSCManager;
char path[MAX_PATH+1];
@@ -125,6 +127,63 @@ int main(int argc, char *argv[]) {
ControlService(hService, IRCD_SERVICE_CONTROL_REHASH, &status);
printf("UnrealIRCd NT Service successfully rehashed");
}
else if (!stricmp(argv[1], "config")) {
SERVICE_STATUS status;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd",
SERVICE_CHANGE_CONFIG|SERVICE_START);
if (argc < 3) {
show_usage();
return -1;
}
if (!stricmp(argv[2], "startup")) {
if (ChangeServiceConfig(hService, SERVICE_NO_CHANGE,
!stricmp(argv[3], "auto") ? SERVICE_AUTO_START
: SERVICE_DEMAND_START, SERVICE_NO_CHANGE,
NULL, NULL, NULL, NULL, NULL, NULL, NULL))
printf("UnrealIRCd NT Service configuration changed");
else
printf("UnrealIRCd NT Service configuration change failed - %s", show_error(GetLastError()));
}
else if (!stricmp(argv[2], "crashrestart") && VerInfo.dwMajorVersion == 5) {
SERVICE_FAILURE_ACTIONS hFailActions;
SC_ACTION hAction;
memset(&hFailActions, 0, sizeof(hFailActions));
if (argc >= 4) {
hFailActions.dwResetPeriod = 30;
hFailActions.cActions = 1;
hAction.Type = SC_ACTION_RESTART;
hAction.Delay = atoi(argv[3])*60000;
hFailActions.lpsaActions = &hAction;
if (ChangeServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS,
&hFailActions))
printf("UnrealIRCd NT Service configuration changed");
else
printf("UnrealIRCd NT Service configuration change failed - %s", show_error(GetLastError()));
}
else {
hFailActions.dwResetPeriod = 0;
hFailActions.cActions = 0;
hAction.Type = SC_ACTION_NONE;
hFailActions.lpsaActions = &hAction;
if (ChangeServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS,
&hFailActions))
printf("UnrealIRCd NT Service configuration changed");
else
printf("UnrealIRCd NT Service configuration change failed - %s", show_error(GetLastError()));
}
}
else {
show_usage();
return -1;
}
}
else {
show_usage();
return -1;
}