home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mmap-177.zip / ealib.h next >
C/C++ Source or Header  |  1999-06-13  |  5KB  |  120 lines

  1. /* -*-C-*-
  2.  
  3. $Id$
  4.  
  5. Copyright (c) 1995 Massachusetts Institute of Technology
  6.  
  7. This material was developed by the Scheme project at the Massachusetts
  8. Institute of Technology, Department of Electrical Engineering and
  9. Computer Science.  Permission to copy this software, to redistribute
  10. it, and to use it for any purpose is granted, subject to the following
  11. restrictions and understandings.
  12.  
  13. 1. Any copy made of this software must include this copyright notice
  14. in full.
  15.  
  16. 2. Users of this software agree to make their best efforts (a) to
  17. return to the MIT Scheme project any improvements or extensions that
  18. they make, so that these may be included in future releases; and (b)
  19. to inform MIT of noteworthy uses of this software.
  20.  
  21. 3. All materials developed as a consequence of the use of this
  22. software shall duly acknowledge such use, in accordance with the usual
  23. standards of acknowledging credit in academic research.
  24.  
  25. 4. MIT has made no warrantee or representation that the operation of
  26. this software will be error-free, and MIT is under no obligation to
  27. provide any services, by way of maintenance, update, or otherwise.
  28.  
  29. 5. In conjunction with products arising from the use of this material,
  30. there shall be no use of the name of the Massachusetts Institute of
  31. Technology nor of any adaptation thereof in any advertising,
  32. promotional, or sales literature without prior written consent from
  33. MIT in each case. */
  34.  
  35. #ifndef EALIB_H
  36. #define EALIB_H
  37.  
  38. typedef struct
  39. {
  40.   BYTE flags;
  41.   BYTE name_length;
  42.   USHORT value_length;
  43.   PSZ name;
  44.   PSZ value;
  45. } ea_binding;
  46. #define EA_BINDING_FLAGS(binding) ((binding) -> flags)
  47. #define EA_BINDING_NAME_LENGTH(binding) ((binding) -> name_length)
  48. #define EA_BINDING_VALUE_LENGTH(binding) ((binding) -> value_length)
  49. #define EA_BINDING_NAME(binding) ((binding) -> name)
  50. #define EA_BINDING_VALUE(binding) ((binding) -> value)
  51.  
  52. typedef struct _ea_list
  53. {
  54.   ea_binding * binding;
  55.   struct _ea_list * next;
  56. } ea_list;
  57. #define EA_LIST_BINDING(list) ((list) -> binding)
  58. #define EA_LIST_NEXT(list) ((list) -> next)
  59.  
  60. /* Set this to handle errors signalled by the Dos... API.
  61.    It will be called with the return code as the first argument.
  62.    The second argument will be the string name of the procedure
  63.    that signalled the error.  If set to 0 (the default), errors will
  64.    be handled by printing a simple error message to `stderr', and
  65.    terminating the program with `exit'.  */
  66. extern void ea_error_hook(APIRET, const char *);
  67.  
  68. /* Each of the following procedures comes in two flavors.  One flavor
  69.    operates on previously-opened file handles, and the other operates
  70.    on file pathnames.  */
  71.  
  72. /* Read all of the extended attributes, and return them as a list.
  73.    Returns 0 if there are no attributes.  The returned list of
  74.    attributes should be freed by calling `free_ea_list'.  */
  75. extern ea_list * read_file_eas (HFILE);
  76. extern ea_list * read_path_eas (PSZ);
  77.  
  78. /* Return the extended attribute specified by a given index.  The
  79.    index of the first attribute is 1.  Returns 0 if the index is
  80.    larger than the number of attributes attached to the file; in
  81.    particular, returns 0 for index 1 if there are no attributes.  The
  82.    returned binding should be freed by calling `free_ea_binding'.  */
  83. extern ea_binding * read_file_ea_by_index (HFILE, ULONG);
  84. extern ea_binding * read_path_ea_by_index (PSZ, ULONG);
  85.  
  86. /* Return the extended attribute specified by the given name.  If
  87.    there is no such attribute, returns 0.  The returned binding should
  88.    be freed by calling `free_ea_binding'.  */
  89. extern ea_binding * read_file_ea_by_name (HFILE, PSZ);
  90. extern ea_binding * read_path_ea_by_name (PSZ, PSZ);
  91.  
  92. /* The following procedures write extended attributes to a given file.
  93.    A given attribute is deleted if its `value_length' is 0; in that
  94.    case the `value' field is also permitted to be 0.  */
  95.  
  96. /* Write a list of extended attributes to a given file.  These
  97.    attributes add to any attributes already stored on the file.  */
  98. extern void write_file_eas (HFILE, ea_list *);
  99. extern void write_path_eas (PSZ, ea_list *);
  100.  
  101. /* Write a single extended attribute to a given file.  This attribute
  102.    is added to any attributes already stored on the file.  */
  103. extern void write_file_ea (HFILE, ea_binding *);
  104. extern void write_path_ea (PSZ, ea_binding *);
  105.  
  106. /* The following procedures deallocate the EA binding memory
  107.    structures that are generated by the `read_...' procedures
  108.    described above.  These procedures assume that `malloc' is used for
  109.    allocation of all storage, and that the `name' and `value' fields
  110.    of each binding are also allocated with `malloc'.  The `value'
  111.    field may also be 0.  */
  112.  
  113. /* Free the storage associated with a list of EA bindings.  */
  114. extern void free_ea_list (ea_list *);
  115.  
  116. /* Free the storage associated with a single EA binding.  */
  117. extern void free_ea_binding (ea_binding *);
  118.  
  119. #endif /* not EALIB_H */
  120.