Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  3. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  4. #ifndef __dj_include_crt0_h_
  5. #define __dj_include_crt0_h_
  6.  
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10.  
  11. #ifndef __dj_ENFORCE_ANSI_FREESTANDING
  12.  
  13. #ifndef __STRICT_ANSI__
  14.  
  15. #ifndef _POSIX_SOURCE
  16.  
  17. /*****************************************************************************\
  18.  * crt0.h - specific to go32 v2.0 applications, controls command line
  19.  * argument creation.
  20. \*****************************************************************************/
  21.  
  22. /*****************************************************************************\
  23.  * If the application wishes to provide a wildcard expansion function,
  24.  * it should define a __crt0_glob_function function.  It should return
  25.  * a list of the expanded values, or 0 if no expansion will occur.
  26.  * The startup code will free the returned pointer if it is nonzero.
  27.  *
  28.  * If no expander function is provided, wildcards will be expanded in
  29.  * the POSIX.1 style.  To disable expansion, provide a __crt0_glob_function
  30.  * that always returns 0.
  31.  *
  32.  * Applications that do not rely on environment variables can provide an
  33.  * alternate version of __crt0_load_environment_file that does nothing.
  34.  *
  35.  * Applications that do not rely on arguments passed to main() can
  36.  * provide an alternate version of __crt0_setup_arguments() that does
  37.  * nothing.
  38. \*****************************************************************************/
  39.  
  40. extern char  *__dos_argv0;
  41. extern int    __crt0_argc;
  42. extern char **__crt0_argv;
  43.  
  44. void   __crt0_load_environment_file(char *_app_name);
  45. void   __crt0_setup_arguments(void);
  46. char **__crt0_glob_function(char *_arg);
  47.  
  48. /*****************************************************************************\
  49.  *
  50.  *  To set any of these startup flags, add the following declaration to
  51.  *  *your* source code:
  52.  *  
  53.  *      int _crt0_startup_flags = _CRT0_FLAG_* | _CRT0_FLAG_*;
  54.  *  
  55.  *  The default is all flags off.
  56.  *
  57. \*****************************************************************************/
  58.  
  59. extern int _crt0_startup_flags;
  60.  
  61. /* If set, argv[0] is left in whatever case it was.  If not set, all
  62. ** characters are mapped to lower case.  Note that if the argv0 field in
  63. ** the stubinfo structure is present, the case of that part of argv0 is not
  64. ** affected.
  65. */
  66. #define _CRT0_FLAG_PRESERVE_UPPER_CASE          0x0001
  67.  
  68. /* If set, reverse slashes (dos-style) are preserved in argv[0].  If not
  69. ** set, all reverse slashes are replaced with unix-style slashes.
  70. */
  71. #define _CRT0_FLAG_USE_DOS_SLASHES              0x0002
  72.  
  73. /* If set, the .EXE suffix is removed from the file name component of
  74. ** argv[0].  If not set, the suffix remains.
  75. */
  76. #define _CRT0_FLAG_DROP_EXE_SUFFIX              0x0004
  77.  
  78. /* If set, the drive specifier (ex: `C:') is removed from the beginning of
  79. ** argv[0] (if present).  If not set, the drive specifier remains.
  80. */
  81. #define _CRT0_FLAG_DROP_DRIVE_SPECIFIER 0x0008
  82.  
  83. /* If set, response files (ex: @gcc.rf) are not expanded.  If not set, the
  84. ** contents of the response files are used to create arguments.  Note that
  85. ** if the file does not exist, that argument remains unexpanded.
  86. */
  87. #define _CRT0_FLAG_DISALLOW_RESPONSE_FILES      0x0010
  88.  
  89. /* If set, fill sbrk()'d memory with a constant value.  If not, memory
  90. ** gets whatever happens to have been in there, which breaks some
  91. ** applications.
  92. */
  93. #define _CRT0_FLAG_FILL_SBRK_MEMORY             0x0020
  94.  
  95. /* If set, fill memory (above) with 0xdeadbeef, else fill with zero.
  96. ** This is especially useful for debugging uninitialized memory problems.
  97. */
  98. #define _CRT0_FLAG_FILL_DEADBEEF                0x0040
  99.  
  100. /* If set, set DS limit to 4GB which allows use of near pointers to DOS
  101. ** (and other) memory.  WARNING, disables memory protection and bad pointers
  102. ** may crash the machine or wipe out your data.
  103. */
  104. #define _CRT0_FLAG_NEARPTR                      0x0080
  105.  
  106. /* If set, disable NULL pointer protection (if it can be controlled at all).
  107. */
  108. #define _CRT0_FLAG_NULLOK                       0x0100
  109.  
  110. /* If set, enabled capture of NMI in exception code.  This may cause problems
  111. ** with laptops and "green" boxes which use it to wake up.  Default is to
  112. ** leave NMIs alone and pass through to real mode code.  You decide.
  113. */
  114. #define _CRT0_FLAG_NMI_SIGNAL                   0x0200
  115.  
  116. /* If set, disable usage of long file name functions even on systems
  117. ** (such as Win95) which support them.  This might be needed to work
  118. ** around program assumptions on file name format on programs written
  119. ** specifically for DOS.
  120. */
  121. #define _CRT0_FLAG_NO_LFN                       0x0400
  122.  
  123. /* If set, chooses an sbrk() algorithm.  If your code requires one type
  124. ** or the other, set the value (since the default may change).  The non-move
  125. ** sbrk makes sure the base of CS/DS/SS does not change.  Each new sbrk()
  126. ** allocation is put in a different DPMI memory block.  This works best with
  127. ** DOS programs which would like to use near pointers or hardware interrupts.
  128. ** The unix sbrk resizes a single memory block, so programs making assumptions
  129. ** about unix-like sbrk behavior may run better with this choice.
  130. */
  131. #define _CRT0_FLAG_NONMOVE_SBRK                 0x0000          /* Default */
  132. #define _CRT0_FLAG_UNIX_SBRK                    0x0800
  133.  
  134. /* If set, locks all memory as it is allocated.  This effectively disables
  135. ** virtual memory, and may be useful if using extensive hardware interrupt
  136. ** codes in a relatively small image size.  The memory is locked after it
  137. ** is sbrk()ed, so the locking may fail.  This bit may be set or cleared
  138. ** during execution.  When sbrk() uses multiple memory zones, it can be
  139. ** difficult to lock all memory since the memory block size and location is
  140. ** impossible to determine.
  141. */
  142.  
  143. #define _CRT0_FLAG_LOCK_MEMORY                  0x1000
  144.  
  145. /* If set, disables all filename letter-case conversion in functions that
  146. ** traverse directories (except findfirst/findnext which always return the
  147. ** filenames exactly as found in the directory entry).  When reset, all
  148. ** filenames on 8+3 MSDOS filesystems and DOS-style 8+3 filenames on LFN
  149. ** systems are converted to lower-case by functions such as `readdir',
  150. ** `getcwd', `_fixpath' and `srchpath'.  Note that when this flag is set,
  151. ** ALL filenames on MSDOS systems will appear in upper-case, which is
  152. ** both ugly and will break many Unix-born programs.  Use only if you know
  153. ** exactly what you are doing!
  154. */
  155.  
  156. #define _CRT0_FLAG_PRESERVE_FILENAME_CASE       0x2000
  157.  
  158. /* If set, the quote characters ', ", and \ will be retained in argv[]
  159. ** elements when processing command lines passed via `system'.  This is
  160. ** used by `redir', and should only be needed if you want to get the
  161. ** original command line exactly as it was passed by the caller.
  162. */
  163.  
  164. #define _CRT0_FLAG_KEEP_QUOTES                  0x4000
  165.  
  166. /*****************************************************************************\
  167.  *  Access to the memory handles used by the non-move sbrk algorithm.  
  168.  *  The handle is the SI:DI DPMI handle; the address is the offset relative
  169.  *  to the application's address space.  Address will be zero unused slots > 1.
  170. \*****************************************************************************/
  171.  
  172. typedef struct {
  173.   long handle;
  174.   unsigned address;
  175.   } __djgpp_sbrk_handle;
  176.  
  177. extern __djgpp_sbrk_handle __djgpp_memory_handle_list[256];
  178. __djgpp_sbrk_handle *__djgpp_memory_handle(unsigned address);
  179.  
  180. #endif /* !_POSIX_SOURCE */
  181. #endif /* !__STRICT_ANSI__ */
  182. #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
  183.  
  184. #ifndef __dj_ENFORCE_FUNCTION_CALLS
  185. #endif /* !__dj_ENFORCE_FUNCTION_CALLS */
  186.  
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190.  
  191. #endif /* !__dj_include_crt0_h_ */
  192.