On 03/20/2014 12:16 AM, Phil Dibowitz wrote:
> OK here we go...
> 
> We generate a more complete FW dump file now... INFORMATION, PHASE, TYPE,
> DATAS, and DATA tags are all there.
> 
> I reverted all of the reading/detection changes now.
> 
> And this still reverts the int -> uint32_t change.
> 
> I think this should work for pretty much everything.

Whoops, forgot to revert the python bindings too. This does that.


-- 
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 c1876fd992d7e2c8bf52e54f4b82d8996f20748f
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 int* -> uint32_t*
    * write out firmware files with the proper XML tags
    
    libconcord/operationfile.cpp
    libconcord/operationfile.h
    * revert ReadAndParseFile API change from int* -> uint32_t*
    * revert accepting files without enclosing INFORMATION/PHASE tags
    * revert accepting DATA tags as evidence of FW files, MH config files
      also have these
    
    bindings/python/libconcord.py
    * revert read_and_parse_file API change from int* -> uint32_t*
    
    Signed-off-by: Phil Dibowitz <p...@ipom.com>

diff --git a/libconcord/bindings/perl/concord.i b/libconcord/bindings/perl/concord.i
index fcbd5a6..1c640a9 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
@@ -113,7 +112,6 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
  */
 %typemap(in) lc_callback %{
     AV* args;
-    SV *tmp;
 
     /*
      * create a new array, store our perl callback in it. We also
@@ -152,6 +150,7 @@ void lc_cb_wrapper(uint32_t stage_id, uint32_t count, uint32_t curr,
      * add the arg to our array. See the typemap for lc_callback
      * for more details
      */
+    SvREFCNT_inc($input);
     av_store(args, 1, $input);
     /* The array is our callback's argument */
     $1 = (void *)args;
@@ -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/bindings/python/libconcord.py b/libconcord/bindings/python/libconcord.py
index a2dd4e6..6d475de 100644
--- a/libconcord/bindings/python/libconcord.py
+++ b/libconcord/bindings/python/libconcord.py
@@ -563,7 +563,7 @@ read_and_parse_file = _create_func(
     'read_and_parse_file',
     _ret_lc_concord(),
     _in('filename', c_char_p),
-    _out('type', c_uint)
+    _out('type', c_int)
 )
 
 # void delete_opfile_obj();
diff --git a/libconcord/libconcord.cpp b/libconcord/libconcord.cpp
index 0c4c344..be54ab5 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);
@@ -1512,6 +1512,9 @@ 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");
+        of.write("\t<PHASE>\n");
+        of.write("\t\t<TYPE>Firmware_Main</TYPE>\n");
+        of.write("\t\t<DATAS>\n");
         do {
             of.write("\t\t\t<DATA>");
             char hex[16];
@@ -1527,6 +1530,8 @@ int write_firmware_to_file(uint8_t *in, uint32_t size, char *file_name,
             }
             of.write("</DATA>\n");
         } while (pf < fwend);
+        of.write("\t\t</DATAS>\n");
+        of.write("\t</PHASE>\n");
         of.write("</INFORMATION>\n");
     }
 
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..b3a00b6 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");
@@ -328,25 +318,11 @@ int OperationFile::ReadAndParseOpFile(char *file_name, uint32_t *type)
          * 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("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;
+                debug("not a firmware file");
                 break;
             }
         }
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