static RNG *
get_rng (void)
{
  static RNG rng;
  static bool rng_initialized = false;

  if (!rng_initialized)
    {
      if (!check_result (InitRng (&rng)))
        return NULL;
      rng_initialized = true;
    }

  return &rng;
}
Esempio n. 2
0
int cgroup_add(unicorn_t * u){
	int i;
	for (i=0; i< cgroup_subsystems_lengh; i++){
		char system_path[80];
		check_result(sprintf(system_path, "%s/%s", cgroup_base_dir, cgroup_subsystems[i]),system_path);

		char cmd[100];
		check_result(sprintf(cmd, "mkdir -p %s/%s", system_path, u->unicorn_id),cmd);
		check_result(system(cmd), "system call mkdir ");

		// char file_path[100];
		// check_result(sprintf(file_path, "%s/%s/%s/tasks", cgroup_base_dir, cgroup_subsystems[i], u->unicorn_id),file_path);

  //       char value[10];
  //       check_result(sprintf(value, "%d", u->child_pid), value);
  //       printf("write value %s to %s \n", value, file_path);	
		// FILE * f = fopen(file_path, "w");
		// if(f == NULL){
		// 	printf("open file error %s \n", strerror(errno));
		// 	exit(errno);
		// }
		// int rt = fputs("2345", f);
		// if( rt < 0) {
		// 	printf("write task file error %s ", cgroup_subsystems[i]);
		// 	exit(-1);
		// }
		// printf("write %d chars \n", rt);
        if( strcmp(cgroup_subsystems[i], "cpuset") == 0){
        	check_result(sprintf(cmd, "cat %s/cpuset.mems > %s/%s/cpuset.mems", system_path, system_path, u->unicorn_id),cmd);
        	check_result(system(cmd), "system call add cpuset.mems ");

        	check_result(sprintf(cmd, "cat %s/cpuset.cpus > %s/%s/cpuset.cpus", system_path, system_path, u->unicorn_id),cmd);
        	check_result(system(cmd), "system call add cpuset.cpus ");

        }
		check_result(sprintf(cmd, "echo %d > %s/%s/tasks", u->child_pid, system_path, u->unicorn_id),cmd);
		check_result(system(cmd), "system call add pid ");
    }

	return 0;
}
bool
tr_rand_buffer (void   * buffer,
                size_t   length)
{
  bool ret;
  tr_lock * rng_lock = get_rng_lock ();

  assert (buffer != NULL);

  tr_lockLock (rng_lock);
  ret = check_result (RNG_GenerateBlock (get_rng (), buffer, length));
  tr_lockUnlock (rng_lock);

  return ret;
}
Esempio n. 4
0
int flatcc_verify_struct_as_nested_root(flatcc_table_verifier_descriptor_t *td,
        voffset_t id, int required, const char *fid, uint16_t align, size_t size)
{
    const uoffset_t *buf;
    uoffset_t bufsiz;

    check_result(flatcc_verify_vector_field(td, id, required, align, 1, FLATBUFFERS_COUNT_MAX(1)));
    if (0 == (buf = get_field_ptr(td, id))) {
        return flatcc_verify_ok;
    }
    buf = (const uoffset_t *)((size_t)buf + read_uoffset(buf, 0));
    bufsiz = read_uoffset(buf, 0);
    ++buf;
    return flatcc_verify_struct_as_root(buf, bufsiz, fid, align, size);
}
Esempio n. 5
0
void TopParser::next(TypeDef::Atom *atom)
 {
  TypeDef::State *state=topState();
  
  TypeDef::Rule *rule=Find(state->final->actions,atom);
  
  if( rule )
    {
     Printf(Exception,"App::TopParser::next(...) : rule mismatch");
    }
  
  if( atom ) 
    push(atom,Transition(state->transitions,atom));
  else
    check_result();
 }
Esempio n. 6
0
int ulcd_sd_image_load(ulcd_dev *dev, const char *file, uint16_t x, uint16_t y) {
    // Write commands
    write_char(dev, 0x40);
    write_char(dev, 0x6D);
    serial_write(dev->port, file, strlen(file));
    write_char(dev, 0x00);
    write_word(dev, x);
    write_word(dev, y);
    write_word(dev, 0);

    // Check results
    if(!check_result(dev, "Image load+show failed.")) {
        return 0;
    }
    return 1;
}
Esempio n. 7
0
static int maintain_reactor(int epoll_fd, int action, int fd, int event_type)
{
	CHECK_FD_RETURN(epoll_fd, -1);
	CHECK_FD_RETURN(fd, -1);

	struct epoll_event event;
	memset(&event, 0, sizeof(event));

	event.events = event_type;
	event.data.fd = fd;

	int ret = epoll_ctl(epoll_fd, action, fd, &event);
	check_result(ret, errno, "epoll_ctl");

	return ret;
}
Esempio n. 8
0
/*
 * This could be further simplified by constructing an expected
 * HANDSHAKE_RESULT, and implementing comparison methods for
 * its fields.
 */
static int check_test(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
{
    int ret = 1;
    ret &= check_result(result, test_ctx);
    ret &= check_alerts(result, test_ctx);
    if (result->result == SSL_TEST_SUCCESS) {
        ret &= check_protocol(result, test_ctx);
        ret &= check_servername(result, test_ctx);
        ret &= check_session_ticket(result, test_ctx);
        ret &= (result->session_ticket_do_not_call == 0);
        ret &= check_npn(result, test_ctx);
        ret &= check_alpn(result, test_ctx);
        ret &= check_resumption(result, test_ctx);
    }
    return ret;
}
Esempio n. 9
0
bool
tr_sha1_final (tr_sha1_ctx_t   handle,
               uint8_t       * hash)
{
  bool ret = true;

  if (hash != NULL)
    {
      assert (handle != NULL);

      ret = check_result (ShaFinal (handle, hash));
    }

  tr_free (handle);
  return ret;
}
Esempio n. 10
0
main ()
{
  int	lp;

  int	errors = 0;


  thds = omp_get_max_threads ();
  if (thds == 1) {
    printf ("should be run this program on multi threads.\n");
    exit (0);
  }
  buf = (int *) malloc (sizeof (int) * (LOOPNUM + 1));
  if (buf == NULL) {
    printf ("can not allocate memory.\n");
    exit (1);
  }
  idbuf = (int *) malloc (sizeof (int) * thds);
  if (idbuf == NULL) {
    printf ("can not allocate memory.\n");
    exit (1);
  }
  omp_set_dynamic (0);


  clear ();
  #pragma omp parallel
  {
    #pragma omp for
    for (lp=0; lp<LOOPNUM; lp++) {
      buf[lp] = omp_get_thread_num ();
    }
  }
  errors += check_result ();


  if (errors == 0) {
    printf ("for 010 : SUCCESS\n");
    if (use_thd == 1) {
      printf ("but, for loop executed by 1 thread.\n");
    }
    return 0;
  } else {
    printf ("for 010 : FAILED\n");
    return 1;
  }
}
Esempio n. 11
0
File: dig.c Progetto: Gradwell/bind9
/*%
 * short_form message print handler.  Calls above say_message()
 */
static isc_result_t
short_answer(dns_message_t *msg, dns_messagetextflag_t flags,
	     isc_buffer_t *buf, dig_query_t *query)
{
	dns_name_t *name;
	dns_rdataset_t *rdataset;
	isc_result_t result, loopresult;
	dns_name_t empty_name;
	dns_rdata_t rdata = DNS_RDATA_INIT;

	UNUSED(flags);

	dns_name_init(&empty_name, NULL);
	result = dns_message_firstname(msg, DNS_SECTION_ANSWER);
	if (result == ISC_R_NOMORE)
		return (ISC_R_SUCCESS);
	else if (result != ISC_R_SUCCESS)
		return (result);

	for (;;) {
		name = NULL;
		dns_message_currentname(msg, DNS_SECTION_ANSWER, &name);

		for (rdataset = ISC_LIST_HEAD(name->list);
		     rdataset != NULL;
		     rdataset = ISC_LIST_NEXT(rdataset, link)) {
			loopresult = dns_rdataset_first(rdataset);
			while (loopresult == ISC_R_SUCCESS) {
				dns_rdataset_current(rdataset, &rdata);
				result = say_message(&rdata, query,
						     buf);
				if (result == ISC_R_NOSPACE)
					return (result);
				check_result(result, "say_message");
				loopresult = dns_rdataset_next(rdataset);
				dns_rdata_reset(&rdata);
			}
		}
		result = dns_message_nextname(msg, DNS_SECTION_ANSWER);
		if (result == ISC_R_NOMORE)
			break;
		else if (result != ISC_R_SUCCESS)
			return (result);
	}

	return (ISC_R_SUCCESS);
}
Esempio n. 12
0
// gets a json value from a key
int json_object_get_string(json_t *object, char *key, char **value)
{
  char *value_return = NULL;

  int exit_code = 0;

  check_not_null(object);
  check_not_null(key);
  check_not_null(value);

  json_t *json_string_peek = json_object_get(object, key);
  if (json_string_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_string_peek);
  if (json_typeof_result != JSON_STRING)
  {
    *value = NULL;
    goto cleanup;
  }

  char *value_peek = (char *)json_string_value(json_string_peek);
  if (value_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  check_result(malloc_memcpy_string(&value_return, value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
Esempio n. 13
0
static int
cgm_begin_picture(gx_device_cgm * cdev)
{
    cgm_picture_elements pic;
    cgm_result result;
    cgm_edge_width edge;

    result = cgm_BEGIN_PICTURE(cdev->st, "", 0);
    check_result(result);
    pic.scaling_mode = cgm_scaling_abstract;
    pic.color_selection_mode =
	(cdev->color_info.depth <= 8 ?
	 cgm_color_selection_indexed :
	 cgm_color_selection_direct);
    pic.line_width_specification_mode = cgm_line_marker_absolute;
    pic.edge_width_specification_mode = cgm_line_marker_absolute;
    cgm_set_rect(pic.vdc_extent, 0, 0, cdev->width, cdev->height);
    result = cgm_set_picture_elements(cdev->st, &pic,
				      cgm_set_SCALING_MODE |
				      cgm_set_COLOR_SELECTION_MODE |
				      cgm_set_LINE_WIDTH_SPECIFICATION_MODE |
				      cgm_set_EDGE_WIDTH_SPECIFICATION_MODE |
				      cgm_set_VDC_EXTENT);
    check_result(result);
    result = cgm_BEGIN_PICTURE_BODY(cdev->st);
    check_result(result);
    result = cgm_VDC_INTEGER_PRECISION(cdev->st,
				       (cdev->width <= 0x7fff &&
					cdev->height <= 0x7fff ?
					16 : sizeof(cdev->width) * 8));
    check_result(result);
    edge.absolute.integer = 0;
    result = cgm_EDGE_WIDTH(cdev->st, &edge);
    check_result(result);
    if (cdev->color_info.depth <= 8) {
	cgm_color colors[256];
	int i;

	for (i = 0; i < (1 << cdev->color_info.depth); i++) {
	    gx_color_value rgb[3];

	    (*dev_proc(cdev, map_color_rgb)) ((gx_device *) cdev,
					      (gx_color_index) i, rgb);
	    colors[i].rgb.r =
		rgb[0] >> (gx_color_value_bits - 8);
	    colors[i].rgb.g =
		rgb[1] >> (gx_color_value_bits - 8);
	    colors[i].rgb.b =
		rgb[2] >> (gx_color_value_bits - 8);
	}
	result = cgm_COLOR_TABLE(cdev->st, 0, colors,
				 1 << cdev->color_info.depth);
	check_result(result);
    }
Esempio n. 14
0
int ulcd_draw_pixel(ulcd_dev *dev,
                    uint16_t x, uint16_t y,
                    uint16_t color) {
    char buf[7];
    buf[0] = 0x50;
    buf[1] = x >> 8;
    buf[2] = x & 0xFF;
    buf[3] = y >> 8;
    buf[4] = y & 0xFF;
    buf[5] = color >> 8;
    buf[6] = color & 0xFF;
    serial_write(dev->port, buf, 7);
    if(!check_result(dev, "Error while drawing pixel.")) {
        return 0;
    }
    return 1;
}
Esempio n. 15
0
int solve(ull_t n)
{
	ull_t sum = 0;
	for(ull_t i = 0; i <= n; i++) {
		sum += i * i;
	}
	ull_t sum_square = 0;
	for(ull_t i = 0; i <= n; i++) {
		sum_square += i;
	}
	sum_square = sum_square * sum_square;
	printf("Sum of the squares: %llu\n", sum);
	printf("Square of the sum: %llu\n", sum_square);
	printf("Difference: %llu\n", sum_square - sum);
	check_result(n == 10, sum == 385 && sum_square == 3025);
	return 0;
}
Esempio n. 16
0
// 读取sock peer信息
void getpeerinfo(int fd, char* addr, uint32_t* port)
{
	if (-1 == fd || NULL == addr || NULL == port) {
		assert(0);
		return;
	}

	struct sockaddr_in saddr;
	socklen_t   len = sizeof(saddr);

	int ret = getpeername(fd, (struct sockaddr*)&saddr, &len);
	check_result(ret, errno, "getpeername");
	const char* paddr = inet_ntop(AF_INET, &saddr.sin_addr, addr, INET_ADDRSTRLEN);
	assert(NULL != paddr);

	*port = ntohs(saddr.sin_port);
}
Esempio n. 17
0
/**
 *
 * @brief Mutex lock/unlock test
 *
 * @return N/A
 */
void mutex_test(void)
{
	u32_t et; /* elapsed time */
	int i;

	PRINT_STRING(dashline, output_file);
	et = BENCH_START();
	for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
		k_mutex_lock(&DEMO_MUTEX, K_FOREVER);
		k_mutex_unlock(&DEMO_MUTEX);
	}
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT, "average lock and unlock mutex",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
}
Esempio n. 18
0
static int konoha_test(const char *testname)
{
	verbose_debug = 0;
	verbose_sugar = 0;
	verbose_gc    = 0;
	verbose_code  = 0;
	konoha_t konoha = konoha_open();
	if(preimport != NULL) {
		konoha_preimport((CTX_t)konoha, preimport);
	}
	if(startup_script != NULL) {
		konoha_startup(konoha, startup_script);
	}
	int ret = 0;//OK
	char script_file[256];
	char correct_file[256];
	char result_file[256];
	snprintf(script_file, 256, "%s", testname);
	snprintf(correct_file, 256, "%s.proof", script_file);
	snprintf(result_file, 256, "%s.tested", script_file);
	FILE *fp = fopen(correct_file, "r");
	if (fp == NULL) {
		fprintf(stdout, "no proof file: %s\n", testname);
	}
	stdlog = fopen(result_file, "w");
	((struct _klib2*)konoha->lib2)->Kreport  = Kreport;
	((struct _klib2*)konoha->lib2)->Kreportf = Kreportf;
	konoha_load(konoha, script_file);
	fprintf(stdlog, "Q.E.D.\n");   // Q.E.D.
	fclose(stdlog);
	if(fp != NULL) {
		FILE *fp2 = fopen(result_file, "r");
		ret = check_result(fp, fp2);
		if(ret == 0) {
			fprintf(stdout, "[PASS]: %s\n", testname);
		}
		fclose(fp);
		fclose(fp2);
	}
	else {
		ret = 1;
	}
	konoha_close(konoha);
	return ret;
}
Esempio n. 19
0
static void
show_settings(isc_boolean_t full, isc_boolean_t serv_only) {
	dig_server_t *srv;
	isc_sockaddr_t sockaddr;
	dig_searchlist_t *listent;
	isc_result_t result;

	srv = ISC_LIST_HEAD(server_list);

	while (srv != NULL) {
		char sockstr[ISC_SOCKADDR_FORMATSIZE];

		result = get_address(srv->servername, port, &sockaddr);
		check_result(result, "get_address");

		isc_sockaddr_format(&sockaddr, sockstr, sizeof(sockstr));
		printf("Default server: %s\nAddress: %s\n",
			srv->userarg, sockstr);
		if (!full)
			return;
		srv = ISC_LIST_NEXT(srv, link);
	}
	if (serv_only)
		return;
	printf("\nSet options:\n");
	printf("  %s\t\t\t%s\t\t%s\n",
	       tcpmode ? "vc" : "novc",
	       short_form ? "nodebug" : "debug",
	       debugging ? "d2" : "nod2");
	printf("  %s\t\t%s\n",
	       usesearch ? "search" : "nosearch",
	       recurse ? "recurse" : "norecurse");
	printf("  timeout = %d\t\tretry = %d\tport = %d\tndots = %d\n",
	       timeout, tries, port, ndots);
	printf("  querytype = %-8s\tclass = %s\n", deftype, defclass);
	printf("  srchlist = ");
	for (listent = ISC_LIST_HEAD(search_list);
	     listent != NULL;
	     listent = ISC_LIST_NEXT(listent, link)) {
		     printf("%s", listent->origin);
		     if (ISC_LIST_NEXT(listent, link) != NULL)
			     printf("/");
	}
	printf("\n");
}
Esempio n. 20
0
void
tr_rc4_process (tr_rc4_ctx_t   handle,
                const void   * input,
                void         * output,
                size_t         length)
{
  int output_length;

  assert (handle != NULL);

  if (length == 0)
    return;

  assert (input != NULL);
  assert (output != NULL);

  check_result (EVP_CipherUpdate (handle, output, &output_length, input, length));
}
Esempio n. 21
0
/**
 *
 * @brief Write the number of data chunks into the mailbox
 *
 * @param size    The size of the data chunk.
 * @param count   Number of data chunks.
 * @param time    The total time.
 *
 * @return N/A
 */
void mailbox_put(u32_t size, int count, u32_t *time)
{
	int i;
	unsigned int t;

	Message.rx_source_thread = K_ANY;
	Message.tx_target_thread = K_ANY;

	/* first sync with the receiver */
	k_sem_give(&SEM0);
	t = BENCH_START();
	for (i = 0; i < count; i++) {
		k_mbox_put(&MAILB1, &Message, K_FOREVER);
	}
	t = TIME_STAMP_DELTA_GET(t);
	*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
	check_result();
}
Esempio n. 22
0
static void
parse_name(char **cmdlinep, dns_name_t *name) {
	isc_result_t result;
	char *word;
	isc_buffer_t source;

	word = nsu_strsep(cmdlinep, " \t\r\n");
	if (word == NULL || *word == 0) {
		fprintf(stderr, "could not read owner name\n");
		exit(1);
	}

	isc_buffer_init(&source, word, strlen(word));
	isc_buffer_add(&source, strlen(word));
	result = dns_name_fromtext(name, &source, dns_rootname, 0, NULL);
	check_result(result, "dns_name_fromtext");
	isc_buffer_invalidate(&source);
}
Esempio n. 23
0
int validator_test(void)
{
    int i=0;
    int success_count=0;
    jerif_err err_code = jerif_ok;

    for(i=0; i<validator_test_case_count; i++){
        printf("Test Case #%d\n", i+1);
        err_code = jerif_check_validation(validator_test_case_json_str[i]);
        success_count += check_result(validator_test_case_expected_result[i] == err_code);
    }

    if(success_count >= validator_test_case_count){
        return 0;
    }else{
        return -1;
    }
}
Esempio n. 24
0
isc_result_t
printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
	      isc_buffer_t *target)
{
	isc_result_t result;
	dns_master_style_t *style = NULL;
	unsigned int styleflags = 0;

	if (rdataset == NULL || owner_name == NULL || target == NULL)
		return(ISC_FALSE);

	styleflags |= DNS_STYLEFLAG_REL_OWNER;
	if (nottl)
		styleflags |= DNS_STYLEFLAG_NO_TTL;
	if (noclass)
		styleflags |= DNS_STYLEFLAG_NO_CLASS;
	if (multiline) {
		styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
		styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
		styleflags |= DNS_STYLEFLAG_REL_DATA;
		styleflags |= DNS_STYLEFLAG_OMIT_TTL;
		styleflags |= DNS_STYLEFLAG_TTL;
		styleflags |= DNS_STYLEFLAG_MULTILINE;
		styleflags |= DNS_STYLEFLAG_COMMENT;
	}
	if (multiline || (nottl && noclass))
		result = dns_master_stylecreate(&style, styleflags,
						24, 24, 24, 32, 80, 8, mctx);
	else if (nottl || noclass)
		result = dns_master_stylecreate(&style, styleflags,
						24, 24, 32, 40, 80, 8, mctx);
	else
		result = dns_master_stylecreate(&style, styleflags,
						24, 32, 40, 48, 80, 8, mctx);
	check_result(result, "dns_master_stylecreate");

	result = dns_master_rdatasettotext(owner_name, rdataset, style, target);

	if (style != NULL)
		dns_master_styledestroy(&style, mctx);

	return(result);
}
Esempio n. 25
0
int ulcd_draw_circle(ulcd_dev *dev,
                     uint16_t x, uint16_t y,
                     uint16_t radius,
                     uint16_t color) {
    char buf[9];
    buf[0] = 0x43;
    buf[1] = x >> 8;
    buf[2] = x & 0xFF;
    buf[3] = y >> 8;
    buf[4] = y & 0xFF;
    buf[5] = radius >> 8;
    buf[6] = radius & 0xFF;
    buf[7] = color >> 8;
    buf[8] = color & 0xFF;
    serial_write(dev->port, buf, 9);
    if(!check_result(dev, "Error while drawing circle.")) {
        return 0;
    }
    return 1;
}
Esempio n. 26
0
bool
tr_sha1_final (tr_sha1_ctx_t   handle,
               uint8_t       * hash)
{
  bool ret = true;

  if (hash != NULL)
    {
      unsigned int hash_length;

      assert (handle != NULL);

      ret = check_result (EVP_DigestFinal_ex (handle, hash, &hash_length));

      assert (!ret || hash_length == SHA_DIGEST_LENGTH);
    }

  EVP_MD_CTX_destroy (handle);
  return ret;
}
Esempio n. 27
0
int flatcc_verify_union_field(flatcc_table_verifier_descriptor_t *td,
        voffset_t id, int required, flatcc_union_verifier_f *uvf)
{
    voffset_t vte_type, vte_table;
    const uint8_t *type;

    if (0 == (vte_type = read_vt_entry(td, id - 1))) {
        vte_table = read_vt_entry(td, id);
        verify(vte_table == 0, flatcc_verify_error_union_cannot_have_a_table_without_a_type);
        verify(!required, flatcc_verify_error_type_field_absent_from_required_union_field);
        return flatcc_verify_ok;
    }
    /* No need to check required here. */
    check_result(verify_field(td, id - 1, 0, 1, 1));
    /* Only now is it safe to read the type. */
    vte_table = read_vt_entry(td, id);
    type = (const uint8_t *)td->buf + td->table + vte_type;
    verify(*type || vte_table == 0, flatcc_verify_error_union_type_NONE_cannot_have_a_table);
    return uvf(td, id, *type);
}
Esempio n. 28
0
void Engine::unload_library(const void *data, const char *name)
{
    if (m_process == 0) {
       return;
    }
    for (DynLibList::iterator it = m_dyn_libs.begin();
         it != m_dyn_libs.end(); it++) {
         if (it->data == data) {
            COIRESULT res;
            OFFLOAD_DEBUG_TRACE(2,
               "Unloading library \"%s\"\n",name);
            res = COI::ProcessUnloadLibrary(m_process,it->lib);
            m_dyn_libs.erase(it);
            if (res != COI_SUCCESS) {
                check_result(res, c_unload_library, m_index, res);
            }
            return;
         }
    }
}
Esempio n. 29
0
tr_dh_ctx_t tr_dh_new(uint8_t const* prime_num, size_t prime_num_length, uint8_t const* generator_num,
    size_t generator_num_length)
{
    struct tr_dh_ctx* handle = tr_new0(struct tr_dh_ctx, 1);

    TR_ASSERT(prime_num != NULL);
    TR_ASSERT(generator_num != NULL);

    API(InitDhKey)(&handle->dh);

    if (!check_result(API(DhSetKey)(&handle->dh, prime_num, prime_num_length, generator_num, generator_num_length)))
    {
        tr_free(handle);
        return NULL;
    }

    handle->key_length = prime_num_length;

    return handle;
}
Esempio n. 30
0
static void
printsoa(dns_rdata_t *rdata) {
	dns_rdata_soa_t soa;
	isc_result_t result;
	char namebuf[DNS_NAME_FORMATSIZE];

	result = dns_rdata_tostruct(rdata, &soa, NULL);
	check_result(result, "dns_rdata_tostruct");

	dns_name_format(&soa.origin, namebuf, sizeof(namebuf));
	printf("\torigin = %s\n", namebuf);
	dns_name_format(&soa.contact, namebuf, sizeof(namebuf));
	printf("\tmail addr = %s\n", namebuf);
	printf("\tserial = %u\n", soa.serial);
	printf("\trefresh = %u\n", soa.refresh);
	printf("\tretry = %u\n", soa.retry);
	printf("\texpire = %u\n", soa.expire);
	printf("\tminimum = %u\n", soa.minimum);
	dns_rdata_freestruct(&soa);
}