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

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

?? setenv.c

?? C標準庫源代碼,能提高對C的理解,不錯的哦
?? C
字號:
/***
*setenv.c -set an environment variable in the environment
*
*       Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
*       defines __crtsetenv() - adds a new variable to environment.
*       Internal use only.
*
*******************************************************************************/


#include <windows.h>
#include <cruntime.h>
#include <internal.h>
#include <stdlib.h>
#include <tchar.h>
#include <rterr.h>
#include <dbgint.h>

static _TSCHAR **copy_environ(_TSCHAR **);

#ifdef WPRFLAG
static int __cdecl wfindenv(const wchar_t *name, int len);
#else  /* WPRFLAG */
static int __cdecl findenv(const char *name, int len);
#endif  /* WPRFLAG */

/***
*int __crtsetenv(option) - add/replace/remove variable in environment
*
*Purpose:
*       option should be of the form "option=value".  If a string with the
*       given option part already exists, it is replaced with the given
*       string; otherwise the given string is added to the environment.
*       If the string is of the form "option=", then the string is
*       removed from the environment, if it exists.  If the string has
*       no equals sign, error is returned.
*
*Entry:
*       char *option - option string to set in the environment list.
*           should be of the form "option=value".
*       int primary - Only the primary call to _crt[w]setenv needs to
*           create new copies or set the OS environment.
*           1 indicates that this is the primary call.
*
*Exit:
*       returns 0 if OK, -1 if fails.
*
*Exceptions:
*
*Warning:
*       This code will not work if variables are removed from the
*       environment by deleting them from environ[].  Use _putenv("option=")
*       to remove a variable.
*
*******************************************************************************/

#ifdef WPRFLAG
int __cdecl __crtwsetenv (
#else  /* WPRFLAG */
int __cdecl __crtsetenv (
#endif  /* WPRFLAG */
        const _TSCHAR *option,
        const int primary
        )
{
        int ix;
        int remove; /* 1 if variable is to be removed */
        _TSCHAR **env;
        _TSCHAR *name, *value;
        const _TSCHAR *equal;

        /*
         * check that the option string is valid, find the equal sign
         * and verify '=' is not the first character in string.
         */
        if ( (option == NULL) || ((equal = _tcschr(option, _T('='))) == NULL)
            || option == equal)
            return(-1);

        /* if the character following '=' is null, we are removing the
         * the environment variable. Otherwise, we are adding or updating
         * an environment variable.
         */
        remove = (*(equal + 1) == _T('\0'));

        /*
         * the first time _[w]putenv() is called, copy the environment
         * block that was passed to [w]main to avoid making a
         * dangling pointer if the block is re-alloced.
         */
#ifdef WPRFLAG
        if (_wenviron == __winitenv)
            _wenviron = copy_environ(_wenviron);
#else  /* WPRFLAG */
        if (_environ == __initenv)
            _environ = copy_environ(_environ);
#endif  /* WPRFLAG */

        /* see if requested environment array exists */
        if (_tenviron == NULL) {

            /*
             * The requested type of environment does not exist.
             * See if other type exists, if so convert it to requested type.
             * The functions that convert the enviroment (__mbtow_environ and
             * __wtomb_environ) will call this function (__crt[w]setenv) once
             * for each of the pre-existing environment variables. To avoid
             * an infinite loop, test the primary flag.
             */

#ifdef WPRFLAG
            if (primary && _environ)
            {
                if (__mbtow_environ() != 0)
                    return -1;
            }
#else  /* WPRFLAG */
            if (primary && _wenviron)
            {
                if (__wtomb_environ() != 0)
                    return -1;
            }
#endif  /* WPRFLAG */
            else {
                /* nothing to remove, return */
                if ( remove )
                    return 0;
                else {
                    /* create ones that do not exist */

                    if (_environ == NULL)
                    {
                        if ( (_environ = _malloc_crt(sizeof(char *))) == NULL)
                            return -1;
                        *_environ = NULL;
                    }

                    if (_wenviron == NULL)
                    {
                        if ( (_wenviron = _malloc_crt(sizeof(wchar_t *))) == NULL)
                            return -1;
                        *_wenviron = NULL;
                    }
                }
            }
        }

        /*
         * At this point, the two types of environments are in sync (as much
         * as they can be anyway). The only way they can get out of sync
         * (besides users directly modifiying the environment) is if there
         * are conversion problems: If the user sets two Unicode EVs,
         * "foo1" and "foo2" and converting then to multibyte yields "foo?"
         * and "foo?", then the environment blocks will differ.
         */

        /* init env pointers */
        env = _tenviron;

        /* See if the string is already in the environment */
#ifdef WPRFLAG
        ix = wfindenv(option, equal - option);
#else  /* WPRFLAG */
        ix = findenv(option, equal - option);
#endif  /* WPRFLAG */

        if ((ix >= 0) && (*env != NULL)) {
            /* String is already in the environment - overwrite/remove it */
            if (remove) {

                /* free the string being removed */
                _free_crt(env[ix]);

                /* removing -- move all the later strings up */
                for ( ; env[ix] != NULL; ++ix) {
                    env[ix] = env[ix+1];
                }

                /* shrink the environment memory block
                   (ix now has number of strings, including NULL) --
                   this realloc probably can't fail, since we're
                   shrinking a mem block, but we're careful anyway. */
                if (env = (_TSCHAR **) _realloc_crt(env, ix * sizeof(_TSCHAR *)))
                    _tenviron = env;
            }
            else {
                /* replace the option */
                env[ix] = (_TSCHAR *) option;
            }
        }
        else {
            /*
             * String is NOT in the environment
             */
            if ( !remove )  {
                /*
                 * Append the string to the environ table. Note that
                 * table must be grown to do this.
                 */
                if (ix < 0)
                    ix = -ix;    /* ix = length of environ table */

                if ( (env = (_TSCHAR **)_realloc_crt(env, sizeof(_TSCHAR *) *
                    (ix + 2))) == NULL )
                    return -1;

                env[ix] = (_TSCHAR *)option;
                env[ix + 1] = NULL;

                _tenviron = env;
            }
            else
                /*
                 * We are asked to remove an environment var that
                 * isn't there...just return success
                 */
                return 0;
        }

        /*
         * Update the OS environment. Don't give an error if this fails
         * since the failure will not affect the user unless he/she is making
         * direct API calls. Only need to do this for one type, OS converts
         * to other type automatically.
         */
        if ( primary &&
            (name = (_TSCHAR *)_malloc_crt((_tcslen(option) + 2) * sizeof(_TSCHAR))) != NULL )
        {
            _tcscpy(name, option);
            value = name + (equal - option);
            *value++ = _T('\0');
            SetEnvironmentVariable(name, remove ? NULL : value);
            _free_crt(name);
        }

        return 0;
}


/***
*int findenv(name, len) - [STATIC]
*
*Purpose:
*       Scan for the given string within the environment
*
*Entry:
*
*Exit:
*       Returns the offset in "environ[]" of the given variable
*       Returns the negative of the length of environ[] if not found.
*       Returns 0 if the environment is empty.
*
*       [NOTE: That a 0 return can mean that the environment is empty
*       or that the string was found as the first entry in the array.]
*
*Exceptions:
*
*******************************************************************************/

#ifdef WPRFLAG
static int __cdecl wfindenv (
#else  /* WPRFLAG */
static int __cdecl findenv (
#endif  /* WPRFLAG */
        const _TSCHAR *name,
        int len
        )
{
        _TSCHAR **env;

        for ( env = _tenviron ; *env != NULL ; env++ ) {
            /*
             * See if first len characters match, up to case
             */
            if ( _tcsnicoll(name, *env, len) == 0 )
                /*
                 * the next character of the environment string must
                 * be an '=' or a '\0'
                 */
                if ( (*env)[len] == _T('=') || (*env)[len] == _T('\0') )
                    return(env - _tenviron);
//
// We cannot break here since findenv must report the total number of strings.
//              else
//                  break;
        }

        return(-(env - _tenviron));
}


/***
*copy_environ - copy an environment block
*
*Purpose:
*       Create a copy of an environment block.
*
*Entry:
*       _TSCHAR **oldenviron - pointer to enviroment to be copied.
*
*Exit:
*       Returns a pointer to newly created environment.
*
*Exceptions:
*
*******************************************************************************/

static _TSCHAR **copy_environ(_TSCHAR **oldenviron)
{
        int cvars = 0;
        _TSCHAR **oldenvptr = oldenviron;
        _TSCHAR **newenviron, **newenvptr;

        /* no environment */
        if (oldenviron == NULL)
            return NULL;

        /* count number of environment variables */
        while (*oldenvptr++)
            cvars++;

        /* need pointer for each string, plus one null ptr at end */
        if ( (newenviron = newenvptr = (_TSCHAR **)
            _malloc_crt((cvars+1) * sizeof(_TSCHAR *))) == NULL )
            _amsg_exit(_RT_SPACEENV);

        /* duplicate the environment variable strings */
        oldenvptr = oldenviron;
        while (*oldenvptr)
#ifdef _DEBUG
        {
            if ( (*newenvptr = _malloc_crt((_tcslen(*oldenvptr)+1)
                  * sizeof(_TSCHAR))) != NULL )
                _tcscpy(*newenvptr, *oldenvptr);
            oldenvptr++;
            newenvptr++;
        }
#else  /* _DEBUG */
            *newenvptr++ = _tcsdup(*oldenvptr++);
#endif  /* _DEBUG */

        *newenvptr = NULL;

        return newenviron;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩亚洲欧美一区二区三区| 日日夜夜免费精品| 午夜精品视频在线观看| 国产美女一区二区| 欧美日韩激情在线| 亚洲卡通欧美制服中文| 国产精品 日产精品 欧美精品| 欧美日韩一区二区三区免费看| 国产精品久久久久久亚洲伦| 久久精品国产亚洲高清剧情介绍| 欧美性大战久久| 国产精品白丝在线| 成人一二三区视频| 精品国产成人在线影院| 日日夜夜免费精品视频| 欧美日韩精品一区二区三区 | 91影视在线播放| 久久这里只精品最新地址| 日韩av一二三| 日韩一区二区三区视频| 天天色天天操综合| 欧美乱熟臀69xxxxxx| 一区二区三区精密机械公司| 色综合久久综合网97色综合 | 欧美日韩免费不卡视频一区二区三区| 欧美国产精品一区| 成人一区二区在线观看| 久久婷婷国产综合国色天香| 久久成人av少妇免费| 日韩欧美国产精品一区| 麻豆精品精品国产自在97香蕉| 宅男噜噜噜66一区二区66| 亚洲成av人**亚洲成av**| 欧美日韩夫妻久久| 午夜视频在线观看一区| 欧美美女一区二区在线观看| 一区二区三区精密机械公司| 欧洲精品一区二区三区在线观看| 亚洲男人都懂的| 色一情一乱一乱一91av| 一区二区理论电影在线观看| 在线观看一区二区视频| 亚洲高清在线视频| 91精品国产色综合久久久蜜香臀| 三级在线观看一区二区 | 色天天综合久久久久综合片| 一区二区三区欧美视频| 91麻豆精品国产91久久久久| 黄色成人免费在线| 日本一二三不卡| 91成人网在线| 日韩和欧美的一区| 久久日韩精品一区二区五区| 国产suv一区二区三区88区| 日韩美女精品在线| 欧美色老头old∨ideo| 美女尤物国产一区| 国产精品久久影院| 欧美日韩亚洲综合在线 | 欧美一区二区三区免费大片| 狠狠色狠狠色合久久伊人| 国产精品无圣光一区二区| 91尤物视频在线观看| 日韩综合在线视频| 国产视频视频一区| 欧美三区在线视频| 国产精品888| 一区二区三区四区视频精品免费 | 久久99精品久久久久婷婷| 国产欧美日韩另类一区| 欧美性色欧美a在线播放| 国产在线视频一区二区| 亚洲欧美日韩一区| 精品处破学生在线二十三| 日本精品视频一区二区| 国产主播一区二区| 亚洲第一综合色| 国产三级欧美三级日产三级99| 在线观看av不卡| 国产成人一级电影| 日韩精品免费专区| 中文字幕制服丝袜成人av | 成人在线综合网| 性欧美疯狂xxxxbbbb| 欧美激情一区二区三区全黄| 欧美精品一级二级三级| 99久久婷婷国产综合精品| 麻豆成人久久精品二区三区小说| 亚洲免费观看高清在线观看| 久久精品无码一区二区三区| 欧美日本一区二区在线观看| 91视频国产观看| 成年人国产精品| 国产成人午夜精品5599| 麻豆精品在线看| 午夜成人免费视频| 一区二区三区中文字幕精品精品| 国产欧美视频一区二区| 欧美成人高清电影在线| 制服丝袜中文字幕一区| 欧美日韩在线播放一区| 色视频欧美一区二区三区| 成人动漫一区二区在线| 国产精品一区二区男女羞羞无遮挡| 三级精品在线观看| 亚洲国产精品久久久久秋霞影院| 亚洲女厕所小便bbb| 日韩美女视频19| 亚洲特级片在线| 亚洲三级在线免费观看| 欧美韩国日本一区| 中文字幕一区二区三区在线播放| 日本一区二区三区电影| 久久精品夜色噜噜亚洲a∨| 精品久久久久久久人人人人传媒| 精品久久国产字幕高潮| 欧美成人高清电影在线| 久久噜噜亚洲综合| 久久久久久电影| 日本一区二区成人| 中文字幕一区二区三中文字幕| 亚洲图片另类小说| 一区二区三区四区视频精品免费 | 波多野洁衣一区| 94-欧美-setu| 日本福利一区二区| 欧美专区日韩专区| 在线91免费看| 日韩精品专区在线影院观看| 久久综合久久99| 日本一区二区视频在线| 亚洲欧美一区二区三区久本道91| 亚洲精选视频在线| 日韩电影在线一区二区| 国产一区二区三区最好精华液| 国产美女视频一区| 91网站黄www| 538prom精品视频线放| 欧美va天堂va视频va在线| 久久久国产午夜精品| 椎名由奈av一区二区三区| 亚洲一区二区三区四区在线免费观看 | 亚洲欧美另类图片小说| 亚洲成人动漫一区| 国产精品一区一区三区| 色综合久久久久| 日韩精品中文字幕在线不卡尤物| 国产拍欧美日韩视频二区| 亚洲欧美日韩久久| 日韩高清在线一区| 本田岬高潮一区二区三区| 欧美老肥妇做.爰bbww视频| 欧美大片一区二区| 亚洲欧美日韩国产另类专区| 免费欧美日韩国产三级电影| 99久久精品99国产精品| 欧美精品成人一区二区三区四区| 国产欧美精品一区aⅴ影院 | 欧美日韩国产首页| 久久精品亚洲一区二区三区浴池| 亚洲婷婷在线视频| 极品美女销魂一区二区三区 | 亚洲综合男人的天堂| 国产制服丝袜一区| 欧美精品丝袜久久久中文字幕| 国产亚洲一区二区三区在线观看| 亚洲图片一区二区| 国产盗摄一区二区三区| 欧美人伦禁忌dvd放荡欲情| 中文字幕在线观看一区| 玖玖九九国产精品| 在线观看网站黄不卡| 国产精品女主播av| 激情久久久久久久久久久久久久久久| 欧美中文字幕一区| 亚洲视频精选在线| 国产精品中文欧美| 日韩片之四级片| 亚洲第一精品在线| 91视频国产观看| 中文字幕在线不卡| 国产精品亚洲成人| 久久久亚洲精品一区二区三区| 日本午夜精品一区二区三区电影| 91小视频在线免费看| 国产精品毛片大码女人| 激情六月婷婷久久| 精品美女在线播放| 精品亚洲成a人| 欧美一区二区三区思思人| 天天综合日日夜夜精品| 欧美日韩精品欧美日韩精品一 | 久久久精品影视| 国产真实乱偷精品视频免| 日韩片之四级片| 久久99最新地址| 欧美大片在线观看| 国产九九视频一区二区三区| 久久久精品中文字幕麻豆发布| 国产精品一二三在|