view common/selftest.c @ 754:27043d74dc90

(Issue25) Align header contents in their own column. We now also stretch column 3 so that the contents are aligned with the descriptive labels without a space in between. Sadly this causes the quit button to be resized to it's minimum instead of sharing the space with the installation button as the installation button is so large that it squeezes the push button.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 07 Jul 2014 12:38:33 +0200
parents 80d1a80b3e8d
children f89b41fa7048
line wrap: on
line source
#include "selftest.h"
#include "binverify.h"
#include "strhelp.h"
#include "logging.h"

bool
selftest()
{
#ifdef WIN32
  wchar_t wPath[MAX_PATH];
  char *utf8path = NULL;

  if (!GetModuleFileNameW (NULL, wPath, MAX_PATH - 1)) 
    {
      PRINTLASTERROR ("Failed to obtain module file name. Path too long?");
      return false;
    }

  /* wPath might not be 0 terminated */
  wPath[MAX_PATH - 1] = '\0';

  utf8path = wchar_to_utf8 (wPath, wcsnlen(wPath, MAX_PATH));

  if (utf8path == NULL)
    {
      ERRORPRINTF ("Failed to convert module path to utf-8");
      return false;
    }

  if (!verify_binary (utf8path, strlen(utf8path)) != VerifyValid)
    {
      ERRORPRINTF ("Verification of the binary failed");
      syslog_error_printf ("Integrity check failed.");
      xfree(utf8path);
      return false;
    }

  xfree(utf8path);
#else
  if (!verify_binary ("/proc/self/exe", 14) != VerifyValid)
    {
      syslog_error_printf ("Integrity check failed.");
      return false;
    }
#endif
}

http://wald.intevation.org/projects/trustbridge/