Ignore:
Timestamp:
Feb 7, 2001, 7:30:59 PM (25 years ago)
Author:
umoeller
Message:

misc. changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/prfh.c

    r22 r33  
    304304
    305305ULONG prfhCopyKey(HINI hiniSource,       // in: source profile (can be HINI_USER or HINI_SYSTEM)
    306                  const char *pcszSourceApp,      // in: source application
    307                  const char *pcszKey,            // in: source/target key
    308                  HINI hiniTarget,       // in: target profile (can be HINI_USER or HINI_SYSTEM)
    309                  const char *pcszTargetApp)      // in: target app
     306                  const char *pcszSourceApp,      // in: source application
     307                  const char *pcszKey,            // in: source/target key
     308                  HINI hiniTarget,       // in: target profile (can be HINI_USER or HINI_SYSTEM)
     309                  const char *pcszTargetApp)      // in: target app
    310310{
    311311    ULONG   ulSizeOfData = 0,
     
    391391 *
    392392 *      Returns:
     393 *
    393394 *      --  0: no error
     395 *
    394396 *      --  PRFERR_KEYSLIST: couldn't query keys for pszSourceApp
     397 *
    395398 *      --  PRFERR_DATASIZE: couldn't query data size for key
     399 *
    396400 *      --  PRFERR_MEMORY: couldn't allocate memory
     401 *
    397402 *      --  PRFERR_READ: couldn't read data from source (PrfQueryProfileData error)
     403 *
    398404 *      --  PRFERR_WRITE: couldn't write data to target (PrfWriteProfileData error)
    399405 *
     
    445451
    446452/*
     453 *@@ prfhRenameKey:
     454 *      renames a key in an INI file.
     455 *
     456 *      Since there's no such thing as a PrfRename,
     457 *      what we do here is load the old data, write
     458 *      it under a new key, and delete the old data.
     459 *
     460 *      Returns:
     461 *
     462 *      --  0: no error
     463 *
     464 *      --  PRFERR_INVALID_KEY: pcszApp or pcszOldKey do not exist.
     465 *
     466 *      --  PRFERR_KEY_EXISTS: pcszNewApp/pcszNewKey is already occupied.
     467 *
     468 *      --  PRFERR_WRITE: couldn't write data to target (PrfWriteProfileData error)
     469 *
     470 *@@added V0.9.9 (2000-02-06) [umoeller]
     471 */
     472
     473ULONG prfhRenameKey(HINI hini,
     474                    const char *pcszOldApp,
     475                    const char *pcszOldKey, // in: key to rename
     476                    const char *pcszNewApp, // in: new app (if NULL, pcszOldApp is used)
     477                    const char *pcszNewKey) // in: new name for pcszOldKey
     478{
     479    ULONG ulrc = 0;
     480
     481    ULONG   cbData = 0;
     482    PSZ pszData = prfhQueryProfileData(hini,
     483                                       pcszOldApp,
     484                                       pcszOldKey,
     485                                       &cbData);
     486    if (!pszData)
     487        // not found:
     488        ulrc = PRFERR_INVALID_KEY;
     489    else
     490    {
     491        ULONG   cb;
     492
     493        if (!pcszNewApp)
     494            // is NULL:
     495            pcszNewApp = pcszOldApp;
     496
     497        // make sure target doesn't exist
     498        if (    (PrfQueryProfileSize(hini,
     499                                     (PSZ)pcszNewApp,
     500                                     (PSZ)pcszNewKey,
     501                                     &cb))
     502             && (cb)
     503           )
     504            ulrc = PRFERR_KEY_EXISTS;
     505        else
     506        {
     507            if (!PrfWriteProfileData(hini,
     508                                     (PSZ)pcszNewApp,
     509                                     (PSZ)pcszNewKey,
     510                                     pszData,
     511                                     cbData))
     512                ulrc = PRFERR_WRITE;
     513            else
     514            {
     515                // success writing:
     516                // delete old
     517                PrfWriteProfileData(hini,
     518                                    (PSZ)pcszOldApp,
     519                                    (PSZ)pcszOldKey,
     520                                    NULL,
     521                                    0);
     522            }
     523        }
     524
     525        free(pszData);
     526    }
     527
     528    return (ulrc);
     529}
     530
     531/*
    447532 *@@ prfhSetUserProfile:
    448533 *      calls PrfReset to change the current user
Note: See TracChangeset for help on using the changeset viewer.