/************************************************************************************************* * FUNCTION :- prh_free_inquiry_db * * DESCRIPTION :- This function frees the inq db and all of its entries * ************************************************************************************************/ void prh_free_inquiry_db(void) { struct st_t_BT_InquiryInfo *current, *next; /* cancel timer if it is set - no race since handler aborts if prh_mgr_inqdb_num_entries==0 */ pMutexLock(prh_mgr_inqdb_list_lock); prh_mgr_inqdb_num_entries=0; pMutexUnlock(prh_mgr_inqdb_list_lock); //pTimerCancel(prh_mgr_inqdb_timer_handle); pMutexFree(prh_mgr_inqdb_list_lock); current=prh_mgr_inqdb_head; while (current) { #if pDEBUG if (current->entryUsage) pDebugPrintfEX((pLOGNOTICE,pLOGMANAGER,"prh_mgr_free_inquiry_db: freeing in-use record at 0x%p\n",current)); #endif next=current->next; if (current->deviceName) pFree(current->deviceName); pFree(current); current=next; } prh_mgr_inqdb_head = NULL; pDebugPrintfEX((pLOGNOTICE,pLOGMANAGER,"free inquiry db finished...................................\n",current)); }
static TermEntry* mergeFirst(TermEntry** termEntries, unsigned int nbFiles, FILE** openFiles) { int nbElected = 0; int* indexes = electedEntries(termEntries, nbFiles, &nbElected); if (!nbElected) { pFree(indexes, nbElected * sizeof(int)); indexes = NULL; return NULL; // Finished } TermEntry* merged = NULL; if (!initTerm(&merged, termEntries[indexes[0]]->token)) return NULL; for (int i = 0; i < nbElected; ++i) { if (!merge(merged, termEntries[indexes[i]])) { pFreeTerm(termEntries[indexes[i]]); termEntries[indexes[i]] = NULL; pFree(indexes, nbElected * sizeof(int)); indexes = NULL; return NULL; } pFreeTerm(termEntries[indexes[i]]); termEntries[indexes[i]] = NULL; termEntries[indexes[i]] = readTermEntry(openFiles[indexes[i]]); } pFree(indexes, nbElected * sizeof(int)); indexes = NULL; return merged; }
int main() { setlocale(LC_ALL, "en_US.UTF-8"); // For unicode handling FILE* input = stdin; FILE* output = stdout; unsigned int currentSize = kInitialNbFiles; unsigned int nbFiles = 0; FILE** openFiles = (FILE**) pMalloc(sizeof(FILE*) * currentSize); if (!openFiles) return MEMORY_ERROR; // Open an array of files for (unsigned int i = 0; !feof(input); ++i) { char filepath[kBufferSize]; memset(filepath, 0, kBufferSize); if (!fgets(filepath, kBufferSize, input)) { if (!feof(input)) { return INPUT_ERROR; } else { break; } } unsigned int sizePath = strlen(filepath); if (filepath[sizePath - 1] == '\n') filepath[sizePath - 1] = '\0'; if (i >= currentSize) { unsigned int previousSize = currentSize * sizeof(FILE*); currentSize *= 2; openFiles = (FILE**) pRealloc(openFiles, previousSize, currentSize * sizeof(FILE*)); if (!openFiles) return MEMORY_ERROR; } openFiles[i] = fopen(filepath, "r"); ++nbFiles; } TermEntry** terms = filesToTerms(openFiles, nbFiles); TermEntry * term = mergeFirst(terms, nbFiles, openFiles); while (term) { fprintTerm(output, term, SERIALIZATION); pFreeTerm(term); term = mergeFirst(terms, nbFiles, openFiles); } for (unsigned int i = 0; i < nbFiles; ++i) { if (openFiles[i]) fclose(openFiles[i]); // Closing remaining files pFreeTerm(terms[i]); } pFree(terms, nbFiles * sizeof(TermEntry*)); pFree(openFiles, currentSize * sizeof(FILE*)); return 0; }
int prh_tcs_wug_keydb_trav_helper(void *data, void *input) { struct prh_st_tcs_wug_member *instance=(struct prh_st_tcs_wug_member *)data; struct prh_st_tcs_wug_member *wug_mem=(struct prh_st_tcs_wug_member *)input; int ret; struct prh_st_tcs_wug_member_link_key *link_key1, *link_key2; /* generate link key */ link_key1=(struct prh_st_tcs_wug_member_link_key *)pMalloc(sizeof(struct prh_st_tcs_wug_member_link_key)); if (link_key1==pNULL) return BT_NORESOURCES; link_key2=(struct prh_st_tcs_wug_member_link_key *)pMalloc(sizeof(struct prh_st_tcs_wug_member_link_key)); if (link_key2==pNULL) { pFree(link_key1); return BT_NORESOURCES; } prh_tcs_wug_keydb_generate_linkkey(link_key1->link_key); pMemcpy(link_key2->link_key, link_key1->link_key, 16); link_key1->peer = instance->addr; link_key2->peer = wug_mem->addr; /* add link key to both wug_members */ ret=prh_tcs_wug_keydb_add_key(wug_mem, link_key1); if (ret!=BT_NOERROR) { pFree(link_key1); pFree(link_key2); return BT_NORESOURCES; } ret=prh_tcs_wug_keydb_add_key(instance, link_key2); if (ret!=BT_NOERROR) { prh_tcs_wug_keydb_remove_key_by_bd_addr(wug_mem, instance->addr, &link_key1); pFree(link_key1); pFree(link_key2); return BT_NORESOURCES; } return BT_NOERROR; }
/* this is called by a timer callback at intervals of HOST_INQDB_CULL_GRANULARITY */ void prh_mgr_cull_inquiry_db(void *unused) { extern u_int8 prh_mgr_inquiryInProgress; extern u_int32 prh_mgr_inqdb_num_entries; /* increment each age by one, and remove any old entry */ struct st_t_BT_InquiryInfo *current, *temp; char err_str[50]={0}; pMutexLock(prh_mgr_inqdb_list_lock); if (!(prh_mgr_discoveryInProgress || prh_mgr_inquiryInProgress)) { if (!prh_mgr_inqdb_num_entries) { pMutexUnlock(prh_mgr_inqdb_list_lock); return; } current=prh_mgr_inqdb_head; while (current) { temp=current->next; if (current->entryAge>HOST_INQDB_CULL_THRESHOLD && prh_mgr_inqdb_num_entries>HOST_INQDB_CULL_MIN_ENTRIES && !current->entryUsage) { /* remove the record */ pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_cull_inquiry_db: removing device entry for %s, age=%d, prh_mgr_inqdb_num_entries=%d\n",prh_mgr_printBDAddress(current->bdAddress),current->entryAge,prh_mgr_inqdb_num_entries)); prh_mgr_unlink_inquiry_entry(current); if (current->deviceName) pFree(current->deviceName); pFree(current); prh_mgr_inqdb_num_entries--; } else { if (current->entryAge+1>current->entryAge && current->entryAge!=0) /* don't allow age to wrap, age=0 means inquiry is in progress */ current->entryAge++; } current=temp; } } if (prh_mgr_inqdb_num_entries) /* reset the timer */ prh_mgr_inqdb_timer_handle=pTimerCreate(HOST_INQDB_CULL_GRANULARITY,prh_mgr_cull_inquiry_db,NULL,pTIMER_ONESHOT); pMutexUnlock(prh_mgr_inqdb_list_lock); }
t_api PRH_RFCOMM_UE_Register_Server(prh_t_rfcomm_schan schan, struct prh_rfcomm_dlc_cb *dlc_cbs) { #if COMBINED_HOST==1 struct prh_rfcomm_server_inst *serv_inst = &_serv_inst[prh_num]; #else struct prh_rfcomm_server_inst *serv_inst; #endif int ret; pMutexLock(prh_rfcomm_core_lock); /* user should have asked for channel with Allocate_Server_Channel */ if (schan==0 || schan>PRH_RFCOMM_MAX_SCHAN) { ret=BT_INVALIDPARAM; goto out; } if ((prh_rfcomm_core->channel_registered_state & (1U<<schan)) == (1U<<schan)) { ret=BT_INVALIDPARAM; goto out; } #if COMBINED_HOST==0 serv_inst=(struct prh_rfcomm_server_inst *)pMalloc(sizeof(struct prh_rfcomm_server_inst)); if (serv_inst==pNULL) { ret=BT_NORESOURCES; goto out; } #endif serv_inst->server_chan=schan; serv_inst->dlc_cbs=*dlc_cbs; serv_inst->lock=pMutexCreate(FALSE); prh_rfcomm_core->channel_registered_state |= 1<<schan; ret=prh_host_ll_add(&(prh_rfcomm_core->server_list), (void *)serv_inst); if (ret!=BT_NOERROR) { prh_rfcomm_core->channel_registered_state &= ~(1<<schan); pMutexFree(serv_inst->lock); pFree(serv_inst); ret=BT_NORESOURCES; goto out; } /* reaffirm allocation of channel */ prh_rfcomm_core->channel_allocation_state |= 1<<schan; ret=BT_NOERROR; #if COMBINED_HOST==1 prh_num++; #endif out: pMutexUnlock(prh_rfcomm_core_lock); return ret; }
void prh_tcs_cc_core_freeCallParamMembers(struct st_t_TCS_callParams *callParams) { if(callParams) { if(PRH_TCS_CC_PARAM_CALLEDPARTYNUMBER_EXISTS(callParams->bitMask) && callParams->calledPartyNumber) pFree(callParams->calledPartyNumber); if(PRH_TCS_CC_PARAM_CALLINGPARTYNUMBER_EXISTS(callParams->bitMask) && callParams->callingPartyNumber) pFree(callParams->callingPartyNumber); if(PRH_TCS_CC_PARAM_BEARERCAPABILITY_EXISTS(callParams->bitMask) && (PRH_TCS_BEARER_CAP_LINK_TYPE_ACL == callParams->linkType) && callParams->aclBearer) pFree(callParams->aclBearer); if(PRH_TCS_CC_PARAM_AUDIOCONTROL_EXISTS(callParams->bitMask) && callParams->audioControlInfo) pFree(callParams->audioControlInfo); if(PRH_TCS_CC_PARAM_COMPANYSPECIFIC_EXISTS(callParams->bitMask) && callParams->companySpecific) pFree(callParams->companySpecific); } }
void prh_tcs_cc_core_freeCallInstanceMembers(struct st_t_TCS_callInstance *callInstance) { prh_tcs_cc_core_freeCallParams(callInstance->inCallParams); callInstance->inCallParams = NULL; prh_tcs_cc_core_freeCallParams(callInstance->outCallParams); callInstance->outCallParams = NULL; pFree(callInstance); }
void prh_tcs_cc_core_freeCallParams(struct st_t_TCS_callParams *callParams) { if(callParams) { prh_tcs_cc_core_freeCallParamMembers(callParams); pFree(callParams); } }
/* clean up for reset remove everything */ int prh_rfcomm_entity_remove_all_pending_conns_helper(void *data, void *func_info) { struct prh_rfcomm_entity_pending_conns *pe_conn=(struct prh_rfcomm_entity_pending_conns *)data; /* if any pending dlcs free em all */ if (pe_conn->pending_dlc_head) { prh_rfcomm_entity_remove_all_pending_channels(pe_conn); } pFree(pe_conn); return BT_NOERROR; }
//------------------------------------------------------------------------------ // Public Functions: //------------------------------------------------------------------------------ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // System Initialize System_Initialize(hInstance, nCmdShow); // GSM Initialize GSM_Initialize(GS_L1); // Game Flow while(Current != GS_Quit) { if(Current == GS_Restart) { Current = Previous; Next = Previous; } else { // GSM Update GSM_Update(Current); pLoad(); } pIni(); // Game Loop while(Current == Next) { AESysFrameStart(); //Input_Handle(); »Øµ÷º¯Êý pUpdate(); pDraw(); AESysFrameEnd(); } pFree(); if(Next != GS_Restart) pUnload(); Previous = Current; Current = Next; } // System Exit system("pause"); System_Exit(); return 0; }
static int prh_rfcomm_entity_remove_pending_device(t_bdaddr bd_addr) { int ret; struct prh_rfcomm_entity_pending_conns *pe_conn; ret=prh_host_ll_remove(&prh_rfcomm_pending_list, (void **)&pe_conn, (void *)&bd_addr, prh_rfcomm_entity_bdaddr_cmp); if (ret==BT_NOERROR) { #if COMBINED_HOST==1 pe_conn->info_used = 0; #else pFree(pe_conn); #endif } return BT_NOERROR; }
/* * PRH_RFCOMM_UE_Deregister_Server * -- Remove a registered server application from RFCOMM */ t_api PRH_RFCOMM_UE_Deregister_Server(prh_t_rfcomm_schan schan) { struct prh_rfcomm_server_inst *serv_inst; int ret; PRH_RFCOMM_UE_Set_Channel_Closed(schan); PRH_RFCOMM_UE_Deallocate_Server_Channel(schan); ret=prh_rfcomm_remove_server_inst_by_schan(schan, &serv_inst); pMutexLock(serv_inst->lock); pMutexUnlock(serv_inst->lock); pMutexFree(serv_inst->lock); pFree(serv_inst); return BT_NOERROR; }
void main(void) { System_Initialize(); GSM_Initialize(1); while (Current != Quit) { FrameInitialization(); if (Current == Restart) { Current = Previous; Next = Previous; } else { GSM_Update(); pLoad(); } pInitialize(); while (Current == Next) { FrameControllerStart(); Input_Handle(); pUpdate(); pDraw(); FrameControllerEnd(); } pFree(); if (Next != Restart) { pUnload(); } Previous = Current; Current = Next; } System_Exit(); }
u_int8 prh_tcs_cc_core_freeTLPeerByBdAddress(t_bdaddr address) { int i; for(i=0; i<PRH_TCS_MAXTERMINALSPERGATEWAY; i++) { if(TCSInstance.TLPeer[i]) { if(BD_ADDR_CMP(TCSInstance.TLPeer[i]->bdAddress, address)) { pFree(TCSInstance.TLPeer[i]); TCSInstance.TLPeer[i] = NULL; return 0; } } } return 1; }
static int prh_rfcomm_entity_remove_pending_channel_helper(void *data, void *func_info) { u_int32 multi_open=(u_int32)func_info; struct prh_rfcomm_entity_pending_dlc *pending_info=(struct prh_rfcomm_entity_pending_dlc *)data; /* Multiplexer established? */ if (multi_open==PRH_RFCOMM_ACCEPT) { PRH_RFCOMM_UE_DLC_Estab_Req(pending_info->parent->bd_addr, pending_info->dlci, &pending_info->dlc_params, &pending_info->cbs, pending_info->parent->multi_inst); } else { /* Call back DLCI ind with failure */ if (pending_info->cbs.dlc_estab_ind) pending_info->cbs.dlc_estab_conf(pending_info->parent->bd_addr, pending_info->dlci, &pending_info->dlc_params, PRH_RFCOMM_REFUSE, pending_info->parent->multi_inst); } #if COMBINED_HOST==1 pending_info->info_used = 0; #else pFree(pending_info); #endif return BT_NOERROR; }
//03-28-2009, add by tan void rdabt_being_bonding_cb(t_bdaddr address, int status) { bth_dev_struct dev_Info; struct st_t_BT_ConnectionEntry * cur=NULL, *next=NULL; bt_bm_bonding_result_ind_struct *param_ptr=NULL; bt_bm_bonding_cnf_struct * bonding_cnf=NULL; u_int8 flag_present=0; kal_prompt_trace(1,"rdabt_being_bonding_cb status = %d\n",status); //status = 1; if( g_PairingFinished == 0) g_PairingFinished = 1; //7-12-2009, add by tan else return; memset(&dev_Info, 0, sizeof(bth_dev_struct)); param_ptr = (bt_bm_bonding_result_ind_struct*)construct_local_para((kal_uint16)sizeof(bt_bm_bonding_result_ind_struct), TD_CTRL); param_ptr->bd_addr.lap= BDADDR_Get_LAP(&address); param_ptr->bd_addr.uap = BDADDR_Get_UAP(&address); param_ptr->bd_addr.nap = BDADDR_Get_NAP(&address); kal_prompt_trace(1,"rdabt_being_bonding_cb\n"); if (wait_bonding_timer) { kal_prompt_trace(1,"wait_bonding_timer be canceled wait_bonding_timer=%d\n",wait_bonding_timer); pTimerCancel(wait_bonding_timer); wait_bonding_timer=0; } MGR_GetNextConnectionRecord(NULL, &next); while(next) { cur = next; if( BD_ADDR_CMP(next->bdAddress, address)) { if( next->linkKey) { kal_prompt_trace(1,"get the device' s info, link_key:%s and cod:%d\n", print_link_key(next->linkKey),next->cod); dev_Info.bd_addr = param_ptr->bd_addr; dev_Info.KeyType = next->linkKeyType; memcpy( dev_Info.linkKey, next->linkKey, 0x10); dev_Info.cod =param_ptr->cod = next->cod; flag_present=1;//zhou siyou add 20070725 } //break; } //else { MGR_GetNextConnectionRecord(cur, &next); } } //if(next && next->linkKey) if(flag_present) { bth_write_paired_device_info(&dev_Info); status = 0; // kal_prompt_trace(1,"write the device info into a file, status:%d (0 indicates succeed)\n", status_tem); } param_ptr->result = status; pMemcpy(param_ptr->linkKey, dev_Info.linkKey, 16); param_ptr->KeyType = dev_Info.KeyType; bonding_cnf = (bt_bm_bonding_cnf_struct *)construct_local_para((kal_uint16)sizeof(bt_bm_bonding_cnf_struct), TD_CTRL); bonding_cnf->result = status; bonding_cnf->bd_addr = param_ptr->bd_addr; rdabt_send_msg_up(MOD_MMI, MSG_ID_BT_BM_BONDING_RESULT_IND, (void *)param_ptr, NULL); rdabt_send_msg_up(MOD_MMI, MSG_ID_BT_BM_BE_BONDING_CNF, (void*)bonding_cnf, NULL);//zhou siyou add 200728 if(deviceName != NULL) { pFree(deviceName); deviceName = NULL; nameLen = 0; } return ; }
int prh_test_rfcomm_pe_connect_port(t_bdaddr remote_bd_addr, prh_t_rfcomm_schan rem_schan, char *pName, prh_t_rfcomm_dlci *dlci, struct prh_rfcomm_pe_port **pe_info_ptr, u_int16 max_frame_size) { struct prh_rfcomm_multi_cb multi_cbs; struct prh_rfcomm_dlc_cb dlc_cbs; prh_t_rfcomm_dlc_params dlc_params; int dbit; t_api ret; struct prh_rfcomm_l2cap_inst *l2cap_inst; void *multi_inst; struct prh_rfcomm_pe_port *pe_info; /* Allocate memory for pe_info */ pe_info=(struct prh_rfcomm_pe_port *)pMalloc(sizeof(struct prh_rfcomm_pe_port)); if (pe_info==pNULL) return BT_NORESOURCES; pe_info->portname=(char *)pMalloc(pStrlen(pName)+1); if (pe_info->portname==pNULL) { pFree(pe_info); return BT_NORESOURCES; } /* copy in portname */ pStrcpy(pe_info->portname, pName); /* Check does a multiplexer to the remote BD Address exist already */ ret=prh_rfcomm_lookup_l2cap_inst_by_bd_addr(remote_bd_addr, &l2cap_inst); if (ret==BT_INVALIDPARAM) { ret=prh_test_rfcomm_open_multiplexer(remote_bd_addr, &multi_inst); if (ret!=BT_NOERROR) return ret; dbit=1; } else { dbit=l2cap_inst->initiating; multi_inst=(void *)l2cap_inst; } /* Either Multiplexer is started or we've returned */ dlc_params.max_frame_size=max_frame_size; dlc_params.priority=0; /* Generate the DLCI from direction and remote server channel */ pe_info->dlci=*dlci=((!dbit) | (rem_schan<<1)); pe_info->multi_inst=multi_inst; pe_info->flow_sem=pSemCreate(0); pe_info->remote_device_addr=remote_bd_addr; pe_info->portnum=0; pe_info->mode=PRH_PORT_ENT_CLIENT_CONN; prh_rfcomm_init_pe_struct(pe_info); prh_test_rfcomm_dlc_estab(remote_bd_addr, *dlci,multi_inst, &dlc_params); pSemLock(test_prh_rfcomm_ms.sem, 0); pSemFree(test_prh_rfcomm_ms.sem); if (test_prh_rfcomm_ms.status==PRH_RFCOMM_REFUSE) return BT_UNKNOWNERROR; else { prh_rfcomm_pe_add_port_entity(pe_info); *pe_info_ptr=pe_info; return BT_NOERROR; } }
prh_t_l2_acl_link* prh_l2_acl_alloc_link(t_bdaddr* p_bd_addr, u_int16 pending_cid) { prh_t_l2_acl_link* p_link; int i; /* First Check does a link already exist to this Address */ for(i=0;i<PRH_L2_MAX_NUM_LINKS;i++) { #if COMBINED_HOST==1 p_link = &(prh_l2_acl_links[i]); if(p_link->flag == 0) { pMemset(p_link,0,sizeof(prh_t_l2_acl_link)); p_link->flag = 1; #else p_link = prh_l2_acl_links[i]; if(p_link == 0) { p_link = pMalloc(sizeof(prh_t_l2_acl_link)); if (!p_link) return 0; pMemset(p_link,0,sizeof(prh_t_l2_acl_link)); prh_l2_acl_links[i] = p_link; p_link->cur_pos=0; #endif prh_l2_utils_set_bd_addr(&p_link->bd_addr, p_bd_addr); p_link->pending_cid = pending_cid; p_link->mtu_complete = 1; return p_link; } } return 0; } /************************************************************** * Function : prh_l2_acl_free_Link * * Parameters : * p_link :- A pointer to the link structure to be freed. * * Returns * -- * * Description * Frees a link structure for a link to a specific Bd_ADDR. * Also cancels any timers associated with the link. **************************************************************/ void prh_l2_acl_free_link(prh_t_l2_acl_link* p_link) { #if COMBINED_HOST==0 u_int16 i; #endif #if (L2CAP_GROUPS_SUPPORTED==1) prh_t_l2_channel* p_channel; #endif if (p_link != 0) { #if (L2CAP_GROUPS_SUPPORTED==1) for (i = PRH_L2_MIN_USER_CID; i < (PRH_L2_MAX_NUM_CHANNEL_IDENTIFIERS + PRH_L2_MIN_USER_CID);i++) { p_channel = prh_l2_chn_get_p_channel(i); if ((p_channel) && (p_channel->bda_list)) { prh_l2_bda_list_remove(p_channel->bda_list,&p_link->bd_addr); } } #endif #if COMBINED_HOST==1 p_link->flag = 0; if (p_link->timer_active) pTimerCancel(p_link->timer_handle); #else for(i=0;i<PRH_L2_MAX_NUM_LINKS;i++) { if(prh_l2_acl_links[i] == p_link) { if (p_link->timer_active) { pTimerCancel(p_link->timer_handle); p_link->timer_active = 0; p_link->timer_handle=0; } pFree(p_link); prh_l2_acl_links[i] = 0; return; } } #endif } }
void prh_l2_chn_free_channel(prh_t_l2_channel* p_channel, u_int8 flags) { prh_t_l2_acl_link* p_link; u_int16 handle = p_channel->handle; #if (PRH_L2CAP_AUTO_CONFIG==1) if (!(flags & PRH_L2_DONT_RELEASE_CONFIG)) prh_l2_config_helper_remove_cid(p_channel->local_cid); #endif //prh_l2_channel_list[p_channel->local_cid-PRH_L2_MIN_USER_CID] = 0; #if COMBINED_HOST==1 p_channel->flag = 0; #else if (p_channel->outQOS != 0) pFree(p_channel->outQOS); if (p_channel->inQOS != 0) pFree(p_channel->inQOS); #endif if (p_channel->timer_active) { pTimerCancel(p_channel->timer_handle); p_channel->timer_active = 0; p_channel->timer_handle=0; } if (p_channel->config_timer_handle) { pTimerCancel(p_channel->config_timer_handle); p_channel->config_timer_handle = 0; } #if (L2CAP_GROUPS_SUPPORTED==1) if (p_channel->bda_list) prh_l2_bda_list_free(p_channel->bda_list); #endif #if COMBINED_HOST==0 prh_l2_channel_list[p_channel->local_cid-PRH_L2_MIN_USER_CID] = 0; if(p_channel!=NULL) pFree(p_channel); p_channel=NULL; #else //add by xzc prh_l2_channel_list[p_channel->local_cid-PRH_L2_MIN_USER_CID].flag= 0; p_channel = 0; #endif if (handle != 0x00) { if((!prh_l2_chn_handle_in_use(handle)) && (flags & PRH_L2_RELEASE_ACL)) { #if COMBINED_HOST==1 LMconnection_LM_Disconnect_Req(handle,PRH_USER_ENDED_CONNECTION); #else /* if(FindObjectPushServer_callback) { prh_mgr_releaseACL(handle,PRH_USER_ENDED_CONNECTION, FindObjectPushServer_callback); FindObjectPushServer_callback =NULL; #if pDEBUG pDebugPrintfEX((pLOGDEBUG,pLOGL2CAP,"prh_l2_chn_free_channel opp _releaseACL\n")); #endif } */ if(FindFTPServer_callback) { prh_mgr_releaseACL(handle,PRH_USER_ENDED_CONNECTION, FindFTPServer_callback); FindFTPServer_callback =NULL; pDebugPrintfEX((pLOGDEBUG,pLOGL2CAP,"prh_l2_chn_free_channel ftp _releaseACL\n")); } else prh_mgr_releaseACL(handle,PRH_USER_ENDED_CONNECTION, NULL); #endif p_link = prh_l2_acl_find_handle(handle); prh_l2_acl_free_link(p_link); } } }
void rdabt_SDP_serviceSearch(bt_bm_service_search_req_struct * msg_p) { t_SDP_Addresses devices; t_SDP_SearchPattern pattern; t_SDP_AttributeIDs attributes; t_SDP_StopRule rule; u_int16 criteria=0; t_bdaddr bdAddr; u_int32 cod = 0; btbm_bd_addr_t bd_addr; kal_prompt_trace(1,"--> rdabt_SDP_serviceSearch"); BDADDR_Set_LAP(&bdAddr,msg_p ->bd_addr.lap); BDADDR_Set_UAP(&bdAddr,msg_p ->bd_addr.uap); BDADDR_Set_NAP(&bdAddr,msg_p ->bd_addr.nap); bd_addr = msg_p->bd_addr; bth_get_specified_device_class(bd_addr, &cod); kal_prompt_trace(1,"--> rdabt_SDP_serviceSearch, cod == %d", cod); devices.numItems = 1; devices.addresses = ( t_bdaddr *)pMalloc(sizeof(t_bdaddr)); if(devices.addresses) devices.addresses[0] = bdAddr; pattern.numItems = 1; pattern.patternUUIDs = (u_int32*)pMalloc(pattern.numItems*sizeof(u_int32)); if(pattern.patternUUIDs) pattern.patternUUIDs[0] = SDP_PROTOCOL_UUID_L2CAP; if(cod & 0x200) attributes.numItems = 1; else attributes.numItems = 4; attributes.attributeIDs =(u_int32*)pMalloc(attributes.numItems*sizeof(u_int32)); if(attributes.attributeIDs) { attributes.attributeIDs[0] = SDP_AID_SERVICE_CLASS; if(!(cod&0x200)) { attributes.attributeIDs[1] = SDP_AID_PROFILE_LIST; attributes.attributeIDs[2] = SDP_AID_PROTOCOL; attributes.attributeIDs[3] = SDP_AID_SUPPORTED_FEATURES; } } rule.maxBytes = 512; rule.maxDuration = 50; rule.maxItems = 10; SDP_ServiceBrowse(&pResults,&devices,&pattern,&attributes,&rule,criteria,(sdp_api_callback)rdabt_ServiceSearch_cb); pFree(devices.addresses); pFree(pattern.patternUUIDs); pFree(attributes.attributeIDs); }
//Entry point of the application int WINAPI WinMain(HINSTANCE instance, HINSTANCE hPreviousInstance, LPSTR command_line, int show) { WNDCLASS wc; HWND hWnd; MSG msg; wc.style = CS_HREDRAW | CS_VREDRAW; /*Class style*/ wc.lpfnWndProc = WinProc; /*A function pointer which should point to the procedure function. Remember that the procedure function handles the window messages*/ wc.cbClsExtra = 0; /*The number of extra bytes you want to allocate for this window class structure. The default value is 0*/ wc.cbWndExtra = 0; /*The number of extra bytes you want to allocate for the window instance*/ wc.hInstance = instance; /*Instance of the module associated with the window. This is the 1st paramter passed to the WinMain function*/ wc.hIcon = LoadIcon(NULL, IDI_EXCLAMATION); /*Handle to the icon class which will be displayed on the top left part of the window*/ wc.hCursor = LoadCursor(NULL, IDC_ARROW); /*Handle to the cursor class which will be used in this window class*/ wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); /*Handle to the class background brush. It can be a color value*/ wc.lpszMenuName = NULL; /*Pointer to a null terminated string which specifies the name of the menu resources used by this window class (if any)*/ wc.lpszClassName = "Window Class Name"; /*String that specifies thw window class name. This is needed to create any window based on this window class*/ RegisterClass(&wc); hWnd = CreateWindow(wc.lpszClassName, /*The class name we chose for the window class*/ "Win32 Sample", /*The window caption*/ WS_OVERLAPPEDWINDOW, /*The style of the window, which determines if the window will have a minimize/maximize buttons, if its frame is thick or not.. */ 200, /*The X position of the top left corner of the window. Remember that (0,0) is the top left of the monitor*/ 100, /*The Y position of the top left corner of the window. Remember that (0,0) is the top left of the monitor*/ 640, /*The width of the window*/ 480, /*The heiht of the window*/ NULL, /*Handle to the parent window (in case this was a child window)*/ NULL, /*Handle to a menu (In case there is a menu for this window)*/ instance, /*Instance of the module associated with the window. This is the 1st paramter passed to the WinMain function*/ NULL); /*Pointer to a value sent to the window in the WM_CREATE message*/ ShowWindow(hWnd, show); UpdateWindow(hWnd); UnregisterClass(wc.lpszClassName, instance); System_Initialize(); GSM_Initialize(1); while (Current != Quit) { while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } FrameInitialization(); if (Current == Restart) { Current = Previous; Next = Previous; } else { GSM_Update(); pLoad(); } pInitialize(); while (Current == Next) { FrameControllerStart(); Input_Handle(); pUpdate(); pDraw(); FrameControllerEnd(); } pFree(); if (Next != Restart) { pUnload(); } Previous = Current; Current = Next; } System_Exit(); return (int)msg.wParam; }
/* clean up for reset remove everything */ int prh_rfcomm_entity_remove_all_pending_channels_helper(void *data, void *func_info) { struct prh_rfcomm_entity_pending_dlc *pending_info=(struct prh_rfcomm_entity_pending_dlc *)data; pFree(pending_info); return BT_NOERROR; }
/* * prh_rfcomm_entity_connect_port * -- Port Entity DLC Establish helper function * * Allocate a Port entity structure, sets it up, * finds a multiplexer, (either gets current one or starts one) * Sets up callbacks, sends Parameter negotiation, and then does * the DLC establish. * * Returns: BT_NOERROR - a multiplexer is already started * BT_PENDING - a multiplexer start is in progress or required * BT_NORESOURCES - no resources were available */ int prh_rfcomm_entity_connect_port(t_bdaddr remote_bd_addr, prh_t_rfcomm_schan rem_schan, prh_t_rfcomm_dlci *dlci, prh_t_rfcomm_dlc_params *dlc_params, struct prh_rfcomm_dlc_cb *cbs, void **multi_inst_ptr) { int dbit; struct prh_rfcomm_l2cap_inst *l2cap_inst; struct prh_rfcomm_entity_pending_dlc *pending_info; struct prh_rfcomm_entity_pending_conns *pending_conns; t_api ret; #if COMBINED_HOST==1 int i =0; #endif pMutexLock(prh_rfcomm_pending_lock); /* Check does a multiplexer to the remote BD Address exist already or is one pending */ ret=PRH_RFCOMM_UE_Get_Multiplexer_State(remote_bd_addr, (void **)&l2cap_inst); if (ret==BT_NOERROR) { /* A Multiplexer exists */ dbit=l2cap_inst->initiating; /* If it exists establish the DLC */ *dlci=((!dbit) | (rem_schan<<1)); *multi_inst_ptr=(void *)l2cap_inst; PRH_RFCOMM_UE_DLC_Estab_Req(remote_bd_addr, *dlci, dlc_params, cbs, *multi_inst_ptr); ret=BT_NOERROR; goto out; } #if COMBINED_HOST==1 //cui jian changed to static malloc pending information. 2009.02.11 for( i =0; i< PRH_RFCOMM_MAX_Connect_Port ; i++) { if( pending_info2[i].info_used == 0 ) { pending_info = &pending_info2[i ]; pending_info2[i].info_used = 1; break; } } if( i == PRH_RFCOMM_MAX_Connect_Port ) { ret=BT_NORESOURCES; goto out; } #else /* we'll be pending - malloc pending information */ pending_info=(struct prh_rfcomm_entity_pending_dlc *)pMalloc(sizeof(struct prh_rfcomm_entity_pending_dlc)); if (pending_info==NULL) { ret=BT_NORESOURCES; goto out; } #endif pMemset(pending_info, 0, sizeof(struct prh_rfcomm_entity_pending_dlc)); pending_info->remote_schan=rem_schan; pending_info->cbs=*cbs; pending_info->dlc_params=*dlc_params; dbit=1; pending_info->dlci=*dlci=((!dbit) | (rem_schan<<1)); if (ret==BT_INVALIDPARAM) { /* No Multiplexer exists or is being started */ /* Need to start a pending list */ #if COMBINED_HOST==1 //cui jian changed to static malloc pending information. 2009.02.11 for( i =0; i< PRH_RFCOMM_MAX_Connect_Port ; i++) { if( pending_conns2[i].info_used == 0 ) { pending_conns = &pending_conns2[i ]; pending_conns2[i].info_used = 1; break; } } if( i == PRH_RFCOMM_MAX_Connect_Port ) { ret=BT_NORESOURCES; goto out; } #else pending_conns=(struct prh_rfcomm_entity_pending_conns *)pMalloc(sizeof(struct prh_rfcomm_entity_pending_conns)); if (pending_conns==NULL) { ret=BT_NORESOURCES; goto out_free_info; } #endif pMemset(pending_conns, 0, sizeof(struct prh_rfcomm_entity_pending_conns)); pending_conns->bd_addr=remote_bd_addr; pending_conns->pending_dlc_head=NULL; pending_conns->multi_inst=NULL; /* Add to the list */ ret=prh_rfcomm_entity_add_pending_device(pending_conns); if (ret==BT_NORESOURCES) { goto out_free_conns; } ret=prh_rfcomm_entity_add_pending_channel(remote_bd_addr, pending_info); if (ret==BT_NORESOURCES) { prh_rfcomm_entity_remove_pending_device(remote_bd_addr); goto out_free_info; } ret=prh_rfcomm_open_multiplexer(remote_bd_addr, &pending_conns->multi_inst); if (ret!=BT_PENDING && ret!=BT_NOERROR) { prh_rfcomm_entity_remove_all_pending_channels(pending_conns); prh_rfcomm_entity_remove_pending_device(remote_bd_addr); } else *multi_inst_ptr=pending_conns->multi_inst; } else if (ret==BT_PENDING) { /* A multiplexer start is pending */ *multi_inst_ptr=(void *)l2cap_inst; /* add to the list */ ret=prh_rfcomm_entity_add_pending_channel(remote_bd_addr, pending_info); /* if we are pending return pending not no-error */ if (ret!=BT_NOERROR) { ret=BT_NORESOURCES; goto out_free_info; } else ret=BT_PENDING; } goto out; out_free_conns: pFree(pending_conns); out_free_info: pFree(pending_info); out: pMutexUnlock(prh_rfcomm_pending_lock); return ret; }
static int prh_tcs_wug_lk_removeall_helper(void *cur_mem, void *input_data) { struct prh_st_tcs_wug_member_link_key *link_key = (struct prh_st_tcs_wug_member_link_key *)cur_mem; pFree(link_key); return BT_NOERROR; }