Changeset 14 for trunk/src/helpers/eah.c


Ignore:
Timestamp:
Dec 9, 2000, 8:19:42 PM (25 years ago)
Author:
umoeller
Message:

Major updates; timers, LVM, miscellaneous.

File:
1 edited

Legend:

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

    r8 r14  
    6767 *      Copyright (C) 1995 Massachusetts Institute of Technology.
    6868 *      Copyright (C) 1997-2000 Ulrich M”ller.
    69  *      This file is part of the XWorkplace source package.
    70  *      XWorkplace is free software; you can redistribute it and/or modify
     69 *      This file is part of the "XWorkplace helpers" source package.
     70 *      This is free software; you can redistribute it and/or modify
    7171 *      it under the terms of the GNU General Public License as published
    7272 *      by the Free Software Foundation, in version 2 as it comes in the
     
    8383    // as unsigned char
    8484
    85 #define INCL_DOS
     85#define INCL_DOSFILEMGR
    8686#define INCL_DOSERRORS
    8787#include <os2.h>
     
    101101
    102102/********************************************************************
    103  *                                                                  *
    104  *   Extended Attribute handling                                    *
    105  *                                                                  *
     103 *
     104 *   Extended Attribute handling
     105 *
    106106 ********************************************************************/
    107107
     
    173173
    174174/* ******************************************************************
    175  *                                                                  *
    176  *   Read-EA functions                                              *
    177  *                                                                  *
     175 *
     176 *   Read-EA functions
     177 *
    178178 ********************************************************************/
    179179
     
    196196 */
    197197
    198 ULONG eaPathQueryTotalSize(PSZ pszPath)
     198ULONG eaPathQueryTotalSize(const char *pcszPath)
    199199{
    200200    APIRET  arc;
     
    202202    FILEFINDBUF4   ffb4;
    203203
    204     _Pmpf(("eaPathQueryTotalSize %s", pszPath));
    205 
    206     arc = DosQueryPathInfo(pszPath,
     204    arc = DosQueryPathInfo((PSZ)pcszPath,
    207205                           FIL_QUERYEASIZE,
    208206                           &ffb4,
     
    220218
    221219        arc = DosEnumAttribute(ENUMEA_REFTYPE_PATH,
    222                                pszPath,
     220                               (PSZ)pcszPath,
    223221                               1,
    224222                               abBuf,
     
    230228        pdena2 = (PDENA2)abBuf;
    231229
    232         _Pmpf(("  %s: arc = %d, count = %d", pszPath, arc, lCount));
    233 
    234230        if (lCount > 0)
    235231        {
     
    247243    }
    248244
    249     _Pmpf(("    %s: total %d", pszPath, ulTotalEASize));
    250 
    251245    return (ulTotalEASize);
    252246}
     
    259253 */
    260254
    261 PEALIST eaPathReadAll(PSZ path)
    262 {
    263     return (ReadEAList(ENUMEA_REFTYPE_PATH, path));
     255PEALIST eaPathReadAll(const char *pcszPath)
     256{
     257    return (ReadEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath));
    264258}
    265259
     
    283277 */
    284278
    285 PEABINDING eaPathReadOneByIndex(PSZ path, ULONG index)
    286 {
    287     return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, path, index));
     279PEABINDING eaPathReadOneByIndex(const char *pcszPath, ULONG index)
     280{
     281    return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, index));
    288282}
    289283
     
    305299 */
    306300
    307 PEABINDING eaPathReadOneByName(PSZ path, PSZ name)
    308 {
    309     return (ReadEAByName(ENUMEA_REFTYPE_PATH, path, name));
     301PEABINDING eaPathReadOneByName(const char *pcszPath, const char *pcszEAName)
     302{
     303    return (ReadEAByName(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, (PSZ)pcszEAName));
    310304}
    311305
     
    315309 */
    316310
    317 PEABINDING eaHFileReadOneByName(HFILE hfile, PSZ name)
    318 {
    319     return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), name));
     311PEABINDING eaHFileReadOneByName(HFILE hfile, const char *pcszEAName)
     312{
     313    return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), (PSZ)pcszEAName));
    320314}
    321315
    322316/* ******************************************************************
    323  *                                                                  *
    324  *   Write-EA functions                                             *
    325  *                                                                  *
     317 *
     318 *   Write-EA functions
     319 *
    326320 ********************************************************************/
    327321
     
    335329 *      field is 0; only in that case, the EABINDING.value
    336330 *      field may also be NULL.
    337  */
    338 
    339 void eaPathWriteAll(PSZ path, PEALIST list)
    340 {
    341     WriteEAList(ENUMEA_REFTYPE_PATH, path, list);
     331 *
     332 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET
     333 */
     334
     335APIRET eaPathWriteAll(const char *pcszPath, PEALIST list)
     336{
     337    return (WriteEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, list));
    342338}
    343339
     
    345341 *@@ eaHFileWriteAll:
    346342 *      like eaPathWriteAll, but for an open file handle.
    347  */
    348 
    349 void eaHFileWriteAll(HFILE hfile, PEALIST list)
    350 {
    351     WriteEAList(ENUMEA_REFTYPE_FHANDLE, (&hfile), list);
     343 *
     344 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET
     345 */
     346
     347APIRET eaHFileWriteAll(HFILE hfile, PEALIST list)
     348{
     349    return (WriteEAList(ENUMEA_REFTYPE_FHANDLE, (&hfile), list));
    352350}
    353351
     
    362360 *
    363361 *      To delete an EA, you may also use eaPathDeleteOne.
    364  */
    365 
    366 void eaPathWriteOne(PSZ path, PEABINDING peab)
    367 {
    368     WriteEA(ENUMEA_REFTYPE_PATH, path, peab);
     362 *
     363 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET
     364 */
     365
     366APIRET eaPathWriteOne(const char *pcszPath, PEABINDING peab)
     367{
     368    return (WriteEA(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, peab));
    369369}
    370370
     
    372372 *@@ eaHFileWriteOne:
    373373 *      like eaPathWriteOne, but for an open file handle.
    374  */
    375 
    376 void eaHFileWriteOne(HFILE hfile, PEABINDING peab)
    377 {
    378     WriteEA(ENUMEA_REFTYPE_FHANDLE, (&hfile), peab);
     374 *
     375 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET
     376 */
     377
     378APIRET eaHFileWriteOne(HFILE hfile, PEABINDING peab)
     379{
     380    return (WriteEA(ENUMEA_REFTYPE_FHANDLE, (&hfile), peab));
    379381}
    380382
     
    386388 *
    387389 *@@added V0.9.0 [umoeller]
    388  */
    389 
    390 void eaPathDeleteOne(PSZ path, PSZ pszEAName)
     390 *@@changed V0.9.7 (2000-11-30) [umoeller]: now returning APIRET
     391 */
     392
     393APIRET eaPathDeleteOne(const char *pcszPath, const char *pcszEAName)
    391394{
    392395    EABINDING eab;
    393396    eab.bFlags = 0;
    394     eab.bNameLength = strlen(pszEAName);
    395     eab.pszName = pszEAName;
     397    eab.bNameLength = strlen(pcszEAName);
     398    eab.pszName = (PSZ)pcszEAName;
    396399    eab.usValueLength = 0;
    397400    eab.pszValue = 0;
    398     eaPathWriteOne(path, &eab);
     401    return (eaPathWriteOne(pcszPath, &eab));
    399402}
    400403
     
    404407
    405408/********************************************************************
    406  *                                                                  *
    407  *   Translation funcs                                              *
    408  *                                                                  *
     409 *
     410 *   Translation funcs
     411 *
    409412 ********************************************************************/
    410413
     
    484487 */
    485488
    486 PEABINDING eaCreateBindingFromPSZ(PSZ pszEAName,    // in: EA name (e.g. ".LONGNAME")
    487                                   PSZ pszString)     // in: string for EAT_ASCII EA
     489PEABINDING eaCreateBindingFromPSZ(const char *pcszEAName, // in: EA name (e.g. ".LONGNAME")
     490                                  const char *pcszInput)  // in: string for EAT_ASCII EA
    488491{
    489492    PEABINDING peab = (PEABINDING)malloc(sizeof(EABINDING));
     
    491494    {
    492495        SHORT cbString = 0;
    493         if (pszString)
    494             cbString = strlen(pszString);
     496        if (pcszInput)
     497            cbString = strlen(pcszInput);
    495498
    496499        peab->bFlags = 0;
    497         peab->bNameLength = strlen(pszEAName);
    498         peab->pszName = strdup(pszEAName);
     500        peab->bNameLength = strlen(pcszEAName);
     501        peab->pszName = strdup(pcszEAName);
    499502
    500503        if (cbString)
     
    510513                *((PUSHORT)(peab->pszValue + 2)) = cbString;
    511514                // copy string to byte 4 (no null-terminator)
    512                 memcpy(peab->pszValue + 4, pszString, cbString);
     515                memcpy(peab->pszValue + 4, pcszInput, cbString);
    513516            }
    514517            else
     
    743746
    744747PSZ eaCreatePSZFromMVBinding(PEABINDING peab,       // in: EAT_MVMT binding
    745                              PSZ     pszSeparator,  // in: null-terminated string used as separator
     748                             const char *pcszSeparator,  // in: null-terminated string used as separator
    746749                             PUSHORT pusCodepage)   // out: codepage found in binding (ptr can be NULL)
    747750{
     
    765768            USHORT  us = 0;
    766769            USHORT  cbComment = 0;
    767             USHORT  cbSeparator = strlen(pszSeparator);
     770            USHORT  cbSeparator = strlen(pcszSeparator);
    768771            while (us < usMVCount)
    769772            {
     
    794797                            // append separator
    795798                            memcpy(pszTotal + cbCommentOld,
    796                                    pszSeparator,
     799                                   pcszSeparator,
    797800                                   cbSeparator);
    798801                            // copy the rest after the separator (below)
     
    846849 */
    847850
    848 PEABINDING eaCreateMVBindingFromPSZ(PSZ pszEAName,      // in: EA name (e.g. ".KEYPHRASES")
    849                                     PSZ pszInput,       // in: string to parse
    850                                     PSZ pszSeparator,   // in: separator used in pszInput
     851PEABINDING eaCreateMVBindingFromPSZ(const char *pcszEAName,      // in: EA name (e.g. ".KEYPHRASES")
     852                                    const char *pcszInput,       // in: string to parse
     853                                    const char *pcszSeparator,   // in: separator used in pszInput
    851854                                    USHORT usCodepage)  // in: codepage to set in EAT_MVMT
    852855{
    853856    PEABINDING peab;
    854     if (pszInput)
     857    if (pcszInput)
    855858    {
    856859        peab = (PEABINDING)malloc(sizeof(EABINDING));
    857860        if (peab)
    858861        {
    859             PSZ     p = pszInput,
    860                     pSource,
    861                     pTarget;
    862             USHORT  cbInput = strlen(pszInput),
    863                     cbSep = strlen(pszSeparator),
     862            const char *p = pcszInput,
     863                    *pSource;
     864            PSZ     pTarget;
     865            USHORT  cbInput = strlen(pcszInput),
     866                    cbSep = strlen(pcszSeparator),
    864867                    usSepCount = 0,
    865868                    cbToAlloc = 0,
     
    868871
    869872            peab->bFlags = 0;
    870             peab->bNameLength = strlen(pszEAName);
    871             peab->pszName = strdup(pszEAName);
     873            peab->bNameLength = strlen(pcszEAName);
     874            peab->pszName = strdup(pcszEAName);
    872875
    873876            // now count the number of pszSeparators in pszInput
    874             while ((p = strstr(p, pszSeparator)))
     877            while ((p = strstr(p, pcszSeparator)))
    875878            {
    876879                usSepCount++;
     
    898901
    899902            // set pointer to first field
    900             pSource = pszInput;
     903            pSource = pcszInput;
    901904            pTarget = peab->pszValue + 6;
    902905
     
    907910            {
    908911                // find the next separator
    909                 PSZ     pNextSep = strstr(pSource, pszSeparator);
     912                PSZ     pNextSep = strstr(pSource, pcszSeparator);
    910913                // calculate the length of the substring
    911914                cbThis = pNextSep - pSource;
     
    934937
    935938/********************************************************************
    936  *                                                                  *
    937  *   EA helper funcs                                                *
    938  *                                                                  *
     939 *
     940 *   EA helper funcs
     941 *
    939942 ********************************************************************/
    940943
     
    12171220
    12181221/* ******************************************************************
    1219  *                                                                  *
    1220  *   Direct plain-string EA handling                                *
    1221  *                                                                  *
     1222 *
     1223 *   Direct plain-string EA handling
     1224 *
    12221225 ********************************************************************/
    12231226
Note: See TracChangeset for help on using the changeset viewer.