56 if (time_Info != NULL) {
57 time_Info->tv_sec = time(NULL);
58 time_Info->tv_usec = timeGetTime()*1000;
61 if (timezone_Info != NULL) {
84 filespec = malloc(strlen(dir)+2+1);
85 strcpy(filespec, dir);
86 index = strlen(filespec)-1;
87 if (index >= 0 && (filespec[index] ==
'/' || filespec[index] ==
'\\'))
88 filespec[index] =
'\0';
89 strcat(filespec,
"/*");
91 dp = (
DIR *)malloc(
sizeof(
DIR));
94 dp->
dir = strdup(dir);
96 if ((handle = _findfirst(filespec, &(dp->
fileinfo))) < 0) {
177 filespec = malloc(strlen(dir_Info->
dir)+2+1);
178 strcpy(filespec, dir_Info->
dir);
179 index = strlen(filespec)-1;
180 if (index >= 0 && (filespec[index] ==
'/' || filespec[index] ==
'\\'))
181 filespec[index] =
'\0';
182 strcat(filespec,
"/*");
184 if ((handle = _findfirst(filespec, &(dir_Info->
fileinfo))) < 0) {
185 if (errno == ENOENT) {
189 dir_Info->
handle = handle;
204 #ifndef PYTHON_PLUGIN_EXPORTS
209 #define SERVICE_NAME "Crossfire"
211 #define SERVICE_DISPLAY "Crossfire server"
213 #define SERVICE_DESCRIPTION "Crossfire is a multiplayer online RPG game."
223 HANDLE schSCManager, schService;
226 GetModuleFileName(NULL, strDir, 1024);
227 strcat(strDir,
" -srv");
229 schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
231 if (schSCManager == NULL) {
232 printf(
"openscmanager failed");
236 schService = CreateService(schSCManager,
240 SERVICE_WIN32_OWN_PROCESS,
241 SERVICE_DEMAND_START,
242 SERVICE_ERROR_NORMAL,
250 if (schService == NULL) {
251 printf(
"createservice failed");
255 ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &strDescription);
257 CloseServiceHandle(schService);
258 CloseServiceHandle(schSCManager);
270 schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
272 if (schSCManager == NULL) {
273 printf(
"open failed");
277 hService = OpenService(schSCManager,
SERVICE_NAME, SERVICE_ALL_ACCESS);
279 if (hService == NULL) {
280 printf(
"openservice failed");
284 if (DeleteService(hService) == 0) {
285 printf(
"Delete failed");
289 if (CloseServiceHandle(hService) == 0) {
290 printf(
"close failed");
294 if (!CloseServiceHandle(schSCManager)) {
295 printf(
"close schSCManager failed");
310 case SERVICE_CONTROL_PAUSE:
314 case SERVICE_CONTROL_CONTINUE:
318 case SERVICE_CONTROL_STOP:
332 case SERVICE_CONTROL_INTERROGATE:
338 extern int main(
int argc,
char **argv);
351 GetModuleFileName(NULL, strDir, 1024);
352 strSlash = strrchr(strDir,
'\\');
385 SERVICE_TABLE_ENTRY DispatchTable[] = {
389 StartServiceCtrlDispatcher(DispatchTable);
#define SERVICE_DESCRIPTION
DIR * opendir(const char *dir)
int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info)
void service_unregister()
void WINAPI ServiceCtrlHandler(DWORD Opcode)
int main(int argc, char **argv)
char d_name[_MAX_FNAME+1]
SERVICE_STATUS m_ServiceStatus
struct dirent * readdir(DIR *dp)
void LOG(LogLevel logLevel, const char *format,...)
struct _finddata_t fileinfo
SERVICE_STATUS_HANDLE m_ServiceStatusHandle
void rewinddir(DIR *dir_Info)
void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)