Skip to content
Snippets Groups Projects
Select Git revision
  • 22aaec41b283dd9cb6d3b9b05f346e6ec14f44ff
  • master default
  • dbck-q-n-d-link
  • foutput-text_stat-override
  • generations
  • text-stat-sha256
  • use-nettle
  • import-nettle
  • refactor-cached_get_text
  • refactor-cached_get_text-part-2
  • add-text_store
  • introduce-generation_position
  • remove-reclamation
  • dbfile-temp-filenames
  • sstrdup
  • dbfile_open_read-check-magic
  • adns_dist
  • liboop_dist
  • search
  • isc
  • dbdbckmultiplechoice
  • last.cvs.revision
  • 2.1.2
  • 2.1.1
  • 2.1.0
  • adns_1_0
  • liboop_0_9
  • 2.0.7
  • search_bp
  • 2.0.6
  • 2.0.5
  • isc_1_01
  • Protocol-A-10.4
  • 2.0.4
  • 2.0.3
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • isc_1_00
  • isc_merge_1999_05_01
  • isc_merge_1999_04_21
41 results

mux.c

Blame
  • yarrow-test.c 4.61 KiB
    #include "testutils.h"
    #include "yarrow.h"
    #include "knuth-lfib.h"
    
    #include "macros.h"
    
    #include <assert.h>
    #include <errno.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    /* Lagged fibonacci sequence as described in Knuth 3.6 */
    
    struct knuth_lfib_ctx lfib;
    
    static int
    get_event(FILE *f, struct sha256_ctx *hash,
              unsigned *key, unsigned *time)
    {
      static int t = 0;
      uint8_t buf[1];
      
      int c = getc(f);
      if (c == EOF)
        return 0;
    
      buf[0] = c;
      sha256_update(hash, sizeof(buf), buf);
        
      *key = c;
    
      t += (knuth_lfib_get(&lfib) % 10000);
      *time = t;
    
      return 1;
    }
    
    static FILE *
    open_file(const char *name)
    {
      /* Tries opening the file in $srcdir, if set, otherwise the current
       * working directory */
    
      const char *srcdir = getenv("srcdir");
      if (srcdir && srcdir[0])
        {
          /* Leaks this name, but that doesn't matter. */
          char *buf = xalloc(strlen(name) + strlen(srcdir) + 10);
          sprintf(buf, "%s/%s", srcdir, name);
          name = buf;
        }
    
      /* Opens the file in text mode. */
      return fopen(name, "r");
    }
    
    int
    test_main(void)
    {
      FILE *input;
      
      struct yarrow256_ctx yarrow;
      struct yarrow_key_event_ctx estimator;
    
      struct yarrow_source sources[2];
    
      struct sha256_ctx output_hash;
      struct sha256_ctx input_hash;
      uint8_t digest[SHA256_DIGEST_SIZE];