Changeset 33 for trunk/src/helpers/prfh.c
- Timestamp:
- Feb 7, 2001, 7:30:59 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/prfh.c
r22 r33 304 304 305 305 ULONG prfhCopyKey(HINI hiniSource, // in: source profile (can be HINI_USER or HINI_SYSTEM) 306 const char *pcszSourceApp, // in: source application307 const char *pcszKey, // in: source/target key308 HINI hiniTarget, // in: target profile (can be HINI_USER or HINI_SYSTEM)309 const char *pcszTargetApp) // in: target app306 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 310 310 { 311 311 ULONG ulSizeOfData = 0, … … 391 391 * 392 392 * Returns: 393 * 393 394 * -- 0: no error 395 * 394 396 * -- PRFERR_KEYSLIST: couldn't query keys for pszSourceApp 397 * 395 398 * -- PRFERR_DATASIZE: couldn't query data size for key 399 * 396 400 * -- PRFERR_MEMORY: couldn't allocate memory 401 * 397 402 * -- PRFERR_READ: couldn't read data from source (PrfQueryProfileData error) 403 * 398 404 * -- PRFERR_WRITE: couldn't write data to target (PrfWriteProfileData error) 399 405 * … … 445 451 446 452 /* 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 473 ULONG 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 /* 447 532 *@@ prfhSetUserProfile: 448 533 * calls PrfReset to change the current user
Note:
See TracChangeset
for help on using the changeset viewer.