Crossfire Server, Trunk  R20911
win32.h File Reference
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <winsock2.h>
#include <time.h>
#include <direct.h>
#include <math.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <process.h>
+ Include dependency graph for win32.h:

Go to the source code of this file.

Data Structures

struct  DIR
 
struct  dirent
 

Macros

#define __STDC__   1 /* something odd, CF want this, but don'T include it */
 
#define AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_
 
#define atoll   _atoi64
 
#define CONFDIR   "share"
 
#define CS_LOGSTATS
 
#define DATADIR   "share"
 
#define F_OK   6
 
#define FMT64   "I64d"
 
#define FMT64U   "I64u"
 
#define getpid()   _getpid()
 
#define HAVE_LIBCURL
 
#define HAVE_STRERROR
 
#define HAVE_STRTOL
 
#define inline   __inline
 
#define LIBDIR   "share"
 
#define LOCALDIR   "var"
 
#define MAXPATHLEN   256
 
#define mkdir(__a, __b)   mkdir(__a)
 
#define NAMLEN(dirent)   strlen((dirent)->d_name)
 
#define pclose(__a)   _pclose(__a)
 
#define PLUGIN_SUFFIX   ".dll"
 
#define popen(__a, __b)   _popen(__a, __b)
 
#define PREFIXDIR   ""
 
#define R_OK   6 /* for __access() */
 
#define S_IRGRP   0000040
 
#define S_IROTH   0000400
 
#define S_IRUSR   0000004
 
#define S_ISDIR(x)   (((x)&S_IFMT) == S_IFDIR)
 
#define S_ISGID   0002000
 
#define S_ISREG(x)   (((x)&S_IFMT) == S_IFREG)
 
#define S_IWGRP   0000020
 
#define S_IWOTH   0000200
 
#define S_IWUSR   0000002
 
#define sleep(x)   Sleep(x*1000)
 
#define snprintf   _snprintf
 
#define socklen_t   int /* Doesn't exist, just a plain int */
 
#define strtok_r(x, y, z)   strtok(x, y)
 
#define unlink(__a)   _unlink(__a)
 
#define VERSION   "1.9.1 (trunk) snapshot 20061229"
 
#define vsnprintf   _vsnprintf
 
#define WEXITSTATUS(x)   x
 
#define WIFEXITED(x)   1
 
#define WIN32_LEAN_AND_MEAN
 

Typedefs

typedef struct dirent dirent
 
typedef signed short int16_t
 
typedef signed int int32_t
 
typedef signed __int64 int64_t
 
typedef signed char int8_t
 
typedef unsigned short uint16_t
 
typedef unsigned int uint32_t
 
typedef unsigned __int64 uint64_t
 
typedef unsigned char uint8_t
 

Functions

int closedir (DIR *)
 
DIRopendir (const char *)
 
struct direntreaddir (DIR *)
 
void rewinddir (DIR *)
 
void service_handle ()
 
void service_register ()
 
void service_unregister ()
 
int strcasecmp (const char *s1, const char *s2)
 
int strncasecmp (const char *s1, const char *s2, int n)
 

Variables

int bRunning
 

Detailed Description

Structures and types used to implement opendir/readdir/closedir on Windows 95/NT and set the loe level defines.

Also some Windows-specific includes and tweaks.

Definition in file win32.h.

Macro Definition Documentation

◆ __STDC__

#define __STDC__   1 /* something odd, CF want this, but don'T include it */

Definition at line 43 of file win32.h.

◆ AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_

#define AFX_STDAFX_H__31666CA1_2474_11D5_AE6C_F07569C10000__INCLUDED_

Definition at line 13 of file win32.h.

◆ atoll

#define atoll   _atoi64

Definition at line 170 of file win32.h.

Referenced by init_experience(), and load_settings().

◆ CONFDIR

#define CONFDIR   "share"

Definition at line 100 of file win32.h.

◆ CS_LOGSTATS

#define CS_LOGSTATS

Definition at line 49 of file win32.h.

◆ DATADIR

#define DATADIR   "share"

Definition at line 98 of file win32.h.

◆ F_OK

#define F_OK   6

Definition at line 65 of file win32.h.

Referenced by tempnam().

◆ FMT64

#define FMT64   "I64d"

Definition at line 172 of file win32.h.

◆ FMT64U

#define FMT64U   "I64u"

Definition at line 173 of file win32.h.

◆ getpid

#define getpid ( )    _getpid()

Definition at line 58 of file win32.h.

Referenced by tempnam().

◆ HAVE_LIBCURL

#define HAVE_LIBCURL

Definition at line 144 of file win32.h.

◆ HAVE_STRERROR

#define HAVE_STRERROR

Definition at line 52 of file win32.h.

◆ HAVE_STRTOL

#define HAVE_STRTOL

Definition at line 51 of file win32.h.

◆ inline

#define inline   __inline

Definition at line 55 of file win32.h.

◆ LIBDIR

#define LIBDIR   "share"

Definition at line 99 of file win32.h.

Referenced by command_loadplugin(), and initPlugins().

◆ LOCALDIR

#define LOCALDIR   "var"

Definition at line 103 of file win32.h.

◆ MAXPATHLEN

#define MAXPATHLEN   256

Definition at line 50 of file win32.h.

◆ mkdir

#define mkdir (   __a,
  __b 
)    mkdir(__a)

Definition at line 57 of file win32.h.

Referenced by make_path_to_file(), and START_TEST().

◆ NAMLEN

#define NAMLEN (   dirent)    strlen((dirent)->d_name)

Definition at line 117 of file win32.h.

◆ pclose

#define pclose (   __a)    _pclose(__a)

Definition at line 60 of file win32.h.

◆ PLUGIN_SUFFIX

#define PLUGIN_SUFFIX   ".dll"

Definition at line 106 of file win32.h.

Referenced by initPlugins().

◆ popen

#define popen (   __a,
  __b 
)    _popen(__a, __b)

Definition at line 59 of file win32.h.

◆ PREFIXDIR

#define PREFIXDIR   ""

Definition at line 67 of file win32.h.

◆ R_OK

#define R_OK   6 /* for __access() */

Definition at line 64 of file win32.h.

Referenced by load_unique_objects().

◆ S_IRGRP

#define S_IRGRP   0000040

Definition at line 88 of file win32.h.

Referenced by check_path().

◆ S_IROTH

#define S_IROTH   0000400

Definition at line 85 of file win32.h.

Referenced by check_path().

◆ S_IRUSR

#define S_IRUSR   0000004

Definition at line 91 of file win32.h.

Referenced by check_path(), and tempnam_secure().

◆ S_ISDIR

#define S_ISDIR (   x)    (((x)&S_IFMT) == S_IFDIR)

◆ S_ISGID

#define S_ISGID   0002000

Definition at line 73 of file win32.h.

◆ S_ISREG

#define S_ISREG (   x)    (((x)&S_IFMT) == S_IFREG)

Definition at line 70 of file win32.h.

Referenced by check_path(), and find_help_file().

◆ S_IWGRP

#define S_IWGRP   0000020

Definition at line 79 of file win32.h.

Referenced by check_path().

◆ S_IWOTH

#define S_IWOTH   0000200

Definition at line 76 of file win32.h.

Referenced by check_path().

◆ S_IWUSR

#define S_IWUSR   0000002

Definition at line 82 of file win32.h.

Referenced by check_path(), and tempnam_secure().

◆ sleep

#define sleep (   x)    Sleep(x*1000)

Definition at line 150 of file win32.h.

Referenced by metaserver2_thread().

◆ snprintf

#define snprintf   _snprintf

Definition at line 46 of file win32.h.

Referenced by account_char_load(), account_char_save(), accounts_load(), accounts_save(), add_abilities(), add_author(), add_exit_to_item(), add_region_link(), add_required_parameter(), addConstants(), addSimpleConstants(), adjust_sign_msg(), animate_weapon(), apply_anim_suffix(), apply_builder_floor(), apply_builder_wall(), apply_changes_to_player(), apply_check_race_restrictions(), apply_race_and_class(), attack_message(), attempt_steal(), basic_emote(), CREMapInformationManager::browseMaps(), can_pay(), cast_consecrate(), cast_create_town_portal(), cfapi_map_set_map_property(), cfapi_object_get_property(), cfpython_globalEventListener(), cfpython_runPluginCommand(), change_book(), check_login(), check_path(), check_pick(), check_probe(), check_split_string(), checkbanned(), checkdm(), clean_path(), command_banish(), command_bowmode(), command_cointoss(), command_help(), command_loadtest(), command_me(), command_party(), command_players(), command_rename_item(), command_reset(), command_title(), command_use(), compute_face_name(), content_recipe_value(), convert_newline(), copy_message(), create_items_path(), create_overlay_pathname(), create_pathname(), create_player_cmd(), create_singularity(), create_template_pathname(), Crossfire_Object_Say(), dead_player(), deep_swamp_type_process(), delete_character(), describe_god(), display_motd(), display_who_entry(), do_map_index(), do_parameters(), do_region_kills(), do_tell(), do_tiled_map_picture(), dragon_ability_gain(), dragon_eat_flesh(), draw_one_high_score(), dump_alchemy(), dump_alchemy_costs(), dump_gods(), dump_unused_maps(), enter_fixed_template_map(), enter_random_map(), enter_random_template_map(), enter_unique_map(), esrv_draw_look(), esrv_send_inventory(), esrv_update_item(), eventListener(), examine(), find_help_file(), find_ingred_cost(), find_maps(), find_style(), fix_flesh_item(), fix_tiled_map(), food_type_apply(), forbid_play(), format_time(), generate_monster(), get_exit_seed(), get_levelnumber(), get_ob_diff(), get_who_escape_code_value(), getPluginProperty(), give_artifact_abilities(), god_enchants_weapon(), god_examines_item(), god_info_msg(), gravestone_text(), help_topics(), hiscore_init(), i18n_init(), infect_object(), init_anim(), init_artifacts(), init_attackmess(), init_book_archive(), init_clocks(), init_dynamic(), init_emergency_mappath(), init_experience(), init_formulae(), init_listening_socket(), init_msgfile(), init_races(), init_regions(), init_server(), init_startup(), init_stats(), initPlugins(), is_defined_recipe(), key_change_class(), key_confirm_quit(), keyplace(), kill_object(), kill_player(), kill_player_not_permadeath(), kill_player_permadeath(), knowledge_alchemy_attempt(), knowledge_alchemy_detail(), knowledge_god_face(), knowledge_item_can_be_used_alchemy(), knowledge_player_knows(), knowledge_read_player_data(), knowledge_write_player_data(), load_archetypes(), load_dir(), load_map_header(), load_materials(), load_quests_from_file(), load_settings(), load_treasures(), load_unique_objects(), QuestManager::loadQuestFile(), lock_and_hide_doors(), magic_wall(), main(), make_formula_book(), make_map_floor(), make_map_walls(), map_remove_unique_files(), mapfile_load(), metaserver2_init(), metaserver2_writer(), monster_communicate(), move_symptom(), msgfile_msg(), new_connection(), npcSay(), nstrtok(), object_split(), old_describe_monster(), party_form(), party_join(), party_leave(), party_set_password(), path_combine(), perceive_self(), pets_summon_golem(), pick_up_object(), place_chest(), place_exits(), place_monsters(), place_treasure(), player_get_title(), player_lvl_adj(), player_set_dragon_title(), player_set_own_title(), plugins_find_plugin(), poison_type_apply(), postInitPlugin(), potion_type_apply(), pray(), prepare_weapon(), print_los(), print_shop_string(), process_map(), put_doors(), put_score(), query_base_name(), query_short_name(), query_weight(), quest_read_player_data(), quest_write_player_data(), rangetostring(), read_bmap_names(), read_client_images(), read_face_data(), read_map_log(), read_smooth(), remove_directory(), replace(), reply_cmd(), resurrect_player(), ring_navar(), ring_scorn(), save_map(), save_player(), send_arch_info(), send_file(), send_new_char_info(), send_news(), send_rules(), set_title(), shop_describe(), show_matching_spells(), show_skills(), spell_consume_items(), ss_dump_statistics(), ss_dump_table(), START_TEST(), store_spell_expiry(), store_time(), strtoktolin(), tailor_god_spell(), teardown(), tempnam(), tiled_map_need_pic(), time_format_time(), unclean_path(), verify_player(), write_attribute_file(), write_attribute_index(), write_book_archive(), write_equipment_index(), write_map_log(), write_map_page(), write_maps_by_level(), write_note(), write_npc_list(), write_quests_page(), write_race_index(), write_readable_list(), write_region_index(), write_regions_link(), write_rune(), write_slaying_info(), write_todclock(), write_type_file(), write_type_index(), write_world_info(), and write_world_map().

◆ socklen_t

#define socklen_t   int /* Doesn't exist, just a plain int */

Definition at line 130 of file win32.h.

Referenced by init_connection(), and new_connection().

◆ strtok_r

#define strtok_r (   x,
  y,
 
)    strtok(x, y)

◆ unlink

◆ VERSION

#define VERSION   "1.9.1 (trunk) snapshot 20061229"

Definition at line 16 of file win32.h.

◆ vsnprintf

#define vsnprintf   _vsnprintf

◆ WEXITSTATUS

#define WEXITSTATUS (   x)    x

Definition at line 95 of file win32.h.

◆ WIFEXITED

#define WIFEXITED (   x)    1

Definition at line 94 of file win32.h.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 26 of file win32.h.

Typedef Documentation

◆ dirent

typedef struct dirent dirent

◆ int16_t

typedef signed short int16_t

Definition at line 160 of file win32.h.

◆ int32_t

typedef signed int int32_t

Definition at line 159 of file win32.h.

◆ int64_t

typedef signed __int64 int64_t

Definition at line 168 of file win32.h.

◆ int8_t

typedef signed char int8_t

Type definitions for fixed-size integer types. This is only required on Windows when compiling with Visual Studio because autoconf makes sure that certain types exist.

Definition at line 158 of file win32.h.

◆ uint16_t

typedef unsigned short uint16_t

Definition at line 163 of file win32.h.

◆ uint32_t

typedef unsigned int uint32_t

Definition at line 162 of file win32.h.

◆ uint64_t

typedef unsigned __int64 uint64_t

Definition at line 167 of file win32.h.

◆ uint8_t

typedef unsigned char uint8_t

Definition at line 161 of file win32.h.

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:

◆ 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.

◆ strcasecmp()

int strcasecmp ( const char *  s1,
const char *  s2 
)

◆ strncasecmp()

int strncasecmp ( const char *  s1,
const char *  s2,
int  n 
)

Case-insensitive comparaison of strings.

This seems to be lacking on some system.

Parameters
s1
s2strings to compare.
nmaximum number of chars to compare.
Returns
  • -1 if s1 is less than s2
  • 0 if s1 equals s2
  • 1 if s1 is greater than s2

Definition at line 224 of file porting.c.

References tolower.

Referenced by examine(), find_player_options(), find_skill_by_name(), init_experience(), init_stats(), learn_skill(), object_matches_string(), strcasestr(), and use_skill().

+ 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().