/* Parse miscellaneous data chunks such as name, author, copyright, and annotation chunks. */ static status ParseMiscellaneous (AFfilehandle file, AFvirtualfile *fh, uint32_t type, size_t size) { int misctype = AF_MISC_UNRECOGNIZED; assert(!memcmp(&type, "NAME", 4) || !memcmp(&type, "AUTH", 4) || !memcmp(&type, "(c) ", 4) || !memcmp(&type, "ANNO", 4)); /* Skip zero-length miscellaneous chunks. */ if (size == 0) return AF_FAIL; file->miscellaneousCount++; file->miscellaneous = _af_realloc(file->miscellaneous, file->miscellaneousCount * sizeof (_Miscellaneous)); if (!memcmp(&type, "NAME", 4)) misctype = AF_MISC_NAME; else if (!memcmp(&type, "AUTH", 4)) misctype = AF_MISC_AUTH; else if (!memcmp(&type, "(c) ", 4)) misctype = AF_MISC_COPY; else if (!memcmp(&type, "ANNO", 4)) misctype = AF_MISC_ANNO; file->miscellaneous[file->miscellaneousCount - 1].id = file->miscellaneousCount; file->miscellaneous[file->miscellaneousCount - 1].type = misctype; file->miscellaneous[file->miscellaneousCount - 1].size = size; file->miscellaneous[file->miscellaneousCount - 1].position = 0; file->miscellaneous[file->miscellaneousCount - 1].buffer = _af_malloc(size); af_fread(file->miscellaneous[file->miscellaneousCount - 1].buffer, size, 1, file->fh); return AF_SUCCEED; }
/* Parse miscellaneous data chunks such as name, author, copyright, and annotation chunks. */ status IFFFile::parseMiscellaneous(const Tag &type, size_t size) { int misctype = AF_MISC_UNRECOGNIZED; assert(type == "NAME" || type == "AUTH" || type == "(c) " || type == "ANNO"); /* Skip zero-length miscellaneous chunks. */ if (size == 0) return AF_FAIL; m_miscellaneousCount++; m_miscellaneous = (Miscellaneous *) _af_realloc(m_miscellaneous, m_miscellaneousCount * sizeof (Miscellaneous)); if (type == "NAME") misctype = AF_MISC_NAME; else if (type == "AUTH") misctype = AF_MISC_AUTH; else if (type == "(c) ") misctype = AF_MISC_COPY; else if (type == "ANNO") misctype = AF_MISC_ANNO; m_miscellaneous[m_miscellaneousCount - 1].id = m_miscellaneousCount; m_miscellaneous[m_miscellaneousCount - 1].type = misctype; m_miscellaneous[m_miscellaneousCount - 1].size = size; m_miscellaneous[m_miscellaneousCount - 1].position = 0; m_miscellaneous[m_miscellaneousCount - 1].buffer = _af_malloc(size); m_fh->read(m_miscellaneous[m_miscellaneousCount - 1].buffer, size); return AF_SUCCEED; }
/* Parse an INFO sub-chunk within a LIST chunk. */ status WAVEFile::parseINFOSubChunk(const Tag &id, uint32_t size) { AFfileoffset endPos = fh->tell() + size; while (fh->tell() < endPos) { int misctype = AF_MISC_UNRECOGNIZED; Tag miscid; uint32_t miscsize; readTag(&miscid); readU32(&miscsize); if (miscid == "IART") misctype = AF_MISC_AUTH; else if (miscid == "INAM") misctype = AF_MISC_NAME; else if (miscid == "ICOP") misctype = AF_MISC_COPY; else if (miscid == "ICMT") misctype = AF_MISC_ICMT; else if (miscid == "ICRD") misctype = AF_MISC_ICRD; else if (miscid == "ISFT") misctype = AF_MISC_ISFT; if (misctype != AF_MISC_UNRECOGNIZED) { char *string = (char *) _af_malloc(miscsize); fh->read(string, miscsize); miscellaneousCount++; miscellaneous = (Miscellaneous *) _af_realloc(miscellaneous, sizeof (Miscellaneous) * miscellaneousCount); miscellaneous[miscellaneousCount-1].id = miscellaneousCount; miscellaneous[miscellaneousCount-1].type = misctype; miscellaneous[miscellaneousCount-1].size = miscsize; miscellaneous[miscellaneousCount-1].position = 0; miscellaneous[miscellaneousCount-1].buffer = string; } else { fh->seek(miscsize, File::SeekFromCurrent); } /* Make the current position an even number of bytes. */ if (miscsize % 2 != 0) fh->seek(1, File::SeekFromCurrent); } return AF_SUCCEED; }
void SampleVisionFile::addMiscellaneous(int type, const char *data) { m_miscellaneousCount++; m_miscellaneous = (Miscellaneous *) _af_realloc(m_miscellaneous, m_miscellaneousCount * sizeof (Miscellaneous)); Miscellaneous &m = m_miscellaneous[m_miscellaneousCount - 1]; m.id = m_miscellaneousCount; m.type = type; m.size = strlen(data); m.position = 0; m.buffer = _af_malloc(m.size); memcpy(m.buffer, data, m.size); }