get_proplist_entry(3) — Subroutines
NAME
get_proplist_entry - Initializes pointers to the corresponding entries in an Extended File Attribute buffer
LIBRARY
Extended File Attribute Library (libproplist.so, libproplist.a)
SYNOPSIS
#include <sys/proplist.h> int get_proplist_entry (
char ∗∗name,
int ∗∗flags,
int ∗∗value_size,
char ∗∗value,
char ∗∗bufptr );
PARAMETERS
∗∗name
Points to the Extended File Attribute name.
∗∗flags
Points to the system-wide file attributes for Extended File Attribute entries in the Property List.
∗∗value_size
Points to the size in bytes of the Extended File Attribute value.
∗∗value
Points to the Extended File Attribute value.
∗∗bufptr
Points to the Extended File Attribute buffer.
DESCRIPTION
The get_proplist_entry routine initializes the ∗∗name, ∗∗value_size, and ∗∗value parameters with the corresponding values in the Extended File Attribute buffer pointed to by ∗∗bufptr. The routine can be called repeatedly, because it advances the Extended File Attribute buffer pointer ∗∗bufptr to the end of the current entry. An Extended File Attribute is a name and value pair that is contained in a variable-sized structure called a Property List. A Property List is part of a file’s metadata and can contain abstract name and value pairs (Extended File Attributes) that can be set either by the operating system (for example, ACLs and privileges) or by a user-level application (for example, PC File Attributes).
This routine should be used to parse the Extended File Attribute buffer returned by the getproplist(3) routine.
EXAMPLES
#include <sys/proplist.h>
main()
{
char ∗ptr, ∗buf, ∗name, ∗value;
int ∗value_len, ∗flags, buffer_size, min_buffer_size, ret, nbytes;
struct getproplist_args getargs;
static char ∗names[] = {
"primary_name",
"secondary_name",
""
};
/∗
∗ How big a buffer do I need to store my name and value
∗ pair in a property list ?
∗/
buffer_size = sizeof_proplist_entry("primary_name", 18);
buffer_size += sizeof_proplist_entry("secondary_name", 13);
/∗
∗ Malloc the buffer
∗/
buf = ptr = (char ∗)malloc(buffer_size);
.
.
.
again:
/∗
∗ Call the system call to load buffer with property list
∗ entries.
∗/
ret = getproplist("/tmp/foo", &getargs, buffer_size, buf,
&min_buffer_size);
if (ret < 0) {
perror("getproplist");
free(buf);
exit(1);
}
/∗
∗ If buffer_size is not sufficient to store the name and value
∗ pairs, malloc a bigger buffer and try again.
∗/
if (ret == 0 && min_buffer_size) {
free(buf);
buf = (char ∗)malloc(min_buffer_size);
buffer_size = min_buffer_size;
goto again;
}
/∗
∗ Buffer contains ret bytes of name and value pairs
∗/
ptr = buf;
while (ret > 0) {
/∗
∗ Call getproplist_entry to initialize name and value
∗ pointers to entries position within buffer.
∗/
ret -= get_proplist_entry(&name, &flags, &value_len, &value,
&ptr);
printf("name %s value len %d value %s0,
name, ∗value_len, value);
}
.
.
.
RETURN VALUES
If successful, the routine returns the size of the current Extended File Attribute in the Property List.
RELATED INFORMATION
Functions: add_proplist_entry(3), delproplist(3), fdelproplist(3), fgetproplist(3), fsetproplist(3), get_proplist_entry(3), getproplist(3), setproplist(3), sizeof_proplist_entry(3).
Files: proplist(4), sys/proplist.h.