This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fwd: Re: How do I split binaries to manageable chunks


 
 
===
Earnie Boyd <mailto:earnie_boyd@yahoo.com>

Newbies, please visit
<http://www.freeyellow.com/members5/gw32/index.html>

(If you respond to the list, then please don't cc me)
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


>--- "William S. Shu" <wshu@essex.ac.uk> wrote:
>> Hello all,
>> I tried using the cygwin-20 split command (under windows 95) to split binary
>> files into manageable chunks.  This is for them to be transmitted down noisy
>> lines, and be reconstituted (cf. your split version of full.exe).
>> Unfortunately, it seems to handle only text files.
>>
>> My question is/are:
>> 1)    Could you please indicate to split and later recombine binary file(s)?
>> 2)    Do I need to convert the file to a text equivalent before using split?
>> If so, what software can I use to do this?
>
>> Hmm.  The split program is part of the textutils package.  I just checked the
>> cygwin source and find that it does not specify any file processing mode. :-((
>> I suggest that you get the textutils package and properly port split.c by
>> specifying the processing mode for the files being open both input and
>> output.
>
> Well, this looks exactly like the situation that shows the ultimate
> futility of trying to accomodate MSDOG text files.  How is split to
> know what type of file it is handling?  Should we embed a copy of
> file(1) into split?  Stoop down to MSDOG practice and rely on file
> names?  Or what?

split operates in byte mode (equate to binary) and line mode (equate to
text). It also has a combined byte/line mode which I arbitrarily assign
to text mode - a line has no meaning in binary mode. Give that, the
following seems to fix split in textutils 1.22 quite nicely. I've been
using this for the last year with no problems.

Mark Levedahl

diff -ubr textutils-1.22-orig/src/split.c textutils-1.22/src/split.c
--- textutils-1.22-orig/src/split.c	Sat Jan 25 01:06:23 1997
+++ textutils-1.22/src/split.c	Mon Jun 21 13:30:15 1999
@@ -39,6 +39,10 @@
 # define INT_MAX ((int) (UINT_MAX >> 1))
 #endif

+#ifdef __CYGWIN__
+int     binary_mode = 0;
+#endif
+
 #include "system.h"
 #include "error.h"
 #include "xstrtol.h"
@@ -179,7 +183,13 @@
       next_file_name ();
       if (verbose)
 	fprintf (stderr, _("creating file `%s'\n"), outfile);
-      output_desc = open (outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+#ifdef __CYGWIN__
+      output_desc = open (outfile, O_WRONLY | O_BINARY | O_CREAT |
O_TRUNC
+		| (binary_mode ? O_BINARY : O_TEXT), 0666);
+#else	
+      output_desc = open (outfile, O_WRONLY | O_BINARY | O_CREAT |
O_TRUNC, 0666);
+#endif
+
       if (output_desc < 0)
 	error (EXIT_FAILURE, errno, "%s", outfile);
     }
@@ -508,12 +518,20 @@
       usage (EXIT_FAILURE);
     }

+#ifdef __CYGWIN__
+	binary_mode = (split_type == type_bytes);
+#endif
+
   /* Open the input file.  */
   if (!strcmp (infile, "-"))
     input_desc = 0;
   else
     {
+#ifdef __CYGWIN__
+      input_desc = open (infile, O_RDONLY | (binary_mode ? O_BINARY :
O_TEXT));
+#else
       input_desc = open (infile, O_RDONLY);
+#endif
       if (input_desc < 0)
 	error (EXIT_FAILURE, errno, "%s", infile);
     }


=========================





--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]