#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#include <dbEvent.h>
#include <dbDefs.h>
#include <dbCommon.h>
#include <registryFunction.h>
#include <epicsExport.h>
#include <recSup.h>
#include <genSubRecord.h>

long wfconvert(genSubRecord *pgsub) {
  char* ina = (char*)pgsub->a;
  char* outa = (char*)pgsub->vala;
  if (ina[0] == ina[1]) {
    memcpy(outa, ina, pgsub->noa);
    outa[0] = outa[0] == 255 ? 1 : outa[0] + 1;
    return(0);
  }
  return(1);
}

/* Register these symbols for use by IOC code */

epicsRegisterFunction(wfconvert);

