Example #1
0
FILE *smfPrintStart(FILE *fp, char *name, void *p, size_t l, BOOL *f, BOOL *newFile,columnHeader_t **h)
{
  FILE *fpNew = fp;
  BOOL first = *f;
  int i;

  offsetH=0;
  offsetD=0;
  columnCount=0;
  tableName = name;
  columnHeadersTmp = h;
  localFirst = first;
  /* Dump the entire record in hex */
  if (debugLevel >=1 )
  {
    printDEBUG(name,p,(l));
  }

  if (first) {
    switch (outputFormat)
    {
    case OF_CSV:
    case OF_SQL:
      fpNew = fopencsv(name,newFile);
      if (outputFormat == OF_SQL)
        openDDL(name);

      if (!fpNew)
      {
        exit(1);
      }
      break;
    case OF_JSON:
      if (!fpNew)
      {
        fpNew = fopenext("MQSMF","json",newFile);
        if (!fpNew)
        {
          exit(1);
        }
      }
      break;
    }
    for(i=0;i<HEADINGS_COUNT;i++) {
      h[i] = 0;
    }
  }
  if (outputFormat == OF_JSON)
    jsonNew(fpNew,name);

  ADDSTR ("Date",commonF.recordDate,8);
  ADDSTR ("Time",commonF.recordTime,16);
  ADDSTRN("LPAR",commonF.systemId,4,4);
  ADDSTRN("QMgr",commonF.qMgr,4,4);
  ADDSTRN("MQ_Version",commonF.mqVer,3,3);

  if (recordType == 115 && commonF.intstart != 0)
  {
    char *dt[2];
    unsigned long long du = conv64(commonF.intduration)/1000000L;
    ADDTIME("Interval_Start",commonF.intstart);
    ADDHEAD("Interval_Duration",DDL_I,0);
    /* Not documented, but this subtype uses a different scale for */
    /* measuring the duration.                                     */
    if (recordSubType == 231)
    {
      ADDDATA(ODT_I64,"%llu,",du/4096L);
    } else {
      ADDDATA(ODT_I64,"%llu,",du);
    }
  }
  *f = first;

  return fpNew;
}
static boolean jsonDelete(Json *json);

void jsonError(char* type, int line) {
  p("JSON %s ERROR: line %d\n",type,line);
}

static void jsonMemoryError(int line) {
  jsonError("MEMMORY",line);
}

struct Json * jsonNewInt(long value) {
  DEBUG(p("%s(%x)\n",__FUNCTION__,value));
  Json * number;
  if (value >= (((long)2)<<15) || value < -(((long)2)<<15)) {
    DEBUG(p("creating a long\n");)
    number = jsonNew(JSON_LONG);
    *(number->longPtr) = value;
  }
  else {
    DEBUG(p("creating an int\n");)
    number = jsonNew(JSON_INT);
    number->intVal = (int)value;
  }
  return number;
}

struct Json * jsonNewDouble(double value) {
  DEBUG(p("%s(%x)\n",__FUNCTION__,value));
  Json *number = jsonNew(JSON_DOUBLE);
  *(number->doublePtr) = value;
  return number;