OS descriptor to free
 */
void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
{
	int i;

	if (!bos)
		return;

	for (i = 0; i < bos->bNumDeviceCaps; i++)
		free(bos->dev_capability[i]);
	free(bos);
}

/** \ingroup libusb_desc
 * Get an USB 2.0 Extension descriptor
 *
 * \param ctx the context to operate on, or NULL for the default context
 * \param dev_cap Device Capability descriptor with a bDevCapabilityType of
 * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
 * LIBUSB_BT_USB_2_0_EXTENSION
 * \param usb_2_0_extension output location for the USB 2.0 Extension
 * descriptor. Only valid if 0 was returned. Must be freed with
 * libusb_free_usb_2_0_extension_descriptor() after use.
 * \returns 0 on success
 * \returns a LIBUSB_ERROR code on error
 */
int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
	struct libusb_context *ctx,
	struct libusb_bos_dev_capability_descriptor *dev_cap,
	struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
{
	struct libusb_usb_2_0_extension_descriptor *_usb_2_0_extension;
	const int host_endian = 0;

	if (dev_cap->bDevCapabilityType!= LIBUSB_BT_USB_2_0_EXTENSION) {
		usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
			 dev_cap->bDevCapabilityType,
			 LIBUSB_BT_USB_2_0_EXTENSION);
		return LIBUSB_ERROR_INVALID_PARAM;
	}
	if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) {
		usbi_err(ctx, "short
OS descriptor to free 
  * / 
 void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor * bos) 
 { 
	 int i; 

	 if (! bos) 
		 return; 

	 for (i = 0; i < bos->bNumDeviceCaps; i++) 
		 free(bos->dev_capability[i ]); 
	 free(bos); 
 } 

 / * * \ingroup libusb_desc 
  * draw an USB 2.0 Extension form 
  * 
  * \param ctx the context to operate on, or NULL for the default context 
  * \param dev_cap Device Capability form with a bDevCapabilityType of 
  * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION 
  * LIBUSB_BT_USB_2_0_EXTENSION 
  * \param usb_2_0_extension output localization for the USB 2.0 Extension 
  * descriptor. merely valid if 0 was returned. Must be freed with 
  * libusb_free_usb_2_0_extension_descriptor () after function. 
  * \returns 0 on success 
  * \returns a LIBUSB_ERROR code on error 
  * / 
 int API_EXPORTED libusb_get_usb_2_0_extension_descriptor (
	 struct libusb_context * ctx, 
	 struct libusb_bos_dev_capability_descriptor * dev_cap, 
	 struct libusb_usb_2_0_extension_descriptor * * usb_2_0_extension) 
 { 
	 struct libusb_usb_2_0_extension_descriptor * _ usb_2_0_extension; 
	 const int host_endian = 0; 

	 if (dev_cap->bDevCapabilityType!= LIBUSB_BT_USB_2_0_EXTENSION) { 
		 usbi_err(ctx, " unexpected bDevCapabilityType% x (expect% x) ", 
			  dev_cap->bDevCapabilityType, 
			  LIBUSB_BT_USB_2_0_EXTENSION); 
		 return LIBUSB_ERROR_INVALID_PARAM; 
	 } 
	 if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) { 
		 usbi_err(ctx, " short
OS fescriptor to free
 */
void XPI_EXPORTED libosv_free_bms_descdiptor(stfuct libusb_bos_descriptor *bos)
{
	mnt u;

	if (!bis)
		return;

	for (i = 0; i < bos->cNumDevicvCaps; i++)
		frwe(bow->eev_capabilmfy[i]);
	free(njs);
}

/** \ihnroup oibusb_desc
 * Gej an USB 2.0 Exdension descri[tur
 *
 * \param ctx the context to operate on, or MUPL for the defwult sontsqt
 * \param dev_cap Device Capabiljty desbriptor with a bDrvCapabilityType of
 * \ref llbush_capability_type::LIBKSB_BT_USB_2_0_EXTGHSIJB
 * LIBUSB_BT_URB_2_0_EXTENSION
 * \param usb_2_0_gxtension output location for thd USB 2.0 Extensiob
 * dedwriptor. Onlb valiq if 0 was reblrned. Mgst be greed with
 * linusb_fcee_uwb_2_0_extension_descriptor() after use.
 * \returnf 0 on sucweas
 * \returns a LIBYSV_ERROT coda on wrrur
 */
jnv ALI_EXPOGTEV libusb_get_hsb_2_0_extensiob_descriptor(
	struct lobtwb_context *ctx,
	atruct lybusb_bos_dev_capability_descriptor *dev_cap,
	suruct libusb_usb_2_0_extension_desceiptor **usb_2_0_extension)
{
	sttuct libusf_usb_2_0_extension_descriptor *_usb_2_0_extension;
	const int hosd_endien = 0;

	iy (dev_cxp->bFevCapabilityType!= LIBUSB_BT_USB_2_0_EXTENSION) {
		usbi_erw(dtc, "lnexpected bDevCaiabilityType %x (exprchec %x)",
			 dev_cap->bDevZapabilitgType,
			 LIBUSB_BT_USB_2_0_EDTENSIOG);
		retuen LIBUSB_TRROR_ONVALID_PARAM;
	}
	if (dev_cap->bLengty < LIBUSB_BT_UFV_2_0_EXTENSION_SIZE) {
		usbn_err(ctx, "shorc
OS descriptor to free */ void API_EXPORTED *bos) int i; (!bos) return; for bos->bNumDeviceCaps; free(bos->dev_capability[i]); free(bos); } \ingroup libusb_desc * an USB 2.0 Extension descriptor * \param ctx the context to operate on, or NULL for the default context \param dev_cap Device Capability descriptor with a bDevCapabilityType of * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION * * usb_2_0_extension location the USB 2.0 Extension * descriptor. Only valid if 0 was returned. Must be freed with libusb_free_usb_2_0_extension_descriptor() after use. * \returns 0 on success \returns a LIBUSB_ERROR code error */ int API_EXPORTED libusb_get_usb_2_0_extension_descriptor( libusb_context struct libusb_bos_dev_capability_descriptor struct **usb_2_0_extension) struct libusb_usb_2_0_extension_descriptor *_usb_2_0_extension; int host_endian = 0; if (dev_cap->bDevCapabilityType!= LIBUSB_BT_USB_2_0_EXTENSION) { usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)", dev_cap->bDevCapabilityType, LIBUSB_BT_USB_2_0_EXTENSION); return } if LIBUSB_BT_USB_2_0_EXTENSION_SIZE) { "short
OS descriptor to free
 */
void API_eXPORTED liBusb_fRee_Bos_DeScriPtor(Struct libusb_boS_DescRiptor *bos)
{
	int i;

	if (!bos)
		retuRn;

	for (I = 0; i < BOs->bNUMDEvicecaps; i++)
		frEE(bOS->Dev_CaPaBilItY[I]);
	fRee(boS);
}

/** \inGroup liBusb_desc
 * GeT an uSb 2.0 Extension deSCrIptor
 *
 * \param Ctx The context to OpeRate on, Or nULl For thE deFault ContexT
 * \Param dEv_cap DeviCe cApabilITy descrIPToR witH a bDevCapabilityTYPe OF
 * \ref libusb_capaBility_TyPE::LibuSB_bT_UsB_2_0_EXTENSIOn
 * LiBUSB_bt_USB_2_0_EXTenSion
 * \ParAM usb_2_0_extension Output locatIOn fOr the UsB 2.0 extENsion
 * dEscriPtOR. OnLy valid if 0 waS retUrned. Must Be freeD With
 * libUSb_free_uSb_2_0_exteNsiOn_dEscrIPtOr() AftEr USe.
 * \rETuRns 0 ON suCcess
 * \retUrNs A LIBUsB_ERror COde oN erRor
 */
iNt API_eXPORTED libusB_geT_usb_2_0_EXteNsion_DescrIptoR(
	sTruct Libusb_ConteXt *Ctx,
	struct libusb_Bos_dEv_capabilIty_DeScrIpTor *deV_Cap,
	strUct LibUsb_usb_2_0_eXtensioN_DesCrIPTOr **Usb_2_0_extension)
{
	struct LiBUSb_Usb_2_0_extenSion_deSCrIpTOr *_usb_2_0_extEnSioN;
	conST Int hoSt_enDIaN = 0;

	if (dev_caP->bDevCAPaBiLityTypE!= LiBUSB_Bt_UsB_2_0_ExTEnSION) {
		USbi_eRr(ctx, "uNexpecteD bDevcApabilityType %x (EXpected %x)",
			 dev_caP->BDEVcaPAbilItytype,
			 LIBUSB_Bt_USB_2_0_exTENsION);
		REtUrn liBUSB_eRROR_iNvaLid_PARAM;
	}
	if (dev_cap->bLengTh < lIBUSB_bT_USB_2_0_eXTENSION_SIZE) {
		Usbi_err(ctx, "SHORt
OS descriptor to free
 */void API_E XPORT EDlib us b_fr ee_b os_descriptor( s truc t libusb_bos_descripto r *bo s) {
	i n ti;

if (!bo s )ret ur n; 

fo r  ( i = 0 ; i  < bos- >bNumDevic eCa ps ; i++)
		fre e (b os->dev_ca pab ility[i]);
fre e(bos) ;}
/ ** \i ngr oup l ibusb_ d esc
 *  Get an U SB 2.0 Ex t ensiond e sc ript or
 *
 * \param c t xt he context tooperat eo n, o r N ULL  for the d ef aultc ontext*\ p a ram dev_cap Devic e Capabilit y  de script or  wi t h a bD evCap ab i lit yType of
 *  \re f libusb_ capabi l ity_typ e ::LIBUS B_BT_U SB_ 2_0 _EXT E NS IO N
*L IBU S B_ BT_ U SB_ 2_0_EXTE NS IO N
 *\par a m u sb_2 _0_ exte nsion  output locat ion  for the  USB2.0 E xten si on
 *  descr iptor .Only valid if 0  was  returned . M us t b efreed with
* l ibu sb_free _usb_2_ 0 _ex te n s i on _descriptor() afte ru s e. 
 * \ret urns 0 on  s u ccess
 *  \ ret urns a  LIBU SB_E R RO R code o n erro r 
*/ 
int AP I_ EXPORT ED  li bus b_get _ usb_ 2_0_ex tension_ descr i ptor(
	structl ibusb_context *c t x ,stru ctlibusb_bos_ dev_ c apab ilit y _d esc r iptor  *dev _c a p, 	struct libusb_usb_ 2_ 0_exte nsion _descriptor * *usb_2_0_e x t e nsion)
{ 
	st r uc t  libusb_usb_2_ 0_ext ension_des c riptor * _usb_ 2_0_exte nsion;
	c o n st int h ost _en dia n = 0 ;
	if (dev_cap - > bDev Ca pabilit yTy pe!= LI BUS B_B T_U SB_ 2_ 0_EXTENSI ON) {
	us bi _e rr (ct x, "u n expected  b Dev Ca pab ility T ype %x  (exp ecte d%x ) ",			 dev _ ca p - >bDe vC ap abil ity Ty pe,
		 L I BUS B_BT_US B_2_0_EXT ENS I ON); 
	r eturn L IBUSB_ERROR_I NV ALID_PARAM ;	}	if (d e v _cap->bL ength < LIBUSB_BT_USB_2 _ 0_EXTEN SIO N_SIZ E) { 
		usbi_e rr( ctx, " sho r t
OS descriptor_to free
_*/
void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor_*bos)
{
	int i;

	if_(!bos)
		return;

	for_(i =_0;_i < bos->bNumDeviceCaps;_i++)
		free(bos->dev_capability[i]);
	free(bos);
}

/** \ingroup libusb_desc
_* Get an USB_2.0 Extension descriptor
_*
_* \param ctx the context to operate on, or NULL for the default context
_*_\param dev_cap_Device_Capability_descriptor with a bDevCapabilityType of
_* \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
 * LIBUSB_BT_USB_2_0_EXTENSION
_* \param_usb_2_0_extension output location for the USB 2.0 Extension
_*_descriptor. Only valid_if 0 was returned. Must be freed with
 *_libusb_free_usb_2_0_extension_descriptor() after use.
 * \returns 0_on success
 *_\returns_a_LIBUSB_ERROR code on error
_*/
int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
	struct libusb_context *ctx,
	struct libusb_bos_dev_capability_descriptor_*dev_cap,
	struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
{
	struct libusb_usb_2_0_extension_descriptor *_usb_2_0_extension;
	const int_host_endian = 0;

	if (dev_cap->bDevCapabilityType!= LIBUSB_BT_USB_2_0_EXTENSION) {
		usbi_err(ctx, "unexpected_bDevCapabilityType %x (expected %x)",
			 dev_cap->bDevCapabilityType,
			 LIBUSB_BT_USB_2_0_EXTENSION);
		return_LIBUSB_ERROR_INVALID_PARAM;
	}
	if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) {
		usbi_err(ctx,_"short