SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bd.cpp File Reference
This graph shows which files directly or indirectly include this file:

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.

References ErrNotify(), TOnExeStop::GetOnExeStopF(), TOnExeStop::IsOnExeStopF(), and SaveToErrLog().

                                                       {
  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
  }
}

Here is the call graph for this function:

void SaveToErrLog ( const char *  MsgCStr)

Definition at line 47 of file bd.cpp.

Referenced by ExeStop(), and TZipIn::GetFLen().

                                      {
  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;
}

Here is the caller graph for this function:

void WrNotify ( const char *  CaptionCStr,
const char *  NotifyCStr 
)

Definition at line 39 of file bd.cpp.

Referenced by ErrNotify(), TZipIn::GetFLen(), InfoNotify(), StatNotify(), and WarnNotify().

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

Here is the caller graph for this function: