« Return to Thread: hetget - RDW option

hetget - RDW option

by kerravon86 :: Rate this Message:

Reply to Author | View in Thread

I have added an option to hetget to make it add a
RDW to each record, regardless of where it
originated from. This allows variable files to be
transmitted in a more "standard" form. (standard
set by ftp with rdw option). This is distinct from
current options which allow preservation of BDW
plus multiple RDW, stripping of both BDW and RDW,
and losing the lengths for RECFM=U.

This helps simplify something else I am working
on.

BFN.  Paul.



Index: hercules/hetget.c
diff -c hercules/hetget.c:1.6 hercules/hetget.c:1.7
*** hercules/hetget.c:1.6 Wed Jun 17 01:34:39 2009
--- hercules/hetget.c Sun Jun 21 16:11:55 2009
***************
*** 37,42 ****
--- 37,43 ----
  #define O_STRIP     0x20
  #define O_UNBLOCK   0x10
  #define O_NO_NEW    0x08
+ #define O_RDW       0x04
  struct
  {
      char *ifile;
***************
*** 69,74 ****
--- 70,76 ----
      "  -h  display usage summary\n"
      "  -n  file is an NL (or BLP like) tape\n"
      "  -u  unblock (removes BDWs and RDWs if RECFM=V)\n"
+     "  -r  add an artificial RDW to anything\n"
      "  -s  strip trailing blanks (requires -a)\n"
      "  -z  don't add newlines when converting RECFM=U to ASCII\n";
 
***************
*** 538,544 ****
      /*
      || Different processing when converting to ASCII
      */
!     if( opts.flags & ( O_ASCII | O_UNBLOCK ) )
      {
          /*
          || Get a record
--- 540,546 ----
      /*
      || Different processing when converting to ASCII
      */
!     if( opts.flags & ( O_ASCII | O_UNBLOCK | O_RDW ) )
      {
          /*
          || Get a record
***************
*** 596,601 ****
--- 598,604 ----
              if ( (opts.flags & O_ASCII)
                   && rc == 1
                   && ptr[0] == ' '
+                  && !(opts.flags & O_RDW)
                   && ( ((opts.recfm & O_UNDEFINED)
                         && !(opts.flags & O_NO_NEW)
                        )
***************
*** 612,622 ****
                     care of newlines themselves for RECFM=U, then
                     any single space in the last block would be
                     genuine albeit extremely unlikely. */
              }
!             else
              {
!                 fwrite( ptr, rc, 1, outf );
              }
 
              /*
              || Put out a linefeed when converting
--- 615,648 ----
                     care of newlines themselves for RECFM=U, then
                     any single space in the last block would be
                     genuine albeit extremely unlikely. */
+                 rc = 0;
              }
!            
!             /* write out an artificial RDW */
!             if (opts.flags & O_RDW)
              {
!                 int havenl = 0;
!
!                 /* take into account newline */
!                 if( opts.flags & O_ASCII
!                     && (!(opts.flags & O_NO_NEW)
!                         || !(opts.recfm & O_UNDEFINED)
!                        )
!                   )
!                 {
!                     havenl = 1;
!                     rc++;
!                 }
!                 fputc( (((unsigned int)rc >> 8) & 0xff), outf );
!                 fputc( ((unsigned int)rc & 0xff), outf );
!                 fputc( 0x00, outf );
!                 fputc( 0x00, outf );
!                 if (havenl)
!                 {
!                     rc--;
!                 }
              }
+             fwrite( ptr, rc, 1, outf );
 
              /*
              || Put out a linefeed when converting
***************
*** 690,696 ****
      */
      while( TRUE )
      {
!         rc = getopt( argc, argv, "abhnsuz" );
          if( rc == -1 )
          {
              break;
--- 716,722 ----
      */
      while( TRUE )
      {
!         rc = getopt( argc, argv, "abhnsurz" );
          if( rc == -1 )
          {
              break;
***************
*** 719,724 ****
--- 745,754 ----
                  opts.flags |= O_UNBLOCK;
              break;
 
+             case 'r':
+                 opts.flags |= O_RDW;
+             break;
+
              case 'z':
                  opts.flags |= O_NO_NEW;
              break;


 « Return to Thread: hetget - RDW option