ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

errno.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS system libraries
00004  * FILE:        lib/crt/errno.c
00005  * PURPOSE:     Unknown
00006  * PROGRAMER:   Unknown
00007  *
00008  */
00009 #include <precomp.h>
00010 #include "doserrmap.h"
00011 #include <errno.h>
00012 #include <internal/wine/msvcrt.h>
00013 
00014 static _invalid_parameter_handler invalid_parameter_handler = NULL;
00015 
00016 /*
00017  * @implemented
00018  */
00019 unsigned long* CDECL __doserrno(void)
00020 {
00021     return &(msvcrt_get_thread_data()->thread_doserrno);
00022 }
00023 
00024 /*
00025  * @implemented
00026  */
00027 int CDECL *_errno(void)
00028 {
00029     return &(msvcrt_get_thread_data()->thread_errno);
00030 }
00031 
00032 /*
00033  * @implemented
00034  */
00035 errno_t CDECL _get_doserrno(unsigned long *pValue)
00036 {
00037     if (!pValue)
00038         return EINVAL;
00039 
00040     *pValue = *__doserrno();
00041     return 0;
00042 }
00043 
00044 /*
00045  * @implemented
00046  */
00047 errno_t CDECL _set_doserrno(unsigned long error)
00048 {
00049     *__doserrno() = error;
00050     return 0;
00051 }
00052 
00053 /*
00054  * @implemented
00055  */
00056 errno_t CDECL _get_errno(int *pValue)
00057 {
00058     if (!pValue)
00059         return EINVAL;
00060 
00061     *pValue = *_errno();
00062     return 0;
00063 }
00064 
00065 /*
00066  * @implemented
00067  */
00068 int CDECL _set_errno(int error)
00069 {
00070     *_errno() = error;
00071     return 0;
00072 }
00073 
00074 /*
00075  * This function sets both doserrno to the passed in OS error code
00076  * and also maps this to an appropriate errno code.  The mapping
00077  * has been deduced automagically by running this functions, which
00078  * exists in MSVCRT but is undocumented, on all the error codes in
00079  * winerror.h.
00080  */
00081 void CDECL _dosmaperr(unsigned long oserror)
00082 {
00083     int pos, base, lim;
00084 
00085     _set_doserrno(oserror);
00086 
00087     /* Use binary chop to find the corresponding errno code */
00088     for (base=0, lim=sizeof(doserrmap)/sizeof(doserrmap[0]); lim; lim >>= 1) {
00089         pos = base+(lim >> 1);
00090         if (doserrmap[pos].winerr == oserror) {
00091             _set_errno(doserrmap[pos].en);
00092             return;
00093         } else if (doserrmap[pos].winerr < oserror) {
00094             base = pos + 1;
00095             --lim;
00096         }
00097     }
00098     /* EINVAL appears to be the default */
00099     _set_errno(EINVAL);
00100 }
00101 
00102 /******************************************************************************
00103 *              _set_error_mode (MSVCRT.@)
00104 *
00105 * Set the error mode, which describes where the C run-time writes error
00106 * messages.
00107 *
00108 * PARAMS
00109 *   mode - the new error mode
00110 *
00111 * RETURNS
00112 *   The old error mode.
00113 *
00114 */
00115 int msvcrt_error_mode = MSVCRT__OUT_TO_DEFAULT;
00116 
00117 int CDECL _set_error_mode(int mode)
00118 {
00119     const int old = msvcrt_error_mode;
00120     if ( MSVCRT__REPORT_ERRMODE != mode ) {
00121         msvcrt_error_mode = mode;
00122     }
00123     return old;
00124 }
00125 
00126 /******************************************************************************
00127 *              _seterrormode (MSVCRT.@)
00128 */
00129 void CDECL _seterrormode(int mode)
00130 {
00131     SetErrorMode( mode );
00132 }
00133 
00134 /******************************************************************************
00135  *      _invalid_parameter (MSVCRT.@)
00136  */
00137 void CDECL _invalid_parameter(const wchar_t *expr, const wchar_t *func,
00138                                        const wchar_t *file, unsigned int line, uintptr_t arg)
00139 {
00140     if (invalid_parameter_handler) invalid_parameter_handler( expr, func, file, line, arg );
00141     else
00142     {
00143         ERR( "%s:%u %s: %s %lx\n", debugstr_w(file), line, debugstr_w(func), debugstr_w(expr), arg );
00144         RaiseException( STATUS_INVALID_CRUNTIME_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, NULL );
00145     }
00146 }
00147 
00148 /* _get_invalid_parameter_handler - not exported in native msvcrt, added in msvcr80 */
00149 _invalid_parameter_handler CDECL _get_invalid_parameter_handler(void)
00150 {
00151     TRACE("\n");
00152     return invalid_parameter_handler;
00153 }
00154 
00155 /* _set_invalid_parameter_handler - not exproted in native msvcrt, added in msvcr80 */
00156 _invalid_parameter_handler CDECL _set_invalid_parameter_handler(
00157         _invalid_parameter_handler handler)
00158 {
00159     _invalid_parameter_handler old = invalid_parameter_handler;
00160 
00161     TRACE("(%p)\n", handler);
00162 
00163     invalid_parameter_handler = handler;
00164     return old;
00165 }
00166 /* EOF */

Generated on Thu May 24 2012 04:37:03 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.