hetget - RDW option

View: New views
2 Messages — Rating Filter:   Alert me  

hetget - RDW option

by kerravon86 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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;



Re: hetget - RDW option

by kerravon86 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- In hercules-390@..., "kerravon86" <kerravon86@...> wrote:
>
> I have added an option to hetget to make it add a
> RDW to each record, regardless of where it
> originated from.

I've got a replacement for this patch. New patch
adds a binary and text option for much simpler
processing.

BFN.  Paul.



Index: hetget.c
===================================================================
RCS file: c:\cvsroot/hercules/hetget.c,v
retrieving revision 1.6
retrieving revision 1.9
diff -c -r1.6 -r1.9
*** hetget.c 16 Jun 2009 15:34:39 -0000 1.6
--- hetget.c 27 Jun 2009 14:15:05 -0000 1.9
***************
*** 37,42 ****
--- 37,45 ----
  #define O_STRIP     0x20
  #define O_UNBLOCK   0x10
  #define O_NO_NEW    0x08
+ #define O_RDW       0x04
+ #define O_HRCBIN    0x02
+ #define O_HRCTXT    0x01
  struct
  {
      char *ifile;
***************
*** 66,75 ****
--- 69,81 ----
      "Usage: %s [options] hetfile outfile fileno [recfm lrecl blksize]\n\n"
      "Options:\n"
      "  -a  convert to ASCII (implies -u)\n"
+     "  -b  sensible defaults for binary files\n"
      "  -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"
+     "  -t  sensible defaults for text files\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
--- 544,550 ----
      /*
      || Different processing when converting to ASCII
      */
!     if( opts.flags & ( O_ASCII | O_UNBLOCK | O_RDW ) )
      {
          /*
          || Get a record
***************
*** 582,593 ****
              /*
              || Strip trailing blanks
              */
!             if( opts.flags & O_STRIP )
              {
                  while( rc > 0 && ptr[ rc - 1 ] == ' ' )
                  {
                      rc--;
                  }
              }
             
              /*
--- 588,615 ----
              /*
              || Strip trailing blanks
              */
!             if( opts.flags & O_STRIP
!                 || ((opts.flags & O_HRCTXT)
!                     && (opts.recfm & O_FIXED)
!                    )
!               )
              {
                  while( rc > 0 && ptr[ rc - 1 ] == ' ' )
                  {
                      rc--;
                  }
+                
+                 /* if a text file has been copied, in binary mode,
+                    into a fixed dataset, it will have NUL-padding.
+                    Since we don't want NULs in a text file, we
+                    clean them up too */
+                 if (opts.recfm & O_FIXED)
+                 {
+                     while( rc > 0 && ptr[ rc - 1 ] == '\0' )
+                     {
+                         rc--;
+                     }
+                 }
              }
             
              /*
***************
*** 596,601 ****
--- 618,624 ----
              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
--- 635,674 ----
                     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)
!                 || ((opts.flags & O_HRCBIN)
!                     && (opts.recfm & O_VARIABLE)
!                    )
!                )
              {
!                 int havenl = 0;
!
!                 /* take into account newline */
!                 if( opts.flags & O_ASCII
!                     && (!(opts.flags & O_NO_NEW)
!                         || !(opts.recfm & O_UNDEFINED)
!                        )
!                   )
!                 {
!                     havenl = 1;
!                     rc++;
!                 }
!                 rc += 4;
!                 fputc( (((unsigned int)rc >> 8) & 0xff), outf );
!                 fputc( ((unsigned int)rc & 0xff), outf );
!                 fputc( 0x00, outf );
!                 fputc( 0x00, outf );
!                 rc -= 4;
!                 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;
--- 742,748 ----
      */
      while( TRUE )
      {
!         rc = getopt( argc, argv, "abhnsturz" );
          if( rc == -1 )
          {
              break;
***************
*** 702,707 ****
--- 754,764 ----
                  opts.flags |= O_ASCII;
              break;
 
+             case 'b':
+                 opts.flags |= O_HRCBIN;
+                 opts.flags |= O_UNBLOCK;
+             break;
+
              case 'h':
                  usage( argv[ 0 ] );
                  exit( 1 );
***************
*** 715,724 ****
--- 772,792 ----
                  opts.flags |= O_STRIP;
              break;
 
+             case 't':                
+                 opts.flags |= O_HRCTXT;
+                 opts.flags |= O_ASCII;
+                 opts.flags |= O_UNBLOCK;
+                 opts.flags |= O_NO_NEW;
+             break;
+
              case 'u':
                  opts.flags |= O_UNBLOCK;
              break;
 
+             case 'r':
+                 opts.flags |= O_RDW;
+             break;
+
              case 'z':
                  opts.flags |= O_NO_NEW;
              break;