Ejemplo n.º 1
0
Archivo: slab.c Proyecto: yubo/bird
void *sl_alloc(struct slab * s)
{
    struct sl_obj *o = xmalloc(sizeof(struct sl_obj) + s->size);

    add_tail(&s->objs, &o->n);
    return o->data;
}
int verificar_parenteses(char formula[],int num){
    int i;

    for(i=0;formula[i]!='\0';i++){
        if(formula[i]=='('){
            add_tail(tail,formula[i]);
//            printf("\n\n");
//            ver_frente(head);
//            printf("\n\n");
           }

        if(formula[i]==')'){
            if(pop_tail(tail)!='('){
               while(pop_tail(tail)!='*');
                return 0;

        }
        }

    }
    if(pop_tail(tail)=='*')return 1;
    else{
            while(pop_tail(tail)!='*');
            return 0;}


}
Ejemplo n.º 3
0
/*
RING<0>
This is the keyboard interrupt handler
*/
PUBLIC	void key_interrupt()
{
	/*get scan code from 8042,and append it in the buffer.*/
	t_8	value;
	value=in_byte(0x60);
	add_tail(kb_input,value);
}
void klist_add_tail(struct klist_node * n, struct klist * k)
{
#if defined(__VMKLNX__)
	VMK_ASSERT(vmk_PreemptionIsEnabled() == VMK_FALSE);
#endif
	klist_node_init(k, n);
	add_tail(k, n);
}
Ejemplo n.º 5
0
Archivo: proto.c Proyecto: tohojo/bird
static void
proto_link_ahooks(struct proto *p)
{
  struct announce_hook *h;

  if (p->rt_notify)
    for(h=p->ahooks; h; h=h->next)
      add_tail(&h->table->hooks, &h->n);
}
Ejemplo n.º 6
0
Archivo: buffer.c Proyecto: dmt4/ne
line_desc_pool *alloc_line_desc_pool(int64_t pool_size) {
	if (pool_size < STD_LINE_DESC_POOL_SIZE) pool_size = STD_LINE_DESC_POOL_SIZE;

	line_desc_pool * const ldp = calloc(1, sizeof(line_desc_pool));
	if (ldp) {
		if (ldp->pool = calloc(pool_size, do_syntax ? sizeof(line_desc) : sizeof(no_syntax_line_desc))) {
			ldp->size = pool_size;
			new_list(&ldp->free_list);
			for(int64_t i = 0; i < pool_size; i++) 
				if (do_syntax) add_tail(&ldp->free_list, &ldp->pool[i].ld_node);
				else add_tail(&ldp->free_list, &((no_syntax_line_desc *)ldp->pool)[i].ld_node);
			return ldp;
		}
		free(ldp);
	}

	return NULL;

}
Ejemplo n.º 7
0
Archivo: lsack.c Proyecto: nabeken/bird
void
ospf_lsack_enqueue(struct ospf_neighbor *n, struct ospf_lsa_header *h,
		   int queue)
{
  struct lsah_n *no = mb_alloc(n->pool, sizeof(struct lsah_n));
  memcpy(&no->lsa, h, sizeof(struct ospf_lsa_header));
  add_tail(&n->ackl[queue], NODE no);
  DBG("Adding (%s) ack for %R, ID: %R, RT: %R, Type: %u\n", s_queue[queue],
      n->rid, ntohl(h->id), ntohl(h->rt), h->type);
}
static struct queue_buffer_s* allocate_buffer_space_back(struct queue_buffer *qb) {
	if (qb->unused_head != NULL) {
		struct queue_buffer_s *buf = qb->unused_head;
		qb->unused_head = qb->unused_head->next;
		add_tail(&qb->used_head, buf);
		return buf;
	}

	return NULL;
}
list str2List(char * str)
{
    list ma_liste = NULL;
    char * ptn;
    ptn = strtok (str,"\n");
    while (ptn != NULL)
    {
        ma_liste = add_tail(ptn,ma_liste);
        ptn = strtok (NULL, "\n");
    }
    return ma_liste;
}
Ejemplo n.º 10
0
struct iface *
krt_temp_iface(struct krt_proto *p, char *name)
{
  struct iface *i;

  WALK_LIST(i, p->scan.temp_ifs)
    if (!strcmp(i->name, name))
      return i;
  i = mb_allocz(p->p.pool, sizeof(struct iface));
  strcpy(i->name, name);
  add_tail(&p->scan.temp_ifs, &i->n);
  return i;
}
Ejemplo n.º 11
0
Archivo: io.c Proyecto: yubo/bird
void
ev2_schedule(struct event *e)
{
  struct birdloop *loop = birdloop_current();

  if (loop->poll_active && EMPTY_LIST(loop->event_list))
    wakeup_kick(loop);

  if (e->n.next)
    rem_node(&e->n);

  add_tail(&loop->event_list, &e->n);
}
Ejemplo n.º 12
0
int get_nameservers(list *servers, const char *def_port)
{
	if (servers == NULL || def_port == NULL) {
		DBG_NULL;
		return KNOT_EINVAL;
	}

	// Initialize list of servers.
	init_list(servers);

	// Read nameservers from resolv file.
	int ret = get_resolv_nameservers(servers, def_port);

	// If found nameservers or error.
	if (ret != 0) {
		return ret;
	// If no nameservers.
	} else {
		server_t *server;

		// Add default ipv6 nameservers.
		server = server_create(DEFAULT_IPV6_NAME, def_port);

		if (server != NULL) {
			add_tail(servers, (node *)server);
		}

		// Add default ipv4 nameservers.
		server = server_create(DEFAULT_IPV4_NAME, def_port);

		if (server != NULL) {
			add_tail(servers, (node *)server);
		}

		return list_size(servers);
	}
}
Ejemplo n.º 13
0
int main(void) {
	struct liste l;
	new_list(&l);
	add_first(1, &l);
	show_list(&l);

	printf( "#1\n" );
	add_tail(2, &l);
	add_first(-10, &l);
	show_list(&l);

	printf( "#2\n" );
	list_remove_tail(&l);
	show_list(&l);

	return 0;
}
Ejemplo n.º 14
0
Archivo: buffer.c Proyecto: dmt4/ne
line_desc *alloc_line_desc(buffer * const b) {
	block_signals();
	
	line_desc_pool *ldp;
	for(ldp = (line_desc_pool *)b->line_desc_pool_list.head; ldp->ldp_node.next; ldp = (line_desc_pool *)ldp->ldp_node.next) {

		assert_line_desc_pool(ldp);

		if (ldp->free_list.head->next) {

			line_desc * const ld = (line_desc *)ldp->free_list.head;

			rem(&ld->ld_node);

			if (!ldp->free_list.head->next) {
				rem(&ldp->ldp_node);
				add_tail(&b->line_desc_pool_list, &ldp->ldp_node);
			}

			ldp->allocated_items++;

			ld->line = NULL;
			ld->line_len = 0;
			if (do_syntax) ld->highlight_state.state = -1;
			release_signals();
			return ld;
		}
	}

	/* No chances, all pools are full. Let's allocate a new one,
	using the standard pool size, and let's put it at the start
	of the list, so that it is always scanned first. */

	if (ldp = alloc_line_desc_pool(0)) {
		add_head(&b->line_desc_pool_list, &ldp->ldp_node);
		line_desc * const ld = (line_desc *)ldp->free_list.head;
		rem(&ld->ld_node);
		ldp->allocated_items = 1;
		if (do_syntax) ld->highlight_state.state = -1;
		release_signals();
		return ld;
	}

	release_signals();
	return NULL;
}
Ejemplo n.º 15
0
static Errcode ld_tween(char *name, Tween_state *ts)
{
	Errcode err;
	XFILE *xf;
	Tween_file_header tfh;
	Tween_link *newl;
	long i;

	err = xffopen(name, &xf, XREADONLY);
	if (err < Success)
		return err;

	err = xffread(xf, &tfh, sizeof(tfh));
	if (err < Success)
		goto cleanup;

	if (tfh.magic != TWEEN_MAGIC) {
		err = Err_bad_magic;
		goto cleanup;
	}

	for (i = 0; i < tfh.link_count; i++) {
		err = news(newl);
		if (err < Success)
			goto cleanup;

		err = xffread(xf, &newl->start, 2*sizeof(newl->start));
		if (err < Success)
			goto cleanup;

		add_tail(&ts->links,&newl->node);
	}

	err = ld_poly(xf, &ts->p0);
	if (err < Success)
		goto cleanup;

	err = ld_poly(xf, &ts->p1);
	if (err < Success)
		goto cleanup;

cleanup:
	xffclose(&xf);
	return err;
}
Ejemplo n.º 16
0
int ls_rep(list ma_liste, char* chemin)
{
    DIR *dp = opendir(chemin);
    if (dp)
    {
        struct dirent *entry;
        while ( (entry = readdir(dp) ))
        {
            if (!(strcmp(".", entry->d_name) && strcmp("..", entry->d_name)))
                continue;
            ma_liste = add_tail(entry->d_name,ma_liste);

        }
        closedir(dp);

        return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
}
void queue_buffer_init(struct queue_buffer *qb, uint8_t buffer_size, uint8_t
		num_items, void *buffer_begin) {

	int i;
	struct queue_buffer_s *b;

	qb->queue_size = 0;
	qb->queue_max_size = num_items;
	qb->buffer_size = buffer_size;
	qb->buffer_begin = buffer_begin;

	qb->unused_head = NULL;
	for(i = 0; i < qb->queue_max_size; ++i) {
		b = ITEM(qb, i);
		add_tail(&qb->unused_head, b);
	}
	qb->used_head = NULL;
	qb->iterator = NULL;
}
Ejemplo n.º 18
0
Archivo: request.c Proyecto: dmt4/ne
int request_document(void) {

	int i = -1;
	req_list rl;
	buffer *b = (buffer *)buffers.head;

	if (b->b_node.next && req_list_init(&rl, NULL, true, true, '*')==OK) {
		i = 0;
		int cur_entry = 0;
		while(b->b_node.next) {
			if (b == cur_buffer) cur_entry = i;
			req_list_add(&rl, b->filename ? b->filename : UNNAMED_NAME, b->is_modified);
			b = (buffer *)b->b_node.next;
			i++;
		}
		rl.ignore_tab = true;
		req_list_finalize(&rl);
		print_message(info_msg[SELECT_DOC]);
		i = request_strings(&rl, cur_entry);
		reset_window();
		draw_status_bar();
		if (i >= 0 && rl.reordered) {
			/* We're going to cheat big time here. We have an array of pointers
				at rl.entries that's big enough to hold all the buffer pointers,
				and that's exactly what we're going to use it for now. */
			b = (buffer *)buffers.head;
			for (int j = 0; b->b_node.next; j++ ) {
				rl.entries[j] = (char *)b;
				b = (buffer *)b->b_node.next;
				rem(b->b_node.prev);
			}
			/* Ack! We're removed all our buffers! */
			for (int j = 0; j < rl.cur_entries; j++) {
				add_tail(&buffers, (node *)rl.entries[rl.orig_order[j]]);
			}
		}

		req_list_free(&rl);
	}

	return i;
}
Ejemplo n.º 19
0
/**
 * proto_add_announce_hook - connect protocol to a routing table
 * @p: protocol instance
 * @t: routing table to connect to
 * @stats: per-table protocol statistics
 *
 * This function creates a connection between the protocol instance @p
 * and the routing table @t, making the protocol hear all changes in
 * the table.
 *
 * The announce hook is linked in the protocol ahook list and, if the
 * protocol accepts routes, also in the table ahook list. Announce
 * hooks are allocated from the routing table resource pool, they are
 * unlinked from the table ahook list after the protocol went down,
 * (in proto_schedule_flush()) and they are automatically freed after the
 * protocol is flushed (in proto_fell_down()).
 *
 * Unless you want to listen to multiple routing tables (as the Pipe
 * protocol does), you needn't to worry about this function since the
 * connection to the protocol's primary routing table is initialized
 * automatically by the core code.
 */
struct announce_hook *
proto_add_announce_hook(struct proto *p, struct rtable *t, struct proto_stats *stats)
{
  struct announce_hook *h;

  DBG("Connecting protocol %s to table %s\n", p->name, t->name);
  PD(p, "Connected to table %s", t->name);

  h = mb_allocz(rt_table_pool, sizeof(struct announce_hook));
  h->table = t;
  h->proto = p;
  h->stats = stats;

  h->next = p->ahooks;
  p->ahooks = h;

  if (p->rt_notify)
    add_tail(&t->hooks, &h->n);
  return h;
}
Ejemplo n.º 20
0
Archivo: cli.c Proyecto: yubo/bird
void
cli_set_log_echo(struct cli *c, uint mask, uint size)
{
  if (c->ring_buf)
    {
      mb_free(c->ring_buf);
      c->ring_buf = c->ring_end = c->ring_read = c->ring_write = NULL;
      rem_node(&c->n);
    }
  c->log_mask = mask;
  if (mask && size)
    {
      c->ring_buf = mb_alloc(c->pool, size);
      c->ring_end = c->ring_buf + size;
      c->ring_read = c->ring_write = c->ring_buf;
      add_tail(&cli_log_hooks, &c->n);
      c->log_threshold = size / 8;
    }
  c->ring_overflow = 0;
}
Ejemplo n.º 21
0
_public_
int knot_requestor_enqueue(struct knot_requestor *requestor,
                           struct knot_request *request)
{
	if (requestor == NULL || request == NULL) {
		return KNOT_EINVAL;
	}

	/* Set socket as uninitialized. */
	request->fd = -1;

	/* Prepare response buffers. */
	request->resp  = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, requestor->mm);
	if (request->resp == NULL) {
		mm_free(requestor->mm, request);
		return KNOT_ENOMEM;
	}

	add_tail(&requestor->pending, &request->node);

	return KNOT_EOK;
}
Ejemplo n.º 22
0
Archivo: proto.c Proyecto: tohojo/bird
static void
proto_relink(struct proto *p)
{
  list *l = NULL;

  switch (p->core_state)
    {
    case FS_HUNGRY:
      l = &inactive_proto_list;
      break;
    case FS_HAPPY:
      l = &active_proto_list;
      break;
    case FS_FLUSHING:
      l = &flush_proto_list;
      break;
    default:
      ASSERT(0);
    }

  rem_node(&p->n);
  add_tail(l, &p->n);
}
Ejemplo n.º 23
0
/* Consumer method
 * Sleeps for random amount of time and adds to seller line after
 */
void *QueueConsumer(void *threadarg) {
    // Get thread args that contain designated seller info
    struct seller_data *my_data;
    my_data = (struct seller_data *) threadarg;
    sleep(rand() % SECS_TO_RUN); // Sleep from 0 - 59 seconds
    pthread_mutex_lock(&my_data->mutex);
    char *str = time_elapsed_string();
    if (my_data->closed != 1) {
        add_tail(my_data, 0); // Add to designated seller line
        printf("%s: A customer has arrived at seller %s\n", str, my_data->name);
    } else {
        // Increment customers who came when seller was closed
        if (my_data->type == H)
            h_closed++;
        else if (my_data->type == M)
            m_closed++;
        else
            l_closed++;
        printf("%s: A customer has arrived at seller %s, but they were already closed\n", str, my_data->name);
    }
    free(str);
    pthread_mutex_unlock(&my_data->mutex);
}
Ejemplo n.º 24
0
static void
proto_enqueue(list *l, struct proto *p)
{
  add_tail(l, &p->n);
  p->last_state_change = now;
}
Ejemplo n.º 25
0
TimeType
ghw_main(char *fname)
{
  struct ghw_handler handle;
  int i;
  int rc;

  if(!GLOBALS->hier_was_explicitly_set) /* set default hierarchy split char */
    {
      GLOBALS->hier_delimeter='.';
    }

 handle.flag_verbose = 0;
 if ((rc=ghw_open (&handle, fname)) < 0)
   {
     fprintf (stderr, "Error opening ghw file '%s', rc=%d.\n", fname, rc);
     return(LLDescriptor(0));        /* look at return code in caller for success status... */
   }

 GLOBALS->time_scale = 1;
 GLOBALS->time_dimension = 'f';
 GLOBALS->asbuf = malloc_2(4097);

 if (ghw_read_base (&handle) < 0)
   {
     free_2(GLOBALS->asbuf);
     GLOBALS->asbuf = NULL;
     fprintf (stderr, "Error in ghw file '%s'.\n", fname);
     return(LLDescriptor(0));        /* look at return code in caller for success status... */
   }

 GLOBALS->min_time = 0;
 GLOBALS->max_time = 0;

 GLOBALS->nbr_sig_ref_ghw_c_1 = 0;

 GLOBALS->nxp_ghw_c_1 =(struct Node **)calloc_2(handle.nbr_sigs, sizeof(struct Node *));
 for(i=0;i<handle.nbr_sigs;i++)
	{
        GLOBALS->nxp_ghw_c_1[i] = (struct Node *)calloc_2(1,sizeof(struct Node));
	}

 GLOBALS->treeroot = build_hierarchy (&handle, handle.hie);
 /* GHW does not contains a 'top' name.
    FIXME: should use basename of the file.  */

 create_facs (&handle);
 read_traces (&handle);
 add_tail (&handle);

 set_fac_name (&handle);
 free_2(GLOBALS->nxp_ghw_c_1); GLOBALS->nxp_ghw_c_1 = NULL;

 /* fix up names on aliased nodes via cloning... */
 for(i=0;i<GLOBALS->numfacs;i++)
	{
	if(strcmp(GLOBALS->facs[i]->name, GLOBALS->facs[i]->n->nname))
		{
		struct Node *n = malloc_2(sizeof(struct Node));
		memcpy(n, GLOBALS->facs[i]->n, sizeof(struct Node));
		GLOBALS->facs[i]->n = n;
		n->nname = GLOBALS->facs[i]->name;
		}
	}

 /* treeroot->name = "top"; */
 {
 const char *base_hier = "top";

 struct tree *t = calloc_2(1, sizeof(struct tree) + strlen(base_hier) + 1);
 memcpy(t, GLOBALS->treeroot, sizeof(struct tree));
 strcpy(t->name, base_hier); /* scan-build false warning here, thinks name[1] is total length */
#ifndef WAVE_TALLOC_POOL_SIZE
 free_2(GLOBALS->treeroot); /* if using tree alloc pool, can't deallocate this */
#endif
 GLOBALS->treeroot = t;
 }

 ghw_close (&handle);

 rechain_facs();	/* vectorize bitblasted nets */
 ghw_sortfacs();	/* sort nets as ghw is unsorted ... also fix hier tree (it should really be built *after* facs are sorted!) */

#if 0
 treedebug(GLOBALS->treeroot,"");
 facs_debug();
#endif

  GLOBALS->is_ghw = 1;

  fprintf(stderr, "["TTFormat"] start time.\n["TTFormat"] end time.\n", GLOBALS->min_time*GLOBALS->time_scale, GLOBALS->max_time*GLOBALS->time_scale);
  if(GLOBALS->num_glitches_ghw_c_1) fprintf(stderr, "Warning: encountered %d glitch%s across %d glitch region%s.\n",
                GLOBALS->num_glitches_ghw_c_1, (GLOBALS->num_glitches_ghw_c_1!=1)?"es":"",
                GLOBALS->num_glitch_regions_ghw_c_1, (GLOBALS->num_glitch_regions_ghw_c_1!=1)?"s":"");

  return GLOBALS->max_time;
}
Ejemplo n.º 26
0
/**
 * klist_add_tail - Initialize a klist_node and add it to back.
 * @n: node we're adding.
 * @k: klist it's going on.
 */
void klist_add_tail(struct klist_node *n, struct klist *k)
{
	klist_node_init(k, n);
	add_tail(k, n);
}
Ejemplo n.º 27
0
static int get_resolv_nameservers(list *servers, const char *def_port)
{
	char	line[512];

	// Open config file.
	FILE *f = fopen(RESOLV_FILE, "r");

	// Check correct open.
	if (f == NULL) {
		return KNOT_ENOENT;
	}

	// Read lines from config file.
	while (fgets(line, sizeof(line), f) != NULL) {
		size_t len;
		char   *pos = line;
		char   *option, *value;

		// Find leading white characters.
		len = strspn(pos, SEP_CHARS);
		pos += len;

		// Start of the first token.
		option = pos;

		// Find length of the token.
		len = strcspn(pos, SEP_CHARS);
		pos += len;

		// Check if the token is not empty.
		if (len <= 0) {
			continue;
		}

		// Find separating white characters.
		len = strspn(pos, SEP_CHARS);
		pos += len;

		// Check if there is a separation between tokens.
		if (len <= 0) {
			continue;
		}

		// Copy of the second token.
		value = strndup(pos, strcspn(pos, SEP_CHARS));

		// Process value with respect to option name.
		if (strncmp(option, "nameserver", strlen("nameserver")) == 0) {
			server_t *server;

			server = parse_nameserver(value, def_port);

			// If value is correct, add nameserver to the list.
			if (server != NULL) {
				add_tail(servers, (node *)server);
			}
		}

		// Drop value string.
		free(value);
	}

	// Close config file.
	fclose(f);

	// Return number of servers.
	return list_size(servers);
}
Ejemplo n.º 28
0
/**
 * ev_enqueue - enqueue an event
 * @l: an event list
 * @e: an event
 *
 * ev_enqueue() stores the event @e to the specified event
 * list @l which can be run by calling ev_run_list().
 */
inline void
ev_enqueue(event_list *l, event *e)
{
  ev_postpone(e);
  add_tail(l, &e->n);
}
Ejemplo n.º 29
0
struct pipes_res *pseek(struct pipes_seek *pcmd, struct pipe *p, int task)
{
	if(p->type == PIPES_FILEPIPE)
	{
		if(fseek(p->pf, pcmd->possition, pcmd->origin))
		{
			return build_response_msg(PIPESERR_EOF);
		}
		else
		{
			return build_response_msg(PIPESERR_OK);
		}
	}
	else
	{
		unsigned long long newpos = 0;

		// calculate new possition
		switch(pcmd->origin)
		{
			case PIPES_SEEK_SET:
				newpos = pcmd->possition;
				break;
			case PIPES_SEEK_CUR:
				newpos = ((task == p->taskid)? p->buffer->wcursor : p->buffer->rcursor) + pcmd->possition;
				break;
			case PIPES_SEEK_END:
				if(p->buffer->size < pcmd->possition) 
					return build_response_msg(PIPESERR_ERR);
				newpos = p->buffer->size - pcmd->possition;
				break;
			default:
				return build_response_msg(PIPESERR_ERR);
		}

		// calculate blocks needed
		unsigned int bc = (int)(newpos / PIPES_BUFFER_SIZE) + ((newpos % PIPES_BUFFER_SIZE == 0)? 0 : 1);

		// if trying to seek beyond with the reading cursor
		if(bc > length(&p->buffer->blocks) && task == p->taskid2)
		{
			// if writing task has not closed, put the message on pending status
			if(p->task1_closed)
			{
				return build_response_msg(PIPESERR_EOF);
			}
			p->pending = 1;
			p->pending_cmd = *((struct pipes_cmd*)pcmd);
			return NULL;
		}

		if(task == p->taskid2)
		{
			// get as many new blocks as needed
			while(bc > length(&p->buffer->blocks))
			{
				add_tail(&p->buffer->blocks, alloc_block());	
			}
			p->buffer->rcursor = newpos;
		}
		else
		{
			p->buffer->wcursor = newpos;
		}
		return build_response_msg(PIPESERR_OK);
	}
}
Ejemplo n.º 30
0
static int parse_name(const char *value, list *queries, const query_t *conf)
{
	char	*reverse = get_reverse_name(value);
	char	*fqd_name = NULL;
	query_t	*query;

	// If name is not FQDN, append trailing dot.
	fqd_name = get_fqd_name(value);

	// RR type is known.
	if (conf->type_num >= 0) {
		if (conf->type_num == KNOT_RRTYPE_PTR) {
			free(fqd_name);

			// Check for correct address.
			if (reverse == NULL) {
				ERR("invalid IPv4 or IPv6 address %s\n", value);
				return KNOT_EINVAL;
			}

			// Add reverse query for address.
			query = query_create(reverse, conf);
			free(reverse);
			if (query == NULL) {
				return KNOT_ENOMEM;
			}
			add_tail(queries, (node *)query);
		} else {
			free(reverse);

			// Add query for name and specified type.
			query = query_create(fqd_name, conf);
			free(fqd_name);
			if (query == NULL) {
				return KNOT_ENOMEM;
			}
			add_tail(queries, (node *)query);
		}
	// RR type is unknown, use defaults.
	} else {
		if (reverse == NULL) {
			// Add query for name and type A.
			query = query_create(fqd_name, conf);
			if (query == NULL) {
				free(fqd_name);
				return KNOT_ENOMEM;
			}
			query->type_num = KNOT_RRTYPE_A;
			add_tail(queries, (node *)query);

			// Add query for name and type AAAA.
			query = query_create(fqd_name, conf);
			if (query == NULL) {
				free(fqd_name);
				return KNOT_ENOMEM;
			}
			query->type_num = KNOT_RRTYPE_AAAA;
			add_tail(queries, (node *)query);

			// Add query for name and type MX.
			query = query_create(fqd_name, conf);
			if (query == NULL) {
				free(fqd_name);
				return KNOT_ENOMEM;
			}
			free(fqd_name);
			query->type_num = KNOT_RRTYPE_MX;
			add_tail(queries, (node *)query);
		} else {
			free(fqd_name);

			// Add reverse query for address.
			query = query_create(reverse, conf);
			free(reverse);
			if (query == NULL) {
				return KNOT_ENOMEM;
			}
			query->type_num = KNOT_RRTYPE_PTR;
			add_tail(queries, (node *)query);
		}
	}

	return KNOT_EOK;
}