openusb_init, openusb_fini

OpenUSB Developers Guide
Prev |  | Next

# `openusb_init, openusb_fini`

## Name

`openusb_init, openusb_fini` -- Initialize or destroy a libopenusb instance

## Synopsis

``int32_t openusb_init`(uint32_t flags , openusb_handle_t *handle );`

``void openusb_fini`(openusb_handle_t handle );`

## Parameters

`flags` - Not used in this release. Reserved.

`handle` - Application should pass a valid address and upon successful initialization of openusb_init, a openusb_handle will be returned in it. This hanlde will be used by all operations related with openusb instances.

## Description

Just like the name implies, the `openusb_init()` initialize a openusb instance and sets up some internal structures for that openusb instance. This function MUST be called before any other openusb functions. It will load OS dependent backend and call initialization function of that backend. It also scans for busses and devices on the system. Application should call `openusb_fini()` to destroy a openusb instance when it finishes. `openusb_fini()` will destroy internal structures associated with this instance. All handles associated with this instance become invalid after the call to `openusb_fini()`.

## Return Value

Upon successful initialization of a openusb instance, the `openusb_init()` function will return OPENUSB_SUCCESS. Otherwise, a failure will be returned.

OPENUSB_PLATFORM_FAILURE -- Unspecified kernel/driver failure.

OPENUSB_BADARG -- An invalid argument is passed in. handle is invalid

OPENUSB_NO_RESOURCES -- Memory allocation failure.

## See Also

Prev | Home | Next
Core | Up | `openusb_set_debug`