亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? osfinfo.c

?? C標準庫源代碼,能提高對C的理解,不錯的哦
?? C
?? 第 1 頁 / 共 2 頁
字號:
/***
*osfinfo.c - Win32 _osfhnd[] support routines
*
*       Copyright (c) 1990-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Defines the internally used routine _alloc_osfhnd()
*       and the user visible routine _get_osfhandle().
*
*******************************************************************************/

#ifndef _MAC


#include <cruntime.h>
#include <oscalls.h>
#include <errno.h>
#include <internal.h>
#include <fcntl.h>
#include <malloc.h>
#include <msdos.h>
#include <mtdll.h>
#include <stdlib.h>
#include <dbgint.h>


/***
*int _alloc_osfhnd() - get free _ioinfo struct
*
*Purpose:
*       Finds the first free entry in the arrays of ioinfo structs and
*       returns the index of that entry (which is the CRT file handle to the
*       caller) to the caller.
*
*Entry:
*       none
*
*Exit:
*       returns index of the entry, if successful
*       return -1, if no free entry is available
*
*       MULTITHREAD NOTE: IF SUCCESSFUL, THE HANDLE IS LOCKED WHEN IT IS
*       RETURNED TO THE CALLER!
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _alloc_osfhnd(
        void
        )
{
        int fh = -1;    /* file handle */
        int i;
        ioinfo *pio;

        _mlock(_OSFHND_LOCK);   /* lock the __pioinfo[] array */

        /*
         * Search the arrays of ioinfo structs, in order, looking for the
         * first free entry. The compound index of this free entry is the
         * return value. Here, the compound index of the ioinfo struct
         * *(__pioinfo[i] + j) is k = i * IOINFO_ARRAY_ELTS + j, and k = 0,
         * 1, 2,... is the order of the search.
         */
        for ( i = 0 ; i < IOINFO_ARRAYS ; i++ ) {
            /*
             * If __pioinfo[i] is non-empty array, search it looking for
             * the first free entry. Otherwise, allocate a new array and use
             * its first entry.
             */
            if ( __pioinfo[i] != NULL ) {
                /*
                 * Search for an available entry.
                 */
                for ( pio = __pioinfo[i] ;
                      pio < __pioinfo[i] + IOINFO_ARRAY_ELTS ;
                      pio++ )
                {
                    if ( (pio->osfile & FOPEN) == 0 ) {
#ifdef _MT
                        /*
                         * Make sure the lock is initialized.
                         */
                        if ( pio->lockinitflag == 0 ) {
                            _mlock( _LOCKTAB_LOCK );
                            if ( pio->lockinitflag == 0 ) {
                                InitializeCriticalSection( &(pio->lock) );
                                pio->lockinitflag++;
                            }
                            _munlock( _LOCKTAB_LOCK );
                        }

                        EnterCriticalSection( &(pio->lock) );

                        /*
                         * Check for the case where another thread has
                         * managed to grab the handle out from under us.
                         */
                        if ( (pio->osfile & FOPEN) != 0 ) {
                            LeaveCriticalSection( &(pio->lock) );
                            continue;
                        }
#endif  /* _MT */
                        pio->osfhnd = (long)INVALID_HANDLE_VALUE;
                        fh = i * IOINFO_ARRAY_ELTS + (pio - __pioinfo[i]);
                        break;
                    }
                }

                /*
                 * Check if a free entry has been found.
                 */
                if ( fh != -1 )
                    break;
            }
            else {
            /*
             * Allocate and initialize another array of ioinfo structs.
             */
            if ( (pio = _malloc_crt( IOINFO_ARRAY_ELTS * sizeof(ioinfo) ))
                != NULL )
            {

                /*
                 * Update __pioinfo[] and _nhandle
                 */
                __pioinfo[i] = pio;
                _nhandle += IOINFO_ARRAY_ELTS;

                for ( ; pio < __pioinfo[i] + IOINFO_ARRAY_ELTS ; pio++ ) {
                    pio->osfile = 0;
                    pio->osfhnd = (long)INVALID_HANDLE_VALUE;
                    pio->pipech = 10;
#ifdef _MT
                    pio->lockinitflag = 0;
#endif  /* _MT */
                }

                /*
                 * The first element of the newly allocated array of ioinfo
                 * structs, *(__pioinfo[i]), is our first free entry.
                 */
                fh = i * IOINFO_ARRAY_ELTS;
#ifdef _MT
                    _lock_fhandle( fh );
#endif  /* _MT */
            }

            break;
            }
        }

        _munlock(_OSFHND_LOCK); /* unlock the __pioinfo[] table */


        /*
         * return the index of the previously free table entry, if one was
         * found. return -1 otherwise.
         */
        return( fh );
}


/***
*int _set_osfhnd(int fh, long value) - set Win32 HANDLE value
*
*Purpose:
*       If fh is in range and if _osfhnd(fh) is marked with
*       INVALID_HANDLE_VALUE then set _osfhnd(fh) to the passed value.
*
*Entry:
*       int fh      - CRT file handle
*       long value  - new Win32 HANDLE value for this handle
*
*Exit:
*       Returns zero if successful.
*       Returns -1 and sets errno to EBADF otherwise.
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _set_osfhnd (
        int fh,
        long value
        )
{
        if ( ((unsigned)fh < (unsigned)_nhandle) &&
             (_osfhnd(fh) == (long)INVALID_HANDLE_VALUE)
           ) {
            if ( __app_type == _CONSOLE_APP ) {
                switch (fh) {
                case 0:
                    SetStdHandle( STD_INPUT_HANDLE, (HANDLE)value );
                    break;
                case 1:
                    SetStdHandle( STD_OUTPUT_HANDLE, (HANDLE)value );
                    break;
                case 2:
                    SetStdHandle( STD_ERROR_HANDLE, (HANDLE)value );
                    break;
                }
            }

            _osfhnd(fh) = value;
            return(0);
        } else {
            errno = EBADF;      /* bad handle */
            _doserrno = 0L;     /* not an OS error */
            return -1;
        }
}


/***
*int _free_osfhnd(int fh) - mark osfhnd field of ioinfo struct as free
*
*Purpose:
*       If fh is in range, the corrsponding ioinfo struct is marked as
*       being open, and the osfhnd field is NOT set to INVALID_HANDLE_VALUE,
*       then mark it with INVALID_HANDLE_VALUE.
*
*Entry:
*       int fh -    CRT file handle
*
*Exit:
*       Returns zero if successful.
*       Returns -1 and sets errno to EBADF otherwise.
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _free_osfhnd (
        int fh      /* user's file handle */
        )
{
        if ( ((unsigned)fh < (unsigned)_nhandle) &&
             (_osfile(fh) & FOPEN) &&
             (_osfhnd(fh) != (long)INVALID_HANDLE_VALUE) )
        {
            if ( __app_type == _CONSOLE_APP ) {
                switch (fh) {
                case 0:
                    SetStdHandle( STD_INPUT_HANDLE, NULL );
                    break;
                case 1:
                    SetStdHandle( STD_OUTPUT_HANDLE, NULL );
                    break;
                case 2:
                    SetStdHandle( STD_ERROR_HANDLE, NULL );
                    break;
                }
            }

            _osfhnd(fh) = (long)INVALID_HANDLE_VALUE;
            return(0);
        } else {
            errno = EBADF;      /* bad handle */
            _doserrno = 0L;     /* not an OS error */
            return -1;
        }
}


/***
*long _get_osfhandle(int fh) - get Win32 HANDLE value
*
*Purpose:
*       If fh is in range and marked open, return _osfhnd(fh).
*
*Entry:
*       int fh  - CRT file handle
*
*Exit:
*       Returns the Win32 HANDLE successful.
*       Returns -1 and sets errno to EBADF otherwise.
*
*Exceptions:
*
*******************************************************************************/

long __cdecl _get_osfhandle (
        int fh      /* user's file handle */
        )
{
        if ( ((unsigned)fh < (unsigned)_nhandle) && (_osfile(fh) & FOPEN) )
            return( _osfhnd(fh) );
        else {
            errno = EBADF;      /* bad handle */
            _doserrno = 0L;     /* not an OS error */
            return -1;
        }
}

/***
*int _open_osfhandle(long osfhandle, int flags) - open C Runtime file handle
*
*Purpose:
*       This function allocates a free C Runtime file handle and associates
*       it with the Win32 HANDLE specified by the first parameter.
*
*Entry:
*       long osfhandle - Win32 HANDLE to associate with C Runtime file handle.
*       int flags      - flags to associate with C Runtime file handle.
*
*Exit:
*       returns index of entry in fh, if successful
*       return -1, if no free entry is found
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _open_osfhandle(
        long osfhandle,
        int flags
        )
{
        int fh;
        char fileflags;         /* _osfile flags */
        DWORD isdev;            /* device indicator in low byte */

        /* copy relevant flags from second parameter */

        fileflags = 0;

        if ( flags & _O_APPEND )
            fileflags |= FAPPEND;

        if ( flags & _O_TEXT )
            fileflags |= FTEXT;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丁香亚洲综合激情啪啪综合| 欧美在线观看一区二区| 最新欧美精品一区二区三区| 欧美日韩国产一二三| 91啪亚洲精品| 97久久超碰国产精品| www.66久久| 成人亚洲一区二区一| 成人看片黄a免费看在线| 91精品婷婷国产综合久久竹菊| 欧美性感一区二区三区| 欧美色图激情小说| 91麻豆精品国产91久久久| 国产精品乱子久久久久| 中文字幕亚洲欧美在线不卡| 久久国产欧美日韩精品| 蜜乳av一区二区| 国产资源在线一区| 国产一区二区三区美女| 国产精品正在播放| 99re亚洲国产精品| 国产三级一区二区| 国产精品不卡视频| 香蕉久久夜色精品国产使用方法 | 国产乱码精品一区二区三区五月婷| 91在线视频18| 国产精品伦一区| 成人美女视频在线看| 国产精品素人视频| 国产风韵犹存在线视精品| 日本乱码高清不卡字幕| 91精品国产全国免费观看| 欧美精品一区二区在线观看| 中文字幕精品一区二区精品绿巨人| 国产精品国产三级国产有无不卡| 精品一区二区三区香蕉蜜桃| 色婷婷国产精品久久包臀| 555www色欧美视频| 日日夜夜精品视频免费| 国产精品一区二区你懂的| 精品国产免费人成在线观看| 美脚の诱脚舐め脚责91| 日韩免费看的电影| 中文字幕字幕中文在线中不卡视频| 免费日本视频一区| 日本韩国精品一区二区在线观看| 亚洲欧美日韩精品久久久久| 久久99国内精品| 久久免费视频一区| 午夜精品影院在线观看| 99久久精品免费精品国产| 国产精品久久久久久妇女6080| 成人app软件下载大全免费| 日韩无一区二区| 亚洲综合激情小说| 成人性视频网站| 中文字幕一区二区三区在线不卡| 99免费精品视频| 亚洲综合偷拍欧美一区色| 欧美日本在线看| 九九国产精品视频| 国产精品视频你懂的| 欧美吻胸吃奶大尺度电影| 九九在线精品视频| 1区2区3区国产精品| 欧美色综合网站| 国产精品一区在线| 亚洲黄色片在线观看| 成人av集中营| 亚洲国产成人va在线观看天堂| 91色婷婷久久久久合中文| 五月综合激情网| 久久精品免视看| 在线免费观看日本欧美| 精品一区二区国语对白| 亚洲黄色录像片| 精品剧情v国产在线观看在线| 日韩福利电影在线观看| 欧美久久久久久久久中文字幕| 一区二区久久久久| 色综合久久中文综合久久牛| 天天综合网天天综合色| 国产精品免费人成网站| 欧美一区二区三区视频在线观看| 成人精品国产福利| 久久激情五月激情| 亚洲欧美日韩一区| 久久久夜色精品亚洲| 91精品欧美久久久久久动漫| 99热国产精品| 国产精品99久久久久久久vr| 亚洲成人免费电影| 成人欧美一区二区三区| 2017欧美狠狠色| 成人av高清在线| 韩国三级中文字幕hd久久精品| 亚洲国产精品视频| 亚洲激情图片小说视频| 中文字幕高清不卡| 久久久九九九九| 欧美一区二区在线看| 欧美日韩一区二区三区不卡| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | k8久久久一区二区三区| 久久99精品国产.久久久久| 视频一区中文字幕| 亚洲自拍偷拍欧美| 一区二区三区精品在线观看| 国产精品嫩草影院com| 国产亚洲成av人在线观看导航| 欧美成人a视频| 欧美欧美欧美欧美首页| 欧美人牲a欧美精品| 在线观看av一区二区| 在线一区二区视频| 色欧美片视频在线观看在线视频| 不卡一区二区在线| 9人人澡人人爽人人精品| 成av人片一区二区| 不卡一卡二卡三乱码免费网站| 不卡一二三区首页| 99免费精品在线| 欧美亚洲一区二区在线观看| 日本大香伊一区二区三区| 91成人免费在线| 欧美高清视频不卡网| 欧美高清激情brazzers| 欧美电影一区二区三区| 欧美第一区第二区| 国产欧美日韩麻豆91| 欧美精品在线一区二区| 欧美精品乱人伦久久久久久| 欧美一级免费观看| 久久综合久久综合亚洲| 久久久www成人免费毛片麻豆 | 精品少妇一区二区三区日产乱码| 欧美一区二区三区在线电影| 日韩欧美一区在线| 国产午夜精品一区二区三区嫩草 | 麻豆91精品视频| 国产一本一道久久香蕉| 99久久精品国产观看| 欧洲av在线精品| 欧美高清dvd| 欧美精品一区男女天堂| 综合色天天鬼久久鬼色| 亚洲成a人v欧美综合天堂| 久久se这里有精品| 99久久婷婷国产综合精品电影| 欧美三级电影在线看| 久久综合狠狠综合久久激情| 亚洲欧美影音先锋| 免费欧美日韩国产三级电影| 国产v日产∨综合v精品视频| 在线免费观看视频一区| 26uuu久久综合| 亚洲男女一区二区三区| 久久精品国产免费看久久精品| 丁香婷婷综合色啪| 欧美日韩一区二区三区视频| 久久九九国产精品| 三级在线观看一区二区| 99久久精品国产麻豆演员表| 日韩一区二区三区在线| 亚洲特级片在线| 黄页视频在线91| 欧美日韩国产电影| 中文字幕日本不卡| 久久超碰97中文字幕| 欧美三级中文字| 国产精品乱人伦中文| 国模娜娜一区二区三区| 欧美视频精品在线观看| 中文字幕日韩一区| 福利电影一区二区| 777奇米四色成人影色区| 亚洲青青青在线视频| 国产福利一区二区三区| 欧美一区二区三区啪啪| 亚洲精品一二三区| www.综合网.com| 国产亚洲精品中文字幕| 日本免费在线视频不卡一不卡二| 97se狠狠狠综合亚洲狠狠| 久久网站最新地址| 久久99精品久久只有精品| 91 com成人网| 亚洲国产精品影院| 在线亚洲一区二区| 亚洲免费在线观看视频| 成人午夜私人影院| 中文子幕无线码一区tr| 成人一区在线观看| 久久蜜臀中文字幕| 国产毛片精品一区| 国产拍欧美日韩视频二区| 国产伦精品一区二区三区免费迷| 日韩欧美黄色影院| 精品一区二区免费视频| 欧美成人一区二区|