当前位置: 首页>>代码示例>>C++>>正文


C++ MSVCRT__errno函数代码示例

本文整理汇总了C++中MSVCRT__errno函数的典型用法代码示例。如果您正苦于以下问题:C++ MSVCRT__errno函数的具体用法?C++ MSVCRT__errno怎么用?C++ MSVCRT__errno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MSVCRT__errno函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strncpy_s

/*********************************************************************
 *		strncpy_s ([email protected])
 */
int CDECL strncpy_s(char *dest, MSVCRT_size_t numberOfElements,
        const char *src, MSVCRT_size_t count)
{
    MSVCRT_size_t i, end;

    TRACE("(%s %lu %s %lu)\n", dest, numberOfElements, src, count);

    if(!count)
        return 0;

    if(!dest || !src || !numberOfElements) {
        MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    if(count!=MSVCRT__TRUNCATE && count<numberOfElements)
        end = count;
    else
        end = numberOfElements-1;

    for(i=0; i<end && src[i]; i++)
        dest[i] = src[i];

    if(!src[i] || end==count || count==MSVCRT__TRUNCATE) {
        dest[i] = '\0';
        return 0;
    }

    MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
    dest[0] = '\0';
    *MSVCRT__errno() = MSVCRT_EINVAL;
    return MSVCRT_EINVAL;
}
开发者ID:pstrealer,项目名称:wine,代码行数:37,代码来源:heap.c

示例2: MSVCRT__get_tzname

/*********************************************************************
 *		_get_tzname ([email protected])
 */
int CDECL MSVCRT__get_tzname(MSVCRT_size_t *ret, char *buf, MSVCRT_size_t bufsize, int index)
{
    char *timezone;

    switch(index)
    {
    case 0:
        timezone = tzname_std;
        break;
    case 1:
        timezone = tzname_dst;
        break;
    default:
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    if(!ret || (!buf && bufsize > 0) || (buf && !bufsize))
    {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    *ret = strlen(timezone)+1;
    if(!buf && !bufsize)
        return 0;

    strcpy(buf, timezone);
    return 0;
}
开发者ID:mikekap,项目名称:wine,代码行数:33,代码来源:time.c

示例3: MSVCRT__wgetdcwd

/*********************************************************************
 *		_wgetdcwd ([email protected])
 *
 * Unicode version of _wgetdcwd.
 */
MSVCRT_wchar_t* CDECL MSVCRT__wgetdcwd(int drive, MSVCRT_wchar_t * buf, int size)
{
  static MSVCRT_wchar_t* dummy;

  TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);

  if (!drive || drive == MSVCRT__getdrive())
    return MSVCRT__wgetcwd(buf,size); /* current */
  else
  {
    MSVCRT_wchar_t dir[MAX_PATH];
    MSVCRT_wchar_t drivespec[4] = {'A', ':', '\\', 0};
    int dir_len;

    drivespec[0] += drive - 1;
    if (GetDriveTypeW(drivespec) < DRIVE_REMOVABLE)
    {
      *MSVCRT__errno() = MSVCRT_EACCES;
      return NULL;
    }

    dir_len = GetFullPathNameW(drivespec,MAX_PATH,dir,&dummy);
    if (dir_len >= size || dir_len < 1)
    {
      *MSVCRT__errno() = MSVCRT_ERANGE;
      return NULL; /* buf too small */
    }

    TRACE(":returning %s\n", debugstr_w(dir));
    if (!buf)
      return MSVCRT__wcsdup(dir); /* allocate */
    strcpyW(buf,dir);
  }
  return buf;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:40,代码来源:dir.c

示例4: _localtime64_s

/*********************************************************************
 *      _localtime64_s ([email protected])
 */
int CDECL _localtime64_s(struct MSVCRT_tm *time, const MSVCRT___time64_t *secs)
{
    struct tm *tm;
    time_t seconds;

    if (!time || !secs || *secs < 0 || *secs > _MAX__TIME64_T)
    {
        if (time)
            write_invalid_msvcrt_tm(time);

        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    seconds = *secs;

    _mlock(_TIME_LOCK);
    if (!(tm = localtime(&seconds)))
    {
        _munlock(_TIME_LOCK);
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    unix_tm_to_msvcrt(time, tm);
    _munlock(_TIME_LOCK);
    return 0;
}
开发者ID:mikekap,项目名称:wine,代码行数:31,代码来源:time.c

示例5: _strlwr_s_l

/*********************************************************************
 *		_strlwr_s_l ([email protected])
 */
int CDECL _strlwr_s_l(char *str, MSVCRT_size_t len, MSVCRT__locale_t locale)
{
    char *ptr = str;

    if (!str || !len)
    {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    while (len && *ptr)
    {
        len--;
        ptr++;
    }

    if (!len)
    {
        str[0] = '\0';
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    while (*str)
    {
        *str = MSVCRT__tolower_l((unsigned char)*str, locale);
        str++;
    }

    return 0;
}
开发者ID:PatroxGaurab,项目名称:wine,代码行数:34,代码来源:string.c

示例6: MSVCRT__wcsupr_s_l

/******************************************************************
 *		_wcsupr_s_l ([email protected])
 */
int CDECL MSVCRT__wcsupr_s_l( MSVCRT_wchar_t* str, MSVCRT_size_t n,
   MSVCRT__locale_t locale )
{
  MSVCRT_wchar_t* ptr = str;

  if (!str || !n)
  {
    if (str) *str = '\0';
    *MSVCRT__errno() = MSVCRT_EINVAL;
    return MSVCRT_EINVAL;
  }

  while (n--)
  {
    if (!*ptr) return 0;
    /* FIXME: add locale support */
    *ptr = toupperW(*ptr);
    ptr++;
  }

  /* MSDN claims that the function should return and set errno to
   * ERANGE, which doesn't seem to be true based on the tests. */
  *str = '\0';
  *MSVCRT__errno() = MSVCRT_EINVAL;
  return MSVCRT_EINVAL;
}
开发者ID:bpowers,项目名称:wine,代码行数:29,代码来源:wcs.c

示例7: memmove_s

/*********************************************************************
 *		memmove_s ([email protected])
 */
int CDECL memmove_s(void *dest, MSVCRT_size_t numberOfElements, const void *src, MSVCRT_size_t count)
{
    TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count);

    if(!count)
        return 0;

    if(!dest || !src) {
        if(dest)
            memset(dest, 0, numberOfElements);

        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    if(count > numberOfElements) {
        memset(dest, 0, numberOfElements);

        *MSVCRT__errno() = MSVCRT_ERANGE;
        return MSVCRT_ERANGE;
    }

    memmove(dest, src, count);
    return 0;
}
开发者ID:pstrealer,项目名称:wine,代码行数:28,代码来源:heap.c

示例8: MSVCRT___wcserror_s

/**********************************************************************
 *		__wcserror_s	([email protected])
 */
int CDECL MSVCRT___wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, const MSVCRT_wchar_t* str)
{
    int err;
    static const WCHAR colonW[] = {':', ' ', '\0'};
    static const WCHAR nlW[] = {'\n', '\0'};
    size_t len;

    err = *MSVCRT__errno();
    if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;

    len = MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, NULL, 0) + 1 /* \n */;
    if (str && *str) len += lstrlenW(str) + 2 /* ': ' */;
    if (len > nc)
    {
        MSVCRT_INVALID_PMT("buffer[nc] is too small", MSVCRT_ERANGE);
        return MSVCRT_ERANGE;
    }
    if (str && *str)
    {
        lstrcpyW(buffer, str);
        lstrcatW(buffer, colonW);
    }
    else buffer[0] = '\0';
    len = lstrlenW(buffer);
    MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer + len, 256 - len);
    lstrcatW(buffer, nlW);

    return 0;
}
开发者ID:ccpgames,项目名称:wine,代码行数:32,代码来源:errno.c

示例9: _cwait

/*********************************************************************
 *		_cwait ([email protected])
 */
MSVCRT_intptr_t CDECL _cwait(int *status, MSVCRT_intptr_t pid, int action)
{
  HANDLE hPid = (HANDLE)pid;
  int doserrno;

  action = action; /* Remove warning */

  if (!WaitForSingleObject(hPid, INFINITE))
  {
    if (status)
    {
      DWORD stat;
      GetExitCodeProcess(hPid, &stat);
      *status = (int)stat;
    }
    return pid;
  }
  doserrno = GetLastError();

  if (doserrno == ERROR_INVALID_HANDLE)
  {
    *MSVCRT__errno() =  MSVCRT_ECHILD;
    *MSVCRT___doserrno() = doserrno;
  }
  else
    msvcrt_set_errno(doserrno);

  return status ? *status = -1 : -1;
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:32,代码来源:process.c

示例10: MSVCRT_malloc

/*********************************************************************
 *                  malloc ([email protected])
 */
void* CDECL MSVCRT_malloc(MSVCRT_size_t size)
{
  void *ret = msvcrt_heap_alloc(0, size);
  if (!ret)
      *MSVCRT__errno() = MSVCRT_ENOMEM;
  return ret;
}
开发者ID:iXit,项目名称:wine,代码行数:10,代码来源:heap.c

示例11: MSVCRT_malloc

/*********************************************************************
 *                  malloc ([email protected])
 */
void* CDECL MSVCRT_malloc(MSVCRT_size_t size)
{
  void *ret = HeapAlloc(GetProcessHeap(),0,size);
  if (!ret)
      *MSVCRT__errno() = MSVCRT_ENOMEM;
  return ret;
}
开发者ID:pstrealer,项目名称:wine,代码行数:10,代码来源:heap.c

示例12: _wstrtime_s

/*********************************************************************
 *              _wstrtime_s ([email protected])
 */
int CDECL _wstrtime_s(MSVCRT_wchar_t* time, MSVCRT_size_t size)
{
    if(time && size)
        time[0] = '\0';

    if(!time) {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    if(size < 9) {
        *MSVCRT__errno() = MSVCRT_ERANGE;
        return MSVCRT_ERANGE;
    }

    _wstrtime(time);
    return 0;
}
开发者ID:mikekap,项目名称:wine,代码行数:21,代码来源:time.c

示例13: _wstrdate_s

/**********************************************************************
 *              _wstrdate_s ([email protected])
 */
int CDECL _wstrdate_s(MSVCRT_wchar_t* date, MSVCRT_size_t size)
{
    if(date && size)
        date[0] = '\0';

    if(!date) {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }

    if(size < 9) {
        *MSVCRT__errno() = MSVCRT_ERANGE;
        return MSVCRT_ERANGE;
    }

    _wstrdate(date);
    return 0;
}
开发者ID:mikekap,项目名称:wine,代码行数:21,代码来源:time.c

示例14: MSVCRT_rand_s

/*********************************************************************
 *		rand_s ([email protected])
 */
int CDECL MSVCRT_rand_s(unsigned int *pval)
{
    if (!pval || !RtlGenRandom(pval, sizeof(*pval)))
    {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }
    return 0;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:12,代码来源:misc.c

示例15: MSVCRT__ctime32_s

/*********************************************************************
 *		_ctime32_s ([email protected])
 */
int CDECL MSVCRT__ctime32_s(char *res, MSVCRT_size_t len, const MSVCRT___time32_t *time)
{
    struct MSVCRT_tm *t;
    if( !MSVCRT_CHECK_PMT( res != NULL ) || !MSVCRT_CHECK_PMT( len >= 26 ) )
    {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }
    res[0] = '\0';
    if( !MSVCRT_CHECK_PMT( time != NULL ) || !MSVCRT_CHECK_PMT( *time > 0 ) )
    {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return MSVCRT_EINVAL;
    }
    t = MSVCRT__localtime32( time );
    strcpy( res, MSVCRT_asctime( t ) );
    return 0;
}
开发者ID:mikekap,项目名称:wine,代码行数:21,代码来源:time.c


注:本文中的MSVCRT__errno函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。