Ignore:
Timestamp:
Dec 4, 2006, 12:57:42 PM (19 years ago)
Author:
pr
Message:

Add CREATEOBJECT FAIL option. Bug 893.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cppbase/bs_config.cpp

    r328 r343  
    6969
    7070/*
    71  *      This file Copyright (C) 1999-2001 Ulrich M”ller.
     71 *      This file Copyright (C) 1999-2006 Ulrich M”ller.
    7272 *      This program is free software; you can redistribute it and/or modify
    7373 *      it under the terms of the GNU General Public License as published by
     
    14261426 *
    14271427 +          CREATEOBJECT="[REPLACE] classname|title|location[|config]]"
     1428 +          CREATEOBJECT="[FAIL] classname|title|location[|config]]"
    14281429 *
    14291430 *      Throws:
     
    14331434 *@@changed V0.9.15 (2001-08-26) [umoeller]: added WPOEXCPT_INVALIDLOCATION checks
    14341435 *@@changed V0.9.19 (2002-04-14) [umoeller]: REPLACE was never detected, fixed
     1436 *@@changed V1.0.14 (2006-12-03) [pr]: added FAIL mode @@fixes 893
    14351437 */
    14361438
     
    14451447        throw BSConfigExcpt(WPOEXCPT_NOCLASS, ustrCreateObject);
    14461448
    1447     // if (!strcmp(pBegin, "REPLACE "))     BUZZZZ WRONG V0.9.19 (2002-04-14) [umoeller]
    14481449    if (!memcmp(pBegin, "REPLACE ", 8))
    14491450    {
    1450         // added V0.9.3 (2000-04-08) [umoeller]
    1451         _fReplace = TRUE;
    1452         pBegin += 7;
     1451        _ulFlags = CO_REPLACEIFEXISTS;  // V1.0.14 (2006-12-03) [pr]
     1452        pBegin += 8;
    14531453        while (*pBegin == ' ')
    14541454            pBegin++;
    14551455    }
    14561456    else
    1457         _fReplace = FALSE;
     1457        if (!memcmp(pBegin, "FAIL ", 5))  // V1.0.14 (2006-12-03) [pr]
     1458        {
     1459            _ulFlags = CO_FAILIFEXISTS;
     1460            pBegin += 5;
     1461            while (*pBegin == ' ')
     1462                pBegin++;
     1463        }
     1464        else
     1465            _ulFlags = CO_UPDATEIFEXISTS;  // V1.0.14 (2006-12-03) [pr]
    14581466
    14591467    PSZ pEnd;
     
    15441552 *
    15451553 *@@changed V0.9.18 (2002-03-08) [umoeller]: added codec
     1554 *@@changed V1.0.14 (2006-12-03) [pr]: added FAIL mode @@fixes 893
    15461555 */
    15471556
     
    15751584                                  pcszSetupString,
    15761585                                  pcszLocation,
    1577                                   (_fReplace)
    1578                                      ? CO_REPLACEIFEXISTS
    1579                                      : CO_UPDATEIFEXISTS)))
    1580     {
     1586                                  _ulFlags)))
     1587    {
     1588        if (_ulFlags == CO_FAILIFEXISTS)  // V1.0.14 (2006-12-03) [pr]
     1589        {
     1590            if (pLogFile)
     1591                pLogFile->Write("WPS object already exists \"%s\", class \"%s\", location \"%s\", setup \"%s\"",
     1592                                pcszTitle,
     1593                                pcszClassName,
     1594                                pcszLocation,
     1595                                pcszSetupString);
     1596        }
     1597        else
     1598        {
     1599            if (pLogFile)
     1600                pLogFile->Write("Error creating WPS object \"%s\", class \"%s\", location \"%s\", setup \"%s\"",
     1601                                pcszTitle,
     1602                                pcszClassName,
     1603                                pcszLocation,
     1604                                pcszSetupString);
     1605
     1606            throw BSConfigExcpt(WPOEXCPT_CREATE, _ustrTitle);
     1607        }
     1608    }
     1609    else
     1610    {
     1611        // V1.0.5 (2005-02-17) [pr]
     1612        // We now save the object synchronously to prevent objects getting lost if we
     1613        // restart the WPS imminently due to a class registration for example. @@fixes 634.
     1614        WinSaveObject (_hobj, FALSE);
    15811615        if (pLogFile)
    1582             pLogFile->Write("Error creating WPS object \"%s\", class \"%s\", location \"%s\", setup \"%s\"",
    1583                              pcszTitle,
    1584                              pcszClassName,
    1585                              pcszLocation,
    1586                              pcszSetupString);
    1587 
    1588         throw BSConfigExcpt(WPOEXCPT_CREATE, _ustrTitle);
    1589     }
    1590 
    1591     // V1.0.5 (2005-02-17) [pr]
    1592     // We now save the object synchronously to prevent objects getting lost if we
    1593     // restart the WPS imminently due to a class registration for example. @@fixes 634.
    1594     WinSaveObject (_hobj, FALSE);
    1595     if (pLogFile)
    1596     {
    1597         pLogFile->Write("Created WPS object \"%s\", class \"%s\", location \"%s\", setup \"%s\"",
    1598                          pcszTitle,
    1599                          pcszClassName,
    1600                          pcszLocation,
    1601                          pcszSetupString);
    1602         pLogFile->Write("HOBJECT is 0x%lX", _hobj);
     1616        {
     1617            pLogFile->Write("Created WPS object \"%s\", class \"%s\", location \"%s\", setup \"%s\"",
     1618                            pcszTitle,
     1619                            pcszClassName,
     1620                            pcszLocation,
     1621                            pcszSetupString);
     1622            pLogFile->Write("HOBJECT is 0x%lX", _hobj);
     1623        }
    16031624    }
    16041625
Note: See TracChangeset for help on using the changeset viewer.