home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gtak212.zip / LIBX / os2eattr.h < prev    next >
C/C++ Source or Header  |  1992-09-13  |  5KB  |  171 lines

  1. #ifndef __OS2EATTR_H__
  2. #define __OS2EATTR_H__
  3.  
  4. /*
  5.  * $Id: os2eattr.h,v 1.10 1992/07/24 11:43:24 ak Exp $
  6.  *
  7.  * Extended Attribute Management for OS/2.
  8.  *
  9.  * A.Kaiser    Mai 91
  10.  *
  11.  * $Log: os2eattr.h,v $
  12.  * Revision 1.10  1992/07/24  11:43:24  ak
  13.  * 2.0 is incompatible with 1.3 -- added magic number
  14.  * mechanism to allow checking of versions.
  15.  *
  16.  * Revision 1.8  1992/04/21  12:34:46  ak
  17.  * EMX 0.8c.
  18.  *
  19.  * Revision 1.7  1992/03/05  20:27:36  ak
  20.  * Bugfix.
  21.  *
  22.  * Revision 1.6  1992/02/26  21:23:16  ak
  23.  * *** empty log message ***
  24.  *
  25.  * Revision 1.5  1992/02/26  20:54:20  ak
  26.  * OS/2 2.0.
  27.  *
  28.  * Revision 1.4  1992/02/14  18:11:04  ak
  29.  * *** empty log message ***
  30.  *
  31.  * Revision 1.3  1992/01/03  14:24:21  ak
  32.  * $Header: h:/SRC.SSB/inc/os2eattr.h,v 1.10 1992/07/24 11:43:24 ak Exp $Id:
  33.  *
  34.  * Revision 1.2  1992/01/03  13:47:14  ak
  35.  * Zortech fixes.
  36.  *
  37.  * Revision 1.1.1.1  1991/12/12  16:12:37  ak
  38.  * Initial checkin of server source, modified to contain RCS IDs.
  39.  *
  40.  * Revision 1.1  1991/12/12  16:12:33  ak
  41.  * Initial revision
  42.  *
  43.  */
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48.  
  49. /*
  50.  * OS/2 2.2: EA representation is different.
  51.  * Added a ULONG magic number before the internal EA data.
  52.  * Changed external data type from pFEAList to pEABuf.
  53.  */
  54.  
  55. #if defined(__GNUC__)
  56.   #ifndef _far
  57.     #define _far
  58.   #endif
  59. #endif
  60. #if OS2 >= 2
  61.   #ifndef _far
  62.     #define _far
  63.   #endif
  64.   /*
  65.    * DosEnumAttrib:    DENAx = DENA2 = FEA2 mit cbValue != 0,
  66.    *            die Values sind jedoch nicht(!) drin.
  67.    */
  68.   #define GEAData    struct _GEA2
  69.   #define FEAData    struct _FEA2
  70.   #define GEAList    struct _GEA2LIST
  71.   #define FEAList    struct _FEA2LIST
  72.   #define ENAData    struct _FEA2
  73.   #define EAOPData    struct _EAOP2
  74. #else
  75.   #define GEAData    struct _GEA
  76.   #define FEAData    struct _FEA
  77.   #define GEAList    struct _GEALIST
  78.   #define FEAList    struct _FEALIST
  79.   #define ENAData    struct _DENA1
  80.   #define EAOPData    struct _EAOP
  81. #endif
  82. typedef GEAData _far *    pGEA;
  83. typedef GEAList _far *    pGEAList;
  84. typedef FEAData _far *    pFEA;
  85. typedef FEAList _far *    pFEAList;
  86. typedef ENAData _far *    pENA;
  87. typedef struct EABuf _far * pEABuf;
  88.  
  89. #if OS2 >= 2
  90.  
  91. # define SizeFEA(p)   ((p)->oNextEntryOffset)
  92. # define NextFEA(p)   ((pFEA)((unsigned char _far *)p + (p)->oNextEntryOffset))
  93. # define szNameFEA(p) ((p)->szName)
  94. # define aValueFEA(p) ((p)->szName + (p)->cbName+1)
  95. # define EndOfEA(p)   ((unsigned char _far *)(p) + (p)->cbList)
  96. # define WalkFEA(p,q) if (q->cbList) { p = q->list; do {
  97. # define WalkFEAEnd(p,q) } while (p->oNextEntryOffset ? (p = (pFEA)((unsigned char _far *)p + p->oNextEntryOffset)) : 0); }
  98.  
  99. #else
  100.  
  101.   typedef struct {
  102.     unsigned char    fEA;
  103.     unsigned char    cbName;
  104.     unsigned short    cbValue;
  105.     unsigned char    szName[1];
  106.   } _far *pFEAx;
  107.  
  108. # define SizeFEA(p)   ((unsigned char _far *)&((pFEAx)(p))->szName[((pFEAx)(p))->cbName+1+((pFEAx)(p))->cbValue] - (unsigned char _far *)(p))
  109. # define NextFEA(p)   ((pFEA)&((pFEAx)(p))->szName[((pFEAx)(p))->cbName+1+((pFEAx)(p))->cbValue])
  110. # define szNameFEA(p) (((pFEAx)(p))->szName)
  111. # define aValueFEA(p) (((pFEAx)(p))->szName + ((pFEAx)(p))->cbName+1)
  112. # define EndOfEA(p)   ((unsigned char _far *)(p) + (p)->cbList)
  113. # define WalkFEA(p,q) for (p = q->list; p < (pFEA) EndOfEA(q); p = NextFEA(p)) {
  114. # define WalkFEAEnd(p,q) }
  115.  
  116. #endif
  117.  
  118. /*
  119.  * The macro EALength accessed cbList without having
  120.  * to include the whole os2.h headers.
  121.  *
  122.  * Use TestEAMagic to check if EAs were written with
  123.  * the same EA buffer layout. 1.3 EAs have a positive
  124.  * count at the position where 2.0 EAs have a negative
  125.  * magic number.
  126.  */
  127. #if OS2 >= 2
  128. # define EAMagic2    -2
  129. # define ptrFEAList(p)    ((pFEAList)((long *)(p) + 1))
  130. # define EALength(p)    (sizeof(long) + ((long *)(p))[1])
  131. # define TestEAMagic(p)    (((long *)(p))[0] == EAMagic2)
  132. #else
  133. # define ptrFEAList(p)    ((pFEAList)(p))
  134. # define EALength(p)    (*(long _far *)(p))
  135. # define TestEAMagic(p)    (EALength(p) >= 0)
  136. #endif
  137.  
  138.     /* Load EABuf from file. */
  139.     /* Return 0 if file error (->errno) or not enough memory. */
  140. extern pEABuf    ea_load (char *);
  141. extern pEABuf    ea_fload (unsigned);
  142.  
  143.     /* Store EAList into file. */
  144.     /* Return -1 if file error (->errno). */
  145. extern int    ea_store (pEABuf, char *);
  146. extern int    ea_fstore (pEABuf, unsigned);
  147.  
  148.     /* Alloc/free EA data. */
  149. extern pEABuf    ea_alloc (unsigned long size);
  150. extern void    ea_free (pEABuf);
  151.  
  152.     /* UNTESTED: */
  153.  
  154.     /* Get EA value - return 0x100 + flag byte, -1 if not enough space */
  155. extern int    ea_get (pEABuf, char *, void *, int *);
  156.  
  157. #if OS2 < 2
  158.     /* Set EA value - pEABuf reallocated if necessary - 0 if no memory */
  159. extern pEABuf    ea_set (pEABuf, char *, void *, unsigned, unsigned /*flag*/);
  160.  
  161.     /* Remove EA value - return 0 if out of memory */
  162. extern pEABuf    ea_remove (pEABuf, char *);
  163. #endif
  164.  
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168.  
  169. #endif
  170.  
  171.