Crap, that wasn't the most recent version. This adds a minor code cleanup and a lot more comments.
-- Phil Dibowitz p...@ipom.com Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." - Dr. Seuss
commit f0293677fb0cfc8424e242e87e72bb3b711bed6d Author: Phil Dibowitz <p...@ipom.com> Date: Mon Mar 17 22:42:12 2014 -0700 Fix firmware file detection and creation libconcord/operationfile.cpp * Handle firmware files we created ourselves libconcord/libconcord.cpp * Write out more complete XML headers for FW dumps * Minor style cleanups Signed-off-by: Phil Dibowitz <p...@ipom.com> diff --git a/libconcord/libconcord.cpp b/libconcord/libconcord.cpp index fc1ca7d..fe8b2f4 100644 --- a/libconcord/libconcord.cpp +++ b/libconcord/libconcord.cpp @@ -1510,6 +1510,7 @@ int write_firmware_to_file(uint8_t *in, uint32_t size, char *file_name, uint8_t *pf = in; const uint8_t *fwend = in + size; + of.write("<INFORMATION>\n"); do { of.write("\t\t\t<DATA>"); char hex[16]; @@ -1525,6 +1526,7 @@ int write_firmware_to_file(uint8_t *in, uint32_t size, char *file_name, } of.write("</DATA>\n"); } while (pf < fwend); + of.write("</INFORMATION>\n"); } if (of.close() != 0) { diff --git a/libconcord/operationfile.cpp b/libconcord/operationfile.cpp index f20ab72..5311204 100644 --- a/libconcord/operationfile.cpp +++ b/libconcord/operationfile.cpp @@ -269,12 +269,23 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) err = GetTag("INFORMATION", xml, xml_size, start_info_ptr); debug("err is %d", err); if (err == -1) { - return LC_ERROR; - } - - err = GetTag("/INFORMATION", xml, xml_size, end_info_ptr); - if (err == -1) { - return LC_ERROR; + /* + * In theory, we should always have an INFORMATION section + * so we used to return LC_ERROR here. However, for a long time + * when we generated firmware dump files, we didn't surround the + * data in INFORMATION tags. However, since that entire file is + * XML, we assume that's what we have and set the start/end + * of the XML section to the whole file. + */ + debug("Unable to find INFORMATION tag, using whole file"); + start_info_ptr = xml; + end_info_ptr = xml + xml_size; + } else { + err = GetTag("/INFORMATION", xml, xml_size, end_info_ptr); + if (err == -1) { + debug("Unable to find /INFORMATION tag"); + return LC_ERROR; + } } } debug("start/end pointers populated"); @@ -310,11 +321,32 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) while (1) { uint8_t *tag_ptr; string tag_s; + /* + * Firmware files will have either a TYPE or a PATH tag with + * either a URL or a Firmware_Main string in them. + * + * Unless we created them, which is what the DATA check + * is for. + */ + debug("Looking for TYPE tag...\n"); err = GetTag("TYPE", tmp_data, tmp_size, tag_ptr, &tag_s); if (err == -1) { + debug("Looking for PATH tag...\n"); err = GetTag("PATH", tmp_data, tmp_size, tag_ptr, &tag_s); if (err == -1) { - debug("not a firmware file"); + debug("Looking for DATA tag...\n"); + err = GetTag("DATA", tmp_data, tmp_size, tag_ptr, &tag_s); + if (err == -1) { + debug("not a firmware file"); + break; + } + /* + * If all we have is DATA tags, we made the the file, and + * we won't have any of the special strings below, so just + * bo ahead and break the loop, we know it's a firmware file. + */ + debug("Looks like a firmware file we made"); + found_firmware = true; break; } } @@ -365,8 +397,7 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) *type = LC_FILE_TYPE_FIRMWARE; return 0; } - if (!found_get_zaps_only && !found_firmware && - found_learn_ir) { + if (!found_get_zaps_only && !found_firmware && found_learn_ir) { debug("returning IR file"); *type = LC_FILE_TYPE_LEARN_IR; return 0; @@ -378,4 +409,3 @@ int OperationFile::ReadAndParseOpFile(char *file_name, int *type) */ return LC_ERROR; } -
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech
_______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel