(main,install_service) [_WIN32]: Move the construction of full path names

for program file and econfig file for installing a service to main()
instead of install_service(). This is because current directory
information is lost because of the use of chdir() to move the current
directory to the datadir.  This change also fixed the setting of a
relative directory for the econfig file.  The service starts in an
arbitrary directory so a relative path can not used by the service.
This commit is contained in:
Ron Koenderink 2005-05-03 00:06:10 +00:00
parent 9f27f5b02a
commit 921fba6532
2 changed files with 12 additions and 16 deletions

View file

@ -117,6 +117,7 @@ main(int argc, char **argv)
int flags = 0;
#if defined(_WIN32)
int install_service_set = 0;
char *program_name = NULL;
char *service_name = NULL;
int remove_service_set = 0;
#endif
@ -197,6 +198,11 @@ main(int argc, char **argv)
#if defined(_WIN32)
if (remove_service_set)
return remove_service(service_name);
if (install_service_set) {
program_name = _fullpath(NULL, argv[0], 0);
if (config_file != NULL)
config_file = _fullpath(NULL, config_file, 0);
}
#endif /* _WIN32 */
if (emp_config(config_file) < 0)
@ -208,7 +214,7 @@ main(int argc, char **argv)
#if defined(_WIN32)
if (install_service_set)
return install_service(argv[0], service_name, config_file);
return install_service(program_name, service_name, config_file);
#endif /* _WIN32 */
init_server();