[7] | 1 |
|
---|
| 2 | /*
|
---|
| 3 | *@@sourcefile eah.h:
|
---|
| 4 | * header file for eah.c. See remarks there.
|
---|
| 5 | *
|
---|
| 6 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
| 7 | * numbering.
|
---|
| 8 | *
|
---|
| 9 | *@@include #include <os2.h>
|
---|
[113] | 10 | *@@include #include "helpers\eah.h"
|
---|
[7] | 11 | */
|
---|
| 12 |
|
---|
| 13 | /*
|
---|
| 14 | * Most of the code in this file dealing with Extended Attributes
|
---|
| 15 | * is based on code (w) by Chris Hanson (cph@zurich.ai.mit.edu).
|
---|
| 16 | * Copyright (c) 1995 Massachusetts Institute of Technology.
|
---|
| 17 | * The original code is available as EALIB.ZIP at Hobbes.
|
---|
| 18 | *
|
---|
| 19 | * From that code is the following copyright notice:
|
---|
| 20 | *
|
---|
| 21 | * This material was developed by the Scheme project at the Massachusetts
|
---|
| 22 | * Institute of Technology, Department of Electrical Engineering and
|
---|
| 23 | * Computer Science. Permission to copy this software, to redistribute
|
---|
| 24 | * it, and to use it for any purpose is granted, subject to the following
|
---|
| 25 | * restrictions and understandings.
|
---|
| 26 | *
|
---|
| 27 | * 1. Any copy made of this software must include this copyright notice
|
---|
| 28 | * in full.
|
---|
| 29 | *
|
---|
| 30 | * 2. Users of this software agree to make their best efforts (a) to
|
---|
| 31 | * return to the MIT Scheme project any improvements or extensions that
|
---|
| 32 | * they make, so that these may be included in future releases; and (b)
|
---|
| 33 | * to inform MIT of noteworthy uses of this software.
|
---|
| 34 | *
|
---|
| 35 | * 3. All materials developed as a consequence of the use of this
|
---|
| 36 | * software shall duly acknowledge such use, in accordance with the usual
|
---|
| 37 | * standards of acknowledging credit in academic research.
|
---|
| 38 | *
|
---|
| 39 | * 4. MIT has made no warrantee or representation that the operation of
|
---|
| 40 | * this software will be error-free, and MIT is under no obligation to
|
---|
| 41 | * provide any services, by way of maintenance, update, or otherwise.
|
---|
| 42 | *
|
---|
| 43 | * 5. In conjunction with products arising from the use of this material,
|
---|
| 44 | * there shall be no use of the name of the Massachusetts Institute of
|
---|
| 45 | * Technology nor of any adaptation thereof in any advertising,
|
---|
| 46 | * promotional, or sales literature without prior written consent from
|
---|
| 47 | * MIT in each case.
|
---|
| 48 | *
|
---|
| 49 | * This file Copyright (C) 1997-2000 Ulrich Mller,
|
---|
| 50 | * Massachusetts Institute of Technology.
|
---|
[14] | 51 | * This file is part of the "XWorkplace helpers" source package.
|
---|
| 52 | * This is free software; you can redistribute it and/or modify
|
---|
[7] | 53 | * it under the terms of the GNU General Public License as published
|
---|
| 54 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
| 55 | * "COPYING" file of the XWorkplace main distribution.
|
---|
| 56 | * This program is distributed in the hope that it will be useful,
|
---|
| 57 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 58 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 59 | * GNU General Public License for more details.
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | #if __cplusplus
|
---|
| 63 | extern "C" {
|
---|
| 64 | #endif
|
---|
| 65 |
|
---|
| 66 | #ifndef EAS_HEADER_INCLUDED
|
---|
| 67 | #define EAS_HEADER_INCLUDED
|
---|
| 68 |
|
---|
| 69 | /*
|
---|
| 70 | *@@ EABINDING:
|
---|
| 71 | * generic data structure used for all
|
---|
| 72 | * the EA functions.
|
---|
| 73 | *
|
---|
| 74 | * usValueLength gives you the length of *pszValue,
|
---|
| 75 | * which is _not_ necessarily zero-terminated.
|
---|
| 76 | *
|
---|
| 77 | * The format of pszValue depends on the EA type.
|
---|
| 78 | * This pointer points to the "raw" EA data.
|
---|
| 79 | *
|
---|
| 80 | * The first USHORT gives you the EA type (EAT_* flag),
|
---|
| 81 | * on which the other bytes depend.
|
---|
| 82 | *
|
---|
| 83 | * Most EA types have their size in the second USHORT.
|
---|
| 84 | * All EA formats are described in detail in CPREF.
|
---|
| 85 | */
|
---|
| 86 |
|
---|
| 87 | typedef struct _EABINDING
|
---|
| 88 | {
|
---|
| 89 | BYTE bFlags;
|
---|
| 90 | // EA flags, as in FEA2.fEA. This is either
|
---|
| 91 | // FFEA_NEEDEA (for critical EAs) or 0.
|
---|
| 92 | BYTE bNameLength; // length of (*pszName)
|
---|
| 93 | USHORT usValueLength; // length of (*pszValue)
|
---|
| 94 | PSZ pszName; // EA name (e.g. ".CLASSINFO")
|
---|
| 95 | PSZ pszValue; // complete raw EA contents.
|
---|
| 96 | // The first USHORT gives you the type,
|
---|
| 97 | // the second USHORT normally the size.
|
---|
| 98 | } EABINDING, *PEABINDING;
|
---|
| 99 |
|
---|
| 100 | /*
|
---|
| 101 | *@@ EALIST:
|
---|
| 102 | * list structure returned by eaPathReadAll and
|
---|
| 103 | * eaHFileReadAll.
|
---|
| 104 | */
|
---|
| 105 |
|
---|
| 106 | typedef struct _EALIST
|
---|
| 107 | {
|
---|
| 108 | PEABINDING peab;
|
---|
| 109 | struct _EALIST *next;
|
---|
| 110 | } EALIST, *PEALIST;
|
---|
| 111 |
|
---|
| 112 | void eaFreeBinding(PEABINDING peab);
|
---|
| 113 |
|
---|
| 114 | void eaFreeList(PEALIST list);
|
---|
| 115 |
|
---|
| 116 | /* ******************************************************************
|
---|
[14] | 117 | *
|
---|
| 118 | * Read-EA functions
|
---|
| 119 | *
|
---|
[7] | 120 | ********************************************************************/
|
---|
| 121 |
|
---|
| 122 | ULONG eaHFileQueryTotalSize(HFILE hFile);
|
---|
| 123 |
|
---|
[14] | 124 | ULONG eaPathQueryTotalSize(const char *pcszPath);
|
---|
[7] | 125 |
|
---|
| 126 | PEALIST eaHFileReadAll(HFILE hfile);
|
---|
| 127 |
|
---|
[14] | 128 | PEALIST eaPathReadAll(const char *pcszPath);
|
---|
[7] | 129 |
|
---|
| 130 | PEABINDING eaHFileReadOneByIndex(HFILE hfile, ULONG index);
|
---|
| 131 |
|
---|
[14] | 132 | PEABINDING eaPathReadOneByIndex(const char *pcszPath, ULONG index);
|
---|
[7] | 133 |
|
---|
[14] | 134 | PEABINDING eaHFileReadOneByName(HFILE hfile, const char *pcszEAName);
|
---|
[7] | 135 |
|
---|
[14] | 136 | PEABINDING eaPathReadOneByName(const char *pcszPath, const char *pcszEAName);
|
---|
[7] | 137 |
|
---|
| 138 | /* ******************************************************************
|
---|
[14] | 139 | *
|
---|
| 140 | * Write-EA functions
|
---|
| 141 | *
|
---|
[7] | 142 | ********************************************************************/
|
---|
| 143 |
|
---|
[14] | 144 | APIRET eaHFileWriteAll(HFILE hfile, PEALIST list);
|
---|
[7] | 145 |
|
---|
[14] | 146 | APIRET eaPathWriteAll(const char *pcszPath, PEALIST list);
|
---|
[7] | 147 |
|
---|
[14] | 148 | APIRET eaHFileWriteOne(HFILE hfile, PEABINDING peab);
|
---|
[7] | 149 |
|
---|
[14] | 150 | APIRET eaPathWriteOne(const char *pcszPath, PEABINDING peab);
|
---|
[7] | 151 |
|
---|
[14] | 152 | APIRET eaPathDeleteOne(const char *pcszPath, const char *pcszEAName);
|
---|
[7] | 153 |
|
---|
| 154 | /********************************************************************
|
---|
[14] | 155 | *
|
---|
| 156 | * Translation funcs
|
---|
| 157 | *
|
---|
[7] | 158 | ********************************************************************/
|
---|
| 159 |
|
---|
| 160 | USHORT eaQueryEAType(PEABINDING peab);
|
---|
| 161 |
|
---|
| 162 | PSZ eaCreatePSZFromBinding(PEABINDING peab);
|
---|
| 163 |
|
---|
[14] | 164 | PEABINDING eaCreateBindingFromPSZ(const char *pcszEAName,
|
---|
| 165 | const char *pcszInput);
|
---|
[7] | 166 |
|
---|
| 167 | USHORT eaQueryMVCount(PEABINDING peab,
|
---|
| 168 | PUSHORT pusCodepage,
|
---|
| 169 | PUSHORT pusEAType);
|
---|
| 170 |
|
---|
| 171 | PSZ eaQueryMVItem(PEABINDING peab,
|
---|
[14] | 172 | USHORT usIndex,
|
---|
| 173 | PUSHORT pusEAType,
|
---|
| 174 | PUSHORT pusCodepage,
|
---|
| 175 | PUSHORT pusDataLength);
|
---|
[7] | 176 |
|
---|
| 177 | PSZ eaCreatePSZFromMVBinding(PEABINDING peab,
|
---|
[14] | 178 | const char *pcszSeparator,
|
---|
[7] | 179 | PUSHORT pusCodepage);
|
---|
| 180 |
|
---|
[14] | 181 | PEABINDING eaCreateMVBindingFromPSZ(const char *pcszEAName,
|
---|
| 182 | const char *pcszInput,
|
---|
| 183 | const char *pcszSeparator,
|
---|
[7] | 184 | USHORT usCodepage);
|
---|
| 185 |
|
---|
| 186 | /* ******************************************************************
|
---|
[14] | 187 | *
|
---|
| 188 | * Direct plain-string EA handling
|
---|
| 189 | *
|
---|
[7] | 190 | ********************************************************************/
|
---|
| 191 |
|
---|
| 192 | typedef struct _EAMVMT
|
---|
| 193 | {
|
---|
| 194 | USHORT usType;
|
---|
| 195 | USHORT usCodepage;
|
---|
| 196 | USHORT usEntries;
|
---|
| 197 | USHORT usEntryType;
|
---|
| 198 | USHORT usEntryLen;
|
---|
| 199 | CHAR chEntry[1];
|
---|
| 200 | } EAMVMT, *PEAMVMT;
|
---|
| 201 |
|
---|
| 202 | typedef struct _EASVST
|
---|
| 203 | {
|
---|
| 204 | USHORT usType;
|
---|
| 205 | USHORT usEntryLen;
|
---|
| 206 | CHAR chEntry[1];
|
---|
| 207 | } EASVST, *PEASVST;
|
---|
| 208 |
|
---|
| 209 | #define MAX(a,b) (a > b ? a : b)
|
---|
| 210 | #define MAX(a,b) (a > b ? a : b)
|
---|
| 211 | #define NEXTSTR(s) (s+strlen(s) + 1)
|
---|
| 212 |
|
---|
| 213 | APIRET eahWriteStringEA(HFILE hfile,
|
---|
| 214 | PSZ pszEaName,
|
---|
| 215 | PSZ pszEaValue);
|
---|
| 216 |
|
---|
| 217 | APIRET eahReadStringEA(PSZ pszFileName,
|
---|
| 218 | PSZ pszEaName,
|
---|
| 219 | PSZ pszBuffer,
|
---|
| 220 | PULONG pulBuflen);
|
---|
| 221 | #endif
|
---|
| 222 |
|
---|
| 223 | #if __cplusplus
|
---|
| 224 | }
|
---|
| 225 | #endif
|
---|
| 226 |
|
---|