// **************************************************************************
// construct a string with the node number of the 
//  process and the string ".log". This will be used as the suffix
// of the log name forthis process . So if the log name specified by the 
// user in the 
// configuration file is "sql_events", the actual log name will be
// something like "sql_events_<nid>.log"
// **************************************************************************
void getMyNidSuffix(char stringNidSuffix[])
{
  short result = 0;

  NAProcessHandle myPhandle;
  myPhandle.getmine();
  myPhandle.decompose();
  
  char processName[MS_MON_MAX_PROCESS_NAME + 1];
  

  memset(processName, 0, sizeof(processName));
  memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen());
  memset(processName, 0, sizeof(processName));
  memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen());

 

  MS_Mon_Process_Info_Type procInfo;
  Int32 rc = 0;

  Int32 myNid = 0;
  
  do
  {
     rc = msg_mon_get_process_info_detail(processName, &procInfo);
     myNid = procInfo.nid;
   
  } while ((rc == XZFIL_ERR_OK) && (procInfo.parent_nid != -1) && (procInfo.parent_pid != -1));

  snprintf (stringNidSuffix, 5+sizeof(Int32), "_%d.log", myNid);
}
// **************************************************************************
// construct a string with the node number and PIN of the ancestor 
// executor process and the string ".log". This will be used as the suffix
// of the log name. So if the log name specified by the user in the 
// configuration file is "sql_events", the actual log name will be
// something like "sql_events_0_12345.log"
// **************************************************************************
void getMyTopAncestor(char ancsNidPid[])
{
  short result = 0;

  NAProcessHandle myPhandle;
  myPhandle.getmine();
  myPhandle.decompose();
  char processName[MS_MON_MAX_PROCESS_NAME + 1];
  char ppName[MS_MON_MAX_PROCESS_NAME + 1];

  memset(processName, 0, sizeof(processName));
  memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen());

  memset(ppName, 0, sizeof(ppName));

  MS_Mon_Process_Info_Type procInfo;
  Int32 rc = 0;

  Int32 ancsNid = 0;
  Int32 ancsPid = 0;
  do
  {
     rc = msg_mon_get_process_info_detail(processName, &procInfo);
     ancsNid = procInfo.nid;
     ancsPid = procInfo.pid;
     strcpy(ppName, procInfo.parent_name);
     strcpy(processName, ppName);
  } while ((rc == XZFIL_ERR_OK) && (procInfo.parent_nid != -1) && (procInfo.parent_pid != -1));

  snprintf (ancsNidPid, 5+2*sizeof(Int32), "_%d_%d.log", ancsNid, ancsPid);
}