File: librsrc.txt

package info (click to toggle)
hfsutils 3.2.6-16
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,680 kB
  • sloc: ansic: 12,858; tcl: 1,937; makefile: 566; sh: 156; perl: 29
file content (119 lines) | stat: -rw-r--r-- 4,660 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

This file documents the librsrc.a library for accessing resource forks.
Copyright (C) 1996-1998 Robert Leslie

$Id: librsrc.txt,v 1.6 1998/09/19 05:06:32 rob Exp $

===============================================================================

Exported Data

  const char *rsrc_error;

    This contains a pointer to a C string describing the last resource
    library error. It is generally only valid after a resource routine has
    returned an error code (-1 or a NULL pointer).

    In all cases when an error occurs, the global variable `errno' is also
    set to an appropriate value.

Public Routines

  rsrcfile *rsrc_init(void *priv, const rsrcprocs *procs);

    This routine prepares an open file access path to be treated as a
    Macintosh resource fork. `priv' is treated as private file access data,
    and is passed transparently as the first argument to each of:

      procs->seek(priv, ...);
      procs->read(priv, ...);
      procs->write(priv, ...);

    Normally when using this library with libhfs, `priv' will be the
    `hfsfile *' returned from hfs_open(), and `procs' will point to a
    structure containing { hfs_seek, hfs_read, hfs_write }.

    However, any suitable routines may be substituted which accept
    the appropriate arguments.

    Note that the file access path must already exist, and must be ready
    to read and/or write resource data. When using libhfs, this means
    hfs_setfork(..., 1) must be called prior to rsrc_init().

    If an error occurs, this function returns -1. Otherwise it returns 0.

  int rsrc_finish(rsrcfile *rfile);

    Calling this routine causes the library to flush all changes to the
    given resource file `rfile', and release all storage associated with it.

    Note that this routine does not close the underlying file access path;
    this must be done separately after calling rsrc_finish().

    If an error occurs, this function returns -1. Otherwise it returns 0.

  int rsrc_counttypes(rsrcfile *rfile);

    This function returns the number of unique resource types in the given
    resource file `rfile'.

  int rsrc_count(rsrcfile *rfile, const char *type);

    This function returns the number of actual resources in the given
    resource file `rfile' of the given type `type', which must be a pointer
    to a four-character string naming the type.

  void rsrc_gettype(rsrcfile *rfile, int index, char *type);

    This routine stores at `type' a four-character string (plus terminating
    null) representing a resource type present in the given resource file
    `rfile'. The ordinal `index' must be from 1 to the total number of
    types present in the file, given by rsrc_counttypes().

    If `index' is out of range, the effect of this function is undefined.

  void *rsrc_get(rsrcfile *rfile, const char *type, int id);

    This routine fetches an individual resource identified by the given
    `type' and `id' from the resource file `rfile' and returns a pointer to
    the beginning of a block containing the resource data.

    The pointer returned by this function can be passed to other routines
    in this library to manipulate the resource, and must finally be passed
    to rsrc_release() when the resource is no longer needed.

    If this function fails, a NULL pointer will be returned.

  void *rsrc_getnamed(rsrcfile *rfile, const char *type, const char *name);

    Like rsrc_get(), except the resource is identified by the given `name'
    instead of by id.

  void *rsrc_getind(rsrcfile *rfile, const char *type, int index);

    Like rsrc_get(), except the resource is identified by the ordinal
    `index' instead of by id. The `index' must be from 1 to the total number
    of resources of type `type', given by rsrc_count().

  unsigned long rsrc_size(void *rdata);

    This function returns the size (in bytes) of the given resource `rdata'.

  void *rsrc_resize(void *rdata, unsigned long len);

    This routine changes the size of the resource data `rdata' to be `len'.
    The resource data will be unchanged up to the lesser of the original
    size and the new size; newly allocated space will be uninitialized.

    If there is not enough memory to hold the new requested size, a NULL
    pointer is returned and the original `rdata' pointer remains valid.
    Otherwise, a new resource data pointer is returned and the original
    becomes invalid.

  void rsrc_release(void *rdata);

    This function releases the resource data `rdata'. It should be called
    once the data is no longer needed so the associated memory can be freed.

===============================================================================