📄 intprismdownload.c
字号:
len = strtoul(tmpBuffer, NULL, 16); len = L_TO_B_ENDIAN_16(len); /* info record type */ bcopy(lineBuffer + S3_INFO_TYPE_OFFSET, tmpBuffer, S3_INFO_TYPE_LEN); tmpBuffer[S3_INFO_TYPE_LEN] = '\0'; type = strtoul(tmpBuffer, NULL, 16); type = L_TO_B_ENDIAN_16(type); /* data for the info record */ pData = (UINT16 *) malloc((len - 1) * sizeof(UINT16)); if (pData == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: Error - malloc " "for info record data failed\n")); return ERROR; } else { for (i = 0; i < len - 1; i++) { bcopy(lineBuffer + S3_INFO_DATA_OFFSET + (i*4), tmpBuffer, 4); tmpBuffer[4] = '\0'; pData[i] = strtoul(tmpBuffer, NULL, 16); pData[i] = L_TO_B_ENDIAN_16(pData[i]); } } intPrismInfoRecordAdd(type, len, pData); break; } default: /* data record */ { UINT16 * pData; UINT32 dataLen; UINT32 i; /* parse Data Record */ WLANDL_DEBUG(DEBUG_FLOOD, ("intPrismSRecordsParse: Data Record\n")); /* -4 for addr, -1 for checksum */ dataLen = (recLen - 4 - 1) / 2; /* get the data */ pData = (UINT16 * ) malloc(dataLen * sizeof(UINT16)); if (pData == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: Error could not " "malloc space for datarecord data\n")); return ERROR; } for (i = 0; i < dataLen; i++) { bcopy(lineBuffer + S3_DATA_DATA_OFFSET + (i * 4), tmpBuffer, 4); tmpBuffer[4] = '\0'; pData[i] = strtoul(tmpBuffer, NULL, 16); pData[i] = L_TO_B_ENDIAN_16(pData[i]); } intPrismDataRecordAdd(recAddr, dataLen, pData); break; } } } /* close else if S3 record */ else { /* not S7 or S3 record... */ WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSRecordsParse: Error - unknown" " file format\n")); return ERROR; } } /* end 'while not done reading' */ return OK; }/****************************************************************************** * intPrismPlugRecordAdd - Add a plug record to the linked list of records** RETURNS: OK If the record was added successfully, else ERROR* ERRNO: N/A*/LOCAL STATUS intPrismPlugRecordAdd ( UINT32 itemCode, /* Item Code of plug record */ UINT32 destAddr, /* Dest. address for plug record data */ UINT32 dataLen /* Num of bytes of data for this plug record */ ) { PLUG_RECORD * pIndex = NULL; /* create a new record at the end of the list */ if (numPlugRecords == 0) { pPlugRecords = (PLUG_RECORD *) malloc(sizeof(PLUG_RECORD)); if (pPlugRecords == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPlugRecordAdd: Error could not " "malloc space for plug record %i\n", numPlugRecords + 1)); return ERROR; } pIndex = pPlugRecords; } else { pIndex = pPlugRecords; while (pIndex->pNext != NULL) { pIndex = pIndex->pNext; } pIndex->pNext = (PLUG_RECORD *) malloc(sizeof(PLUG_RECORD)); if (pIndex->pNext == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPlugRecordAdd: Error could not " "malloc space for plug record %i\n", numPlugRecords + 1)); return ERROR; } pIndex = pIndex->pNext; } /* pIndex points to the newly created record */ pIndex->itemCode = itemCode; pIndex->destAddr = destAddr; pIndex->dataLen = dataLen; pIndex->pNext = NULL; numPlugRecords++; return OK; }/****************************************************************************** * intPrismCrcRecordAdd - Add a crc record to the linked list of records** RETURNS: OK If the record was added successfully, else ERROR* ERRNO: N/A*/LOCAL STATUS intPrismCrcRecordAdd ( UINT32 addr, /* start addr of CRC calculation */ UINT32 len, /* num of bytes to calculate over */ UINT32 program /* non-zero indicates that the CRC calc. is required */ ) { CRC_RECORD * pIndex; /* create a new record at the end of the list */ if (numCrcRecords == 0) { pCrcRecords = (CRC_RECORD *) malloc(sizeof(CRC_RECORD)); if (pCrcRecords == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismCrcRecordAdd: Error could not " "malloc space for crc record %i\n", numCrcRecords + 1)); return ERROR; } pIndex = pCrcRecords; } else { pIndex = pCrcRecords; while (pIndex->pNext != NULL) { pIndex = pIndex->pNext; } pIndex->pNext = (CRC_RECORD *) malloc(sizeof(CRC_RECORD)); if (pIndex->pNext == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismcrcRecordAdd: Error could not " "malloc space for crc record %i\n", numCrcRecords + 1)); return ERROR; } pIndex = pIndex->pNext; } pIndex->addr = addr; pIndex->len = len; pIndex->program = program; pIndex->pNext = NULL; numCrcRecords++; return OK; }/****************************************************************************** NOMANUAL* intPrismPdaRecordAdd - Add a pda record to the linked list of records** RETURNS: OK If the record was added successfully, else ERROR* ERRNO: N/A*/STATUS intPrismPdaRecordAdd ( UINT32 itemCode, /* Item code of the PDA record */ UINT32 len, /* len in bytes of entire PDA record */ UINT16 * pData /* Data associated with the PDA record */ ) { PDA_RECORD * pIndex; /* create a new record at the end of the list */ if (numPdaRecords == 0) { pPdaRecords = (PDA_RECORD *) malloc(sizeof(PDA_RECORD)); if (pPdaRecords == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPdaRecordAdd: Error could not " "malloc space for pda record %i\n", numPdaRecords + 1)); return ERROR; } pIndex = pPdaRecords; } else { pIndex = pPdaRecords; while (pIndex->pNext != NULL) { pIndex = pIndex->pNext; } pIndex->pNext = (PDA_RECORD *) malloc(sizeof(PDA_RECORD)); if (pIndex->pNext == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismPdaRecordAdd: Error could not " "malloc space for pda record %i\n", numPdaRecords + 1)); return ERROR; } pIndex = pIndex->pNext; } pIndex->pNext = NULL; pIndex->itemCode = itemCode; pIndex->len = len; pIndex->data = pData; numPdaRecords++; return OK; }/****************************************************************************** * intPrismInfoRecordAdd - Add an info record to the linked list of records** RETURNS: OK If the record was added successfully, else ERROR* ERRNO: N/A*/LOCAL STATUS intPrismInfoRecordAdd ( UINT16 type, /* Type of info record */ UINT16 len, /* Num of words in info record */ UINT16 * pData /* Data associated with info record */ ) { INFO_RECORD * pIndex; /* create a new record at the end of the list */ if (numInfoRecords == 0) { pInfoRecords = (INFO_RECORD *) malloc(sizeof(INFO_RECORD)); if (pInfoRecords == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismInfoRecordAdd: Error could not " "malloc space for info record %i\n", numInfoRecords + 1)); return ERROR; } pIndex = pInfoRecords; } else { pIndex = pInfoRecords; while (pIndex->pNext != NULL) { pIndex = pIndex->pNext; } pIndex->pNext = (INFO_RECORD *) malloc(sizeof(INFO_RECORD)); if (pIndex->pNext == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismInfoRecordAdd: Error could not " "malloc space for info record %i\n", numInfoRecords + 1)); return ERROR; } pIndex = pIndex->pNext; } pIndex->len = len; pIndex->type = type; pIndex->data = pData; pIndex->pNext = NULL; numInfoRecords++; return OK; }/****************************************************************************** NOMANUAL* intPrismDataRecordAdd - Add a data record to the sorted list of records** RETURNS: OK If the record was added successfully, else ERROR* ERRNO: N/A*/LOCAL STATUS intPrismDataRecordAdd ( UINT32 addr, /* Address to write Data record */ UINT32 dataLen, /* Num of words of data */ UINT16 * pData /* the data to be written */ ) { DATA_RECORD * pIndex; DATA_RECORD * pNew; if (numDataRecords == 0) /* no records exist yet, create the first one */ { pDataRecords = (DATA_RECORD *) malloc(sizeof(DATA_RECORD)); if (pDataRecords == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismDataRecordAdd: Error could not " "malloc space for data record %i\n", numDataRecords + 1)); return ERROR; } pDataRecords->addr = addr; pDataRecords->dataLen = dataLen; pDataRecords->data = pData; pDataRecords->pNext = NULL; numDataRecords++; return OK; } else /* find where to insert this record into the list */ { pIndex = pDataRecords; /* check if this record goes to first position */ if (pIndex->addr > addr) { pNew = (DATA_RECORD *) malloc(sizeof(DATA_RECORD)); if (pNew == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismDataRecordAdd: Error could not " "malloc space for data record %i\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -