Author Topic: User exit in C - need advice  (Read 1903 times)

ssorich

  • Jr. Member
  • **
  • Posts: 14
    • View Profile
User exit in C - need advice
« on: October 05, 2017, 08:02:43 AM »
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

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: User exit in C - need advice
« Reply #1 on: October 05, 2017, 01:37:04 PM »
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.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

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

ssorich

  • Jr. Member
  • **
  • Posts: 14
    • View Profile
Re: User exit in C - need advice
« Reply #2 on: October 06, 2017, 09:03:19 AM »
Thanks Justin - and agreed - it's one substring or array value from what I want t to be

Steve Bechtolt

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: User exit in C - need advice
« Reply #3 on: February 02, 2018, 05:54:02 AM »
Get rid of the for loop and use: exitstruc->record[0] = 0x20;
Steve Bechtolt
IBM Certified Solutions Expert - IBM Content Management - OnDemand Multiplatform
ERM as a Service - DXC Technology