3#include <winpr/stream.h> 
    5#include <winpr/crypto.h> 
    7#include <freerdp/freerdp.h> 
    8#include <freerdp/streamdump.h> 
   10#include "../streamdump.h" 
   12static BOOL test_entry_read_write(
void)
 
   22  char tmp2[64] = { 0 };
 
   24  size_t entrysize = 
sizeof(UINT64)  + 
sizeof(BYTE)  +
 
   25                     sizeof(UINT32)  + 
sizeof(UINT64) ;
 
   27  winpr_RAND(tmp, 
sizeof(tmp));
 
   29  for (
size_t x = 0; x < 
sizeof(tmp); x++)
 
   30    (
void)_snprintf(&tmp2[x * 2], 
sizeof(tmp2) - 2 * x, 
"%02" PRIx8, tmp[x]);
 
   31  name = GetKnownSubPath(KNOWN_PATH_TEMP, tmp2);
 
   34    (void)fprintf(stderr, 
"[%s] Could not create temporary path\n", __func__);
 
   38  sw = Stream_New(NULL, 8123);
 
   39  sr = Stream_New(NULL, 1024);
 
   42    (void)fprintf(stderr, 
"[%s] Could not create iostreams sw=%p, sr=%p\n", __func__, (
void*)sw,
 
   47  winpr_RAND(Stream_Buffer(sw), Stream_Capacity(sw));
 
   48  entrysize += Stream_Capacity(sw);
 
   49  Stream_SetLength(sw, Stream_Capacity(sw));
 
   51  fp = fopen(name, 
"wb");
 
   54  if (!stream_dump_write_line(fp, 0, sw))
 
   58  fp = fopen(name, 
"rb");
 
   61  if (!stream_dump_read_line(fp, sr, &ts, &offset, &flags))
 
   64  if (entrysize != offset)
 
   66    (void)fprintf(stderr, 
"[%s] offset %" PRIuz 
" bytes, entrysize %" PRIuz 
" bytes\n",
 
   67                  __func__, offset, entrysize);
 
   71  if (Stream_Length(sr) != Stream_Capacity(sw))
 
   73    (void)fprintf(stderr, 
"[%s] Written %" PRIuz 
" bytes, read %" PRIuz 
" bytes\n", __func__,
 
   74                  Stream_Length(sr), Stream_Capacity(sw));
 
   78  if (memcmp(Stream_Buffer(sw), Stream_Buffer(sr), Stream_Capacity(sw)) != 0)
 
   80    (void)fprintf(stderr, 
"[%s] Written data does not match data read back\n", __func__);
 
   85  Stream_Free(sr, TRUE);
 
   86  Stream_Free(sw, TRUE);
 
   90    winpr_DeleteFile(name);
 
   92  (void)fprintf(stderr, 
"xxxxxxxxxxxxx %d\n", rc);
 
   96int TestStreamDump(
int argc, 
char* argv[])
 
  101  if (!test_entry_read_write())