/****************************************************************************** * * Name: nci_data_close_conn * * Description: Close Data Connection upon CONN_CLOSE response or notification and module destruction. * Connection is marked as closed. * All fragments memory is freed. * Fragment's queue is released. * * Input: h_data - handle to NCI DATA context object * conn_id - Connection ID * * Output: None * * Return: None * *******************************************************************************/ void nci_data_close_conn(nfc_handle_t h_data, nfc_u8 conn_id) { struct nci_data_context *p_ctx = (struct nci_data_context *)h_data; struct nci_conn *p_conn = &p_ctx->p_conn_tbl[conn_id]; struct nci_buff *p_buff; osa_report(INFORMATION, ("DATA nci_data_close_conn")); p_conn->b_active_conn = NCI_CONNECTION_DISABLED; /* Marks connection as closed (prepare_2_send will use this to reject new send requests) */ p_conn->maximum_packet_payload_size = 0; p_conn->initial_fc_credit = 0; p_conn->current_fc_credit = 0; /* Flush RX fragment queue */ if(p_conn->h_rx_fragments != NULL) { p_buff = (struct nci_buff *)que_dequeue(p_conn->h_rx_fragments); while(p_buff) { nci_buff_free(p_buff); p_buff = (struct nci_buff *)que_dequeue(p_conn->h_rx_fragments); } p_conn->rx_accumulated_length = 0; que_destroy(p_conn->h_rx_fragments); p_conn->h_rx_fragments = NULL; } /* Flush pending TX packets */ p_ctx->p_conn_tbl[conn_id].instance ++; /* Increment connection instance */ /* nci_data_send CB will drop packets from previous connection, based on conn_instance */ }
/****************************************************************************** * * Name: static_get_rx_packet * * Description: Prepare received packet from all fragments of data connection queue. * Dequeue each fragment from data connection queue and concatenate * it to received buffer p_rx_payload (this buffer has memory allocated * before calling this function). At end set queue's accumulated_length to 0. * * Input: p_ctx - handle to NCI DATA context object * conn_id - Connection ID * * Output: p_rx_payload - pointer of raw buffer for complete packet payload * * Return: None * *******************************************************************************/ static void static_get_rx_packet(struct nci_data_context *p_ctx, nfc_u8 conn_id, nfc_u8 *p_rx_payload) { struct nci_conn *p_conn = &p_ctx->p_conn_tbl[conn_id]; nfc_u32 offset = 0; struct nci_buff *p_buff = (struct nci_buff *)que_dequeue(p_conn->h_rx_fragments); while(p_buff) { #ifndef NCI_DATA_BIG_ENDIAN nfc_u8 *p_temp = p_rx_payload + offset; NCI_SET_ARR_REV(p_temp, nci_buff_data(p_buff), nci_buff_length(p_buff)); #else osa_mem_copy(p_rx_payload + offset, nci_buff_data(p_buff), nci_buff_length(p_buff)); #endif offset += nci_buff_length(p_buff); nci_buff_free(p_buff); p_buff = (struct nci_buff *)que_dequeue(p_conn->h_rx_fragments); } OSA_ASSERT(offset == p_conn->rx_accumulated_length); p_conn->rx_accumulated_length = 0; }
///queue에 있는 삭제된 단어의 고유번호를 파일에 저장 unsigned int fio_write_to_file_kno (char *fname, QUEUE* queue) { register int i; unsigned int *pno, cnt=0; FILE *fp; char akey[ASIZE]; fp = fopen (fname, "w"); if (fp == NULL) { printf ("File(%s) creating error!\n", fname); return 0; } _fio_write_header (fp, fname); //파일 헤더 쓰기 printf ("Writing data to the %s...\n", fname); if (queue->count == 0) { ////printf (", Empty.\n"); fclose (fp); return 0; } while (!que_is_empty (queue)) { if (que_dequeue (queue, (void*)&pno)) { uint_to_str (*pno, akey); //정수키를 문자열키로 변환 i = 0; while (fputc (akey[i++], fp)); //마지막에 널 저장됨 free (pno); //큐의 데이터 메모리 해제 cnt++; } else break; } //while fclose (fp); printf ("have written data: queue (%u)\n", cnt); return cnt; }