Changeset 14 for trunk/src/helpers/eah.c
- Timestamp:
- Dec 9, 2000, 8:19:42 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/eah.c
r8 r14 67 67 * Copyright (C) 1995 Massachusetts Institute of Technology. 68 68 * Copyright (C) 1997-2000 Ulrich Mller. 69 * This file is part of the XWorkplacesource package.70 * XWorkplaceis free software; you can redistribute it and/or modify69 * This file is part of the "XWorkplace helpers" source package. 70 * This is free software; you can redistribute it and/or modify 71 71 * it under the terms of the GNU General Public License as published 72 72 * by the Free Software Foundation, in version 2 as it comes in the … … 83 83 // as unsigned char 84 84 85 #define INCL_DOS 85 #define INCL_DOSFILEMGR 86 86 #define INCL_DOSERRORS 87 87 #include <os2.h> … … 101 101 102 102 /******************************************************************** 103 * *104 * Extended Attribute handling *105 * *103 * 104 * Extended Attribute handling 105 * 106 106 ********************************************************************/ 107 107 … … 173 173 174 174 /* ****************************************************************** 175 * *176 * Read-EA functions *177 * *175 * 176 * Read-EA functions 177 * 178 178 ********************************************************************/ 179 179 … … 196 196 */ 197 197 198 ULONG eaPathQueryTotalSize( PSZ pszPath)198 ULONG eaPathQueryTotalSize(const char *pcszPath) 199 199 { 200 200 APIRET arc; … … 202 202 FILEFINDBUF4 ffb4; 203 203 204 _Pmpf(("eaPathQueryTotalSize %s", pszPath)); 205 206 arc = DosQueryPathInfo(pszPath, 204 arc = DosQueryPathInfo((PSZ)pcszPath, 207 205 FIL_QUERYEASIZE, 208 206 &ffb4, … … 220 218 221 219 arc = DosEnumAttribute(ENUMEA_REFTYPE_PATH, 222 pszPath,220 (PSZ)pcszPath, 223 221 1, 224 222 abBuf, … … 230 228 pdena2 = (PDENA2)abBuf; 231 229 232 _Pmpf((" %s: arc = %d, count = %d", pszPath, arc, lCount));233 234 230 if (lCount > 0) 235 231 { … … 247 243 } 248 244 249 _Pmpf((" %s: total %d", pszPath, ulTotalEASize));250 251 245 return (ulTotalEASize); 252 246 } … … 259 253 */ 260 254 261 PEALIST eaPathReadAll( PSZ path)262 { 263 return (ReadEAList(ENUMEA_REFTYPE_PATH, path));255 PEALIST eaPathReadAll(const char *pcszPath) 256 { 257 return (ReadEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath)); 264 258 } 265 259 … … 283 277 */ 284 278 285 PEABINDING eaPathReadOneByIndex( PSZ path, ULONG index)286 { 287 return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, path, index));279 PEABINDING eaPathReadOneByIndex(const char *pcszPath, ULONG index) 280 { 281 return (ReadEAByIndex(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, index)); 288 282 } 289 283 … … 305 299 */ 306 300 307 PEABINDING eaPathReadOneByName( PSZ path, PSZ name)308 { 309 return (ReadEAByName(ENUMEA_REFTYPE_PATH, path, name));301 PEABINDING eaPathReadOneByName(const char *pcszPath, const char *pcszEAName) 302 { 303 return (ReadEAByName(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, (PSZ)pcszEAName)); 310 304 } 311 305 … … 315 309 */ 316 310 317 PEABINDING eaHFileReadOneByName(HFILE hfile, PSZ name)318 { 319 return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), name));311 PEABINDING eaHFileReadOneByName(HFILE hfile, const char *pcszEAName) 312 { 313 return (ReadEAByName(ENUMEA_REFTYPE_FHANDLE, (&hfile), (PSZ)pcszEAName)); 320 314 } 321 315 322 316 /* ****************************************************************** 323 * *324 * Write-EA functions *325 * *317 * 318 * Write-EA functions 319 * 326 320 ********************************************************************/ 327 321 … … 335 329 * field is 0; only in that case, the EABINDING.value 336 330 * 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 335 APIRET eaPathWriteAll(const char *pcszPath, PEALIST list) 336 { 337 return (WriteEAList(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, list)); 342 338 } 343 339 … … 345 341 *@@ eaHFileWriteAll: 346 342 * 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 347 APIRET eaHFileWriteAll(HFILE hfile, PEALIST list) 348 { 349 return (WriteEAList(ENUMEA_REFTYPE_FHANDLE, (&hfile), list)); 352 350 } 353 351 … … 362 360 * 363 361 * 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 366 APIRET eaPathWriteOne(const char *pcszPath, PEABINDING peab) 367 { 368 return (WriteEA(ENUMEA_REFTYPE_PATH, (PSZ)pcszPath, peab)); 369 369 } 370 370 … … 372 372 *@@ eaHFileWriteOne: 373 373 * 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 378 APIRET eaHFileWriteOne(HFILE hfile, PEABINDING peab) 379 { 380 return (WriteEA(ENUMEA_REFTYPE_FHANDLE, (&hfile), peab)); 379 381 } 380 382 … … 386 388 * 387 389 *@@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 393 APIRET eaPathDeleteOne(const char *pcszPath, const char *pcszEAName) 391 394 { 392 395 EABINDING eab; 393 396 eab.bFlags = 0; 394 eab.bNameLength = strlen(p szEAName);395 eab.pszName = pszEAName;397 eab.bNameLength = strlen(pcszEAName); 398 eab.pszName = (PSZ)pcszEAName; 396 399 eab.usValueLength = 0; 397 400 eab.pszValue = 0; 398 eaPathWriteOne(path, &eab);401 return (eaPathWriteOne(pcszPath, &eab)); 399 402 } 400 403 … … 404 407 405 408 /******************************************************************** 406 * *407 * Translation funcs *408 * *409 * 410 * Translation funcs 411 * 409 412 ********************************************************************/ 410 413 … … 484 487 */ 485 488 486 PEABINDING eaCreateBindingFromPSZ( PSZ pszEAName,// in: EA name (e.g. ".LONGNAME")487 PSZ pszString)// in: string for EAT_ASCII EA489 PEABINDING eaCreateBindingFromPSZ(const char *pcszEAName, // in: EA name (e.g. ".LONGNAME") 490 const char *pcszInput) // in: string for EAT_ASCII EA 488 491 { 489 492 PEABINDING peab = (PEABINDING)malloc(sizeof(EABINDING)); … … 491 494 { 492 495 SHORT cbString = 0; 493 if (p szString)494 cbString = strlen(p szString);496 if (pcszInput) 497 cbString = strlen(pcszInput); 495 498 496 499 peab->bFlags = 0; 497 peab->bNameLength = strlen(p szEAName);498 peab->pszName = strdup(p szEAName);500 peab->bNameLength = strlen(pcszEAName); 501 peab->pszName = strdup(pcszEAName); 499 502 500 503 if (cbString) … … 510 513 *((PUSHORT)(peab->pszValue + 2)) = cbString; 511 514 // copy string to byte 4 (no null-terminator) 512 memcpy(peab->pszValue + 4, p szString, cbString);515 memcpy(peab->pszValue + 4, pcszInput, cbString); 513 516 } 514 517 else … … 743 746 744 747 PSZ eaCreatePSZFromMVBinding(PEABINDING peab, // in: EAT_MVMT binding 745 PSZ pszSeparator, // in: null-terminated string used as separator748 const char *pcszSeparator, // in: null-terminated string used as separator 746 749 PUSHORT pusCodepage) // out: codepage found in binding (ptr can be NULL) 747 750 { … … 765 768 USHORT us = 0; 766 769 USHORT cbComment = 0; 767 USHORT cbSeparator = strlen(p szSeparator);770 USHORT cbSeparator = strlen(pcszSeparator); 768 771 while (us < usMVCount) 769 772 { … … 794 797 // append separator 795 798 memcpy(pszTotal + cbCommentOld, 796 p szSeparator,799 pcszSeparator, 797 800 cbSeparator); 798 801 // copy the rest after the separator (below) … … 846 849 */ 847 850 848 PEABINDING eaCreateMVBindingFromPSZ( PSZ pszEAName, // in: EA name (e.g. ".KEYPHRASES")849 PSZ pszInput, // in: string to parse850 PSZ pszSeparator, // in: separator used in pszInput851 PEABINDING 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 851 854 USHORT usCodepage) // in: codepage to set in EAT_MVMT 852 855 { 853 856 PEABINDING peab; 854 if (p szInput)857 if (pcszInput) 855 858 { 856 859 peab = (PEABINDING)malloc(sizeof(EABINDING)); 857 860 if (peab) 858 861 { 859 PSZ p = pszInput,860 pSource,861 862 USHORT cbInput = strlen(p szInput),863 cbSep = strlen(p szSeparator),862 const char *p = pcszInput, 863 *pSource; 864 PSZ pTarget; 865 USHORT cbInput = strlen(pcszInput), 866 cbSep = strlen(pcszSeparator), 864 867 usSepCount = 0, 865 868 cbToAlloc = 0, … … 868 871 869 872 peab->bFlags = 0; 870 peab->bNameLength = strlen(p szEAName);871 peab->pszName = strdup(p szEAName);873 peab->bNameLength = strlen(pcszEAName); 874 peab->pszName = strdup(pcszEAName); 872 875 873 876 // now count the number of pszSeparators in pszInput 874 while ((p = strstr(p, p szSeparator)))877 while ((p = strstr(p, pcszSeparator))) 875 878 { 876 879 usSepCount++; … … 898 901 899 902 // set pointer to first field 900 pSource = p szInput;903 pSource = pcszInput; 901 904 pTarget = peab->pszValue + 6; 902 905 … … 907 910 { 908 911 // find the next separator 909 PSZ pNextSep = strstr(pSource, p szSeparator);912 PSZ pNextSep = strstr(pSource, pcszSeparator); 910 913 // calculate the length of the substring 911 914 cbThis = pNextSep - pSource; … … 934 937 935 938 /******************************************************************** 936 * *937 * EA helper funcs *938 * *939 * 940 * EA helper funcs 941 * 939 942 ********************************************************************/ 940 943 … … 1217 1220 1218 1221 /* ****************************************************************** 1219 * *1220 * Direct plain-string EA handling *1221 * *1222 * 1223 * Direct plain-string EA handling 1224 * 1222 1225 ********************************************************************/ 1223 1226
Note:
See TracChangeset
for help on using the changeset viewer.