home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / full / activeperl / APi522e.exe / data.z / win32.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-01  |  10.0 KB  |  388 lines

  1. /* WIN32.H
  2.  *
  3.  * (c) 1995 Microsoft Corporation. All rights reserved. 
  4.  *         Developed by hip communications inc., http://info.hip.com/info/
  5.  *
  6.  *    You may distribute under the terms of either the GNU General Public
  7.  *    License or the Artistic License, as specified in the README file.
  8.  */
  9. #ifndef  _INC_WIN32_PERL5
  10. #define  _INC_WIN32_PERL5
  11.  
  12. #include "BuildInfo.h"
  13.  
  14. #ifdef PERL_OBJECT
  15. #  define DYNAMIC_ENV_FETCH
  16. #  define ENV_HV_NAME "___ENV_HV_NAME___"
  17. #  define prime_env_iter()
  18. #  define WIN32IO_IS_STDIO        /* don't pull in custom stdio layer */
  19. #  ifdef PERL_GLOBAL_STRUCT
  20. #    error PERL_GLOBAL_STRUCT cannot be defined with PERL_OBJECT
  21. #  endif
  22. #  define win32_get_privlib PerlEnv_lib_path
  23. #  define win32_get_sitelib PerlEnv_sitelib_path
  24. #endif
  25.  
  26. #ifdef __GNUC__
  27. #  ifndef __int64        /* some versions seem to #define it already */
  28. #    define __int64 long long
  29. #  endif
  30. #  define Win32_Winsock
  31. /* GCC does not do __declspec() - render it a nop 
  32.  * and turn on options to avoid importing data 
  33.  */
  34. #ifndef __declspec
  35. #  define __declspec(x)
  36. #endif
  37. #  ifndef PERL_OBJECT
  38. #    define PERL_GLOBAL_STRUCT
  39. #    define MULTIPLICITY
  40. #  endif
  41. #endif
  42.  
  43. /* Define DllExport akin to perl's EXT, 
  44.  * If we are in the DLL or mimicing the DLL for Win95 work round
  45.  * then Export the symbol, 
  46.  * otherwise import it.
  47.  */
  48.  
  49. #if defined(PERL_OBJECT)
  50. #define DllExport
  51. #else
  52. #if defined(PERLDLL) || defined(WIN95FIX)
  53. #define DllExport
  54. /*#define DllExport __declspec(dllexport)*/    /* noises with VC5+sp3 */
  55. #else 
  56. #define DllExport __declspec(dllimport)
  57. #endif
  58. #endif
  59.  
  60. #define  WIN32_LEAN_AND_MEAN
  61. #include <windows.h>
  62.  
  63. #ifdef   WIN32_LEAN_AND_MEAN        /* C file is NOT a Perl5 original. */
  64. #define  CONTEXT    PERL_CONTEXT    /* Avoid conflict of CONTEXT defs. */
  65. #endif /*WIN32_LEAN_AND_MEAN */
  66.  
  67. #ifndef TLS_OUT_OF_INDEXES
  68. #define TLS_OUT_OF_INDEXES (DWORD)0xFFFFFFFF
  69. #endif
  70.  
  71. #include <dirent.h>
  72. #include <io.h>
  73. #include <process.h>
  74. #include <stdio.h>
  75. #include <direct.h>
  76. #include <stdlib.h>
  77. #ifndef EXT
  78. #include "EXTERN.h"
  79. #endif
  80.  
  81. struct tms {
  82.     long    tms_utime;
  83.     long    tms_stime;
  84.     long    tms_cutime;
  85.     long    tms_cstime;
  86. };
  87.  
  88. #ifndef SYS_NMLN
  89. #define SYS_NMLN    257
  90. #endif
  91.  
  92. struct utsname {
  93.     char sysname[SYS_NMLN];
  94.     char nodename[SYS_NMLN];
  95.     char release[SYS_NMLN];
  96.     char version[SYS_NMLN];
  97.     char machine[SYS_NMLN];
  98. };
  99.  
  100. #ifndef START_EXTERN_C
  101. #undef EXTERN_C
  102. #ifdef __cplusplus
  103. #  define START_EXTERN_C extern "C" {
  104. #  define END_EXTERN_C }
  105. #  define EXTERN_C extern "C"
  106. #else
  107. #  define START_EXTERN_C 
  108. #  define END_EXTERN_C 
  109. #  define EXTERN_C
  110. #endif
  111. #endif
  112.  
  113. #define  STANDARD_C    1
  114. #define  DOSISH        1        /* no escaping our roots */
  115. #define  OP_BINARY    O_BINARY    /* mistake in in pp_sys.c? */
  116.  
  117. /* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
  118.  * real filehandles. XXX Should always be defined (the other version is untested) */
  119. #define USE_SOCKETS_AS_HANDLES
  120.  
  121. /* read() and write() aren't transparent for socket handles */
  122. #define PERL_SOCK_SYSREAD_IS_RECV
  123. #define PERL_SOCK_SYSWRITE_IS_SEND
  124.  
  125.  
  126. /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls
  127.  * to read the environment, bypassing the runtime's (usually broken)
  128.  * facilities for accessing the same.  See note in util.c/my_setenv(). */
  129. /*#define USE_WIN32_RTL_ENV */
  130.  
  131. /* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95.
  132.  * Can only enable it if not using the DLL CRT (it doesn't expose internals) */
  133. #if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86)
  134. #define USE_FIXED_OSFHANDLE
  135. #endif
  136.  
  137. #define ENV_IS_CASELESS
  138.  
  139. #ifndef VER_PLATFORM_WIN32_WINDOWS    /* VC-2.0 headers don't have this */
  140. #define VER_PLATFORM_WIN32_WINDOWS    1
  141. #endif
  142.  
  143. #ifndef FILE_SHARE_DELETE        /* VC-4.0 headers don't have this */
  144. #define FILE_SHARE_DELETE        0x00000004
  145. #endif
  146.  
  147. /* Compiler-specific stuff. */
  148.  
  149. #ifdef __BORLANDC__        /* Borland C++ */
  150.  
  151. #define _access access
  152. #define _chdir chdir
  153. #include <sys/types.h>
  154.  
  155. #ifndef DllMain
  156. #define DllMain DllEntryPoint
  157. #endif
  158.  
  159. #pragma warn -ccc    /* "condition is always true/false" */
  160. #pragma warn -rch    /* "unreachable code" */
  161. #pragma warn -sig    /* "conversion may lose significant digits" */
  162. #pragma warn -pia    /* "possibly incorrect assignment" */
  163. #pragma warn -par    /* "parameter 'foo' is never used" */
  164. #pragma warn -aus    /* "'foo' is assigned a value that is never used" */
  165. #pragma warn -use    /* "'foo' is declared but never used" */
  166. #pragma warn -csu    /* "comparing signed and unsigned values" */
  167. #pragma warn -pro    /* "call to function with no prototype" */
  168.  
  169. /* Borland is picky about a bare member function name used as its ptr */
  170. #ifdef PERL_OBJECT
  171. #define FUNC_NAME_TO_PTR(name)    &(name)
  172. #endif
  173.  
  174. #endif
  175.  
  176. #ifdef _MSC_VER            /* Microsoft Visual C++ */
  177.  
  178. typedef long        uid_t;
  179. typedef long        gid_t;
  180. typedef unsigned short    mode_t;
  181. #pragma  warning(disable: 4018 4035 4101 4102 4244 4245 4761)
  182.  
  183. #ifndef PERL_OBJECT
  184.  
  185. /* Visual C thinks that a pointer to a member variable is 16 bytes in size. */
  186. #define STRUCT_MGVTBL_DEFINITION                    \
  187. struct mgvtbl {                                \
  188.     union {                                \
  189.     int        (CPERLscope(*svt_get))    _((SV *sv, MAGIC* mg));    \
  190.     char        handle_VC_problem1[16];                \
  191.     };                                    \
  192.     union {                                \
  193.     int        (CPERLscope(*svt_set))    _((SV *sv, MAGIC* mg));    \
  194.     char        handle_VC_problem2[16];                \
  195.     };                                    \
  196.     union {                                \
  197.     U32        (CPERLscope(*svt_len))    _((SV *sv, MAGIC* mg));    \
  198.     char        handle_VC_problem3[16];                \
  199.     };                                    \
  200.     union {                                \
  201.     int        (CPERLscope(*svt_clear))    _((SV *sv, MAGIC* mg));    \
  202.     char        handle_VC_problem4[16];                \
  203.     };                                    \
  204.     union {                                \
  205.     int        (CPERLscope(*svt_free))    _((SV *sv, MAGIC* mg));    \
  206.     char        handle_VC_problem5[16];                \
  207.     };                                    \
  208. }
  209.  
  210. #define BASEOP_DEFINITION        \
  211.     OP*        op_next;        \
  212.     OP*        op_sibling;        \
  213.     OP*        (CPERLscope(*op_ppaddr))_((ARGSproto));        \
  214.     char    handle_VC_problem[12];    \
  215.     PADOFFSET    op_targ;        \
  216.     OPCODE    op_type;        \
  217.     U16        op_seq;            \
  218.     U8        op_flags;        \
  219.     U8        op_private;
  220.  
  221. #define UNION_ANY_DEFINITION union any {        \
  222.     void*    any_ptr;                \
  223.     I32        any_i32;                \
  224.     IV        any_iv;                    \
  225.     long    any_long;                \
  226.     void    (CPERLscope(*any_dptr)) _((void*));    \
  227.     char    handle_VC_problem[16];            \
  228. }
  229.  
  230. #endif /* PERL_OBJECT */
  231.  
  232. #endif /* _MSC_VER */
  233.  
  234. #ifdef __MINGW32__        /* Minimal Gnu-Win32 */
  235.  
  236. typedef long        uid_t;
  237. typedef long        gid_t;
  238. #ifndef _environ
  239. #define _environ    environ
  240. #endif
  241. #define flushall    _flushall
  242. #define fcloseall    _fcloseall
  243.  
  244. #ifdef PERL_OBJECT
  245. #define FUNC_NAME_TO_PTR(name)    &(name)
  246. #endif
  247.  
  248. #ifndef _O_NOINHERIT
  249. #  define _O_NOINHERIT    0x0080
  250. #  ifndef _NO_OLDNAMES
  251. #    define O_NOINHERIT    _O_NOINHERIT
  252. #  endif
  253. #endif
  254.  
  255. #ifndef _O_NOINHERIT
  256. #  define _O_NOINHERIT    0x0080
  257. #  ifndef _NO_OLDNAMES
  258. #    define O_NOINHERIT    _O_NOINHERIT
  259. #  endif
  260. #endif
  261.  
  262. #endif /* __MINGW32__ */
  263.  
  264. /* compatibility stuff for other compilers goes here */
  265.  
  266.  
  267. START_EXTERN_C
  268.  
  269. /* For UNIX compatibility. */
  270.  
  271. extern  uid_t    getuid(void);
  272. extern  gid_t    getgid(void);
  273. extern  uid_t    geteuid(void);
  274. extern  gid_t    getegid(void);
  275. extern  int    setuid(uid_t uid);
  276. extern  int    setgid(gid_t gid);
  277. extern  int    kill(int pid, int sig);
  278. extern  void    *sbrk(int need);
  279. extern    char *    getlogin(void);
  280. extern    int    chown(const char *p, uid_t o, gid_t g);
  281.  
  282. #undef     Stat
  283. #define  Stat        win32_stat
  284.  
  285. #undef   init_os_extras
  286. #define  init_os_extras Perl_init_os_extras
  287.  
  288. DllExport void        Perl_win32_init(int *argcp, char ***argvp);
  289. DllExport void        Perl_init_os_extras(void);
  290. DllExport void        win32_str_os_error(void *sv, DWORD err);
  291.  
  292. #ifndef USE_SOCKETS_AS_HANDLES
  293. extern FILE *        my_fdopen(int, char *);
  294. #endif
  295. extern int        my_fclose(FILE *);
  296. extern int        do_aspawn(void *really, void **mark, void **sp);
  297. extern int        do_spawn(char *cmd);
  298. extern int        do_spawn_nowait(char *cmd);
  299. extern char        do_exec(char *cmd);
  300. extern char *        win32_get_privlib(char *pl);
  301. extern char *        win32_get_sitelib(char *pl);
  302. extern int        IsWin95(void);
  303. extern int        IsWinNT(void);
  304.  
  305. extern char *        staticlinkmodules[];
  306.  
  307. END_EXTERN_C
  308.  
  309. typedef  char *        caddr_t;    /* In malloc.c (core address). */
  310.  
  311. /*
  312.  * handle socket stuff, assuming socket is always available
  313.  */
  314. #include <sys/socket.h>
  315. #include <netdb.h>
  316.  
  317. #ifdef MYMALLOC
  318. #define EMBEDMYMALLOC    /**/
  319. /* #define USE_PERL_SBRK    /**/
  320. /* #define PERL_SBRK_VIA_MALLOC    /**/
  321. #endif
  322.  
  323. #if defined(PERLDLL) && !defined(PERL_CORE)
  324. #define PERL_CORE
  325. #endif
  326.  
  327. #ifdef USE_BINMODE_SCRIPTS
  328. #define PERL_SCRIPT_MODE "rb"
  329. EXT void win32_strip_return(struct sv *sv);
  330. #else
  331. #define PERL_SCRIPT_MODE "r"
  332. #define win32_strip_return(sv) NOOP
  333. #endif
  334.  
  335. #define HAVE_INTERP_INTERN
  336. typedef struct {
  337.     long    num;
  338.     DWORD    pids[MAXIMUM_WAIT_OBJECTS];
  339. } child_tab;
  340.  
  341. struct interp_intern {
  342.     char *    perlshell_tokens;
  343.     char **    perlshell_vec;
  344.     long    perlshell_items;
  345.     struct av *    fdpid;
  346.     child_tab *    children;
  347.     HANDLE    child_handles[MAXIMUM_WAIT_OBJECTS];
  348. };
  349.  
  350.  
  351. #define w32_perlshell_tokens    (PL_sys_intern.perlshell_tokens)
  352. #define w32_perlshell_vec    (PL_sys_intern.perlshell_vec)
  353. #define w32_perlshell_items    (PL_sys_intern.perlshell_items)
  354. #define w32_fdpid        (PL_sys_intern.fdpid)
  355. #define w32_children        (PL_sys_intern.children)
  356. #define w32_num_children    (w32_children->num)
  357. #define w32_child_pids        (w32_children->pids)
  358. #define w32_child_handles    (PL_sys_intern.child_handles)
  359.  
  360. /* 
  361.  * Now Win32 specific per-thread data stuff 
  362.  */
  363.  
  364. #ifdef USE_THREADS
  365. #  ifndef USE_DECLSPEC_THREAD
  366. #    define HAVE_THREAD_INTERN
  367.  
  368. struct thread_intern {
  369.     /* XXX can probably use one buffer instead of several */
  370.     char        Wstrerror_buffer[512];
  371.     struct servent    Wservent;
  372.     char        Wgetlogin_buffer[128];
  373.     char        Ww32_perllib_root[MAX_PATH+1];
  374. #    ifdef USE_SOCKETS_AS_HANDLES
  375.     int            Winit_socktype;
  376. #    endif
  377. #    ifdef HAVE_DES_FCRYPT
  378.     char        Wcrypt_buffer[30];
  379. #    endif
  380. #    ifdef USE_RTL_THREAD_API
  381.     void *        retv;    /* slot for thread return value */
  382. #    endif
  383. };
  384. #  endif /* !USE_DECLSPEC_THREAD */
  385. #endif /* USE_THREADS */
  386.  
  387. #endif /* _INC_WIN32_PERL5 */
  388.