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

INT cmd_endlocal ( LPTSTR  param)

Definition at line 87 of file setlocal.c.

Referenced by ExitBatch().

{
    LPTSTR Environ, Name, Value;
    SETLOCAL *Saved;

    /* Pop a SETLOCAL struct off of this batch file's stack */
    if (!bc || !(Saved = bc->setlocal))
        return 0;
    bc->setlocal = Saved->Prev;

    bDelayedExpansion = Saved->DelayedExpansion;

    /* First, clear out the environment. Since making any changes to the
     * environment invalidates pointers obtained from GetEnvironmentStrings(),
     * we must make a copy of it and get the variable names from that */
    Environ = DuplicateEnvironment();
    if (Environ)
    {
        for (Name = Environ; *Name; Name += _tcslen(Name) + 1)
        {
            if (!(Value = _tcschr(Name + 1, _T('='))))
                continue;
            *Value++ = _T('\0');
            SetEnvironmentVariable(Name, NULL);
            Name = Value;
        }
        cmd_free(Environ);
    }

    /* Now, restore variables from the copy saved by cmd_setlocal */
    for (Name = Saved->Environment; *Name; Name += _tcslen(Name) + 1)
    {
        if (!(Value = _tcschr(Name + 1, _T('='))))
            continue;
        *Value++ = _T('\0');
        SetEnvironmentVariable(Name, Value);
        Name = Value;
    }

    cmd_free(Saved->Environment);
    cmd_free(Saved);
    return 0;
}

Generated on Sun May 27 2012 04:46:05 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.