示例#1
0
void json_object_seed(size_t seed) {
    uint32_t new_seed = (uint32_t)seed;

    if (hashtable_seed == 0) {
        if (new_seed == 0) {
            /* Explicit synchronization fences are not supported by the
               __sync builtins, so every thread getting here has to
               generate the seed value.
            */
            new_seed = generate_seed();
        }

        do {
            if (__sync_bool_compare_and_swap(&hashtable_seed, 0, new_seed)) {
                /* We were the first to seed */
                break;
            } else {
                /* Wait for another thread to do the seeding */
#ifdef HAVE_SCHED_YIELD
                sched_yield();
#endif
            }
        } while(hashtable_seed == 0);
    }
}
示例#2
0
文件: main.c 项目: sdzharkov/ECS30
//program to implement the game of minesweeper
//user enters the name of the executable, the row and column dimensions, number of mines, and optionally a seed for random number generator 
int main(int argc, char** argv){
	
	Board board; //intitialize the board with struct type Board
	
  	int row = 0; //intialize the number of rows
  	int column = 0; //initialize the number of columns
  	int mine = 0; //intiialize the number of mines
  	read_args(argc, argv, &row, &column, &mine);
  	board.row = row;
  	board.col = column;
  	board.mine = mine;


	board.seed = generate_seed(argv);
	board.tile = create_board(board); //create the board
	mine_location_generator(board);
	print_board(board);
	play_is_valid(board);



	destroy_board(board); //when the game is over destroy the board

  return 0;
}
示例#3
0
文件: sudoku.c 项目: flackbash/nudoku
char* generate_puzzle(int holes)
{
	char* stream;

	stream = generate_seed();
	solve(stream);
	punch_holes(stream, holes);
	return stream;
}
示例#4
0
std::size_t generate_random_number(unsigned min, unsigned max) {

	std::mt19937 typedef generator_t;
	std::random_device generate_seed;
	generator_t gen(generate_seed());
	boost::uniform_int<> distrib(min, max);
	//std::uniform_int<> distrib(min, max);
	std::function<size_t()> uni_random(std::bind(distrib, gen));
	return uni_random();
}
示例#5
0
/* Fall back to a thread-unsafe version */
void json_object_seed(size_t seed) {
    uint32_t new_seed = (uint32_t)seed;

    if (hashtable_seed == 0) {
        if (new_seed == 0)
            new_seed = generate_seed();

        hashtable_seed = new_seed;
    }
}
示例#6
0
void json_object_seed(size_t seed) {
    uint32_t new_seed = (uint32_t)seed;

    if (hashtable_seed == 0) {
        if (InterlockedIncrement(&seed_initialized) == 1) {
            /* Do the seeding ourselves */
            if (new_seed == 0)
                new_seed = generate_seed();

            hashtable_seed = new_seed;
        } else {
            /* Wait for another thread to do the seeding */
            do {
                SwitchToThread();
            } while (hashtable_seed == 0);
        }
    }
}
示例#7
0
void json_object_seed(size_t seed) {
    uint32_t new_seed = (uint32_t)seed;

    if (hashtable_seed == 0) {
        if (__atomic_test_and_set(&seed_initialized, __ATOMIC_RELAXED) == 0) {
            /* Do the seeding ourselves */
            if (new_seed == 0)
                new_seed = generate_seed();

            __atomic_store_n(&hashtable_seed, new_seed, __ATOMIC_RELEASE);
        } else {
            /* Wait for another thread to do the seeding */
            do {
#ifdef HAVE_SCHED_YIELD
                sched_yield();
#endif
            } while(__atomic_load_n(&hashtable_seed, __ATOMIC_ACQUIRE) == 0);
        }
    }
}
示例#8
0
文件: myssl.c 项目: captdeaf/pennmush
/** Initialize the SSL context.
 * \return pointer to SSL context object.
 */
SSL_CTX *
ssl_init(char *private_key_file, char *ca_file, char *ca_dir,
         int req_client_cert)
{
  const SSL_METHOD
    *meth; /* If this const gives you a warning, you're
              using an old version of OpenSSL. Walker, this means you! */
  /* uint8_t context[128]; */
  unsigned int reps = 1;
  pcg32_random_t rand_state;
  uint64_t seeds[2];
  bool seeded = false;

  if (!bio_err) {
    if (!SSL_library_init())
      return NULL;
    SSL_load_error_strings();
    /* Error write context */
    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
  }

  lock_file(stderr);
  fputs("Seeding OpenSSL random number pool.\n", stderr);
  unlock_file(stderr);
  while (!RAND_status()) {
    /* At this point, a system with /dev/urandom or a EGD file in the usual
       places will have enough entropy. Otherwise, be lazy and use random
       numbers until it's satisfied. */
    uint32_t gibberish[8];
    int n;

    if (!seeded) {
      generate_seed(seeds);
      pcg32_srandom_r(&rand_state, seeds[0], seeds[1]);
      seeded = 1;
    }

    for (n = 0; n < 8; n++)
      gibberish[n] = pcg32_random_r(&rand_state);

    RAND_seed(gibberish, sizeof gibberish);

    reps += 1;
  }

  lock_file(stderr);
  fprintf(stderr, "Seeded after %u %s.\n", reps, reps > 1 ? "cycles" : "cycle");
  unlock_file(stderr);

  /* Set up SIGPIPE handler here? */

  /* Create context */
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
  meth = TLS_server_method();
#else
  meth = SSLv23_server_method();
#endif
  ctx = SSL_CTX_new(meth);
  SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);

  /* Load keys/certs */
  if (private_key_file && *private_key_file) {
    if (!SSL_CTX_use_certificate_chain_file(ctx, private_key_file)) {
      ssl_errordump("Unable to load server certificate - only anonymous "
                    "ciphers supported.");
    }
    if (!SSL_CTX_use_PrivateKey_file(ctx, private_key_file, SSL_FILETYPE_PEM)) {
      ssl_errordump(
        "Unable to load private key - only anonymous ciphers supported.");
    }
  }

  /* Load trusted CAs */
  if ((ca_file && *ca_file) || (ca_dir && *ca_dir)) {
    if (!SSL_CTX_load_verify_locations(ctx,
                                       (ca_file && *ca_file) ? ca_file : NULL,
                                       (ca_dir && *ca_dir) ? ca_dir : NULL)) {
      ssl_errordump("Unable to load CA certificates");
    }
    {
      STACK_OF(X509_NAME) *certs = NULL;
      if (ca_file && *ca_file)
        certs = SSL_load_client_CA_file(ca_file);
      if (certs)
        SSL_CTX_set_client_CA_list(ctx, certs);

      if (req_client_cert)
        SSL_CTX_set_verify(ctx,
                           SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
                           client_verify_callback);
      else
        SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, client_verify_callback);
#if (OPENSSL_VERSION_NUMBER < 0x0090600fL)
      SSL_CTX_set_verify_depth(ctx, 1);
#endif
    }
  }

  SSL_CTX_set_options(ctx, SSL_OP_SINGLE_DH_USE | SSL_OP_ALL);
  SSL_CTX_set_mode(ctx, SSL_MODE_ENABLE_PARTIAL_WRITE |
                          SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);

  /* Set up DH key */
  {
    DH *dh;
    dh = get_dh2048();
    SSL_CTX_set_tmp_dh(ctx, dh);
    DH_free(dh);
  }

#ifdef NID_X9_62_prime256v1
  /* Set up ECDH key */
  {
    EC_KEY *ecdh = NULL;
    ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
    SSL_CTX_set_tmp_ecdh(ctx, ecdh);
    EC_KEY_free(ecdh);
  }
#endif

  /* Set the cipher list to the usual default list, except that
   * we'll allow anonymous diffie-hellman, too.
   */
  SSL_CTX_set_cipher_list(ctx, "ALL:ECDH:ADH:!LOW:!MEDIUM:@STRENGTH");

  /* Set up session cache if we can */
  /*
     strncpy((char *) context, MUDNAME, 128);
     SSL_CTX_set_session_id_context(ctx, context, strlen(context));
   */

  return ctx;
}
示例#9
0
文件: main.cpp 项目: jarulraj/optpls
int main (int argc, char *argv[])
{
  Aoptimizeroptions_t oopt;
  int num_queries = 1, num_rels = 3, num_preds = -1, 
    generate = 0, unparse = 0, header = 0;


 // command line options

  int c;
  extern int my_optind, my_opterr;
  extern char *my_optarg;
  while ((c = my_getopt (argc, argv, 
		      "aAbBcCdeEhHiIJlLmM:n:N:p:rRs:SuvVZ")) != EOF)
    switch (c)
      {
      case 'a': // access_plan
	Aglob_vars()->print_plan = 1;
	break;
      case 'A': // dont use the assembly algorithm
	oopt.dont_use_assembly = 1;
	break;
      case 'b': // dont do bushy_trees, do left deep only
	oopt.left_deep_only = 1;
	break;
      case 'B': // dont do bushy_trees, do right deep only
	oopt.right_deep_only = 1;
	break;
      case 'c': // cartesian_products
	oopt.delay_cartesian_products = 0;
	break;
      case 'C': // dont do mat-collapse
	oopt.do_mat_collapse = 0;
	break;
      case 'd': // dont_execute_queries 
	Aglob_vars()->dont_execute_queries = 1;
	break;
      case 'e': // turn off equivalence classes
	oopt.no_equivalences = 1;
	break;
      case 'E': // dont do exhaustive select positioning
	oopt.do_exhaustive_selects = 0;
	break;
      case 'h': // hash_join
	oopt.do_hash_join = 1;	
	break;
      case 'H': // print the header
	header = 1;
	break;
      case 'i': // index heuristic
	oopt.do_idx_heuristic = 1;
	break;
      case 'I': // dont do path indexes
	oopt.do_path_indexes = 0;
	break;
      case 'J': // dont do mat to join conversion
	oopt.do_mat_to_join = 0;
	break;
      case 'l': // dont split the unexpanded node lists
	oopt.dont_split_lists = 1;
	break;
      case 'L': // dont do select collapse
	oopt.do_select_collapse = 0;
	break;
      case 'm': // merge_join
	oopt.do_merge_join = 1;
	break;
      case 'M': // set the memory size (per operator)
	memory_per_operator = atoi (my_optarg);
	break;
      case 'n': // -n <num>  number of relations
	num_rels = atoi (my_optarg);
	break;
      case 'N': // -N <num>  number of queries 
	num_queries = atoi (my_optarg);
	break;
      case 'p': // -p <num>   number of predicates
	num_preds = atoi (my_optarg);
	break;
      case 'r': // randomize
	srand (generate_seed ());
	break;
      case 'R': // dont read query from file
	generate = 1;
	break;
//       case 's': // -seed <num>   set the seed of the random number generator
// 	srand (atoi (my_optarg));
// 	break;
      case 's': // run setup. 
	use_tcl = 1;
	break;
      case 'S': // secondary joins
	Aglob_vars()->no_secondary_joins = 0;
	break;
      case 'u': // unparse
	unparse = 1;
	break;
      case 'v': // verbose mode. (print stats).
	Aglob_vars()->print_stats = 1;
	break;
      case 'V': // dont use inverse links
	oopt.do_inverse_links = 0;
	break;
      case 'w': // do nothing
	oopt.all_operator_trees = 0;
	oopt.all_operator_trees = 0;
	break;
      case 'W': // do nothing
	oopt.all_operator_trees = 10;
	oopt.all_operator_trees = 0;
	break;
      case 'x': // do nothing
	oopt.all_operator_trees = 90;
	oopt.all_operator_trees = 20;
	break;
      case 'X': // do nothing
	oopt.all_operator_trees = 80;
	oopt.all_operator_trees = 30;
	break;
      case 'y': // do nothing
	oopt.all_operator_trees = 70;
	oopt.all_operator_trees = 5;
	break;
      case 'Y': // do nothing
	oopt.all_operator_trees = -1;
	oopt.all_operator_trees = 60;
	break;
      case 'Z': // dummy argument. ignored.
	break;
      default:
	std::cerr << "usage: " << argv[0] << " [options]" << std::endl
	  << "where options are" << std::endl
	     << " -a\t\tprint the access plan" << std::endl
	     << " -A\t\tdont use the assembly algorithm" << std::endl
	     << " -b\t\tdont do bushy trees, do left deep only" << std::endl
	     << " -B\t\tdont do bushy trees, do right deep only" << std::endl
	     << " -c\t\ttry cartesian products too" << std::endl
	     << " -C\t\tdont do mat collapse" << std::endl
	     << " -d\t\tdont execute queries" << std::endl
	     << " -e\t\tturn off equivalence classes" << std::endl
	     << " -E\t\tdont do exhaustive selects" << std::endl
	     << " -h\t\tuse hash join as a join algorithm too" << std::endl
	     << " -H\t\tprint the header" << std::endl
	     << " -i\t\timplement the index join heuristic" << std::endl
	     << " -I\t\tdont use path indexes" << std::endl
	     << " -l\t\tdont split the unexpanded nodes lists" << std::endl
	     << " -L\t\tdont do select collapse" << std::endl
	     << " -m\t\tuse merge join as a join algorithm too" << std::endl
	     << " -M\t\tset the memory size per operator (pages)" << std::endl
	     << " -n <num>\tnumber of relations to join." << std::endl
	     << " -N <num>\tnumber of queries to run" << std::endl
	     << " -p <num>\tnumber of predicates in where clause" << std::endl
	     << " -r\t\trandomize the random number generator" << std::endl
	     << " -R\t\tread query from file \".query\"" << std::endl
	     << " -s <num>\tset seed for random number generator" << std::endl
	     << " -S\t\tgenerate secondary join predicates too" << std::endl
	     << " -u\t\tunparse and print the generated query" << std::endl
	     << " -v\t\tverbose mode. print statistics and stuff." << std::endl
	     << " -V\t\tdont use inverse links." << std::endl
	     << " -Z\t\tdummy argument. this is ignored." << std::endl;
	exit (1);
	break;
      }

  // setting up the stuff

  Acat_t catalog;
  Asearch_t search;
  Ahashtable_t hashtable (1021);
  Bparser_state_t parser_state;

  Aglob_vars()->cat = &catalog;
  Aglob_vars()->search = &search;
  Aglob_vars()->oopt = &oopt;
  if (getenv ("allops")) Aglob_vars()->oopt->all_operator_trees = 1;

  Aglob_vars()->hashtable = &hashtable;
  Aglob_vars()->parser_state = &parser_state;

  // set up the catalogs
  std::ifstream catfile (".catalog");
  if (!catfile.is_open()) {
    std::cout << "Error opening catalog";
    exit(1);
  }
  //assert (!!catfile);
  catalog.read (catfile);

  
  // do queries.

  if (num_preds < 0) num_preds = num_rels - 1; 
				// useful default
  if (header)
    std::cout
//      << setw (10) << "Startup" 
//      << setw (10) << "Setup" 
      << setw (7) << "SL_tot"
      << setw (7) << "SL_max"
      << setw (7) << "SP_tot"
      << setw (7) << "SP_max"
      << setw (7) << "TotLog"
      << setw (7) << "MaxLog"
      << setw (7) << "TotPhy"
      << setw (7) << "MaxPhy"
      << " "
      << setw (10) << "Cost"
      << " "
      << setw (10) << "OptTime" << std::endl;

//  if (use_tcl)
//    setup_tcl ();

  if (generate)
    for (int i=0; i<num_queries; i++)
      generate_and_execute (num_rels, num_preds, unparse);
  else
    queries_from_parser ();

  return 0;
}
示例#10
0
int main(void)
{
    int     i;
	BIO*    bio_out;

    RSA*    public_key          = NULL;
    RSA*    private_key         = NULL;
    BIGNUM* public_key_exponent = NULL;
    RSA*    key_pair            = NULL;

    int     ciphertext_len      = 0;
    int     plaintext_len       = 0;
    unsigned char*  ciphertext  = NULL;
    unsigned char*  plaintext   = NULL;


    unsigned char   seed_data[SEED_SIZE];

    /* The data to encrypt. The data, in ASCII form is: "Test Data!" */
    unsigned char data[]  = "\x54\x65\x73\x74\x20\x44\x61\x74\x61\x21";

    /* Length of the above data. For PKCS #1 v1.5, this length must be 11 bytes less than the size of the modulus */
    int data_length       = sizeof(data) - 1;

    /* Before generating the keys, the pseudo-random number generator must be seeded */
    generate_seed(seed_data, SEED_SIZE);
    RAND_seed(seed_data, SEED_SIZE);

    /* Generate a 2048-bit key pair with a public exponent of 65537 (RSA_F4) */
    public_key_exponent = BN_new();
    key_pair            = RSA_new();

    BN_set_word(public_key_exponent, RSA_F4);
    RSA_generate_key_ex(key_pair, 2048, public_key_exponent, NULL);

    /*
        NOTE: In the following instance, we split the key-pair in to public and private keys.
              This is not necessary for this code to be functional. We do this because we don't
              want our private key information to be distributed with the public key.
    */

    public_key  = retrieve_public_key(key_pair);
    private_key = retrieve_private_key(key_pair);

    /* Retrieve the ciphertext length (i.e. size of the modulus) */
    ciphertext_len  = RSA_size(public_key);

    /* Allocate the required amount of memory for the ciphertext. */
    ciphertext      = (unsigned char*) calloc(ciphertext_len, sizeof(unsigned char));    
    
    /* Carry out the encryption */
    if ((ciphertext_len = RSA_public_encrypt(data_length, data, ciphertext, public_key, RSA_PKCS1_OAEP_PADDING)) == -1)
    {        
        fprintf(stderr, "Error carrying out encryption. Error code: %lu\n", ERR_get_error());
        exit(1);
    }

    /* Setup output */
    bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);

    BIO_printf(bio_out, "Original plaintext: %s\n\n", data);
    BIO_printf(bio_out, "Ciphertext: ");


    /* Print out the ciphertext */
    for (i = 0; i < ciphertext_len; i++)
        BIO_printf(bio_out, "%02x", ((unsigned char*)ciphertext)[i]);

    BIO_printf(bio_out, "\n\n");


    /* Start the decryption process */

    /* Allocate the same amount of memory (as for the ciphertext) for the plaintext. */
    plaintext   = (unsigned char*) calloc(ciphertext_len, sizeof(unsigned char)); 

    /* Now, carry out the decryption */ 
    if ((plaintext_len = RSA_private_decrypt(ciphertext_len, ciphertext, plaintext, private_key, RSA_PKCS1_OAEP_PADDING)) == -1)
    {
        fprintf(stderr, "Error carrying out the decryption. Error code: %lu\n", ERR_get_error());
        exit(1);
    }
        
    BIO_printf(bio_out, "Recovered plaintext: ");    

    /* Print out the plaintext. Note: We use the length returned by RSA_private_decrypt */
    for (i = 0; i < plaintext_len; i++)
        BIO_printf(bio_out, "%c", ((unsigned char*)plaintext)[i]);

    BIO_printf(bio_out, "\n\n");


    free(ciphertext);
    free(plaintext);

    BIO_free(bio_out);

    RSA_free(public_key);
    RSA_free(private_key);
    RSA_free(key_pair);

    return 0;
}
示例#11
0
int main(int argc, char **argv)
{
  if(argc < 3) print_usage(usage, NULL);

  // Sample reads from ref
  char *refpath = NULL;
  // int optt = 0, tlen = 800; double tlen_stddev = 0.1;
  int insert = 250, rlen = 250, single_ended = 0;
  double depth = 1.0, insert_stddev_prop = 0.2; // stddev as proportion of insert
  int optr = 0, opti = 0, optv = 0, optl = 0, optd = 0; // keeps track of values
  uint64_t seed = generate_seed(); // default RNG seed

  char *in0path = NULL, *in1path = NULL;

  char *profile_paths[argc];
  size_t num_profile_paths = 0, i, total_seq = 0;
  float err_rate = -1;

  int c;
  while((c = getopt(argc, argv, "p:r:i:v:l:d:s1:2:e:g:")) >= 0) {
    switch (c) {
      case 'p': profile_paths[num_profile_paths++] = optarg; break;
      case 'r': refpath = optarg; optr++; break;
      // case 't': tlen = atoi(optarg); optt++; break;
      // case 'v': tlen_stddev = atof(optarg); optv++; break;
      case 'i': insert = atoi(optarg); opti++; break;
      case 'v': insert_stddev_prop = atof(optarg); optv++; break;
      case 'l': rlen = atoi(optarg); optl++; break;
      case 'd': depth = atof(optarg); optd++; break;
      case 's': single_ended = 1; break;
      case '1': in0path = optarg; break;
      case '2': in1path = optarg; break;
      case 'e': err_rate = atof(optarg); break;
      case 'g': seed = atoi(optarg); break;
      default: die("Unknown option: %c", c);
    }
  }

  // Set up
  seed_random(seed);
  init_qual_prob();

  char *outbase = NULL;

  if(optind == argc) {}//print_usage(usage, "Missing <out_base>");
  else if(optind + 1 == argc) outbase = argv[optind];
  else if(optind + 1 < argc) print_usage(usage, "Too many args after %s", outbase);

  if(depth <= 0) print_usage(usage, "Depth [-d] cannot be <= 0");

  if(insert_stddev_prop < 0)
    print_usage(usage, "Insert length standard deviation [-v] cannot be < 0");

  if((opti > 0 || optv > 0 || optl > 0 || optd > 0) && refpath == NULL)
    print_usage(usage, "Missing -r <in.fa>");

  if(optr > 1 || opti > 1 || optv > 1 || optl > 1 || optd > 1)
    print_usage(usage, "Duplicate args");

  if(in0path == NULL && in1path != NULL)
    print_usage(usage, "-2 <in> requires -1 <in>");

  if(in0path != NULL && in1path == NULL) {
    if(refpath == NULL) single_ended = 1;
    else if(!single_ended) print_usage(usage, "Missing -2 for paired-end output");
  }

  if(in0path != NULL && num_profile_paths == 0)
    print_usage(usage, "Need at least one -p <profile.fq.gz> to use -1 .. -2 ..");

  if(num_profile_paths == 0 && refpath == NULL)
    print_usage(usage, "Need one of -p or -r");

  if(num_profile_paths == 0 && outbase == NULL)
    print_usage(usage, "More options required");

  if(num_profile_paths > 0 && err_rate >= 0)
    print_usage(usage, "Cannot use both -p and -E");

  // Profile reads
  FileList fliststore, *flist = NULL;
  if(num_profile_paths > 0) {
    flist = &fliststore;
    filelist_alloc(flist, profile_paths, num_profile_paths);
  }

  if(outbase == NULL)
  {
    // Summarise error profile in input
    filelist_mean_err(flist);
  }
  else
  {
    size_t outlen = strlen(outbase), extlen = strlen(".1.fa.gz");
    char out0path[outlen+extlen+1], out1path[outlen+extlen+1];
    memcpy(out0path, outbase, outlen);
    memcpy(out1path, outbase, outlen);

    if(single_ended) strcpy(out0path+outlen, ".fa.gz");
    else {
      strcpy(out0path+outlen, ".1.fa.gz");
      strcpy(out1path+outlen, ".2.fa.gz");
    }

    gzFile gzout0 = NULL, gzout1 = NULL;
    seq_file_t *sf0 = NULL, *sf1 = NULL, *reffile = NULL;

    if(in0path != NULL && (sf0 = seq_open(in0path)) == NULL) die("Cannot read: %s", in0path);
    if(in1path != NULL && (sf1 = seq_open(in1path)) == NULL) die("Cannot read: %s", in1path);

    if(refpath != NULL)
    {
      if((reffile = seq_open(refpath)) == NULL) die("Cannot read: %s", refpath);
      if((gzout0 = gzopen(out0path, "w")) == NULL) die("Cannot open: %s", out0path);
      if(!single_ended && (gzout1 = gzopen(out1path, "w")) == NULL)
        die("Cannot open: %s", out1path);
    }

    if(sf0 != NULL) {
      printf("Adding error to input reads...\n");
      total_seq += mutate_reads(sf0, gzout0, flist, err_rate);
      seq_close(sf0);
    }
    if(sf1 != NULL) {
      total_seq += mutate_reads(sf1, single_ended ? gzout0 : gzout1, flist, err_rate);
      seq_close(sf1);
    }

    if(refpath != NULL)
    {
      printf("Sampling from %s\n", refpath);
      printf(" sequencing depth: %.2f\n", depth);
      printf(" read length: %i\n", rlen);
      printf(" read pairs: %s\n", single_ended ? "no" : "yes");
      if(!single_ended) {
        printf(" insert length: %i\n", insert);
        printf(" insert stddev: %.2f * insert = %.2f\n",
               insert_stddev_prop, insert_stddev_prop*insert);
      }
      if(num_profile_paths > 0) {
        printf(" seq error files: %s", flist->files[0]->path);
        for(i = 1; i < num_profile_paths; i++)
          printf(",%s", flist->files[i]->path);
        printf("\n");
      } else if(err_rate >= 0) {
        printf(" seq error rate: %.2f%%\n", err_rate * 100.0);
      } else {
        printf(" sequencing errors: no\n");
      }
      total_seq += sim_reads(reffile, gzout0, gzout1, flist, err_rate,
                             insert, insert_stddev_prop*insert, rlen, depth);
      seq_close(reffile);
    }

    if(gzout0 != NULL && gzout1 != NULL)
      printf("Wrote %zu bases to: %s and %s\n", total_seq, out0path, out1path);
    else if(gzout0 != NULL)
      printf("Wrote %zu bases to: %s\n", total_seq, out0path);

    if(gzout0 != NULL) gzclose(gzout0);
    if(gzout1 != NULL) gzclose(gzout1);
  }

  if(flist != NULL)
  {
    // Print error distribution
    size_t err_total = 0;
    for(i = 0; i < flist->errors_len; i++) err_total += flist->errors[i];
    printf("Errors: %zu / %zu (%.2f%%)\n", err_total, total_seq,
                                           (100.0*err_total) / total_seq);
    for(i = 0; i < flist->errors_len; i++) printf(" %zu", flist->errors[i]);
    printf("\n");

    filelist_dealloc(flist);
  }

  return EXIT_SUCCESS;
}