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

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

?? popen.c

?? C標準庫源代碼,能提高對C的理解,不錯的哦
?? C
?? 第 1 頁 / 共 2 頁
字號:
/***
*popen.c - initiate a pipe and a child command
*
*       Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Defines _popen() and _pclose().
*
*******************************************************************************/


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

/* size for pipe buffer
 */
#define PSIZE     1024

#define STDIN     0
#define STDOUT    1


/* definitions for table of stream pointer - process handle pairs. the table
 * is created, maintained and accessed by the idtab function. _popen and
 * _pclose gain access to table entries only by calling idtab. Note that the
 * table is expanded as necessary (by idtab) and free table entries are reused
 * (an entry is free if its stream field is NULL), but the table is never
 * contracted.
 */

typedef struct {
        FILE *stream;
        int prochnd;
} IDpair;

/* number of entries in idpairs table
 */
#ifndef _UNICODE
unsigned __idtabsiz = 0;
#else  /* _UNICODE */
extern unsigned __idtabsiz;
#endif  /* _UNICODE */

/* pointer to first table entry
 */
#ifndef _UNICODE
IDpair *__idpairs = NULL;
#else  /* _UNICODE */
extern IDpair *__idpairs;
#endif  /* _UNICODE */

/* function to find specified table entries. also, creates and maintains
 * the table.
 */
static IDpair * __cdecl idtab(FILE *);


/***
*FILE *_popen(cmdstring,type) - initiate a pipe and a child command
*
*Purpose:
*       Creates a pipe and asynchronously executes a child copy of the command
*       processor with cmdstring (see system()). If the type string contains
*       an 'r', the calling process can read child command's standard output
*       via the returned stream. If the type string contains a 'w', the calling
*       process can write to the child command's standard input via the
*       returned stream.
*
*Entry:
*       _TSCHAR *cmdstring - command to be executed
*       _TSCHAR *type   - string of the form "r|w[b|t]", determines the mode
*                         of the returned stream (i.e., read-only vs write-only,
*                         binary vs text mode)
*
*Exit:
*       If successful, returns a stream associated with one end of the created
*       pipe (the other end of the pipe is associated with either the child
*       command's standard input or standard output).
*
*       If an error occurs, NULL is returned.
*
*Exceptions:
*
*******************************************************************************/

FILE * __cdecl _tpopen (
        const _TSCHAR *cmdstring,
        const _TSCHAR *type
        )
{

        int phdls[2];             /* I/O handles for pipe */
        int ph_open[2];           /* flags, set if correspond phdls is open */
        int i1;                   /* index into phdls[] */
        int i2;                   /* index into phdls[] */

        int tm = 0;               /* flag indicating text or binary mode */

        int stdhdl;               /* either STDIN or STDOUT */
        HANDLE osfhndsv1;         /* used to save _osfhnd(stdhdl) */
        long osfhndsv2;           /* used to save _osfhnd(phdls[i2]) */
        char osfilesv1;           /* used to save _osfile(stdhdl) */
        char osfilesv2;           /* used to save _osfile(phdls[i2]) */

        HANDLE oldhnd;            /* used to hold OS file handle values... */
        HANDLE newhnd;            /* ...in calls to DuplicateHandle API */

        FILE *pstream;            /* stream to be associated with pipe */

        HANDLE prochnd;           /* handle for current process */

        _TSCHAR *cmdexe;                  /* pathname for the command processor */
        int childhnd;             /* handle for child process (cmd.exe) */

        IDpair *locidpair;        /* pointer to IDpair table entry */


        /* first check for errors in the arguments
         */
        if ( (cmdstring == NULL) || (type == NULL) || ((*type != 'w') &&
             (*type != _T('r'))) )
                goto error1;

        /* do the _pipe(). note that neither of the resulting handles will
         * be inheritable.
         */

        if ( *(type + 1) == _T('t') )
                tm = _O_TEXT;
        else if ( *(type + 1) == _T('b') )
                tm = _O_BINARY;

        tm |= _O_NOINHERIT;

        if ( _pipe( phdls, PSIZE, tm ) == -1 )
                goto error1;

        /* test *type and set stdhdl, i1 and i2 accordingly.
         */
        if ( *type == _T('w') ) {
                stdhdl = STDIN;
                i1 = 0;
                i2 = 1;
        }
        else {
                stdhdl = STDOUT;
                i1 = 1;
                i2 = 0;
        }

        /* the pipe now exists. the following steps must be carried out before
         * the child process (cmd.exe) may be spawned:
         *
         *      1. save a non-inheritable dup of stdhdl
         *
         *      2. force stdhdl to be a dup of ph[i1]. close both ph[i1] and
         *         the original OS handle underlying stdhdl
         *
         *      3. associate a stdio-level stream with ph[i2].
         */

        /* set flags to indicate pipe handles are open. note, these are only
         * used for error recovery.
         */
        ph_open[ 0 ] = ph_open[ 1 ] = 1;


        /* get the process handle, it will be needed in some API calls
         */
        prochnd = GetCurrentProcess();

        /* MULTI-THREAD: ASSERT LOCK ON STDHDL HERE!!!!
         */
        _lock_fh( stdhdl );

        /* save a non-inheritable copy of stdhdl for later restoration.
         */

        oldhnd = (HANDLE)_osfhnd( stdhdl );

        if ( (oldhnd == INVALID_HANDLE_VALUE) ||
             !DuplicateHandle( prochnd,
                               oldhnd,
                               prochnd,
                               &osfhndsv1,
                               0L,
                               FALSE,                   /* non-inheritable */
                               DUPLICATE_SAME_ACCESS )
        ) {
                goto error2;
        }

        osfilesv1 = _osfile( stdhdl );

        /* force stdhdl to an inheritable dup of phdls[i1] (i.e., force
         * STDIN to the pipe read handle or STDOUT to the pipe write handle)
         * and close phdls[i1] (so there won't be a stray open handle on the
         * pipe after a _pclose). also, clear ph_open[i1] flag so that error
         * recovery won't try to close it again.
         */

        if ( !DuplicateHandle( prochnd,
                               (HANDLE)_osfhnd( phdls[i1] ),
                               prochnd,
                               &newhnd,
                               0L,
                               TRUE,                    /* inheritable */
                               DUPLICATE_SAME_ACCESS )
        ) {
                goto error3;
        }

        (void)CloseHandle( (HANDLE)_osfhnd(stdhdl) );
        _free_osfhnd( stdhdl );

        _set_osfhnd( stdhdl, (long)newhnd );
        _osfile( stdhdl ) = _osfile( phdls[i1] );

        (void)_close( phdls[i1] );
        ph_open[ i1 ] = 0;


        /* associate a stream with phdls[i2]. note that if there are no
         * errors, pstream is the return value to the caller.
         */
        if ( (pstream = _tfdopen( phdls[i2], type )) == NULL )
                goto error4;

        /* MULTI-THREAD: ASSERT LOCK ON IDPAIRS HERE!!!!
         */
        _mlock( _POPEN_LOCK );

        /* next, set locidpair to a free entry in the idpairs table.
         */
        if ( (locidpair = idtab( NULL )) == NULL )
                goto error5;


        /* temporarily change the osfhnd and osfile entries so that
         * the child doesn't get any entries for phdls[i2].
         */
        osfhndsv2 = _osfhnd( phdls[i2] );
        _osfhnd( phdls[i2] ) = (long)INVALID_HANDLE_VALUE;
        osfilesv2 = _osfile( phdls[i2] );
        _osfile( phdls[i2] ) = 0;

        /* spawn the child copy of cmd.exe. the algorithm is adapted from
         * SYSTEM.C, and behaves the same way.
         */
        if ( ((cmdexe = _tgetenv(_T("COMSPEC"))) == NULL) ||
             (((childhnd = _tspawnl( _P_NOWAIT,
                                    cmdexe,
                                    cmdexe,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
717成人午夜免费福利电影| 成人福利视频网站| 日韩一区二区三区电影在线观看| 极品销魂美女一区二区三区| 一区二区三区四区乱视频| 国产嫩草影院久久久久| 欧美mv和日韩mv国产网站| 欧美精品三级在线观看| 成人动漫一区二区| 国产在线观看免费一区| 久久精品国产亚洲aⅴ | 美女一区二区三区在线观看| 亚洲男人的天堂在线观看| 亚洲国产成人私人影院tom| 2024国产精品| 精品国产免费久久| wwww国产精品欧美| 久久九九久精品国产免费直播| 欧美精品色综合| 91影院在线免费观看| proumb性欧美在线观看| 色综合天天视频在线观看| www.欧美精品一二区| 成人亚洲精品久久久久软件| 国产精品99久久久| av在线综合网| 国产不卡视频一区| 国产一区中文字幕| 国产99久久久国产精品潘金 | 在线一区二区三区四区| 91免费在线播放| 在线影院国内精品| 欧美日韩不卡视频| 精品成人在线观看| 国产精品免费看片| 亚洲视频一区二区在线| 中文在线一区二区| 有码一区二区三区| 日本强好片久久久久久aaa| 蜜桃久久久久久| 国产不卡在线视频| 欧美怡红院视频| 欧洲视频一区二区| 欧美一级理论片| 国产精品理论在线观看| 午夜国产不卡在线观看视频| 久久99精品久久久久婷婷| 成人激情电影免费在线观看| 精品视频一区 二区 三区| 日韩欧美电影一区| 综合激情成人伊人| 日本亚洲一区二区| 91视频观看免费| 欧美精品一区二区在线观看| 亚洲靠逼com| 久草热8精品视频在线观看| 91在线观看污| 欧美tickling挠脚心丨vk| 亚洲欧美日韩久久精品| 日本中文一区二区三区| av毛片久久久久**hd| 91精品久久久久久久久99蜜臂| 久久青草国产手机看片福利盒子| 亚洲影视资源网| 国产成人在线网站| 日韩午夜在线影院| 一区二区三区欧美亚洲| 日产国产高清一区二区三区| av在线播放不卡| 欧美精品一区二区三区高清aⅴ | 国产成人免费9x9x人网站视频| 在线观看日韩高清av| 91精品国产综合久久久久| 久久你懂得1024| 日本少妇一区二区| 欧美日韩综合不卡| 亚洲精品视频一区二区| 成人免费视频一区| 26uuu国产日韩综合| 日韩精品一区第一页| 99久久综合精品| 亚洲三级在线免费| 久久99精品国产| 日韩无一区二区| 亚洲你懂的在线视频| 成人看片黄a免费看在线| 精品av综合导航| 日韩激情av在线| 日韩视频一区二区在线观看| 亚洲成a人在线观看| 欧美怡红院视频| 亚洲成av人影院| 欧美日韩激情一区二区| 亚洲精品第一国产综合野| 99久久综合色| 亚洲精品视频在线看| 色94色欧美sute亚洲线路二| 中文字幕中文在线不卡住| 成人黄色小视频在线观看| 国产精品欧美经典| 91丨porny丨户外露出| 亚洲色图.com| 欧美色老头old∨ideo| 天堂va蜜桃一区二区三区| 91精品国产黑色紧身裤美女| 日韩va欧美va亚洲va久久| 日韩欧美亚洲国产另类| 国产一区二区三区免费| 国产日产欧产精品推荐色| 国产成人aaaa| 亚洲乱码国产乱码精品精小说| 色婷婷精品大在线视频| 亚洲成a天堂v人片| 中文一区在线播放| 日韩欧美综合在线| 色综合久久综合| 国产精品一区二区三区乱码| 亚洲国产一二三| 国产精品久久久久久久久免费桃花| 欧美三级中文字幕| av午夜精品一区二区三区| 麻豆精品新av中文字幕| 亚洲精品ww久久久久久p站| 久久久精品天堂| 日韩欧美国产三级电影视频| 欧美网站大全在线观看| 懂色av噜噜一区二区三区av| 日本特黄久久久高潮| 亚洲mv大片欧洲mv大片精品| 中文字幕一区视频| 国产亚洲成年网址在线观看| 6080午夜不卡| 欧美无砖砖区免费| 日本乱码高清不卡字幕| 成人av在线网站| 床上的激情91.| 国产高清一区日本| 久久99最新地址| 蜜臀91精品一区二区三区| 亚洲一卡二卡三卡四卡 | 91小视频在线免费看| 国产成人av电影在线| 国产一区二区三区不卡在线观看| 日韩不卡一二三区| 日韩电影免费在线看| 三级一区在线视频先锋| 亚洲图片欧美色图| 亚洲成av人片| 午夜不卡av免费| 日韩国产欧美在线播放| 爽爽淫人综合网网站| 爽好久久久欧美精品| 秋霞午夜鲁丝一区二区老狼| 日韩一区精品字幕| 精品一区二区在线视频| 精品一区二区三区视频在线观看| 免费观看91视频大全| 久久成人免费电影| 国产一区二区免费视频| 丰满白嫩尤物一区二区| 成人97人人超碰人人99| 91激情在线视频| 91精品免费在线观看| www成人在线观看| 国产精品久久久久9999吃药| 亚洲毛片av在线| 婷婷开心激情综合| 国产呦精品一区二区三区网站| 国产精品18久久久久| 91小视频在线观看| 欧美另类久久久品| 久久久久综合网| 亚洲精品久久久久久国产精华液| 亚洲第一福利一区| 国产在线精品一区二区夜色 | 午夜欧美大尺度福利影院在线看| 午夜精彩视频在线观看不卡| 国产美女主播视频一区| 暴力调教一区二区三区| 欧洲视频一区二区| 久久久久久一二三区| 亚洲人成网站影音先锋播放| 日韩国产在线观看| 国产成人亚洲综合a∨婷婷| 在线视频国内自拍亚洲视频| 欧美一区二区三区免费| 国产精品传媒入口麻豆| 亚洲成人一区在线| 成人综合激情网| 777色狠狠一区二区三区| 欧美激情一区二区三区不卡| 亚洲成人久久影院| 成人国产电影网| 日韩欧美色综合| 亚洲一区二区中文在线| 国产精一区二区三区| 欧美电影在哪看比较好| 国产精品免费aⅴ片在线观看| 天堂久久久久va久久久久| 91在线看国产|