43 filespec = malloc(strlen(dir)+2+1);
44 strcpy(filespec, dir);
45 index = strlen(filespec)-1;
46 if (index >= 0 && (filespec[index] ==
'/' || filespec[index] ==
'\\'))
47 filespec[index] =
'\0';
48 strcat(filespec,
"/*");
50 dp = (
DIR *)malloc(
sizeof(
DIR));
55 if ((handle = _findfirst(filespec, &(dp->
fileinfo))) < 0) {
134 filespec = malloc(strlen(dir_Info->
dir)+2+1);
135 strcpy(filespec, dir_Info->
dir);
136 index = strlen(filespec)-1;
137 if (index >= 0 && (filespec[index] ==
'/' || filespec[index] ==
'\\'))
138 filespec[index] =
'\0';
139 strcat(filespec,
"/*");
141 if ((handle = _findfirst(filespec, &(dir_Info->
fileinfo))) < 0) {
142 if (errno == ENOENT) {
146 dir_Info->
handle = handle;
161 #ifndef PYTHON_PLUGIN_EXPORTS 168 #define SERVICE_NAME "Crossfire" 170 #define SERVICE_DISPLAY "Crossfire server" 172 #define SERVICE_DESCRIPTION "Crossfire is a multiplayer online RPG game." 182 HANDLE schSCManager, schService;
185 GetModuleFileName(NULL, strDir, 1024);
186 strcat(strDir,
" -srv");
188 schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
190 if (schSCManager == NULL) {
191 printf(
"openscmanager failed");
195 schService = CreateService(schSCManager,
199 SERVICE_WIN32_OWN_PROCESS,
200 SERVICE_DEMAND_START,
201 SERVICE_ERROR_NORMAL,
209 if (schService == NULL) {
210 printf(
"createservice failed");
214 ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &strDescription);
216 CloseServiceHandle(schService);
217 CloseServiceHandle(schSCManager);
229 schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
231 if (schSCManager == NULL) {
232 printf(
"open failed");
236 hService = OpenService(schSCManager,
SERVICE_NAME, SERVICE_ALL_ACCESS);
238 if (hService == NULL) {
239 printf(
"openservice failed");
243 if (DeleteService(hService) == 0) {
244 printf(
"Delete failed");
248 if (CloseServiceHandle(hService) == 0) {
249 printf(
"close failed");
253 if (!CloseServiceHandle(schSCManager)) {
254 printf(
"close schSCManager failed");
269 case SERVICE_CONTROL_PAUSE:
273 case SERVICE_CONTROL_CONTINUE:
277 case SERVICE_CONTROL_STOP:
291 case SERVICE_CONTROL_INTERROGATE:
297 extern int main(
int argc,
char **argv);
310 GetModuleFileName(NULL, strDir, 1024);
311 strSlash = strrchr(strDir,
'\\');
344 SERVICE_TABLE_ENTRY DispatchTable[] = {
348 StartServiceCtrlDispatcher(DispatchTable);
#define SERVICE_DESCRIPTION
DIR * opendir(const char *dir)
void service_register(void)
void WINAPI ServiceCtrlHandler(DWORD Opcode)
int main(int argc, char **argv)
char d_name[_MAX_FNAME+1]
void service_unregister(void)
SERVICE_STATUS m_ServiceStatus
struct dirent * readdir(DIR *dp)
char * strdup(const char *str)
void LOG(LogLevel logLevel, const char *format,...)
struct _finddata_t fileinfo
SERVICE_STATUS_HANDLE m_ServiceStatusHandle
void service_handle(void)
void rewinddir(DIR *dir_Info)
void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)