SNAP Library, User Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bd.cpp File Reference

Go to the source code of this file.

Functions

int _matherr (struct _exception *e)
void WrNotify (const char *CaptionCStr, const char *NotifyCStr)
void SaveToErrLog (const char *MsgCStr)
void ExeStop (const char *MsgCStr, const char *ReasonCStr, const char *CondCStr, const char *FNm, const int &LnN)

Function Documentation

int _matherr ( struct _exception *  e)

Definition at line 31 of file bd.cpp.

                                  {
  e->retval=0;
  return 1;
}
void ExeStop ( const char *  MsgCStr,
const char *  ReasonCStr,
const char *  CondCStr,
const char *  FNm,
const int &  LnN 
)

Definition at line 65 of file bd.cpp.

                                                       {
  char ReasonMsgCStr[1000];

  // stack dump, works for g++
  //void *array[20];
  //size_t size;
  // get the trace and print it out
  //size = backtrace(array, 20);
  //backtrace_symbols_fd(array, size, 2);

  // construct reason message
  if (ReasonCStr==NULL){ReasonMsgCStr[0]=0;}
  else {sprintf(ReasonMsgCStr, " [Reason:'%s']", ReasonCStr);}
  // construct full message
  char FullMsgCStr[1000];
  if (MsgCStr==NULL){
    if (CondCStr==NULL){
      sprintf(FullMsgCStr, "Execution stopped%s!", ReasonMsgCStr);
    } else {
      sprintf(FullMsgCStr, "Execution stopped: %s%s, file %s, line %d",
       CondCStr, ReasonMsgCStr, FNm, LnN);
    }
  } else {
    if (CondCStr==NULL){
      sprintf(FullMsgCStr, "%s\nExecution stopped!", MsgCStr);
    } else {
      sprintf(FullMsgCStr, "Message: %s%s\nExecution stopped: %s, file %s, line %d",
       MsgCStr, ReasonMsgCStr, CondCStr, FNm, LnN);
    }
  }
  // report full message to log file
  SaveToErrLog(FullMsgCStr);
  // report to screen & stop execution
  bool Continue=false;
  // call handler
  if (TOnExeStop::IsOnExeStopF()){
    Continue=!((*TOnExeStop::GetOnExeStopF())(FullMsgCStr));}
  if (!Continue){
    ErrNotify(FullMsgCStr);
#ifdef GLib_WIN32
    abort();
    //ExitProcess(1);
#else
    exit(1);
#endif
  }
}
void SaveToErrLog ( const char *  MsgCStr)

Definition at line 47 of file bd.cpp.

                                      {
  int MxFNmLen=1000;
  char* FNm=new char[MxFNmLen]; if (FNm==NULL){return;}
  int FNmLen=GetModuleFileName(NULL, FNm, MxFNmLen); if (FNmLen==0){return;}
  FNm[FNmLen++]='.'; FNm[FNmLen++]='E'; FNm[FNmLen++]='r'; FNm[FNmLen++]='r';
  FNm[FNmLen++]=char(0);
  time_t Time=time(NULL);
  FILE* fOut=fopen(FNm, "a+b"); if (fOut==NULL){return;}
  fprintf(fOut, "--------\r\n%s\r\n%s%s\r\n--------\r\n",
   FNm, ctime(&Time), MsgCStr);
  fclose(fOut);
  delete[] FNm;
}
void WrNotify ( const char *  CaptionCStr,
const char *  NotifyCStr 
)

Definition at line 39 of file bd.cpp.

                                                              {
#if defined(__CONSOLE__) || defined(_CONSOLE)
  printf("*** %s: %s\n", CaptionCStr, NotifyCStr);
#else
  MessageBox(NULL, NotifyCStr, CaptionCStr, MB_OK);
#endif
}