home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / xfld085s.zip / helpers / eas.h < prev    next >
C/C++ Source or Header  |  1999-02-23  |  7KB  |  194 lines

  1.  
  2. /*
  3.  * eas.h:
  4.  *      header file for eas.c.
  5.  *      This file is new with V0.81.
  6.  *      See explanations in eas.c.
  7.  *
  8.  *      Function prefixes (new with V0.81):
  9.  *      --  ea*         EA helper functions
  10.  *
  11.  *      Required #include's before including this header:
  12.  *      --  OS2.H with INCL_DOS.
  13.  */
  14.  
  15. /*
  16.  *      Most of the code in this file dealing with Extended Attributes
  17.  *      is based on code (w) by Chris Hanson (cph@zurich.ai.mit.edu).
  18.  *      Copyright (c) 1995 Massachusetts Institute of Technology.
  19.  *      The original code is available as EALIB.ZIP at Hobbes.
  20.  *
  21.  *      From that code is the following copyright notice:
  22.  *
  23.  *      This material was developed by the Scheme project at the Massachusetts
  24.  *      Institute of Technology, Department of Electrical Engineering and
  25.  *      Computer Science.  Permission to copy this software, to redistribute
  26.  *      it, and to use it for any purpose is granted, subject to the following
  27.  *      restrictions and understandings.
  28.  *
  29.  *      1. Any copy made of this software must include this copyright notice
  30.  *      in full.
  31.  *
  32.  *      2. Users of this software agree to make their best efforts (a) to
  33.  *      return to the MIT Scheme project any improvements or extensions that
  34.  *      they make, so that these may be included in future releases; and (b)
  35.  *      to inform MIT of noteworthy uses of this software.
  36.  *
  37.  *      3. All materials developed as a consequence of the use of this
  38.  *      software shall duly acknowledge such use, in accordance with the usual
  39.  *      standards of acknowledging credit in academic research.
  40.  *
  41.  *      4. MIT has made no warrantee or representation that the operation of
  42.  *      this software will be error-free, and MIT is under no obligation to
  43.  *      provide any services, by way of maintenance, update, or otherwise.
  44.  *
  45.  *      5. In conjunction with products arising from the use of this material,
  46.  *      there shall be no use of the name of the Massachusetts Institute of
  47.  *      Technology nor of any adaptation thereof in any advertising,
  48.  *      promotional, or sales literature without prior written consent from
  49.  *      MIT in each case.
  50.  *
  51.  *      This file Copyright (C) 1997-99 Ulrich Möller,
  52.  *                                      Massachusetts Institute of Technology.
  53.  *      This file is part of the XFolder source package.
  54.  *      XFolder is free software; you can redistribute it and/or modify
  55.  *      it under the terms of the GNU General Public License as published
  56.  *      by the Free Software Foundation, in version 2 as it comes in the
  57.  *      "COPYING" file of the XFolder main distribution.
  58.  *      This program is distributed in the hope that it will be useful,
  59.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  60.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  61.  *      GNU General Public License for more details.
  62.  */
  63.  
  64. #if __cplusplus
  65. extern "C" {
  66. #endif
  67.  
  68. #ifndef EAS_HEADER_INCLUDED
  69.     #define EAS_HEADER_INCLUDED
  70.  
  71.     typedef struct {
  72.         BYTE bFlags;
  73.         BYTE bNameLength;
  74.         USHORT usValueLength;
  75.         PSZ pszName;
  76.         PSZ pszValue;
  77.     } EABINDING, *PEABINDING;
  78.  
  79.     typedef struct _EALIST {
  80.         EABINDING * binding;
  81.         struct _EALIST * next;
  82.     } EALIST, *PEALIST;
  83.  
  84.  
  85.     /*
  86.      * eaFreeBinding:
  87.      *      deallocate EA binding memory that was generated
  88.      *      by the ea...Read... procedures below. These procs
  89.      *      assume that "malloc" was used for allocation and
  90.      *      that the "name" and "value" fields of each binding
  91.      *      were also allocated using "malloc". "value" may also
  92.      *      be NULL.
  93.      */
  94.  
  95.     void eaFreeBinding(PEABINDING binding);
  96.  
  97.     /*
  98.      * eaFreeList:
  99.      *      the same for an EA binding list.
  100.      */
  101.  
  102.     void eaFreeList(PEALIST list);
  103.  
  104.     /*
  105.      * All of the following functions come in two flavors:
  106.      *
  107.      *      eaHFile*    operate on an open file handle.
  108.      *
  109.      *      eaPath*     operate on any file specified by its
  110.      *                  filename, which may be fully qualified.
  111.      */
  112.  
  113.     /*
  114.      * ------ READ EXTENDED ATTRIBUTES
  115.      */
  116.  
  117.     /*
  118.      * eaHFileQueryTotalSize / eaPathQueryTotalSize:
  119.      *      returns the total size of all EAs.
  120.      */
  121.  
  122.     ULONG eaHFileQueryTotalSize(HFILE hFile);
  123.  
  124.     ULONG eaPathQueryTotalSize(PSZ path);
  125.  
  126.     /*
  127.      * eaHFileReadAll / eaPathReadAll:
  128.      *      reads all of the extended attributes into an EALIST.
  129.      *      Returns NULL if no EAs were found.
  130.      *      The returned list should be freed using eaFreeList.
  131.      */
  132.  
  133.     PEALIST eaHFileReadAll(HFILE hfile);
  134.  
  135.     PEALIST eaPathReadAll(PSZ path);
  136.  
  137.     /*
  138.      * eaHFileReadOneByIndex / eaPathReadOneByIndex:
  139.      *      returns one EA specified by a given index, counting
  140.      *      from 1. Returns NULL if the specified index was not
  141.      *      found, either because the file has no EAs at all or
  142.      *      the index is too large.
  143.      *      The returned binding should be freed using eaFreebinding.
  144.      */
  145.  
  146.     PEABINDING eaHFileReadOneByIndex(HFILE hfile, ULONG index);
  147.  
  148.     PEABINDING eaPathReadOneByIndex(PSZ path, ULONG index);
  149.  
  150.     /*
  151.      * eaHFileReadOneByName / eaPathReadOneByName:
  152.      *      returns one EA specified by the given EA name (e.g.
  153.      *      ".LONGNAME"). Returns NULL if not found.
  154.      *      The returned binding should be freed using eaFreebinding.
  155.      */
  156.  
  157.     PEABINDING eaHFileReadOneByName(HFILE hfile, PSZ name);
  158.  
  159.     PEABINDING eaPathReadOneByName(PSZ path, PSZ name);
  160.  
  161.     /*
  162.      * ------ WRITE EXTENDED ATTRIBUTES
  163.      */
  164.  
  165.     /*
  166.      * eaHFileWriteAll / eaPathWriteAll:
  167.      *      writes a list of EAs to a given file. These EAs
  168.      *      are added to possibly existing EAs on the file.
  169.      *      A given EA is deleted if its usValueLength field
  170.      *      is 0; in that case, the value field may also be NULL.
  171.      */
  172.  
  173.     void eaHFileWriteAll(HFILE hfile, PEALIST list);
  174.  
  175.     void eaPathWriteAll(PSZ path, PEALIST list);
  176.  
  177.     /*
  178.      * eaHFileWriteOne / eaPathWriteOne:
  179.      *      adds one EA to a given file.
  180.      *      A given EA is deleted if its usValueLength field
  181.      *      is 0; in that case, the value field may also be NULL.
  182.      */
  183.  
  184.     void eaHFileWriteOne(HFILE hfile, PEABINDING binding);
  185.  
  186.     void eaPathWriteOne(PSZ path, PEABINDING binding);
  187.  
  188. #endif
  189.  
  190. #if __cplusplus
  191. }
  192. #endif
  193.  
  194.