Crossfire Server, Trunk  R20576
Macros | Functions | Variables
win32.c File Reference

Windows-related compatibility functions. More...

#include <global.h>
#include <stdarg.h>
#include <malloc.h>
#include <string.h>
#include <errno.h>
#include <mmsystem.h>
#include <winsvc.h>
Include dependency graph for win32.c:

Go to the source code of this file.

Macros

#define SERVICE_DESCRIPTION   "Crossfire is a multiplayer online RPG game."
 Description of the service. More...
 
#define SERVICE_DISPLAY   "Crossfire server"
 Name that will appear in the service list. More...
 
#define SERVICE_NAME   "Crossfire"
 Internal name of the service. More...
 

Functions

int closedir (DIR *dp)
 Dispose of a directory handle. More...
 
int main (int argc, char **argv)
 
DIRopendir (const char *dir)
 Opens a directory for reading. More...
 
struct direntreaddir (DIR *dp)
 Returns the next file/directory for specified directory handle, obtained through a call to opendir(). More...
 
void rewinddir (DIR *dir_Info)
 Restart a directory listing from the beginning. More...
 
void service_handle (void)
 Service entry point. More...
 
void service_register (void)
 Registers the server to the service manager. More...
 
void service_unregister (void)
 Removes the Crossfire service from the service manager. More...
 
void WINAPI ServiceCtrlHandler (DWORD Opcode)
 Main service dispatch routine. More...
 
void WINAPI ServiceMain (DWORD argc, LPTSTR *argv)
 Main service entrypoint. More...
 

Variables

int bRunning
 Will be set to FALSE when the server should stop running because the service is turned off. More...
 
SERVICE_STATUS m_ServiceStatus
 Status when the server is started as a service. More...
 
SERVICE_STATUS_HANDLE m_ServiceStatusHandle
 Handle to the service the server is started as. More...
 

Detailed Description

Windows-related compatibility functions.

This file should probably not be used apart under Windows.

Definition in file win32.c.

Macro Definition Documentation

◆ SERVICE_DESCRIPTION

#define SERVICE_DESCRIPTION   "Crossfire is a multiplayer online RPG game."

Description of the service.

Definition at line 172 of file win32.c.

Referenced by service_register().

◆ SERVICE_DISPLAY

#define SERVICE_DISPLAY   "Crossfire server"

Name that will appear in the service list.

Definition at line 170 of file win32.c.

Referenced by service_register().

◆ SERVICE_NAME

#define SERVICE_NAME   "Crossfire"

Internal name of the service.

Definition at line 168 of file win32.c.

Referenced by service_handle(), service_register(), service_unregister(), and ServiceMain().

Function Documentation

◆ closedir()

int closedir ( DIR dp)

Dispose of a directory handle.

Parameters
dphandle to free. Will become invalid.
Returns
0.

Definition at line 108 of file win32.c.

References DIR::dir, and DIR::handle.

Referenced by command_players(), find_maps(), help_topics(), i18n_init(), initPlugins(), load_dir(), and remove_directory().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file cre.cpp.

References add_type_to_attribute(), type_definition::attribute_count, attribute_count, cached_pics, color_blocking, color_linked_exit, color_road, color_slowing, color_unlinked_exit, struct_map_list::count, create_destination(), created_pics, Settings::debug, type_definition::description, do_parameters(), do_regions_link, dump_unused_maps(), elevation_info, elevation_max, elevation_min, CRESettings::ensureOptions(), facesets, regiondef::fallback, fallback_type, find_maps(), first_map_path, first_region, fix_exits_to_tiled_maps(), fix_map_names(), fix_tiled_map(), fix_tiled_map_monsters(), force_pics, found_maps, found_maps_count, gdfaces, generate_index, generate_pics, get_attribute(), get_map_info(), get_region_struct(), get_type_definition(), index_letter, index_map, index_quest_template, index_region_region_template, index_region_template, index_template, infomap, CREPixmap::init(), init_archetypes(), init_artifacts(), init_formulae(), init_globals(), init_gods(), init_library(), init_map_list(), init_race_list(), init_readable(), init_regions(), is_valid_faceset(), jpeg_quality, level_map_template, level_template, level_value_template, list_unused_maps, regiondef::longname, map_exit_template, map_exit_to_template, map_limit, map_lore_template, map_monster_after_template, map_monster_before_template, map_monster_between_template, map_monster_one_template, map_no_exit_template, map_no_exit_to_template, map_no_lore_template, map_no_monster_template, map_no_quest_template, map_one_quest_template, map_template, map_with_exit_template, map_with_exit_to_template, map_with_quests_template, struct_map_list::maps, type_definition::name, regiondef::name, regiondef::next, nrofpixmaps, type_definition::number, OBJECT_TYPE_MAX, OF_JPG, output_extensions, output_format, pics_allocated, process_map(), quest_map_template, quest_template, rawmaps, read_client_images(), read_ignore_list(), read_line(), read_template(), read_type(), region_letter_template, region_map_template, region_template, root, settings, show_maps, snprintf, sortbyname(), strdup(), strdup_local, tileset, type_count, warn_no_path, world_exit_info, world_map, world_map_template, world_row_template, world_template, write_all_maps(), write_all_regions(), write_attribute_file(), write_attribute_index(), write_equipment_index(), write_maps_by_level(), write_maps_index(), write_npc_list(), write_quests_page(), write_race_index(), write_readable_list(), write_region_index(), write_regions_link(), write_slaying_info(), write_tiled_maps(), write_type_file(), write_type_index(), write_world_info(), write_world_map(), and yesno().

Referenced by ServiceCtrlHandler(), and ServiceMain().

Here is the caller graph for this function:

◆ opendir()

DIR* opendir ( const char *  dir)

Opens a directory for reading.

The handle should be disposed through closedir().

Parameters
dirdirectory path.
Returns
directory handle, NULL if failure.

Definition at line 37 of file win32.c.

References DIR::dir, DIR::fileinfo, DIR::finished, DIR::handle, DIR::offset, and strdup().

Referenced by command_players(), find_maps(), help_topics(), i18n_init(), initPlugins(), load_dir(), and remove_directory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdir()

struct dirent* readdir ( DIR dp)

Returns the next file/directory for specified directory handle, obtained through a call to opendir().

Parameters
dphandle.
Returns
next file/directory, NULL if end reached.

Definition at line 75 of file win32.c.

References dirent::d_ino, dirent::d_name, dirent::d_off, dirent::d_reclen, DIR::dent, DIR::fileinfo, DIR::finished, DIR::handle, and DIR::offset.

Referenced by command_players(), find_maps(), help_topics(), i18n_init(), initPlugins(), load_dir(), and remove_directory().

Here is the caller graph for this function:

◆ rewinddir()

void rewinddir ( DIR dir_Info)

Restart a directory listing from the beginning.

Parameters
dir_Infohandle to rewing.

Definition at line 124 of file win32.c.

References DIR::dir, DIR::fileinfo, DIR::finished, DIR::handle, and DIR::offset.

◆ service_handle()

void service_handle ( void  )

Service entry point.

Definition at line 343 of file win32.c.

References SERVICE_NAME, and ServiceMain().

Here is the call graph for this function:

◆ service_register()

void service_register ( void  )

Registers the server to the service manager.

See also
service_unregister().

Definition at line 180 of file win32.c.

References SERVICE_DESCRIPTION, SERVICE_DISPLAY, and SERVICE_NAME.

◆ service_unregister()

void service_unregister ( void  )

Removes the Crossfire service from the service manager.

See also
service_register().

Definition at line 225 of file win32.c.

References SERVICE_NAME.

◆ ServiceCtrlHandler()

void WINAPI ServiceCtrlHandler ( DWORD  Opcode)

Main service dispatch routine.

Parameters
Opcodeservice operation, like pause/start/stop.

Definition at line 267 of file win32.c.

References bRunning, llevInfo, LOG(), m_ServiceStatus, m_ServiceStatusHandle, and main().

Referenced by ServiceMain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ServiceMain()

void WINAPI ServiceMain ( DWORD  argc,
LPTSTR *  argv 
)

Main service entrypoint.

Parameters
argc
argvarguments to the service.

Definition at line 306 of file win32.c.

References bRunning, m_ServiceStatus, m_ServiceStatusHandle, main(), SERVICE_NAME, and ServiceCtrlHandler().

Referenced by service_handle().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ bRunning

int bRunning

Will be set to FALSE when the server should stop running because the service is turned off.

Definition at line 159 of file win32.c.

Referenced by server_main(), ServiceCtrlHandler(), and ServiceMain().

◆ m_ServiceStatus

SERVICE_STATUS m_ServiceStatus

Status when the server is started as a service.

Definition at line 164 of file win32.c.

Referenced by ServiceCtrlHandler(), and ServiceMain().

◆ m_ServiceStatusHandle

SERVICE_STATUS_HANDLE m_ServiceStatusHandle

Handle to the service the server is started as.

Definition at line 166 of file win32.c.

Referenced by ServiceCtrlHandler(), and ServiceMain().