Ignore:
Timestamp:
Nov 7, 2008, 1:15:15 AM (17 years ago)
Author:
pr
Message:

Add missing xprf() functions. Fix broken ones also.

File:
1 edited

Legend:

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

    r229 r371  
    7474
    7575/*
    76  *      Copyright (C) 2000 Ulrich M”ller.
     76 *      Copyright (C) 2000-2008 Ulrich M”ller.
    7777 *      This file is part of the "XWorkplace helpers" source package.
    7878 *      This is free software; you can redistribute it and/or modify
     
    720720 */
    721721
    722 APIRET xprfOpenProfile(const char *pcszFilename,    // in: profile name
    723                        PXINI *ppxini)               // out: profile handle
     722APIRET xprfOpenProfile(PCSZ pcszFilename,    // in: profile name
     723                       PXINI *ppxini)        // out: profile handle
    724724{
    725725    APIRET  arc = NO_ERROR;
     
    814814
    815815APIRET xprfQueryProfileSize(PXINI pXIni,          // in: profile opened with xprfOpenProfile
    816                             PCSZ pszAppName,      // in: application name or NULL
    817                             PCSZ pszKeyName,      // in: key name or NULL
     816                            PCSZ pcszAppName,     // in: application name or NULL
     817                            PCSZ pcszKeyName,     // in: key name or NULL
    818818                            PULONG pulDataLen)    // out: size of requested data
    819819{
     
    821821    ULONG   ulDataLen = 0;
    822822
    823     if (!pszAppName)
     823    if (!pcszAppName)
    824824    {
    825825        PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps);
     
    840840
    841841        if (!(arc = FindApp(pXIni,
    842                             pszAppName,
     842                            pcszAppName,
    843843                            &pAppData)))
    844844        {
    845845            // app exists:
    846846
    847             if (!pszKeyName)
     847            if (!pcszKeyName)
    848848            {
    849849                // app != NULL, but key == NULL:
     
    865865                PXINIKEYDATA pKeyData;
    866866                if (!(arc = FindKey(pAppData,
    867                                     pszKeyName,
     867                                    pcszKeyName,
    868868                                    &pKeyData)))
    869869                    ulDataLen = pKeyData->cbData;
     
    904904
    905905APIRET xprfQueryProfileData(PXINI pXIni,          // in: profile opened with xprfOpenProfile
    906                             PCSZ pszAppName,      // in: application name
    907                             PCSZ pszKeyName,      // in: key name or NULL
     906                            PCSZ pcszAppName,     // in: application name
     907                            PCSZ pcszKeyName,     // in: key name or NULL
    908908                            PVOID pBuffer,        // in: buffer to receive data
    909909                            PULONG pulBufferMax)  // in: buffer size, out: size of written data
     
    912912    ULONG   ulDataLen = 0;
    913913
    914     if (!pszAppName)
     914    if (!pcszAppName)
    915915    {
    916916        PLISTNODE pAppNode = lstQueryFirstNode(&pXIni->llApps);
     
    944944
    945945        if (!(arc = FindApp(pXIni,
    946                             pszAppName,
     946                            pcszAppName,
    947947                            &pAppData)))
    948948        {
    949949            // app exists:
    950950
    951             if (!pszKeyName)
     951            if (!pcszKeyName)
    952952            {
    953953                // app != NULL, but key == NULL:
     
    982982                PXINIKEYDATA pKeyData;
    983983                if (!(arc = FindKey(pAppData,
    984                                     pszKeyName,
     984                                    pcszKeyName,
    985985                                    &pKeyData)))
    986986                {
     
    10021002
    10031003/*
     1004 *@@ xprfQueryProfileInt:
     1005 *      reads data from the given XINI, similarly to
     1006 *      what PrfQueryProfileInt does.
     1007 *
     1008 *      You cannot specify HINI_SYSTEM or HINI_USER for
     1009 *      hINi.
     1010 *
     1011 *@@added WarpIN V1.0.18 (2008-10-04) [pr]
     1012 */
     1013
     1014LONG xprfQueryProfileInt(PXINI pXIni,
     1015                         PCSZ pcszApp,
     1016                         PCSZ pcszKey,
     1017                         LONG lDefault)
     1018{
     1019    char szBuffer[20];
     1020    LONG lVal = lDefault;
     1021    ULONG ulSize = sizeof(szBuffer) - 1;
     1022
     1023    if (pcszApp && pcszApp[0] && pcszKey && pcszKey[0] &&
     1024        !xprfQueryProfileData(pXIni, pcszApp, pcszKey, szBuffer, &ulSize))
     1025    {
     1026        szBuffer[ulSize] = '\0';
     1027        lVal = atol(szBuffer);
     1028    }
     1029
     1030    return lVal;
     1031}
     1032
     1033/*
    10041034 *@@ xprfWriteProfileData:
    10051035 *      writes data into an extended profile (XINI).
     
    10351065
    10361066APIRET xprfWriteProfileData(PXINI pXIni,          // in: profile opened with xprfOpenProfile
    1037                             const char *pcszApp,  // in: application name
    1038                             const char *pcszKey,  // in: key name or NULL
     1067                            PCSZ pcszApp,         // in: application name
     1068                            PCSZ pcszKey,         // in: key name or NULL
    10391069                            PVOID pData,          // in: data to write or NULL
    10401070                            ULONG ulDataLen)      // in: sizeof(*pData) or null
     
    11301160
    11311161/*
     1162 *@@ xprfWriteProfileString:
     1163 *      writes string into an extended profile (XINI).
     1164 *      This operates similar to PrfWriteProfileString.
     1165 *
     1166 *      You cannot specify HINI_SYSTEM or HINI_USER for
     1167 *      hINi.
     1168 *
     1169 *@@added WarpIN V1.0.18 (2008-10-04) [pr]
     1170 */
     1171
     1172APIRET xprfWriteProfileString(PXINI pXIni,          // in: profile opened with xprfOpenProfile
     1173                              PCSZ pcszApp,         // in: application name
     1174                              PCSZ pcszKey,         // in: key name or NULL
     1175                              PCSZ pcszString)      // in: string to write or NULL
     1176{
     1177    ULONG ulDataLen = 0;
     1178
     1179    if (pcszString)
     1180        ulDataLen = strlen(pcszString) + 1;
     1181
     1182    return xprfWriteProfileData(pXIni, pcszApp, pcszKey, (PVOID) pcszString, ulDataLen);
     1183}
     1184
     1185/*
    11321186 *@@ xprfCloseProfile:
    11331187 *      closes a profile opened with xprfOpenProfile.
     
    11771231 *
    11781232 *@@added V1.0.0 (2002-09-17) [umoeller]
     1233 *@@changed WarpIN V1.0.18 (2008-10-04) [pr]: fixed inverted logic bugs
    11791234 */
    11801235
     
    11881243
    11891244    // get size of keys list for pszApp
    1190     if (!xprfQueryProfileSize(hIni, pcszApp, NULL, &ulSizeOfKeysList))
     1245    if (xprfQueryProfileSize(hIni, pcszApp, NULL, &ulSizeOfKeysList))
    11911246        arc = PRFERR_KEYSLIST;
    11921247    else
     
    12001255        {
    12011256            *pKeys = 0;
    1202             if (!xprfQueryProfileData(hIni, pcszApp, NULL, pKeys, &ulSizeOfKeysList))
     1257            if (xprfQueryProfileData(hIni, pcszApp, NULL, pKeys, &ulSizeOfKeysList))
    12031258                arc = PRFERR_KEYSLIST;
    12041259        }
     
    12141269}
    12151270
     1271/*
     1272 *@@ xprfhQueryProfileData:
     1273 *      the equivalent of prfhQueryProfileData for
     1274 *      XINI files.
     1275 *
     1276 *@@added WarpIN V1.0.18 (2008-10-04) [pr]
     1277 */
     1278
     1279PSZ xprfhQueryProfileData(PXINI pXIni,           // in: INI handle
     1280                          PCSZ pcszApp,          // in: application to query
     1281                          PCSZ pcszKey,          // in: key to query
     1282                          PULONG pcbBuf)         // out: size of the returned buffer; ptr can be NULL
     1283{
     1284    PSZ     pData = NULL;
     1285    ULONG   ulSizeOfData;
     1286
     1287    // get size of data for pcszApp/pcszKey
     1288    if (    (!xprfQueryProfileSize(pXIni, (PSZ)pcszApp, (PSZ)pcszKey, &ulSizeOfData))
     1289         && (ulSizeOfData)
     1290         && (pData = (PSZ)malloc(ulSizeOfData))
     1291       )
     1292    {
     1293        if (xprfQueryProfileData(pXIni, (PSZ)pcszApp, (PSZ)pcszKey, pData, &ulSizeOfData))
     1294        {
     1295            free(pData);
     1296            pData = NULL;
     1297        }
     1298    }
     1299
     1300    if (pcbBuf)
     1301        *pcbBuf = ulSizeOfData;
     1302
     1303    return pData;
     1304}
     1305
Note: See TracChangeset for help on using the changeset viewer.