On Thu, Mar 26, 2009 at 09:21:38AM +0100, Olaf Till wrote:
> 
> ...
>
> Looking at the parcellfun stuff, I noticed that there are still more
> functions for sending and receiving Octave variables in octave-forge:
> fsave and fload. Some time ago there was a discussion in the
> octave-maintainers list on save'ing and load'ing over streams. After
> getting some hints, I posted psend and prcv, which can install/read
> Octave variables to/from memory as well as directly returning/taking
> their contents, and which read/write a binary header also (to care for
> endian'ness, as I understood), and which distinguish eof at start of
> reading from eof later. The discussion dried out, probably the
> solution was not general enough and not obviously the right one for
> Octave. For the now contributed code, the functionality of fsave and
> fload would probably be sufficient, if only endian'ness was cared for
> by writing/reading a header (varibles are sent between different
> machines now). If this would be done, I could rewrite my code, and
> then there is probably no reason to keep psend and prcv in the
> package.

Jaroslav,

would you accept the attached small patches for fsave.cc and fload.cc,
to make them robust for usage between different machines?

Also, would you think I could put 'select.cc' (general wrapper around
Unix select) into main/general instead of keeping it in my package,
where I need to call it? (What I attached in the first mail of this
thread did not use texinfo for helptexts, this has changed now.)

There is also an _exit() function which I would also like to put into
main/general.

Actually the functions for advisory locking also do not really belong
into the package, but more into main/general, but they are probably
not general enough, allowing only write-locking a whole file and using
raw file descriptors.

Olaf
--- fload.cc	2009-03-24 11:01:45.000000000 +0100
+++ new-fload.cc	2009-03-26 13:03:42.000000000 +0100
@@ -20,6 +20,7 @@
 
 #include <octave/oct.h>
 #include <octave/mach-info.h>
+#include <octave/load-save.h>
 #include <octave/ls-oct-binary.h>
 #include <octave/oct-stream.h>
 
@@ -46,8 +47,11 @@
           // a more low-level interface, but there doesn't seem to be a more suitable
           // one in Octave, that still does the automatic type lookup.
           std::string doc, filename;
-          bool swap = false, global;
-          read_binary_data (*is, swap, oct_mach_info::native_float_format (),
+          bool swap, global;
+	  oct_mach_info::float_format flt_fmt;
+	  if (read_binary_file_header (*is, swap, flt_fmt, false) < 0)
+	    return retval;
+          read_binary_data (*is, swap, flt_fmt,
                             filename, global, retval, doc);
           if (retval.is_undefined ())
             error ("fload: failed to extract value");
--- fsave.cc	2009-03-24 11:01:45.000000000 +0100
+++ new-fsave.cc	2009-03-26 13:04:48.000000000 +0100
@@ -20,6 +20,7 @@
 
 #include <octave/oct.h>
 #include <octave/mach-info.h>
+#include <octave/load-save.h>
 #include <octave/ls-oct-binary.h>
 #include <octave/oct-stream.h>
 
@@ -49,6 +50,7 @@
           // one in Octave, that still does the automatic type lookup.
           std::string doc, name;
           bool floats = false, global = false;
+	  write_header (*os, LS_BINARY);
           save_binary_data (*os, val, name, doc, global, floats);
         }
       else
------------------------------------------------------------------------------
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to