GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HQUERY(3) libdill Library Functions HQUERY(3)

hquery - gets an opaque pointer associated with a handle and a type


#include <libdillimpl.h>
void* hquery(
    int h,
    const char* type);

    

Returns an opaque pointer associated with the passed handle and type. This function is a fundamental construct for building APIs on top of handles.

The type argument is not interpreted in any way. It is used only as an unique ID. A unique ID can be created, for instance, like this:


int foobar_placeholder = 0;
const void *foobar_type = &foobar_placeholder;

    

The return value has no specified semantics. It is an opaque pointer. One typical use case for it is to return a pointer to a table of function pointers. These function pointers can then be used to access the handle's functionality (see the example).

Pointers returned by hquery are meant to be cachable. In other words, if you call hquery on the same handle with the same type multiple times, the result should be the same.

h: The handle.

type: The opaque ID of the queried type.

In case of success the function returns opaque pointer. In case of error it returns NULL and sets errno to one of the values below.

EBADF: Invalid handle.


struct quux_vfs {
    int (*foo)(struct quux_vfs *vfs, int a, int b);
    void (*bar)(struct quux_vfs *vfs, char *c);
};
int quux_foo(int h, int a, int b) {
    struct foobar_vfs *vfs = hquery(h, foobar_type);
    if(!vfs) return -1;
    return vfs->foo(vfs, a, b);
}
void quux_bar(int h, char *c) {
    struct foobar_vfs *vfs = hquery(h, foobar_type);
    if(!vfs) return -1;
    vfs->bar(vfs, c);
}

    

hclose(3) hmake(3) hown(3)
libdill

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.