Ejemplo n.º 1
0
extern void eventlog_hexdump_data(void const * data, unsigned int len)
{
    unsigned int i;
    char dst[100];
    unsigned char * datac;

    if (!data) {
	eventlog(eventlog_level_error, __FUNCTION__, "got NULL data");
	return;
    }

    for (i = 0, datac = (unsigned char*)data; i < len; i += 16, datac += 16)
    {
	hexdump_string(datac, (len - i < 16) ? (len - i) : 16, dst, i);
	std::fprintf(eventstrm,"%s\n",dst);
#ifdef WIN32_GUI
       if (eventlog_level_gui&currlevel)
	    gui_lprintf(eventlog_level_info,"%s\n",dst);
#endif
       if (eventlog_debugmode)
       {
	       std::printf("%s\n",dst);
       }

    }
    if (eventlog_debugmode) std::fflush(stdout);
    std::fflush(eventstrm);
}
Ejemplo n.º 2
0
int dofunction( const struct ssPWD *pwd )
  {
  hexdump_string("Current", pwd->cur);

  return PWD_FAIL;					/* not found yet */
  }
Ejemplo n.º 3
0
/* run a systematic test converting characters from one encoding into
   UTF-8 and back, and see if everything survived */
void test_conversion (const struct ssPWD* pwd, const enum eEncodings encoding)
  {
  struct sPwdString* str;
  int i;
  /* character was converted to a replacement char U+FFFD? */
  int replaced;
  unsigned char fffd[4] = { 0xef, 0xbf, 0xbd, 0 };

  str = pwdgen_new_string(pwd, 16, encoding);
  if (1 == non_null (str, "string for test_conversion"))
    {
    for (i = 0; i < 256; i++)
      {
      str->content[0] = i;
      str->content[1] = 0x0;
      str->characters = 1;
      str->bytes = 1;
      str->encoding = encoding;

      /* printf ("# # At char %c (0x%02x), encoding %s\n", i, i, pwdgen_encoding(encoding)); */

      pwdgen_convert(pwd, str, UTF_8);

      if (str->encoding != UTF_8)
	{
	equals (str->encoding, UTF_8, "char could be converted to UTF-8");
	}

      if (str->characters != 1)
	{
	equals (str->characters, 1, "number of characters is 1");
	}
      replaced = memcmp(str->content, (char*)fffd, 3);

      pwdgen_convert(pwd, str, encoding);
      if (str->encoding != encoding)
	{
	equals (str->encoding, encoding, "char could be converted back");
	}
      if (str->characters != 1)
	{
	equals (str->characters, 1, "number of characters is still 1");
	}
      if (str->bytes != 1)
        {
	equals (str->bytes, 1, "number of bytes is still 1");
	}
      if (0 != replaced)
        {
        if ((unsigned char)str->content[0] != i)
	  {
	  if (!equals ( (unsigned char)str->content[0], i, "could be converted back"))
	    {
	    printf ("# # Char: %i (0x%02x, '%c') in %s\n", i, i, i, pwdgen_encoding(encoding));
            hexdump_string("pwd",str);
	    }
	  }
        }
      else
        {
	if ( (unsigned char)str->content[0] != '?')
	  {
	  equals ( (unsigned char)str->content[0], '?', "could be converted back to '?'");
	  }
        }
      }
    }
  else { skip ( 256 * 6 + 1, "Couldn't allocate string for test_conversion"); }
 
  }