Here's a patch to revert the uint32_t/int API change (and adds the perl
changes needed to support it) and the lenient file-loading change.

I'm 99.9% sure the latter change won't help you, you'll need to change that
code to handle the MH files better. And if so, I see no reason not to leave
the lenient file-handling as-is (if there's no INFORMATION tags, taking the
whole block is the right thing to do).

LMK.

-- 
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 aaed2addb2a0e7a154cadb647997e551af87ce40
Author: Phil Dibowitz <p...@ipom.com>
Date:   Tue Mar 18 23:18:17 2014 -0700

    Revert lenient file loading and operationfile API change
    
    libconcord/bindings/perl/concord.i
    * Support int* as return-value parameters
    * Cleanup compile warnings
    
    libconcord/bindings/perl/test.pl
    * Cleanup perl warning
    
    libconcord/libconcord.cpp
    libconcord/libconcord.h
    * revert read_and_parse_file API change from uint32 -> int
    
    libconcord/operationfile.cpp
    libconcord/operationfile.h
    * revert ReadAndParseFile API change from uint32 -> int
    * revert accepting files without enclosing INFORMATION tags
    
    Signed-off-by: Phil Dibowitz <p...@ipom.com>

diff --git a/libconcord/bindings/perl/concord.i b/libconcord/bindings/perl/concord.i
index fcbd5a6..f2199ab 100644
--- a/libconcord/bindings/perl/concord.i
+++ b/libconcord/bindings/perl/concord.i
@@ -31,7 +31,6 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
 {
     AV *args = (AV*)arg;
     SV *cb;
-    SV *cbdata;
     int i;
 
     /* get a copy of the stack pointer into SP */
@@ -74,7 +73,7 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
         XPUSHs(*av_fetch(args, i, 0));
     }
 
-    XPUSHs(sv_2mortal(newSViv(stages)));
+    XPUSHs(sv_2mortal(newSVpv((const char *)stages, sizeof(stages))));
 
     /*
      * Tell it we're done pushing things onto the stack, so it should
@@ -184,6 +183,10 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
     $1 = &num;
 }
 
+%typemap(in, numinputs=0) int* (int num) {
+    $1 = &num;
+}
+
 /*
  * Special case for ir_signal - this is an array of ints.
  */
@@ -242,7 +245,7 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
  * outputs, we have to list these individually... ignore only works in input.
  */
 %typemap(argout) uint32_t *size,
-         uint32_t *type,
+         int *type,
          uint32_t *binary_size,
          uint32_t *key_names_length,
          uint32_t *ir_signal_length,
diff --git a/libconcord/bindings/perl/test.pl b/libconcord/bindings/perl/test.pl
index 1c12ba3..7ac94f2 100755
--- a/libconcord/bindings/perl/test.pl
+++ b/libconcord/bindings/perl/test.pl
@@ -142,7 +142,6 @@ sub learn_ir_commands
     my ($err, $type);
 
     print "Reading IR file ";
-    my $type;
     ($err, $type) = concord::read_and_parse_file(IR_FILE);
     print "done\n";
 
diff --git a/libconcord/libconcord.cpp b/libconcord/libconcord.cpp
index 0c4c344..bebe22c 100644
--- a/libconcord/libconcord.cpp
+++ b/libconcord/libconcord.cpp
@@ -441,7 +441,7 @@ const char *lc_cb_stage_str(int stage)
 /*
  * Wrapper around the OperationFile class.
  */
-int read_and_parse_file(char *filename, uint32_t *type)
+int read_and_parse_file(char *filename, int *type)
 {
     of = new OperationFile;
     return of->ReadAndParseOpFile(filename, type);
diff --git a/libconcord/libconcord.h b/libconcord/libconcord.h
index 8dbd0bd..8e6f7ec 100644
--- a/libconcord/libconcord.h
+++ b/libconcord/libconcord.h
@@ -194,7 +194,7 @@ void delete_blob(uint8_t *ptr);
  * Read an operations file from the website, parse it, and return a mode
  * of operations.
  */
-int read_and_parse_file(char *filename, uint32_t *type);
+int read_and_parse_file(char *filename, int *type);
 /*
  * Free the memory used by the file as allocated in read_and_parse_file.
 */
diff --git a/libconcord/operationfile.cpp b/libconcord/operationfile.cpp
index 39807f3..9bab04c 100644
--- a/libconcord/operationfile.cpp
+++ b/libconcord/operationfile.cpp
@@ -229,7 +229,7 @@ int OperationFile::_ExtractFirmwareBinary()
     return 0;
 }
 
-int OperationFile::ReadAndParseOpFile(char *file_name, uint32_t *type)
+int OperationFile::ReadAndParseOpFile(char *file_name, int *type)
 {
     debug("In RAPOF");
     int err;
@@ -269,23 +269,13 @@ int OperationFile::ReadAndParseOpFile(char *file_name, uint32_t *type)
         err = GetTag("INFORMATION", xml, xml_size, start_info_ptr);
         debug("err is %d", err);
         if (err == -1) {
-            /*
-             * 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("Unable to find INFORMATION tag");
+            return LC_ERROR;
+        }
+        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");
diff --git a/libconcord/operationfile.h b/libconcord/operationfile.h
index e534bbc..d6fc4e0 100644
--- a/libconcord/operationfile.h
+++ b/libconcord/operationfile.h
@@ -41,7 +41,7 @@ public:
     uint32_t GetXmlSize() {return xml_size;}
     uint8_t* GetData() {return data;}
     uint8_t* GetXml() {return xml;}
-    int ReadAndParseOpFile(char *file_name, uint32_t *type);
+    int ReadAndParseOpFile(char *file_name, int *type);
 };
 
 #endif /* OPERATIONFILE_H */

Attachment: 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

Reply via email to