Convert spaces to tabs
This commit is contained in:
parent
7465574195
commit
243a15052f
19 changed files with 100 additions and 100 deletions
|
@ -273,21 +273,21 @@ w32_ring_from_file_or_bounce_buf(struct ring *r, int fd)
|
||||||
int i, res;
|
int i, res;
|
||||||
|
|
||||||
if (fd)
|
if (fd)
|
||||||
return ring_from_file(r, fd);
|
return ring_from_file(r, fd);
|
||||||
|
|
||||||
if (bounce_status < 0) {
|
if (bounce_status < 0) {
|
||||||
errno = bounce_error;
|
errno = bounce_error;
|
||||||
res = bounce_status;
|
res = bounce_status;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < bounce_status; i++) {
|
for (i = 0; i < bounce_status; i++) {
|
||||||
if (ring_putc(r, bounce_buf[i]) == EOF) {
|
if (ring_putc(r, bounce_buf[i]) == EOF) {
|
||||||
/* more work to do, hold on to bounce_buf */
|
/* more work to do, hold on to bounce_buf */
|
||||||
memmove(bounce_buf, bounce_buf + i, bounce_status - i);
|
memmove(bounce_buf, bounce_buf + i, bounce_status - i);
|
||||||
bounce_status -= i;
|
bounce_status -= i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = i;
|
res = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetEvent(bounce_full);
|
ResetEvent(bounce_full);
|
||||||
|
|
|
@ -142,7 +142,7 @@ struct as_frompath {
|
||||||
AS_NEW_ARRAY((p), type, 1, err);
|
AS_NEW_ARRAY((p), type, 1, err);
|
||||||
|
|
||||||
#define AS_NEW_MALLOC(p, type, err) \
|
#define AS_NEW_MALLOC(p, type, err) \
|
||||||
(p) = (type *)malloc(sizeof(type)); \
|
(p) = (type *)malloc(sizeof(type)); \
|
||||||
if ((p) == NULL) \
|
if ((p) == NULL) \
|
||||||
return err; \
|
return err; \
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ conv(void)
|
||||||
continue;
|
continue;
|
||||||
if (sect.sct_oldown == player->cnum)
|
if (sect.sct_oldown == player->cnum)
|
||||||
continue;
|
continue;
|
||||||
natp = getnatp(sect.sct_own);
|
natp = getnatp(sect.sct_own);
|
||||||
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
||||||
civ = sect.sct_item[I_CIVIL];
|
civ = sect.sct_item[I_CIVIL];
|
||||||
mil = sect.sct_item[I_MILIT];
|
mil = sect.sct_item[I_MILIT];
|
||||||
|
|
|
@ -69,7 +69,7 @@ coun_list(struct natstr *natp)
|
||||||
&& (player->god
|
&& (player->god
|
||||||
|| natp->nat_stat == STAT_GOD
|
|| natp->nat_stat == STAT_GOD
|
||||||
|| cn == player->cnum || getrel(natp, player->cnum) == ALLIED))
|
|| cn == player->cnum || getrel(natp, player->cnum) == ALLIED))
|
||||||
pr(" Now logged on ");
|
pr(" Now logged on ");
|
||||||
else if (player->god) {
|
else if (player->god) {
|
||||||
if (natp->nat_last_login == 0)
|
if (natp->nat_last_login == 0)
|
||||||
pr(" Never logged on ");
|
pr(" Never logged on ");
|
||||||
|
|
|
@ -319,7 +319,7 @@ lload(void)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
move_amount(int sect_amt, int unit_amt, int unit_max,
|
move_amount(int sect_amt, int unit_amt, int unit_max,
|
||||||
int load_unload, int amount)
|
int load_unload, int amount)
|
||||||
{
|
{
|
||||||
int move_amt;
|
int move_amt;
|
||||||
|
|
||||||
|
@ -641,11 +641,11 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
||||||
land.lnd_harden = 0;
|
land.lnd_harden = 0;
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
* FIXME if this supplies from the sector, the putsect in
|
* FIXME if this supplies from the sector, the putsect in
|
||||||
* load() / lload() duplicates those supplies, causing a
|
* load() / lload() duplicates those supplies, causing a
|
||||||
* seqno mismatch
|
* seqno mismatch
|
||||||
*/
|
*/
|
||||||
if (!lnd_supply_all(&land))
|
if (!lnd_supply_all(&land))
|
||||||
pr("WARNING: %s is out of supply!\n", prland(&land));
|
pr("WARNING: %s is out of supply!\n", prland(&land));
|
||||||
#else
|
#else
|
||||||
|
@ -995,7 +995,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
||||||
land.lnd_harden = 0;
|
land.lnd_harden = 0;
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME same issue as in load_land_ship() */
|
/* FIXME same issue as in load_land_ship() */
|
||||||
if (!lnd_supply_all(&land))
|
if (!lnd_supply_all(&land))
|
||||||
pr("WARNING: %s is out of supply!\n", prland(&land));
|
pr("WARNING: %s is out of supply!\n", prland(&land));
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -359,11 +359,11 @@ switch_leader(struct emp_qelem *list, int uid)
|
||||||
|
|
||||||
save = qp = list->q_back;
|
save = qp = list->q_back;
|
||||||
do {
|
do {
|
||||||
emp_remque(qp);
|
emp_remque(qp);
|
||||||
emp_insque(qp, list);
|
emp_insque(qp, list);
|
||||||
qp = list->q_back;
|
qp = list->q_back;
|
||||||
ulp = (struct ulist *)qp;
|
ulp = (struct ulist *)qp;
|
||||||
if (ulp->unit.gen.uid == uid || uid == -1)
|
if (ulp->unit.gen.uid == uid || uid == -1)
|
||||||
break;
|
break;
|
||||||
} while (list->q_back != save);
|
} while (list->q_back != save);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ vers(void)
|
||||||
pr("The maximum amount of mobility used for land unit combat is %0.2f.\n",
|
pr("The maximum amount of mobility used for land unit combat is %0.2f.\n",
|
||||||
combat_mob);
|
combat_mob);
|
||||||
if (opt_MOB_ACCESS)
|
if (opt_MOB_ACCESS)
|
||||||
pr("The starting mobility when acquiring a sector or unit is %d.\n",
|
pr("The starting mobility when acquiring a sector or unit is %d.\n",
|
||||||
-(etu_per_update / sect_mob_neg_factor));
|
-(etu_per_update / sect_mob_neg_factor));
|
||||||
pr("\n");
|
pr("\n");
|
||||||
pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
|
pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
|
||||||
|
|
|
@ -179,7 +179,7 @@ verify_row(int type, int row)
|
||||||
} while (++j < n);
|
} while (++j < n);
|
||||||
}
|
}
|
||||||
if (!(flags & EFF_MEM))
|
if (!(flags & EFF_MEM))
|
||||||
free(row_ref);
|
free(row_ref);
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -766,9 +766,9 @@ xuheader(FILE *fp, int expected_table)
|
||||||
human = ch == 'c';
|
human = ch == 'c';
|
||||||
res = -1;
|
res = -1;
|
||||||
if ((human
|
if ((human
|
||||||
? fscanf(fp, "config%*[ \t]%63[^ \t#\n]%n", name, &res) != 1
|
? fscanf(fp, "config%*[ \t]%63[^ \t#\n]%n", name, &res) != 1
|
||||||
: fscanf(fp, "XDUMP%*[ \t]%63[^ \t#\n]%*[ \t]%*[^ \t#\n]%n",
|
: fscanf(fp, "XDUMP%*[ \t]%63[^ \t#\n]%*[ \t]%*[^ \t#\n]%n",
|
||||||
name, &res) != 1) || res < 0)
|
name, &res) != 1) || res < 0)
|
||||||
return gripe("Expected xdump header");
|
return gripe("Expected xdump header");
|
||||||
|
|
||||||
type = ef_byname(name);
|
type = ef_byname(name);
|
||||||
|
|
|
@ -376,7 +376,7 @@ empth_init(void **ctx_ptr, int flags)
|
||||||
/* Manual reset */
|
/* Manual reset */
|
||||||
hShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
hShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
if (!hShutdownEvent) {
|
if (!hShutdownEvent) {
|
||||||
logerror("Failed to create shutdown event %lu", GetLastError());
|
logerror("Failed to create shutdown event %lu", GetLastError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SetConsoleCtrlHandler(loc_Exit_Handler, TRUE);
|
SetConsoleCtrlHandler(loc_Exit_Handler, TRUE);
|
||||||
|
|
|
@ -135,9 +135,9 @@ double bankint = 0.25; /* bank interest rate (dt * bars) */
|
||||||
|
|
||||||
/* Note in the taxes below:
|
/* Note in the taxes below:
|
||||||
tradetax - this is charged to the seller, so it is < 1 (because the seller
|
tradetax - this is charged to the seller, so it is < 1 (because the seller
|
||||||
gets the (price paid * tradetax)
|
gets the (price paid * tradetax)
|
||||||
buytax - this is charged to the buyer, so it is > 1 (because the buyer is
|
buytax - this is charged to the buyer, so it is > 1 (because the buyer is
|
||||||
charged (price paid * buytax).
|
charged (price paid * buytax).
|
||||||
Not perfect, but it works. :) */
|
Not perfect, but it works. :) */
|
||||||
|
|
||||||
double tradetax = 0.99; /* Tax charged on trade */
|
double tradetax = 0.99; /* Tax charged on trade */
|
||||||
|
|
|
@ -209,9 +209,9 @@ update_timeused(time_t now)
|
||||||
time_t dt = now - player->lasttime;
|
time_t dt = now - player->lasttime;
|
||||||
|
|
||||||
if (dt > midnight_secs)
|
if (dt > midnight_secs)
|
||||||
natp->nat_timeused = midnight_secs;
|
natp->nat_timeused = midnight_secs;
|
||||||
else
|
else
|
||||||
natp->nat_timeused += dt;
|
natp->nat_timeused += dt;
|
||||||
player->lasttime = now;
|
player->lasttime = now;
|
||||||
putnat(natp);
|
putnat(natp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -605,7 +605,7 @@ perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
|
||||||
use_up_msl:
|
use_up_msl:
|
||||||
plp->plane.pln_effic = 0;
|
plp->plane.pln_effic = 0;
|
||||||
putplane(plp->plane.pln_uid, &plp->plane);
|
putplane(plp->plane.pln_uid, &plp->plane);
|
||||||
}
|
}
|
||||||
emp_remque(qp);
|
emp_remque(qp);
|
||||||
free(qp);
|
free(qp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ pr(char *format, ...)
|
||||||
upr_player(player, C_DATA, buf);
|
upr_player(player, C_DATA, buf);
|
||||||
else
|
else
|
||||||
/* normal text and user text are identical */
|
/* normal text and user text are identical */
|
||||||
pr_player(player, C_DATA, buf);
|
pr_player(player, C_DATA, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -621,9 +621,9 @@ ufindpfx(char *s, int n)
|
||||||
|
|
||||||
while (n && s[i]) {
|
while (n && s[i]) {
|
||||||
if ((s[i++] & 0xc0) == 0xc0)
|
if ((s[i++] & 0xc0) == 0xc0)
|
||||||
while ((s[i] & 0xc0) == 0x80)
|
while ((s[i] & 0xc0) == 0x80)
|
||||||
i++;
|
i++;
|
||||||
--n;
|
--n;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ unit_list(struct emp_qelem *unit_list)
|
||||||
if (type == EF_LAND)
|
if (type == EF_LAND)
|
||||||
pr("lnd# land type x,y a eff sh gun xl mu tech retr\n");
|
pr("lnd# land type x,y a eff sh gun xl mu tech retr\n");
|
||||||
else
|
else
|
||||||
pr("shp# ship type x,y fl eff mil sh gun pn he xl ln mob tech\n");
|
pr("shp# ship type x,y fl eff mil sh gun pn he xl ln mob tech\n");
|
||||||
|
|
||||||
for (; qp != unit_list; qp = next) {
|
for (; qp != unit_list; qp = next) {
|
||||||
next = qp->q_back;
|
next = qp->q_back;
|
||||||
|
|
|
@ -248,7 +248,7 @@ sail_nav_fleet(struct fltheadstr *fltp)
|
||||||
fe->num, cname(fe->own));
|
fe->num, cname(fe->own));
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
if ((shp_check_nav(sectp, sp) == CN_LANDLOCKED) &&
|
if ((shp_check_nav(sectp, sp) == CN_LANDLOCKED) &&
|
||||||
(dchr[sectp->sct_type].d_nav == NAV_CANAL)) {
|
(dchr[sectp->sct_type].d_nav == NAV_CANAL)) {
|
||||||
wu(0, fltp->own,
|
wu(0, fltp->own,
|
||||||
"Your ship #%d (%s) is too big to fit through the canal.\n",
|
"Your ship #%d (%s) is too big to fit through the canal.\n",
|
||||||
|
|
|
@ -147,7 +147,7 @@ upd_ship(struct shpstr *sp, int etus,
|
||||||
product = &pchr[dchr[SCT_OIL].d_prd];
|
product = &pchr[dchr[SCT_OIL].d_prd];
|
||||||
oil_gained = roundavg(total_work(100, etus,
|
oil_gained = roundavg(total_work(100, etus,
|
||||||
sp->shp_item[I_CIVIL],
|
sp->shp_item[I_CIVIL],
|
||||||
sp->shp_item[I_MILIT],
|
sp->shp_item[I_MILIT],
|
||||||
sp->shp_item[I_UW],
|
sp->shp_item[I_UW],
|
||||||
ITEM_MAX)
|
ITEM_MAX)
|
||||||
* sp->shp_effic / 100.0
|
* sp->shp_effic / 100.0
|
||||||
|
|
|
@ -56,35 +56,35 @@ install_service(char *program_name, char *service_name, char *config_file)
|
||||||
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (schSCManager == NULL) {
|
if (schSCManager == NULL) {
|
||||||
fprintf(stderr, "install_service failed to open Service Control Manager\n");
|
fprintf(stderr, "install_service failed to open Service Control Manager\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
schService = CreateService(schSCManager,
|
schService = CreateService(schSCManager,
|
||||||
service_name,
|
service_name,
|
||||||
service_name, /* service name to display */
|
service_name, /* service name to display */
|
||||||
SERVICE_ALL_ACCESS, /* desired access */
|
SERVICE_ALL_ACCESS, /* desired access */
|
||||||
SERVICE_WIN32_OWN_PROCESS, /* service type */
|
SERVICE_WIN32_OWN_PROCESS, /* service type */
|
||||||
SERVICE_AUTO_START, /* start type */
|
SERVICE_AUTO_START, /* start type */
|
||||||
SERVICE_ERROR_NORMAL, /* error control type */
|
SERVICE_ERROR_NORMAL, /* error control type */
|
||||||
program_name, /* service's binary */
|
program_name, /* service's binary */
|
||||||
NULL, /* no load ordering group */
|
NULL, /* no load ordering group */
|
||||||
NULL, /* no tag identifier */
|
NULL, /* no tag identifier */
|
||||||
NULL, /* database service dependency */
|
NULL, /* database service dependency */
|
||||||
NULL, /* LocalSystem account */
|
NULL, /* LocalSystem account */
|
||||||
NULL); /* no password */
|
NULL); /* no password */
|
||||||
|
|
||||||
if (schService == NULL) {
|
if (schService == NULL) {
|
||||||
fprintf(stderr, "install_service failed to create service %s\n", service_name);
|
fprintf(stderr, "install_service failed to create service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sdBuf.lpDescription = "Server for Empire game";
|
sdBuf.lpDescription = "Server for Empire game";
|
||||||
|
|
||||||
if(!ChangeServiceConfig2(
|
if(!ChangeServiceConfig2(
|
||||||
schService, /* handle to service */
|
schService, /* handle to service */
|
||||||
SERVICE_CONFIG_DESCRIPTION, /* change: description */
|
SERVICE_CONFIG_DESCRIPTION, /* change: description */
|
||||||
&sdBuf)) { /* value: new description */
|
&sdBuf)) { /* value: new description */
|
||||||
fprintf(stderr, "install_service failed to set the description\n");
|
fprintf(stderr, "install_service failed to set the description\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Service %s installed.\n", service_name);
|
printf("Service %s installed.\n", service_name);
|
||||||
|
@ -106,28 +106,28 @@ remove_service(char *service_name)
|
||||||
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (schSCManager == NULL) {
|
if (schSCManager == NULL) {
|
||||||
fprintf(stderr, "remove_service failed to open Service Control Manager\n");
|
fprintf(stderr, "remove_service failed to open Service Control Manager\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
|
hService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
|
||||||
|
|
||||||
if (hService == NULL) {
|
if (hService == NULL) {
|
||||||
fprintf(stderr, "remove_service failed to open service %s\n", service_name);
|
fprintf(stderr, "remove_service failed to open service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeleteService(hService) == 0) {
|
if (DeleteService(hService) == 0) {
|
||||||
fprintf(stderr, "remove_service failed to remove service %s\n", service_name);
|
fprintf(stderr, "remove_service failed to remove service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CloseServiceHandle(hService) == 0) {
|
if (CloseServiceHandle(hService) == 0) {
|
||||||
fprintf(stderr, "remove_service failed to close service %s\n", service_name);
|
fprintf(stderr, "remove_service failed to close service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
printf("Service %s removed.\n", service_name);
|
printf("Service %s removed.\n", service_name);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,33 +138,33 @@ static void WINAPI
|
||||||
service_ctrl_handler(DWORD Opcode)
|
service_ctrl_handler(DWORD Opcode)
|
||||||
{
|
{
|
||||||
switch(Opcode) {
|
switch(Opcode) {
|
||||||
case SERVICE_CONTROL_PAUSE:
|
case SERVICE_CONTROL_PAUSE:
|
||||||
service_status.dwCurrentState = SERVICE_PAUSED;
|
service_status.dwCurrentState = SERVICE_PAUSED;
|
||||||
logerror("Pausing the service not supported");
|
logerror("Pausing the service not supported");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SERVICE_CONTROL_CONTINUE:
|
case SERVICE_CONTROL_CONTINUE:
|
||||||
logerror("Continuing the service not supported");
|
logerror("Continuing the service not supported");
|
||||||
service_status.dwCurrentState = SERVICE_RUNNING;
|
service_status.dwCurrentState = SERVICE_RUNNING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
logerror("Service stopping");
|
logerror("Service stopping");
|
||||||
empth_request_shutdown();
|
empth_request_shutdown();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SERVICE_CONTROL_INTERROGATE:
|
case SERVICE_CONTROL_INTERROGATE:
|
||||||
/* Fall through to send current status. */
|
/* Fall through to send current status. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logerror("Unrecognized opcode %ld in ServiceCtrlHandler",
|
logerror("Unrecognized opcode %ld in ServiceCtrlHandler",
|
||||||
Opcode);
|
Opcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send current status. */
|
/* Send current status. */
|
||||||
if (!SetServiceStatus (service_status_handle, &service_status))
|
if (!SetServiceStatus (service_status_handle, &service_status))
|
||||||
logerror("SetServiceStatus error %ld",GetLastError());
|
logerror("SetServiceStatus error %ld",GetLastError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,32 +173,32 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
{
|
{
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
service_status.dwServiceType = SERVICE_WIN32;
|
service_status.dwServiceType = SERVICE_WIN32;
|
||||||
service_status.dwCurrentState = SERVICE_START_PENDING;
|
service_status.dwCurrentState = SERVICE_START_PENDING;
|
||||||
service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
||||||
service_status.dwWin32ExitCode = 0;
|
service_status.dwWin32ExitCode = 0;
|
||||||
service_status.dwServiceSpecificExitCode = 0;
|
service_status.dwServiceSpecificExitCode = 0;
|
||||||
service_status.dwCheckPoint = 0;
|
service_status.dwCheckPoint = 0;
|
||||||
service_status.dwWaitHint = 0;
|
service_status.dwWaitHint = 0;
|
||||||
|
|
||||||
service_status_handle = RegisterServiceCtrlHandler(
|
service_status_handle = RegisterServiceCtrlHandler(
|
||||||
DEFAULT_SERVICE_NAME, service_ctrl_handler);
|
DEFAULT_SERVICE_NAME, service_ctrl_handler);
|
||||||
|
|
||||||
if (service_status_handle == (SERVICE_STATUS_HANDLE)0) {
|
if (service_status_handle == (SERVICE_STATUS_HANDLE)0) {
|
||||||
logerror("RegisterServiceCtrlHandler failed %lu\n", GetLastError());
|
logerror("RegisterServiceCtrlHandler failed %lu\n", GetLastError());
|
||||||
finish_server();
|
finish_server();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_server(0);
|
start_server(0);
|
||||||
|
|
||||||
/* Initialization complete - report running status. */
|
/* Initialization complete - report running status. */
|
||||||
service_status.dwCurrentState = SERVICE_RUNNING;
|
service_status.dwCurrentState = SERVICE_RUNNING;
|
||||||
service_status.dwCheckPoint = 0;
|
service_status.dwCheckPoint = 0;
|
||||||
service_status.dwWaitHint = 0;
|
service_status.dwWaitHint = 0;
|
||||||
|
|
||||||
if (!SetServiceStatus (service_status_handle, &service_status)) {
|
if (!SetServiceStatus (service_status_handle, &service_status)) {
|
||||||
logerror("SetServiceStatus error %ld\n", GetLastError());
|
logerror("SetServiceStatus error %ld\n", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
sig = empth_wait_for_signal();
|
sig = empth_wait_for_signal();
|
||||||
|
@ -215,8 +215,8 @@ stop_service(void)
|
||||||
logerror("Service stopped");
|
logerror("Service stopped");
|
||||||
service_status.dwWin32ExitCode = 0;
|
service_status.dwWin32ExitCode = 0;
|
||||||
service_status.dwCurrentState = SERVICE_STOPPED;
|
service_status.dwCurrentState = SERVICE_STOPPED;
|
||||||
service_status.dwCheckPoint = 0;
|
service_status.dwCheckPoint = 0;
|
||||||
service_status.dwWaitHint = 0;
|
service_status.dwWaitHint = 0;
|
||||||
|
|
||||||
if (!SetServiceStatus (service_status_handle, &service_status))
|
if (!SetServiceStatus (service_status_handle, &service_status))
|
||||||
logerror("Error while stopping service SetServiceStatus"
|
logerror("Error while stopping service SetServiceStatus"
|
||||||
|
|
|
@ -220,7 +220,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove_service_set)
|
if (remove_service_set)
|
||||||
return remove_service(service_name);
|
return remove_service(service_name);
|
||||||
if (install_service_set) {
|
if (install_service_set) {
|
||||||
program_name = _fullpath(NULL, argv[0], 0);
|
program_name = _fullpath(NULL, argv[0], 0);
|
||||||
if (config_file != NULL)
|
if (config_file != NULL)
|
||||||
|
@ -452,7 +452,7 @@ shutdwn(int sig)
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (daemonize)
|
if (daemonize)
|
||||||
stop_service();
|
stop_service();
|
||||||
#endif
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue