User exit in C - need advice

Previous topic - Next topic

ssorich

We already have an exit that changes all x�00� to x�20�... I donlt know C language, but I am trying to change only the value in column1 to spaces instead of all characters... Is anybody familiar with how to change the code to do so? Thanks!

Here is the source:
#include "apkexits.h"                                                           
                                                                     

char *recordptr; /* pointer to record to be analyzed */
int recordlen; /* length of record to be analyzed */

long ACIF_EXPORT INPEXIT( INPEXIT_PARMS *exitstruc)
{

   recordptr = exitstruc->record;
   recordlen = exitstruc->recordln;
   int cnt = 0;


   if(exitstruc->eof != INP_EOFLAG)
   {

      for (cnt = 0; cnt < recordlen; cnt++ ) {
         if ((unsigned char) exitstruc->record[cnt] == 0x00) {
            exitstruc->record[cnt] = 0x20;
         }
      }

      exitstruc->request = INP_USE;
   }

   return( 0 );
}

Justin Derrick

I'm not a C programmer, so I'm not super clear on what's inside that pointer you're being passed in that code. 

If it's a single line of a linedata report, then you could place restrictions on the position (i.e. array offset) of the characters that you're optionally replacing.

Alternately, if you're just getting a buffer of X characters, then you'd need to look for a line ending character followed immediately by the character you want to replace.

Hopefully some other folks with more experience can chime in and get you closer to a solution.

-JD.
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Webinars:  https://CMOD.Training/
IBM CMOD Professional Services: https://CMOD.cloud

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

ssorich

Thanks Justin - and agreed - it's one substring or array value from what I want t to be

sisusteve

Get rid of the for loop and use: exitstruc->record[0] = 0x20;