Ruby  1.9.3p547(2014-05-14revision45962)
Data Structures | Macros | Typedefs | Functions | Variables
win32.c File Reference
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "dln.h"
#include <fcntl.h>
#include <process.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <windows.h>
#include <winbase.h>
#include <wincon.h>
#include <share.h>
#include <shlobj.h>
#include <mbstring.h>
#include "ruby/win32.h"
#include "win32/dir.h"
#include <sys/timeb.h>
Include dependency graph for win32.c:

Go to the source code of this file.

Data Structures

struct  ChildRecord
 
struct  _NtCmdLineElement
 
struct  ioinfo
 
struct  WSAMSG
 
struct  asynchronous_arg_t
 

Macros

#define isdirsep(x)   ((x) == '/' || (x) == '\\')
 
#define enough_to_get(n)   (--(n) >= 0)
 
#define enough_to_put(n)   (--(n) >= 0)
 
#define Debug(something)   /* nothing */
 
#define TO_SOCKET(x)   _get_osfhandle(x)
 
#define RUBY_CRITICAL(expr)   do { expr; } while (0)
 
#define ERROR_PIPE_LOCAL   229L
 
#define map_errno   rb_w32_map_errno
 
#define IsWinNT()   rb_w32_iswinnt()
 
#define IsWin95()   rb_w32_iswin95()
 
#define IfWin95(win95, winnt)   (winnt)
 
#define LK_ERR(f, i)
 
#define LK_LEN   ULONG_MAX
 
#define CSIDL_LOCAL_APPDATA   28
 
#define CSIDL_COMMON_APPDATA   35
 
#define CSIDL_WINDOWS   36
 
#define CSIDL_SYSTEM   37
 
#define CSIDL_PROFILE   40
 
#define numberof(array)   (sizeof(array) / sizeof(*array))
 
#define env   wk.val
 
#define set_env_val(vname)
 
#define MAXCHILDNUM   256 /* max num of child processes */
 
#define FOREACH_CHILD(v)
 
#define END_FOREACH_CHILD   } while (0)
 
#define MAXPATHLEN   512
 
#define STRNDUPV(ptr, v, src, len)   (((char *)memcpy(((ptr) = ALLOCV((v), (len) + 1)), (src), (len)))[len] = 0)
 
#define acp_to_wstr(str, plen)   mbstr_to_wstr(CP_ACP, str, -1, plen)
 
#define wstr_to_acp(str, plen)   wstr_to_mbstr(CP_ACP, str, -1, plen)
 
#define filecp_to_wstr(str, plen)   mbstr_to_wstr(filecp(), str, -1, plen)
 
#define wstr_to_filecp(str, plen)   wstr_to_mbstr(filecp(), str, -1, plen)
 
#define utf8_to_wstr(str, plen)   mbstr_to_wstr(CP_UTF8, str, -1, plen)
 
#define wstr_to_utf8(str, plen)   wstr_to_mbstr(CP_UTF8, str, -1, plen)
 
#define NTGLOB   0x1
 
#define NTMALLOC   0x2
 
#define NTSTRING   0x4
 
#define PATHLEN   1024
 
#define GetBit(bits, i)   ((bits)[(i) / CHAR_BIT] & (1 << (i) % CHAR_BIT))
 
#define SetBit(bits, i)   ((bits)[(i) / CHAR_BIT] |= (1 << (i) % CHAR_BIT))
 
#define BitOfIsDir(n)   ((n) * 2)
 
#define BitOfIsRep(n)   ((n) * 2 + 1)
 
#define DIRENT_PER_CHAR   (CHAR_BIT / 2)
 
#define MTHREAD_ONLY(x)
 
#define STHREAD_ONLY(x)   x
 
#define _CRTIMP   __declspec(dllimport)
 
#define IOINFO_L2E   5
 
#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
 
#define _pioinfo(i)   ((ioinfo*)((char*)(__pioinfo[i >> IOINFO_L2E]) + (i & (IOINFO_ARRAY_ELTS - 1)) * (sizeof(ioinfo) + pioinfo_extra)))
 
#define _osfhnd(i)   (_pioinfo(i)->osfhnd)
 
#define _osfile(i)   (_pioinfo(i)->osfile)
 
#define _pipech(i)   (_pioinfo(i)->pipech)
 
#define pioinfo_extra   0
 
#define _set_osfhnd(fh, osfh)   (void)(_osfhnd(fh) = osfh)
 
#define _set_osflags(fh, flags)   (_osfile(fh) = (flags))
 
#define FOPEN   0x01 /* file handle open */
 
#define FEOFLAG   0x02 /* end of file has been encountered */
 
#define FPIPE   0x08 /* file handle refers to a pipe */
 
#define FNOINHERIT   0x10 /* file handle opened O_NOINHERIT */
 
#define FAPPEND   0x20 /* file handle opened O_APPEND */
 
#define FDEV   0x40 /* file handle refers to device */
 
#define FTEXT   0x80 /* file handle is in text mode */
 
#define open_null(fd)
 
#define ROOT_UID   0
 
#define ROOT_GID   0
 
#define WSAID_WSARECVMSG   {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
 
#define WSAID_WSASENDMSG   {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}
 
#define msghdr_to_wsamsg(msg, wsamsg)
 
#define WNOHANG   -1
 
#define COPY_STAT(src, dest, size_cast)
 
#define win95_stat(path, st)   -1
 
#define yield_once()   Sleep(0)
 
#define yield_until(condition)   do yield_once(); while (!(condition))
 
#define INVALID_SET_FILE_POINTER   ((DWORD)-1)
 

Typedefs

typedef BOOL(WINAPI * cancel_io_t )(HANDLE)
 
typedef struct _NtCmdLineElement NtCmdLineElement
 

Functions

static struct ChildRecordCreateChild (const WCHAR *, const WCHAR *, SECURITY_ATTRIBUTES *, HANDLE, HANDLE, HANDLE, DWORD)
 
static int has_redirection (const char *)
 
int rb_w32_wait_events (HANDLE *events, int num, DWORD timeout)
 
static int rb_w32_open_osfhandle (intptr_t osfhandle, int flags)
 
static int wstati64 (const WCHAR *path, struct stati64 *st)
 
VALUE rb_w32_conv_from_wchar (const WCHAR *wstr, rb_encoding *enc)
 
int rb_w32_map_errno (DWORD winerr)
 
static void get_version (void)
 
DWORD rb_w32_osver (void)
 
HANDLE GetCurrentThreadHandle (void)
 
static uintptr_t flock_winnt (uintptr_t self, int argc, uintptr_t *argv)
 
int flock (int fd, int oper)
 
static WCHAR * translate_wchar (WCHAR *p, int from, int to)
 
static char * translate_char (char *p, int from, int to)
 
static BOOL get_special_folder (int n, WCHAR *env)
 
static void regulate_path (WCHAR *path)
 
static FARPROC get_proc_address (const char *module, const char *func, HANDLE *mh)
 
static UINT get_system_directory (WCHAR *path, UINT len)
 
VALUE rb_w32_special_folder (int type)
 
UINT rb_w32_system_tmpdir (WCHAR *path, UINT len)
 
static void init_env (void)
 
static void init_func (void)
 
static void init_stdhandle (void)
 
static void exit_handler (void)
 
static void StartSockets (void)
 
void rb_w32_sysinit (int *argc, char ***argv)
 
char * getlogin (void)
 
static struct ChildRecordFindChildSlot (rb_pid_t pid)
 
static struct ChildRecordFindChildSlotByHandle (HANDLE h)
 
static void CloseChildHandle (struct ChildRecord *child)
 
static struct ChildRecordFindFreeChildSlot (void)
 
static int internal_match (const void *key, const void *elem)
 
static int is_command_com (const char *interp)
 
static int internal_cmd_match (const char *cmdname, int nt)
 
static int is_internal_cmd (const char *cmd, int nt)
 
SOCKET rb_w32_get_osfhandle (int fh)
 
static int join_argv (char *cmd, char *const *argv, BOOL escape)
 
static int check_spawn_mode (int mode)
 
static rb_pid_t child_result (struct ChildRecord *child, int mode)
 
static int is_batch (const char *cmd)
 
static UINT filecp (void)
 
static WCHAR * mbstr_to_wstr (UINT, const char *, int, long *)
 
static char * wstr_to_mbstr (UINT, const WCHAR *, int, long *)
 
rb_pid_t rb_w32_spawn (int mode, const char *cmd, const char *prog)
 
rb_pid_t rb_w32_aspawn_flags (int mode, const char *prog, char *const *argv, DWORD flags)
 
rb_pid_t rb_w32_aspawn (int mode, const char *prog, char *const *argv)
 
static int insert (const char *path, VALUE vinfo, void *enc)
 
static NtCmdLineElement ** cmdglob (NtCmdLineElement *patt, NtCmdLineElement **tail)
 
static char * skipspace (char *ptr)
 
int rb_w32_cmdvector (const char *cmd, char ***vec)
 
static HANDLE open_dir_handle (const WCHAR *filename, WIN32_FIND_DATAW *fd)
 
static DIRopendir_internal (WCHAR *wpath, const char *filename)
 
DIRrb_w32_opendir (const char *filename)
 
DIRrb_w32_uopendir (const char *filename)
 
static void move_to_next_entry (DIR *dirp)
 
static BOOL win32_direct_conv (const WCHAR *file, struct direct *entry, rb_encoding *dummy)
 
char * rb_w32_conv_from_wstr (const WCHAR *wstr, long *lenp, rb_encoding *enc)
 
static BOOL ruby_direct_conv (const WCHAR *file, struct direct *entry, rb_encoding *enc)
 
static struct directreaddir_internal (DIR *dirp, BOOL(*conv)(const WCHAR *, struct direct *, rb_encoding *), rb_encoding *enc)
 
struct directrb_w32_readdir (DIR *dirp)
 
struct directrb_w32_readdir_with_enc (DIR *dirp, rb_encoding *enc)
 
long rb_w32_telldir (DIR *dirp)
 
void rb_w32_seekdir (DIR *dirp, long loc)
 
void rb_w32_rewinddir (DIR *dirp)
 
void rb_w32_closedir (DIR *dirp)
 
static int is_socket (SOCKET)
 
static int is_console (SOCKET)
 
int rb_w32_io_cancelable_p (int fd)
 
int rb_w32_is_socket (int fd)
 
char * rb_w32_strerror (int e)
 
rb_uid_t getuid (void)
 
rb_uid_t geteuid (void)
 
rb_gid_t getgid (void)
 
rb_gid_t getegid (void)
 
int setuid (rb_uid_t uid)
 
int setgid (rb_gid_t gid)
 
int ioctl (int i, int u,...)
 
void rb_w32_fdset (int fd, fd_set *set)
 
void rb_w32_fdclr (int fd, fd_set *set)
 
int rb_w32_fdisset (int fd, fd_set *set)
 
void rb_w32_fd_copy (rb_fdset_t *dst, const fd_set *src, int max)
 
void rb_w32_fd_dup (rb_fdset_t *dst, const rb_fdset_t *src)
 
static int extract_fd (rb_fdset_t *dst, fd_set *src, int(*func)(SOCKET))
 
static int copy_fd (fd_set *dst, fd_set *src)
 
static int is_not_socket (SOCKET sock)
 
static int is_pipe (SOCKET sock)
 
static int is_readable_pipe (SOCKET sock)
 
static int is_readable_console (SOCKET sock)
 
static int is_invalid_handle (SOCKET sock)
 
static int do_select (int nfds, fd_set *rd, fd_set *wr, fd_set *ex, struct timeval *timeout)
 
int rb_w32_time_subtract (struct timeval *rest, const struct timeval *wait)
 
static int compare (const struct timeval *t1, const struct timeval *t2)
 
int rb_w32_check_interrupt (void *)
 
int rb_w32_select_with_thread (int nfds, fd_set *rd, fd_set *wr, fd_set *ex, struct timeval *timeout, void *th)
 
int WSAAPI rb_w32_select (int nfds, fd_set *rd, fd_set *wr, fd_set *ex, struct timeval *timeout)
 
static FARPROC get_wsa_extension_function (SOCKET s, GUID *guid)
 
int WSAAPI rb_w32_accept (int s, struct sockaddr *addr, int *addrlen)
 
int WSAAPI rb_w32_bind (int s, const struct sockaddr *addr, int addrlen)
 
int WSAAPI rb_w32_connect (int s, const struct sockaddr *addr, int addrlen)
 
int WSAAPI rb_w32_getpeername (int s, struct sockaddr *addr, int *addrlen)
 
int WSAAPI rb_w32_getsockname (int s, struct sockaddr *addr, int *addrlen)
 
int WSAAPI rb_w32_getsockopt (int s, int level, int optname, char *optval, int *optlen)
 
int WSAAPI rb_w32_ioctlsocket (int s, long cmd, u_long *argp)
 
int WSAAPI rb_w32_listen (int s, int backlog)
 
static int finish_overlapped_socket (SOCKET s, WSAOVERLAPPED *wol, int result, DWORD *len, DWORD size)
 
static int overlapped_socket_io (BOOL input, int fd, char *buf, int len, int flags, struct sockaddr *addr, int *addrlen)
 
int WSAAPI rb_w32_recv (int fd, char *buf, int len, int flags)
 
int WSAAPI rb_w32_recvfrom (int fd, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
 
int WSAAPI rb_w32_send (int fd, const char *buf, int len, int flags)
 
int WSAAPI rb_w32_sendto (int fd, const char *buf, int len, int flags, const struct sockaddr *to, int tolen)
 
int recvmsg (int fd, struct msghdr *msg, int flags)
 
int sendmsg (int fd, const struct msghdr *msg, int flags)
 
int WSAAPI rb_w32_setsockopt (int s, int level, int optname, const char *optval, int optlen)
 
int WSAAPI rb_w32_shutdown (int s, int how)
 
static SOCKET open_ifs_socket (int af, int type, int protocol)
 
int WSAAPI rb_w32_socket (int af, int type, int protocol)
 
struct hostent *WSAAPI rb_w32_gethostbyaddr (const char *addr, int len, int type)
 
struct hostent *WSAAPI rb_w32_gethostbyname (const char *name)
 
int WSAAPI rb_w32_gethostname (char *name, int len)
 
struct protoent *WSAAPI rb_w32_getprotobyname (const char *name)
 
struct protoent *WSAAPI rb_w32_getprotobynumber (int num)
 
struct servent *WSAAPI rb_w32_getservbyname (const char *name, const char *proto)
 
struct servent *WSAAPI rb_w32_getservbyport (int port, const char *proto)
 
static int socketpair_internal (int af, int type, int protocol, SOCKET *sv)
 
int rb_w32_socketpair (int af, int type, int protocol, int *sv)
 
void endhostent (void)
 
void endnetent (void)
 
void endprotoent (void)
 
void endservent (void)
 
struct netent * getnetent (void)
 
struct netent * getnetbyaddr (long net, int type)
 
struct netent * getnetbyname (const char *name)
 
struct protoent * getprotoent (void)
 
struct servent * getservent (void)
 
void sethostent (int stayopen)
 
void setnetent (int stayopen)
 
void setprotoent (int stayopen)
 
void setservent (int stayopen)
 
int fcntl (int fd, int cmd,...)
 
static rb_pid_t poll_child_status (struct ChildRecord *child, int *stat_loc)
 
rb_pid_t waitpid (rb_pid_t pid, int *stat_loc, int options)
 
static int filetime_to_timeval (const FILETIME *ft, struct timeval *tv)
 
int _cdecl gettimeofday (struct timeval *tv, struct timezone *tz)
 
char * rb_w32_getcwd (char *buffer, int size)
 
int chown (const char *path, int owner, int group)
 
int rb_w32_uchown (const char *path, int owner, int group)
 
int kill (int pid, int sig)
 
static int wlink (const WCHAR *from, const WCHAR *to)
 
int rb_w32_ulink (const char *from, const char *to)
 
int link (const char *from, const char *to)
 
int wait (int *status)
 
char * rb_w32_getenv (const char *name)
 
static int wrename (const WCHAR *oldpath, const WCHAR *newpath)
 
int rb_w32_urename (const char *from, const char *to)
 
int rb_w32_rename (const char *from, const char *to)
 
static int isUNCRoot (const WCHAR *path)
 
static time_t filetime_to_unixtime (const FILETIME *ft)
 
int rb_w32_fstat (int fd, struct stat *st)
 
int rb_w32_fstati64 (int fd, struct stati64 *st)
 
static unsigned fileattr_to_unixmode (DWORD attr, const WCHAR *path)
 
static int check_valid_dir (const WCHAR *path)
 
static int winnt_stat (const WCHAR *path, struct stati64 *st)
 
int rb_w32_stat (const char *path, struct stat *st)
 
int rb_w32_ustati64 (const char *path, struct stati64 *st)
 
int rb_w32_stati64 (const char *path, struct stati64 *st)
 
int rb_w32_access (const char *path, int mode)
 
int rb_w32_uaccess (const char *path, int mode)
 
static int rb_chsize (HANDLE h, off_t size)
 
int rb_w32_truncate (const char *path, off_t length)
 
int rb_w32_ftruncate (int fd, off_t length)
 
int fseeko (FILE *stream, off_t offset, int whence)
 
off_t rb_w32_ftello (FILE *stream)
 
static long filetime_to_clock (FILETIME *ft)
 
int rb_w32_times (struct tms *tmbuf)
 
static void catch_interrupt (void)
 
int rb_w32_getc (FILE *stream)
 
int rb_w32_putc (int c, FILE *stream)
 
static DWORD WINAPI call_asynchronous (PVOID argp)
 
uintptr_t rb_w32_asynchronize (asynchronous_func_t func, uintptr_t self, int argc, uintptr_t *argv, uintptr_t intrval)
 
char ** rb_w32_get_environ (void)
 
void rb_w32_free_environ (char **env)
 
rb_pid_t rb_w32_getpid (void)
 
rb_pid_t rb_w32_getppid (void)
 
int rb_w32_uopen (const char *file, int oflag,...)
 
int rb_w32_open (const char *file, int oflag,...)
 
int rb_w32_wopen (const WCHAR *file, int oflag,...)
 
int rb_w32_fclose (FILE *fp)
 
int rb_w32_pipe (int fds[2])
 
int rb_w32_close (int fd)
 
static int setup_overlapped (OVERLAPPED *ol, int fd)
 
static void finish_overlapped (OVERLAPPED *ol, int fd, DWORD size)
 
ssize_t rb_w32_read (int fd, void *buf, size_t size)
 
ssize_t rb_w32_write (int fd, const void *buf, size_t size)
 
long rb_w32_write_console (uintptr_t strarg, int fd)
 
static int unixtime_to_filetime (time_t time, FILETIME *ft)
 
static int wutime (const WCHAR *path, const struct utimbuf *times)
 
int rb_w32_uutime (const char *path, const struct utimbuf *times)
 
int rb_w32_utime (const char *path, const struct utimbuf *times)
 
int rb_w32_uchdir (const char *path)
 
static int wmkdir (const WCHAR *wpath, int mode)
 
int rb_w32_umkdir (const char *path, int mode)
 
int rb_w32_mkdir (const char *path, int mode)
 
static int wrmdir (const WCHAR *wpath)
 
int rb_w32_rmdir (const char *path)
 
int rb_w32_urmdir (const char *path)
 
static int wunlink (const WCHAR *path)
 
int rb_w32_uunlink (const char *path)
 
int rb_w32_unlink (const char *path)
 
int rb_w32_uchmod (const char *path, int mode)
 
int rb_w32_isatty (int fd)
 
int signbit (double x)
 
char *WSAAPI rb_w32_inet_ntop (int af, void *addr, char *numaddr, size_t numaddr_len)
 
char rb_w32_fd_is_text (int fd)
 

Variables

struct {
   DWORD   winerr
 
   int   err
 
errmap []
 
static const char * NTLoginName
 
static OSVERSIONINFO osver
 
static cancel_io_t cancel_io = NULL
 
static CRITICAL_SECTION select_mutex
 
static int NtSocketsInitialized = 0
 
static st_tablesocklist = NULL
 
static char * envarea
 
static struct ChildRecord ChildRecord [MAXCHILDNUM]
 
static const char *const szInternalCmds []
 
EXTERN_C _CRTIMP ioinfo__pioinfo []
 

Macro Definition Documentation

#define _CRTIMP   __declspec(dllimport)

Definition at line 2037 of file win32.c.

#define _osfhnd (   i)    (_pioinfo(i)->osfhnd)
#define _osfile (   i)    (_pioinfo(i)->osfile)
#define _pioinfo (   i)    ((ioinfo*)((char*)(__pioinfo[i >> IOINFO_L2E]) + (i & (IOINFO_ARRAY_ELTS - 1)) * (sizeof(ioinfo) + pioinfo_extra)))
#define _pipech (   i)    (_pioinfo(i)->pipech)

Definition at line 2048 of file win32.c.

#define _set_osfhnd (   fh,
  osfh 
)    (void)(_osfhnd(fh) = osfh)
#define _set_osflags (   fh,
  flags 
)    (_osfile(fh) = (flags))

Definition at line 2076 of file win32.c.

Referenced by rb_w32_open_osfhandle(), rb_w32_pipe(), rb_w32_read(), and rb_w32_wopen().

#define acp_to_wstr (   str,
  plen 
)    mbstr_to_wstr(CP_ACP, str, -1, plen)

Definition at line 1104 of file win32.c.

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

#define BitOfIsDir (   n)    ((n) * 2)

Definition at line 1658 of file win32.c.

Referenced by opendir_internal(), and readdir_internal().

#define BitOfIsRep (   n)    ((n) * 2 + 1)

Definition at line 1659 of file win32.c.

Referenced by opendir_internal(), and readdir_internal().

#define COPY_STAT (   src,
  dest,
  size_cast 
)
Value:
do { \
(dest).st_dev = (src).st_dev; \
(dest).st_ino = (src).st_ino; \
(dest).st_mode = (src).st_mode; \
(dest).st_nlink = (src).st_nlink; \
(dest).st_uid = (src).st_uid; \
(dest).st_gid = (src).st_gid; \
(dest).st_rdev = (src).st_rdev; \
(dest).st_size = size_cast(src).st_size; \
(dest).st_atime = (src).st_atime; \
(dest).st_mtime = (src).st_mtime; \
(dest).st_ctime = (src).st_ctime; \
} while (0)

Definition at line 4116 of file win32.c.

Referenced by rb_w32_fstati64(), and rb_w32_stat().

#define CSIDL_COMMON_APPDATA   35

Definition at line 416 of file win32.c.

Referenced by etc_sysconfdir().

#define CSIDL_LOCAL_APPDATA   28

Definition at line 413 of file win32.c.

Referenced by rb_w32_system_tmpdir().

#define CSIDL_PROFILE   40

Definition at line 425 of file win32.c.

Referenced by init_env().

#define CSIDL_SYSTEM   37

Definition at line 422 of file win32.c.

#define CSIDL_WINDOWS   36

Definition at line 419 of file win32.c.

#define Debug (   something)    /* nothing */

Definition at line 61 of file win32.c.

Referenced by rb_w32_asynchronize().

#define DIRENT_PER_CHAR   (CHAR_BIT / 2)

Definition at line 1660 of file win32.c.

Referenced by opendir_internal().

#define END_FOREACH_CHILD   } while (0)

Definition at line 718 of file win32.c.

Referenced by FindChildSlot(), FindChildSlotByHandle(), FindFreeChildSlot(), and waitpid().

#define enough_to_get (   n)    (--(n) >= 0)

Definition at line 54 of file win32.c.

Referenced by rb_w32_getc().

#define enough_to_put (   n)    (--(n) >= 0)

Definition at line 55 of file win32.c.

Referenced by rb_w32_putc().

#define env   wk.val
#define ERROR_PIPE_LOCAL   229L
#define FAPPEND   0x20 /* file handle opened O_APPEND */

Definition at line 2082 of file win32.c.

Referenced by rb_w32_open_osfhandle(), rb_w32_wopen(), and setup_overlapped().

#define FDEV   0x40 /* file handle refers to device */
#define FEOFLAG   0x02 /* end of file has been encountered */

Definition at line 2079 of file win32.c.

Referenced by rb_w32_read(), and rb_w32_write().

#define filecp_to_wstr (   str,
  plen 
)    mbstr_to_wstr(filecp(), str, -1, plen)
#define FNOINHERIT   0x10 /* file handle opened O_NOINHERIT */

Definition at line 2081 of file win32.c.

Referenced by rb_w32_open_osfhandle(), rb_w32_pipe(), and rb_w32_wopen().

#define FOPEN   0x01 /* file handle open */

Definition at line 2078 of file win32.c.

Referenced by rb_w32_open_osfhandle(), rb_w32_pipe(), and rb_w32_wopen().

#define FOREACH_CHILD (   v)
Value:
do { \
struct ChildRecord* v; \
for (v = ChildRecord; v < ChildRecord + sizeof(ChildRecord) / sizeof(ChildRecord[0]); ++v)
for(i=0;i< args;i++)
Definition: win32ole.c:780
static struct ChildRecord ChildRecord[MAXCHILDNUM]
v
Definition: win32ole.c:790

Definition at line 715 of file win32.c.

Referenced by FindChildSlot(), FindChildSlotByHandle(), FindFreeChildSlot(), and waitpid().

#define FPIPE   0x08 /* file handle refers to a pipe */
#define FTEXT   0x80 /* file handle is in text mode */

Definition at line 2084 of file win32.c.

Referenced by rb_w32_fd_is_text(), rb_w32_open_osfhandle(), rb_w32_read(), and rb_w32_write().

#define GetBit (   bits,
  i 
)    ((bits)[(i) / CHAR_BIT] & (1 << (i) % CHAR_BIT))

Definition at line 1655 of file win32.c.

Referenced by readdir_internal().

#define IfWin95 (   win95,
  winnt 
)    (winnt)

Definition at line 266 of file win32.c.

Referenced by kill(), and rb_w32_getpid().

#define INVALID_SET_FILE_POINTER   ((DWORD)-1)

Referenced by setup_overlapped().

#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)

Definition at line 2044 of file win32.c.

#define IOINFO_L2E   5

Definition at line 2043 of file win32.c.

#define isdirsep (   x)    ((x) == '/' || (x) == '\\')

Definition at line 41 of file win32.c.

Referenced by is_command_com().

#define IsWin95 ( )    rb_w32_iswin95()

Definition at line 262 of file win32.c.

Referenced by rb_w32_ftruncate(), rb_w32_getppid(), rb_w32_truncate(), and wutime().

#define IsWinNT ( )    rb_w32_iswinnt()

Definition at line 261 of file win32.c.

Referenced by CreateChild(), flock(), wrename(), and wstati64().

#define LK_ERR (   f,
  i 
)
Value:
do { \
if (f) \
i = 0; \
else { \
DWORD err = GetLastError(); \
if (err == ERROR_LOCK_VIOLATION || err == ERROR_IO_PENDING) \
else if (err == ERROR_NOT_LOCKED) \
i = 0; \
errno = map_errno(err); \
} \
} while (0)
int i
Definition: win32ole.c:776
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: name2ctype.h:23841
IUnknown DWORD
Definition: win32ole.c:149
int err
Definition: win32.c:78
int errno
#define EWOULDBLOCK
Definition: rubysocket.h:89
#define map_errno
Definition: win32.c:233

Definition at line 287 of file win32.c.

Referenced by flock_winnt().

#define LK_LEN   ULONG_MAX

Definition at line 301 of file win32.c.

Referenced by flock_winnt(), rb_w32_close(), and rb_w32_fclose().

#define map_errno   rb_w32_map_errno
#define MAXCHILDNUM   256 /* max num of child processes */

Definition at line 708 of file win32.c.

Referenced by waitpid().

#define MAXPATHLEN   512

Definition at line 964 of file win32.c.

Referenced by cmdglob(), rb_w32_aspawn_flags(), and rb_w32_spawn().

#define msghdr_to_wsamsg (   msg,
  wsamsg 
)
Value:
do { \
int i; \
(wsamsg)->name = (msg)->msg_name; \
(wsamsg)->namelen = (msg)->msg_namelen; \
(wsamsg)->lpBuffers = ALLOCA_N(WSABUF, (msg)->msg_iovlen); \
(wsamsg)->dwBufferCount = (msg)->msg_iovlen; \
for (i = 0; i < (msg)->msg_iovlen; ++i) { \
(wsamsg)->lpBuffers[i].buf = (msg)->msg_iov[i].iov_base; \
(wsamsg)->lpBuffers[i].len = (msg)->msg_iov[i].iov_len; \
} \
(wsamsg)->Control.buf = (msg)->msg_control; \
(wsamsg)->Control.len = (msg)->msg_controllen; \
(wsamsg)->dwFlags = (msg)->msg_flags; \
} while (0)
for(i=0;i< args;i++)
Definition: win32ole.c:780
int i
Definition: win32ole.c:776
static char msg[50]
Definition: strerror.c:8
#define ALLOCA_N(type, n)
Definition: ruby.h:1038
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:3913
register unsigned int len
Definition: name2ctype.h:22210
const char * name
Definition: nkf.c:208

Definition at line 3082 of file win32.c.

Referenced by recvmsg(), and sendmsg().

#define MTHREAD_ONLY (   x)
#define NTGLOB   0x1

Definition at line 1297 of file win32.c.

#define NTMALLOC   0x2

Definition at line 1298 of file win32.c.

Referenced by cmdglob(), insert(), and rb_w32_cmdvector().

#define NTSTRING   0x4

Definition at line 1299 of file win32.c.

#define numberof (   array)    (sizeof(array) / sizeof(*array))

Definition at line 487 of file win32.c.

Referenced by init_env(), and rb_w32_system_tmpdir().

#define open_null (   fd)
Value:
(((nullfd < 0) ? \
(nullfd = open("NUL", O_RDWR)) : 0), \
((nullfd == (fd)) ? (keep = 1) : dup2(nullfd, fd)), \
(fd))
RUBY_EXTERN int dup2(int, int)
Definition: dup2.c:27

Referenced by init_stdhandle().

#define PATHLEN   1024

Definition at line 1647 of file win32.c.

#define pioinfo_extra   0

Definition at line 2072 of file win32.c.

#define ROOT_GID   0

Definition at line 2276 of file win32.c.

Referenced by getegid(), getgid(), and setgid().

#define ROOT_UID   0

Definition at line 2275 of file win32.c.

Referenced by geteuid(), getuid(), and setuid().

#define RUBY_CRITICAL (   expr)    do { expr; } while (0)
#define set_env_val (   vname)
Value:
do { \
typedef char namesizecheck[numberof(wk.name) < numberof(vname) - 1 ? -1 : 1]; \
WCHAR *const buf = wk.name + numberof(wk.name) - numberof(vname) + 1; \
MEMCPY(buf, vname, WCHAR, numberof(vname) - 1); \
_wputenv(buf); \
} while (0)
#define MEMCPY(p1, p2, type, n)
Definition: ruby.h:1053
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:3913
#define numberof(array)
Definition: win32.c:487

Referenced by init_env().

#define SetBit (   bits,
  i 
)    ((bits)[(i) / CHAR_BIT] |= (1 << (i) % CHAR_BIT))

Definition at line 1656 of file win32.c.

Referenced by opendir_internal().

#define STHREAD_ONLY (   x)    x

Definition at line 2018 of file win32.c.

#define STRNDUPV (   ptr,
  v,
  src,
  len 
)    (((char *)memcpy(((ptr) = ALLOCV((v), (len) + 1)), (src), (len)))[len] = 0)

Definition at line 967 of file win32.c.

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

#define TO_SOCKET (   x)    _get_osfhandle(x)
#define utf8_to_wstr (   str,
  plen 
)    mbstr_to_wstr(CP_UTF8, str, -1, plen)
#define win95_stat (   path,
  st 
)    -1

Definition at line 4323 of file win32.c.

Referenced by wstati64().

#define WNOHANG   -1

Definition at line 3623 of file win32.c.

Referenced by waitpid().

#define WSAID_WSARECVMSG   {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}

Definition at line 3076 of file win32.c.

Referenced by recvmsg().

#define WSAID_WSASENDMSG   {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}

Definition at line 3079 of file win32.c.

Referenced by sendmsg().

#define wstr_to_acp (   str,
  plen 
)    wstr_to_mbstr(CP_ACP, str, -1, plen)

Definition at line 1105 of file win32.c.

#define wstr_to_filecp (   str,
  plen 
)    wstr_to_mbstr(filecp(), str, -1, plen)

Definition at line 1107 of file win32.c.

Referenced by rb_w32_conv_from_wstr(), and win32_direct_conv().

#define wstr_to_utf8 (   str,
  plen 
)    wstr_to_mbstr(CP_UTF8, str, -1, plen)

Definition at line 1109 of file win32.c.

#define yield_once ( )    Sleep(0)

Definition at line 4606 of file win32.c.

Referenced by catch_interrupt(), and rb_w32_asynchronize().

#define yield_until (   condition)    do yield_once(); while (!(condition))

Definition at line 4607 of file win32.c.

Referenced by rb_w32_asynchronize().

Typedef Documentation

typedef BOOL(WINAPI * cancel_io_t)(HANDLE)

Definition at line 578 of file win32.c.

Function Documentation

static DWORD WINAPI call_asynchronous ( PVOID  argp)
static
static void catch_interrupt ( void  )
static

Definition at line 4610 of file win32.c.

References NULL, rb_w32_wait_events(), RUBY_CRITICAL, and yield_once.

Referenced by rb_w32_getc(), and rb_w32_putc().

static int check_spawn_mode ( int  mode)
static

Definition at line 971 of file win32.c.

References errno, and P_NOWAIT.

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

static int check_valid_dir ( const WCHAR *  path)
static

Definition at line 4235 of file win32.c.

References NULL, and open_dir_handle().

Referenced by winnt_stat().

static rb_pid_t child_result ( struct ChildRecord child,
int  mode 
)
static

Definition at line 984 of file win32.c.

References CloseChildHandle(), ChildRecord::hProcess, P_NOWAIT, and ChildRecord::pid.

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

int chown ( const char *  path,
int  owner,
int  group 
)

Definition at line 3796 of file win32.c.

Referenced by argf_next_argv(), chown_internal(), get_device_once(), and rb_file_chown().

static void CloseChildHandle ( struct ChildRecord child)
static

Definition at line 745 of file win32.c.

References ChildRecord::hProcess, NULL, and ChildRecord::pid.

Referenced by child_result(), and poll_child_status().

static NtCmdLineElement** cmdglob ( NtCmdLineElement patt,
NtCmdLineElement **  tail 
)
static
static int compare ( const struct timeval t1,
const struct timeval t2 
)
inlinestatic

Definition at line 2587 of file win32.c.

References timeval::tv_sec, and timeval::tv_usec.

Referenced by rb_w32_select_with_thread().

static int copy_fd ( fd_set *  dst,
fd_set *  src 
)
static

Definition at line 2439 of file win32.c.

References FD_SETSIZE.

Referenced by rb_w32_select_with_thread().

static struct ChildRecord * CreateChild ( const WCHAR *  cmd,
const WCHAR *  prog,
SECURITY_ATTRIBUTES *  psa,
HANDLE  hInput,
HANDLE  hOutput,
HANDLE  hError,
DWORD  dwCreationFlags 
)
static
static int do_select ( int  nfds,
fd_set *  rd,
fd_set *  wr,
fd_set *  ex,
struct timeval timeout 
)
static

Definition at line 2538 of file win32.c.

References errno, map_errno, rb_w32_sleep(), RUBY_CRITICAL, timeval::tv_sec, and timeval::tv_usec.

Referenced by rb_w32_select_with_thread().

void endhostent ( void  )

Definition at line 3555 of file win32.c.

void endnetent ( void  )

Definition at line 3556 of file win32.c.

void endprotoent ( void  )

Definition at line 3557 of file win32.c.

void endservent ( void  )

Definition at line 3558 of file win32.c.

static void exit_handler ( void  )
static

Definition at line 622 of file win32.c.

References NULL, and st_free_table.

Referenced by rb_w32_sysinit().

static int extract_fd ( rb_fdset_t dst,
fd_set *  src,
int(*)(SOCKET)  func 
)
static

Definition at line 2398 of file win32.c.

References FD_SETSIZE, func, memmove(), and xrealloc.

Referenced by rb_w32_select_with_thread().

int fcntl ( int  fd,
int  cmd,
  ... 
)
static unsigned fileattr_to_unixmode ( DWORD  attr,
const WCHAR *  path 
)
static

Definition at line 4194 of file win32.c.

References S_IWUSR.

Referenced by winnt_stat().

static UINT filecp ( void  )
inlinestatic

Definition at line 1780 of file win32.c.

static long filetime_to_clock ( FILETIME *  ft)
static

Definition at line 4577 of file win32.c.

Referenced by rb_w32_times().

static int filetime_to_timeval ( const FILETIME *  ft,
struct timeval tv 
)
static

Definition at line 3723 of file win32.c.

References long, lt, timeval::tv_sec, and timeval::tv_usec.

Referenced by filetime_to_unixtime(), and gettimeofday().

static time_t filetime_to_unixtime ( const FILETIME *  ft)
static

Definition at line 4183 of file win32.c.

References filetime_to_timeval(), and timeval::tv_sec.

Referenced by rb_w32_fstat(), rb_w32_fstati64(), and winnt_stat().

static struct ChildRecord* FindChildSlot ( rb_pid_t  pid)
static

Definition at line 721 of file win32.c.

References END_FOREACH_CHILD, FOREACH_CHILD, and NULL.

Referenced by kill(), and waitpid().

static struct ChildRecord* FindChildSlotByHandle ( HANDLE  h)
static

Definition at line 733 of file win32.c.

References END_FOREACH_CHILD, FOREACH_CHILD, and NULL.

Referenced by waitpid().

static struct ChildRecord* FindFreeChildSlot ( void  )
static

Definition at line 754 of file win32.c.

References END_FOREACH_CHILD, FOREACH_CHILD, and NULL.

Referenced by CreateChild().

static void finish_overlapped ( OVERLAPPED *  ol,
int  fd,
DWORD  size 
)
static

Definition at line 5213 of file win32.c.

References _osfhnd, _osfile, FDEV, FPIPE, and size.

Referenced by rb_w32_read(), and rb_w32_write().

static int finish_overlapped_socket ( SOCKET  s,
WSAOVERLAPPED *  wol,
int  result,
DWORD len,
DWORD  size 
)
static
int flock ( int  fd,
int  oper 
)

Definition at line 371 of file win32.c.

References flock_winnt(), IsWinNT, NULL, and rb_w32_asynchronize().

Referenced by rb_thread_flock().

static uintptr_t flock_winnt ( uintptr_t  self,
int  argc,
uintptr_t argv 
)
static

Definition at line 304 of file win32.c.

References argc, errno, i, LK_ERR, LK_LEN, LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN.

Referenced by flock().

int fseeko ( FILE stream,
off_t  offset,
int  whence 
)

Definition at line 4547 of file win32.c.

References fileno, off_t, SEEK_CUR, and SEEK_END.

static FARPROC get_proc_address ( const char *  module,
const char *  func,
HANDLE *  mh 
)
static

Definition at line 454 of file win32.c.

References NULL.

Referenced by get_system_directory(), init_func(), rb_w32_getppid(), rb_w32_inet_ntop(), and wlink().

static BOOL get_special_folder ( int  n,
WCHAR *  env 
)
static

Definition at line 429 of file win32.c.

References alloc, FALSE, and NULL.

Referenced by init_env(), rb_w32_special_folder(), and rb_w32_system_tmpdir().

static UINT get_system_directory ( WCHAR *  path,
UINT  len 
)
static

Definition at line 477 of file win32.c.

References get_proc_address(), len, and NULL.

Referenced by rb_w32_system_tmpdir().

static void get_version ( void  )
static

Definition at line 240 of file win32.c.

References osver.

Referenced by rb_w32_sysinit().

static FARPROC get_wsa_extension_function ( SOCKET  s,
GUID *  guid 
)
static

Definition at line 2755 of file win32.c.

References errno, and NULL.

Referenced by recvmsg(), and sendmsg().

HANDLE GetCurrentThreadHandle ( void  )

Definition at line 270 of file win32.c.

References FALSE, and NULL.

rb_gid_t getegid ( void  )
rb_uid_t geteuid ( void  )
rb_gid_t getgid ( void  )
char* getlogin ( void  )

Definition at line 703 of file win32.c.

References NTLoginName.

Referenced by etc_getlogin().

struct netent* getnetbyaddr ( long  net,
int  type 
)

Definition at line 3562 of file win32.c.

References NULL.

struct netent* getnetbyname ( const char *  name)

Definition at line 3564 of file win32.c.

References NULL.

struct netent* getnetent ( void  )

Definition at line 3560 of file win32.c.

References NULL.

struct protoent* getprotoent ( void  )

Definition at line 3566 of file win32.c.

References NULL.

struct servent* getservent ( void  )

Definition at line 3568 of file win32.c.

References NULL.

int _cdecl gettimeofday ( struct timeval tv,
struct timezone tz 
)
rb_uid_t getuid ( void  )
static int has_redirection ( const char *  cmd)
static

Definition at line 1354 of file win32.c.

References CharNext, FALSE, ISALNUM, ISALPHA, and TRUE.

Referenced by rb_w32_spawn().

static void init_env ( void  )
static
static void init_func ( void  )
static

Definition at line 582 of file win32.c.

References get_proc_address(), and NULL.

Referenced by rb_w32_sysinit().

static void init_stdhandle ( void  )
static

Definition at line 2137 of file win32.c.

References fileno, NULL, O_BINARY, and open_null.

Referenced by rb_w32_sysinit().

static int insert ( const char *  path,
VALUE  vinfo,
void *  enc 
)
static
static int internal_cmd_match ( const char *  cmdname,
int  nt 
)
static

Definition at line 874 of file win32.c.

References internal_match().

Referenced by is_internal_cmd(), and rb_w32_aspawn_flags().

static int internal_match ( const void *  key,
const void *  elem 
)
static

Definition at line 826 of file win32.c.

Referenced by internal_cmd_match().

int ioctl ( int  i,
int  u,
  ... 
)

Definition at line 2319 of file win32.c.

References errno.

Referenced by chfunc(), get_device_once(), io_nread(), io_ready_p(), io_wait(), and nogvl_ioctl().

static int is_batch ( const char *  cmd)
static

Definition at line 1090 of file win32.c.

References len, strcasecmp, and strlen().

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

static int is_command_com ( const char *  interp)
static

Definition at line 832 of file win32.c.

References isdirsep, strcasecmp, and strlen().

Referenced by rb_w32_aspawn_flags(), and rb_w32_spawn().

static int is_console ( SOCKET  sock)
static

Definition at line 2496 of file win32.c.

References RUBY_CRITICAL.

Referenced by rb_w32_io_cancelable_p(), rb_w32_read(), and rb_w32_select_with_thread().

static int is_internal_cmd ( const char *  cmd,
int  nt 
)
static

Definition at line 846 of file win32.c.

References internal_cmd_match().

Referenced by rb_w32_spawn().

static int is_invalid_handle ( SOCKET  sock)
static

Definition at line 2532 of file win32.c.

Referenced by rb_w32_select_with_thread().

static int is_not_socket ( SOCKET  sock)
static

Definition at line 2460 of file win32.c.

References is_socket().

Referenced by rb_w32_select_with_thread().

static int is_pipe ( SOCKET  sock)
static

Definition at line 2466 of file win32.c.

References RUBY_CRITICAL.

Referenced by rb_w32_select_with_thread().

static int is_readable_console ( SOCKET  sock)
static

Definition at line 2510 of file win32.c.

References RUBY_CRITICAL.

Referenced by rb_w32_select_with_thread().

static int is_readable_pipe ( SOCKET  sock)
static

Definition at line 2478 of file win32.c.

References NULL, and RUBY_CRITICAL.

Referenced by rb_w32_select_with_thread().

static int is_socket ( SOCKET  sock)
static
static int isUNCRoot ( const WCHAR *  path)
static

Definition at line 4096 of file win32.c.

References p.

Referenced by wstati64().

static int join_argv ( char *  cmd,
char *const argv,
BOOL  escape 
)
static

Definition at line 894 of file win32.c.

References CharNext, len, and p.

Referenced by rb_w32_aspawn_flags().

int kill ( int  pid,
int  sig 
)
int link ( const char *  from,
const char *  to 
)

Definition at line 3962 of file win32.c.

References filecp_to_wstr, free(), NULL, and wlink().

Referenced by r_object0(), rb_exec_end_proc(), rb_mark_end_proc(), rb_set_end_proc(), and realpath_rec().

static WCHAR * mbstr_to_wstr ( UINT  cp,
const char *  str,
int  clen,
long plen 
)
static

Definition at line 1798 of file win32.c.

References len, malloc(), and NULL.

static void move_to_next_entry ( DIR dirp)
static

Definition at line 1837 of file win32.c.

References DIR::curr, DIR::loc, NULL, DIR::size, and DIR::start.

Referenced by rb_w32_seekdir(), and readdir_internal().

static HANDLE open_dir_handle ( const WCHAR *  filename,
WIN32_FIND_DATAW *  fd 
)
static

Definition at line 1663 of file win32.c.

References ALLOCV_END, ALLOCV_N, errno, len, map_errno, p, and v.

Referenced by check_valid_dir(), and opendir_internal().

static SOCKET open_ifs_socket ( int  af,
int  type,
int  protocol 
)
static

Definition at line 3243 of file win32.c.

References AF_UNSPEC, free(), i, malloc(), and NULL.

Referenced by rb_w32_socket(), and socketpair_internal().

static DIR* opendir_internal ( WCHAR *  wpath,
const char *  filename 
)
static
static int overlapped_socket_io ( BOOL  input,
int  fd,
char *  buf,
int  len,
int  flags,
struct sockaddr *  addr,
int *  addrlen 
)
static
static rb_pid_t poll_child_status ( struct ChildRecord child,
int *  stat_loc 
)
static
static int rb_chsize ( HANDLE  h,
off_t  size 
)
static

Definition at line 4439 of file win32.c.

References errno, long, map_errno, off_t, SEEK_CUR, and SEEK_SET.

Referenced by rb_w32_ftruncate(), and rb_w32_truncate().

int WSAAPI rb_w32_accept ( int  s,
struct sockaddr *  addr,
int *  addrlen 
)
int rb_w32_access ( const char *  path,
int  mode 
)

Definition at line 4411 of file win32.c.

References errno, and rb_w32_stati64().

rb_pid_t rb_w32_aspawn ( int  mode,
const char *  prog,
char *const argv 
)

Definition at line 1280 of file win32.c.

References rb_w32_aspawn_flags().

Referenced by pipe_open().

rb_pid_t rb_w32_aspawn_flags ( int  mode,
const char *  prog,
char *const argv,
DWORD  flags 
)
uintptr_t rb_w32_asynchronize ( asynchronous_func_t  func,
uintptr_t  self,
int  argc,
uintptr_t argv,
uintptr_t  intrval 
)
int WSAAPI rb_w32_bind ( int  s,
const struct sockaddr *  addr,
int  addrlen 
)

Definition at line 2805 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

int rb_w32_check_interrupt ( void *  )
int rb_w32_close ( int  fd)

Definition at line 5160 of file win32.c.

References _set_osfhnd, errno, is_socket(), key, LK_LEN, map_errno, NULL, st_delete, and TO_SOCKET.

Referenced by rb_w32_pipe(), and rb_w32_socketpair().

void rb_w32_closedir ( DIR dirp)

Definition at line 1994 of file win32.c.

References DIR::bits, direct::d_name, DIR::dirstr, free(), and DIR::start.

Referenced by opendir_internal().

int rb_w32_cmdvector ( const char *  cmd,
char ***  vec 
)
int WSAAPI rb_w32_connect ( int  s,
const struct sockaddr *  addr,
int  addrlen 
)

Definition at line 2823 of file win32.c.

References EINPROGRESS, err, errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

VALUE rb_w32_conv_from_wchar ( const WCHAR *  wstr,
rb_encoding enc 
)
char* rb_w32_conv_from_wstr ( const WCHAR *  wstr,
long lenp,
rb_encoding enc 
)

Definition at line 1880 of file win32.c.

References len, malloc(), NIL_P, rb_w32_conv_from_wchar(), RSTRING_LEN, RSTRING_PTR, and wstr_to_filecp.

Referenced by ruby_direct_conv().

int rb_w32_fclose ( FILE fp)

Definition at line 5046 of file win32.c.

References _set_osfhnd, errno, fileno, is_socket(), LK_LEN, map_errno, and TO_SOCKET.

void rb_w32_fd_copy ( rb_fdset_t dst,
const fd_set *  src,
int  max 
)

Definition at line 2362 of file win32.c.

References FD_SETSIZE, min(), and xrealloc.

void rb_w32_fd_dup ( rb_fdset_t dst,
const rb_fdset_t src 
)

Definition at line 2377 of file win32.c.

References FD_SETSIZE, and xrealloc.

char rb_w32_fd_is_text ( int  fd)

Definition at line 5841 of file win32.c.

References _osfile, and FTEXT.

void rb_w32_fdclr ( int  fd,
fd_set *  set 
)

Definition at line 2334 of file win32.c.

References i, memmove(), and TO_SOCKET.

int rb_w32_fdisset ( int  fd,
fd_set *  set 
)

Definition at line 2351 of file win32.c.

References RUBY_CRITICAL, and TO_SOCKET.

void rb_w32_fdset ( int  fd,
fd_set *  set 
)

Definition at line 2326 of file win32.c.

References FD_SET.

void rb_w32_free_environ ( char **  env)

Definition at line 4786 of file win32.c.

References env, and free().

int rb_w32_fstat ( int  fd,
struct stat st 
)

Definition at line 4134 of file win32.c.

References filetime_to_unixtime(), fstat, S_IWGRP, S_IWOTH, and S_IWUSR.

int rb_w32_fstati64 ( int  fd,
struct stati64 *  st 
)

Definition at line 4157 of file win32.c.

References COPY_STAT, filetime_to_unixtime(), fstat, S_IWGRP, S_IWOTH, S_IWUSR, and stat.

off_t rb_w32_ftello ( FILE stream)

Definition at line 4569 of file win32.c.

References off_t.

int rb_w32_ftruncate ( int  fd,
off_t  length 
)

Definition at line 4496 of file win32.c.

References IsWin95, and rb_chsize().

char** rb_w32_get_environ ( void  )

Definition at line 4751 of file win32.c.

References env, malloc(), NULL, strdup, and strlen().

SOCKET rb_w32_get_osfhandle ( int  fh)

Definition at line 888 of file win32.c.

Referenced by rb_io_flush(), and rb_io_rewind().

int rb_w32_getc ( FILE stream)

Definition at line 4633 of file win32.c.

References catch_interrupt(), clearerr, enough_to_get, EOF, and errno.

char* rb_w32_getcwd ( char *  buffer,
int  size 
)

Definition at line 3757 of file win32.c.

References errno, free(), len, malloc(), map_errno, NULL, p, and translate_char().

char* rb_w32_getenv ( const char *  name)

Definition at line 3987 of file win32.c.

References env, len, map_errno, NULL, strlen(), and strncasecmp.

Referenced by init_env().

struct hostent* WSAAPI rb_w32_gethostbyaddr ( const char *  addr,
int  len,
int  type 
)

Definition at line 3320 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

struct hostent* WSAAPI rb_w32_gethostbyname ( const char *  name)

Definition at line 3337 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

int WSAAPI rb_w32_gethostname ( char *  name,
int  len 
)

Definition at line 3354 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, and StartSockets().

int WSAAPI rb_w32_getpeername ( int  s,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 2846 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

rb_pid_t rb_w32_getpid ( void  )

Definition at line 4795 of file win32.c.

References IfWin95.

Referenced by rb_w32_pipe().

rb_pid_t rb_w32_getppid ( void  )

Definition at line 4808 of file win32.c.

References get_proc_address(), IsWin95, len, long, NULL, rb_w32_osver(), and ULONG().

struct protoent* WSAAPI rb_w32_getprotobyname ( const char *  name)

Definition at line 3371 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

struct protoent* WSAAPI rb_w32_getprotobynumber ( int  num)

Definition at line 3388 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

struct servent* WSAAPI rb_w32_getservbyname ( const char *  name,
const char *  proto 
)

Definition at line 3405 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

struct servent* WSAAPI rb_w32_getservbyport ( int  port,
const char *  proto 
)

Definition at line 3422 of file win32.c.

References errno, map_errno, NULL, RUBY_CRITICAL, and StartSockets().

int WSAAPI rb_w32_getsockname ( int  s,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 2863 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

int WSAAPI rb_w32_getsockopt ( int  s,
int  level,
int  optname,
char *  optval,
int *  optlen 
)

Definition at line 2878 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

char* WSAAPI rb_w32_inet_ntop ( int  af,
void *  addr,
char *  numaddr,
size_t  numaddr_len 
)

Definition at line 5825 of file win32.c.

References get_proc_address(), NULL, and snprintf.

int rb_w32_io_cancelable_p ( int  fd)

Definition at line 2090 of file win32.c.

References is_console(), is_socket(), NULL, and TO_SOCKET.

int WSAAPI rb_w32_ioctlsocket ( int  s,
long  cmd,
u_long argp 
)

Definition at line 2895 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

int rb_w32_is_socket ( int  fd)

Definition at line 2198 of file win32.c.

References is_socket(), and TO_SOCKET.

Referenced by rsock_init_sock().

int rb_w32_isatty ( int  fd)

Definition at line 5733 of file win32.c.

References _osfhnd, and errno.

int WSAAPI rb_w32_listen ( int  s,
int  backlog 
)

Definition at line 2912 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

int rb_w32_map_errno ( DWORD  winerr)

Definition at line 213 of file win32.c.

References errmap, i, and winerr.

int rb_w32_mkdir ( const char *  path,
int  mode 
)

Definition at line 5614 of file win32.c.

References filecp_to_wstr, free(), NULL, and wmkdir().

int rb_w32_open ( const char *  file,
int  oflag,
  ... 
)

Definition at line 4857 of file win32.c.

References arg, filecp_to_wstr, free(), NULL, O_BINARY, and rb_w32_wopen().

static int rb_w32_open_osfhandle ( intptr_t  osfhandle,
int  flags 
)
static
DIR* rb_w32_opendir ( const char *  filename)

Definition at line 1809 of file win32.c.

References filecp_to_wstr, free(), NULL, and opendir_internal().

DWORD rb_w32_osver ( void  )

Definition at line 256 of file win32.c.

References osver.

Referenced by rb_w32_getppid().

int rb_w32_pipe ( int  fds[2])
int rb_w32_putc ( int  c,
FILE stream 
)

Definition at line 4653 of file win32.c.

References catch_interrupt(), and enough_to_put.

ssize_t rb_w32_read ( int  fd,
void *  buf,
size_t  size 
)
struct direct* rb_w32_readdir ( DIR dirp)

Definition at line 1940 of file win32.c.

References NULL, readdir_internal(), and win32_direct_conv().

struct direct* rb_w32_readdir_with_enc ( DIR dirp,
rb_encoding enc 
)
int WSAAPI rb_w32_recv ( int  fd,
char *  buf,
int  len,
int  flags 
)

Definition at line 3039 of file win32.c.

References NULL, overlapped_socket_io(), and TRUE.

Referenced by rb_w32_read().

int WSAAPI rb_w32_recvfrom ( int  fd,
char *  buf,
int  len,
int  flags,
struct sockaddr *  from,
int *  fromlen 
)

Definition at line 3045 of file win32.c.

References overlapped_socket_io(), and TRUE.

int rb_w32_rename ( const char *  from,
const char *  to 
)

Definition at line 4077 of file win32.c.

References filecp_to_wstr, free(), NULL, and wrename().

void rb_w32_rewinddir ( DIR dirp)

Definition at line 1983 of file win32.c.

References DIR::curr, DIR::loc, and DIR::start.

Referenced by rb_w32_seekdir().

int rb_w32_rmdir ( const char *  path)

Definition at line 5647 of file win32.c.

References filecp_to_wstr, free(), NULL, and wrmdir().

void rb_w32_seekdir ( DIR dirp,
long  loc 
)

Definition at line 1969 of file win32.c.

References DIR::curr, DIR::loc, move_to_next_entry(), and rb_w32_rewinddir().

int WSAAPI rb_w32_select ( int  nfds,
fd_set *  rd,
fd_set *  wr,
fd_set *  ex,
struct timeval timeout 
)

Definition at line 2748 of file win32.c.

References rb_w32_select_with_thread().

int rb_w32_select_with_thread ( int  nfds,
fd_set *  rd,
fd_set *  wr,
fd_set *  ex,
struct timeval timeout,
void *  th 
)
int WSAAPI rb_w32_send ( int  fd,
const char *  buf,
int  len,
int  flags 
)

Definition at line 3052 of file win32.c.

References FALSE, NULL, and overlapped_socket_io().

Referenced by rb_w32_write().

int WSAAPI rb_w32_sendto ( int  fd,
const char *  buf,
int  len,
int  flags,
const struct sockaddr *  to,
int  tolen 
)

Definition at line 3058 of file win32.c.

References FALSE, and overlapped_socket_io().

int WSAAPI rb_w32_setsockopt ( int  s,
int  level,
int  optname,
const char *  optval,
int  optlen 
)

Definition at line 3211 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, StartSockets(), and TO_SOCKET.

int WSAAPI rb_w32_shutdown ( int  s,
int  how 
)

Definition at line 3228 of file win32.c.

References errno, map_errno, RUBY_CRITICAL, shutdown, StartSockets(), and TO_SOCKET.

int WSAAPI rb_w32_socket ( int  af,
int  type,
int  protocol 
)
int rb_w32_socketpair ( int  af,
int  type,
int  protocol,
int *  sv 
)
rb_pid_t rb_w32_spawn ( int  mode,
const char *  cmd,
const char *  prog 
)
VALUE rb_w32_special_folder ( int  type)
int rb_w32_stat ( const char *  path,
struct stat st 
)

Definition at line 4327 of file win32.c.

References COPY_STAT, and rb_w32_stati64().

int rb_w32_stati64 ( const char *  path,
struct stati64 *  st 
)

Definition at line 4398 of file win32.c.

References filecp_to_wstr, free(), NULL, and wstati64().

Referenced by rb_w32_access(), and rb_w32_stat().

char* rb_w32_strerror ( int  e)

Definition at line 2212 of file win32.c.

References EADDRINUSE, err, errmap, EWOULDBLOCK, i, memmove(), NULL, p, strerror(), strlcpy(), strlen(), sys_nerr, and winerr.

void rb_w32_sysinit ( int *  argc,
char ***  argv 
)
UINT rb_w32_system_tmpdir ( WCHAR *  path,
UINT  len 
)
long rb_w32_telldir ( DIR dirp)

Definition at line 1959 of file win32.c.

References DIR::loc.

int rb_w32_time_subtract ( struct timeval rest,
const struct timeval wait 
)

Definition at line 2569 of file win32.c.

References timeval::tv_sec, and timeval::tv_usec.

Referenced by rb_w32_select_with_thread().

int rb_w32_times ( struct tms tmbuf)
int rb_w32_truncate ( const char *  path,
off_t  length 
)

Definition at line 4470 of file win32.c.

References errno, IsWin95, map_errno, and rb_chsize().

int rb_w32_uaccess ( const char *  path,
int  mode 
)

Definition at line 4425 of file win32.c.

References errno, and rb_w32_ustati64().

int rb_w32_uchdir ( const char *  path)

Definition at line 5569 of file win32.c.

References free(), NULL, and utf8_to_wstr.

int rb_w32_uchmod ( const char *  path,
int  mode 
)

Definition at line 5719 of file win32.c.

References free(), NULL, and utf8_to_wstr.

int rb_w32_uchown ( const char *  path,
int  owner,
int  group 
)

Definition at line 3802 of file win32.c.

int rb_w32_ulink ( const char *  from,
const char *  to 
)

Definition at line 3943 of file win32.c.

References free(), NULL, utf8_to_wstr, and wlink().

int rb_w32_umkdir ( const char *  path,
int  mode 
)

Definition at line 5601 of file win32.c.

References free(), NULL, utf8_to_wstr, and wmkdir().

int rb_w32_unlink ( const char *  path)

Definition at line 5706 of file win32.c.

References filecp_to_wstr, free(), NULL, and wunlink().

int rb_w32_uopen ( const char *  file,
int  oflag,
  ... 
)

Definition at line 4838 of file win32.c.

References arg, free(), NULL, rb_w32_wopen(), and utf8_to_wstr.

DIR* rb_w32_uopendir ( const char *  filename)

Definition at line 1821 of file win32.c.

References free(), NULL, opendir_internal(), and utf8_to_wstr.

int rb_w32_urename ( const char *  from,
const char *  to 
)

Definition at line 4059 of file win32.c.

References free(), NULL, utf8_to_wstr, and wrename().

int rb_w32_urmdir ( const char *  path)

Definition at line 5660 of file win32.c.

References free(), NULL, utf8_to_wstr, and wrmdir().

int rb_w32_ustati64 ( const char *  path,
struct stati64 *  st 
)

Definition at line 4385 of file win32.c.

References free(), NULL, utf8_to_wstr, and wstati64().

Referenced by rb_w32_uaccess().

int rb_w32_utime ( const char *  path,
const struct utimbuf times 
)

Definition at line 5556 of file win32.c.

References filecp_to_wstr, free(), NULL, and wutime().

int rb_w32_uunlink ( const char *  path)

Definition at line 5693 of file win32.c.

References free(), NULL, utf8_to_wstr, and wunlink().

int rb_w32_uutime ( const char *  path,
const struct utimbuf times 
)

Definition at line 5543 of file win32.c.

References free(), NULL, utf8_to_wstr, and wutime().

int rb_w32_wait_events ( HANDLE *  events,
int  num,
DWORD  timeout 
)

Referenced by catch_interrupt().

int rb_w32_wopen ( const WCHAR *  file,
int  oflag,
  ... 
)
ssize_t rb_w32_write ( int  fd,
const void *  buf,
size_t  size 
)
long rb_w32_write_console ( uintptr_t  strarg,
int  fd 
)
static struct direct* readdir_internal ( DIR dirp,
BOOL(*)(const WCHAR *, struct direct *, rb_encoding *)  conv,
rb_encoding enc 
)
static
int recvmsg ( int  fd,
struct msghdr msg,
int  flags 
)
static void regulate_path ( WCHAR *  path)
static

Definition at line 444 of file win32.c.

References p, and translate_wchar().

Referenced by init_env(), and rb_w32_special_folder().

static BOOL ruby_direct_conv ( const WCHAR *  file,
struct direct entry,
rb_encoding enc 
)
static

Definition at line 1894 of file win32.c.

References direct::d_name, direct::d_namlen, FALSE, rb_w32_conv_from_wstr(), and TRUE.

Referenced by rb_w32_readdir_with_enc().

int sendmsg ( int  fd,
const struct msghdr msg,
int  flags 
)
int setgid ( rb_gid_t  gid)

Definition at line 2309 of file win32.c.

References ROOT_GID.

Referenced by p_gid_change_privilege(), and rb_setegid_core().

void sethostent ( int  stayopen)

Definition at line 3570 of file win32.c.

void setnetent ( int  stayopen)

Definition at line 3572 of file win32.c.

void setprotoent ( int  stayopen)

Definition at line 3574 of file win32.c.

void setservent ( int  stayopen)

Definition at line 3576 of file win32.c.

int setuid ( rb_uid_t  uid)

Definition at line 2303 of file win32.c.

References ROOT_UID.

Referenced by p_uid_change_privilege(), and rb_seteuid_core().

static int setup_overlapped ( OVERLAPPED *  ol,
int  fd 
)
static

Definition at line 5184 of file win32.c.

References _osfhnd, _osfile, err, errno, FAPPEND, FDEV, FPIPE, INVALID_SET_FILE_POINTER, map_errno, NULL, and TRUE.

Referenced by rb_w32_read(), and rb_w32_write().

int signbit ( double  x)

Definition at line 5817 of file win32.c.

Referenced by f_signbit(), math_atan2(), math_gamma(), and math_lgamma().

static char* skipspace ( char *  ptr)
inlinestatic

Definition at line 1402 of file win32.c.

References ISSPACE.

Referenced by rb_w32_cmdvector().

static int socketpair_internal ( int  af,
int  type,
int  protocol,
SOCKET *  sv 
)
static

Definition at line 3437 of file win32.c.

References EAFNOSUPPORT, EPROTOTYPE, errno, len, map_errno, open_ifs_socket(), PF_INET, RUBY_CRITICAL, and StartSockets().

Referenced by rb_w32_socketpair().

static void StartSockets ( void  )
static
static char* translate_char ( char *  p,
int  from,
int  to 
)
inlinestatic

Definition at line 402 of file win32.c.

References CharNext, and p.

Referenced by rb_w32_aspawn_flags(), rb_w32_getcwd(), and rb_w32_spawn().

static WCHAR* translate_wchar ( WCHAR *  p,
int  from,
int  to 
)
inlinestatic

Definition at line 392 of file win32.c.

References p.

Referenced by rb_w32_system_tmpdir(), and regulate_path().

static int unixtime_to_filetime ( time_t  time,
FILETIME *  ft 
)
static

Definition at line 5483 of file win32.c.

Referenced by wutime().

int wait ( int *  status)
rb_pid_t waitpid ( rb_pid_t  pid,
int *  stat_loc,
int  options 
)
static BOOL win32_direct_conv ( const WCHAR *  file,
struct direct entry,
rb_encoding dummy 
)
static

Definition at line 1853 of file win32.c.

References direct::d_name, direct::d_namlen, FALSE, TRUE, and wstr_to_filecp.

Referenced by rb_w32_readdir(), and rb_w32_readdir_with_enc().

static int winnt_stat ( const WCHAR *  path,
struct stati64 *  st 
)
static

Definition at line 4253 of file win32.c.

References check_valid_dir(), errno, fileattr_to_unixmode(), filetime_to_unixtime(), and map_errno.

Referenced by wstati64().

static int wlink ( const WCHAR *  from,
const WCHAR *  to 
)
static

Definition at line 3918 of file win32.c.

References errno, get_proc_address(), map_errno, and NULL.

Referenced by link(), and rb_w32_ulink().

static int wmkdir ( const WCHAR *  wpath,
int  mode 
)
static

Definition at line 5582 of file win32.c.

References errno, FALSE, map_errno, NULL, and RUBY_CRITICAL.

Referenced by rb_w32_mkdir(), and rb_w32_umkdir().

static int wrename ( const WCHAR *  oldpath,
const WCHAR *  newpath 
)
static

Definition at line 4008 of file win32.c.

References errno, IsWinNT, map_errno, and RUBY_CRITICAL.

Referenced by rb_w32_rename(), and rb_w32_urename().

static int wrmdir ( const WCHAR *  wpath)
static

Definition at line 5627 of file win32.c.

References errno, FALSE, map_errno, and RUBY_CRITICAL.

Referenced by rb_w32_rmdir(), and rb_w32_urmdir().

static int wstati64 ( const WCHAR *  path,
struct stati64 *  st 
)
static
static char * wstr_to_mbstr ( UINT  cp,
const WCHAR *  wstr,
int  clen,
long plen 
)
static

Definition at line 1787 of file win32.c.

References len, malloc(), and NULL.

static int wunlink ( const WCHAR *  path)
static

Definition at line 5673 of file win32.c.

References errno, map_errno, and RUBY_CRITICAL.

Referenced by rb_w32_unlink(), and rb_w32_uunlink().

static int wutime ( const WCHAR *  path,
const struct utimbuf times 
)
static

Variable Documentation

EXTERN_C _CRTIMP ioinfo* __pioinfo[]

Definition at line 2041 of file win32.c.

cancel_io_t cancel_io = NULL
static

Definition at line 579 of file win32.c.

Referenced by finish_overlapped_socket(), rb_w32_read(), and rb_w32_write().

char* envarea
static

Definition at line 619 of file win32.c.

int err

Definition at line 78 of file win32.c.

Referenced by argf_next_argv(), BSD__sprint(), cleanup_iseq_build(), clsid_from_remote(), date_strftime_with_tmx(), dlhandle_sym(), err_append(), errat_getter(), errat_setter(), expand_case_fold_string(), fetch_name(), fetch_name_with_level(), finish_overlapped_socket(), foletype_s_progids(), foletypelib_s_typelibs(), fptr_finalize(), Init_syslog(), inspect_errno(), kill(), lock_func(), make_econv_exception(), mutex_free(), oletypelib_path(), oletypelib_search_registry(), oletypelib_search_registry2(), onig_compile(), onig_new(), onig_new_with_source(), ossl_exc_new(), ossl_pkcs12_initialize(), ossl_pkcs7_add_data(), ossl_raise(), ossl_x509stctx_get_err_string(), ossl_x509stctx_set_error(), parse_char_class(), parse_subexp(), poll_child_status(), rb_check_backtrace(), rb_deflate_init_copy(), rb_deflate_initialize(), rb_deflate_params(), rb_deflate_s_deflate(), rb_deflate_set_dictionary(), rb_dlhandle_initialize(), rb_enc_reg_new(), rb_f_raise(), rb_gzreader_initialize(), rb_gzwriter_initialize(), rb_inflate_initialize(), rb_inflate_s_inflate(), rb_inflate_set_dictionary(), rb_inflate_sync_point_p(), rb_iterate(), rb_mutex_unlock(), rb_mutex_unlock_th(), rb_reg_check_preprocess(), rb_reg_compile(), rb_reg_init_copy(), rb_reg_init_str(), rb_reg_initialize_m(), rb_reg_prepare_re(), rb_reg_preprocess_dregexp(), rb_reg_search(), rb_reg_to_s(), rb_set_errinfo(), rb_strftime_with_timespec(), rb_threadptr_execute_interrupts_common(), rb_threadptr_unlock_all_locking_mutexes(), rb_w32_connect(), rb_w32_pipe(), rb_w32_read(), rb_w32_strerror(), rb_w32_write(), reg_compile_gen(), reg_enum_key(), reg_fragment_check_gen(), reg_get_val(), reg_get_val2(), ruby_cleanup(), ruby_close(), ruby_float_step(), ruby_getpeername(), ruby_getsockname(), ruby_shutdown(), setup_overlapped(), syserr_initialize(), thread_create_core(), thread_join(), typelib_file_from_clsid(), typelib_file_from_typelib(), vm_exec(), vm_throw(), zstream_end(), zstream_finalize(), zstream_reset(), zstream_run(), and zstream_sync().

struct { ... } errmap[]
const char* NTLoginName
static

Definition at line 235 of file win32.c.

Referenced by getlogin(), and init_env().

int NtSocketsInitialized = 0
static

Definition at line 617 of file win32.c.

OSVERSIONINFO osver
static

Definition at line 237 of file win32.c.

Referenced by get_version(), rb_w32_osver(), and rb_w32_read().

CRITICAL_SECTION select_mutex
static

Definition at line 616 of file win32.c.

st_table* socklist = NULL
static

Definition at line 618 of file win32.c.

const char* const szInternalCmds[]
static

Definition at line 773 of file win32.c.

DWORD winerr

Definition at line 77 of file win32.c.

Referenced by rb_w32_map_errno(), and rb_w32_strerror().