Example #1
0
/** Writes to a file extra information used by the crash reporting
 * application such as how long the application was running before it
 * crashed, the application to restart, as well as any extra arguments.
 * The contents of the file are formatted as a series of "Key=Val\n" pairs.
 * The written file has the same path and base filename as the minidump
 * file, with ".info" appended to the end. Returns true if the file was
 * created succesfully. Otherwise, returns false.
 */
static bool
write_extra_dump_info(const _char_t *path, const _char_t *id, time_t crashTime)
{
  static const char *KeyBuildVersion = "BuildVersion";
  static const char *KeyCrashTime = "CrashTime";
  static const char *KeyStartupTime = "StartupTime";
  static const char *KeyRestartExecutable = "RestartExecutable";
  static const char *KeyRestartExecutableArgs = "RestartExecutableArgs";

  _char_t extraInfoPath[MAX_PATH_LEN] = TEXT("");
  append_string(extraInfoPath, path, MAX_PATH_LEN);
  append_string(extraInfoPath, PATH_SEPARATOR, MAX_PATH_LEN);
  append_string(extraInfoPath, id, MAX_PATH_LEN);
  size_t len = append_string(extraInfoPath, TEXT(".dmp.info"), MAX_PATH_LEN);
  if (len >= MAX_PATH_LEN)
    return false;

#if defined(Q_OS_WIN32)
  HANDLE hFile = CreateFile(extraInfoPath, GENERIC_WRITE, 0, NULL,
                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  if (hFile == INVALID_HANDLE_VALUE)
    return false;
#else
  _file_handle_t hFile = creat(extraInfoPath, S_IRUSR | S_IWUSR);
  if(hFile == -1) {
    return false;
  }
#endif

  char crashTimeString[24], startupTimeString[24];
  TIME_TO_STRING(crashTimeString, 24, crashTime);
  TIME_TO_STRING(startupTimeString, 24, startupTime);

  write_keyval_to_file(hFile, KeyBuildVersion, buildVersion);
  write_keyval_to_file(hFile, KeyCrashTime, crashTimeString);
  write_keyval_to_file(hFile, KeyStartupTime, startupTimeString);
  write_keyval_to_file(hFile, KeyRestartExecutable, restartExecutable);
  write_keyval_to_file(hFile, KeyRestartExecutableArgs, restartExecutableArgs);

#if defined(Q_OS_WIN32)
  CloseHandle(hFile);
#else
  close(hFile);
#endif
  return true;
}
void FORTE_F_TIME_TO_STRING::executeEvent(int pa_nEIID){
	if(scm_nEventREQID == pa_nEIID){
		OUT() = TIME_TO_STRING(IN());
		sendOutputEvent(scm_nEventCNFID);
	}
}