Exemple #1
0
static int maybe_add_from_scan(struct manios *manios,
	struct slist *slist, struct asfd *chfd, struct sbuf **csb)
{
	int ret=-1;
	struct sbuf *snew=NULL;

	while(1)
	{
		sbuf_free(&snew);
		if(!manios->phase1) return 0;
		// Limit the amount loaded into memory at any one time.
		if(slist && slist->head)
		{
			if(slist->head->protocol2->index
			  - slist->tail->protocol2->index>4096)
				return 0;
		}
		if(!(snew=sbuf_alloc(PROTO_2))) goto end;

		switch(manio_read(manios->phase1, snew))
		{
			case 0: break;
			case 1: manio_close(&manios->phase1);
				ret=0; // Finished.
			default: goto end;
		}

		switch(entry_changed(snew, manios, chfd, csb))
		{
			case 0: continue; // No change.
			case 1: break;
			default: goto end; // Error.
		}

		if(data_needed(snew)) snew->flags|=SBUF_NEED_DATA;

		slist_add_sbuf(slist, snew);
		snew=NULL;
	}
	return 0;
end:
	sbuf_free(&snew);
	return ret;
}
Exemple #2
0
static int maybe_add_from_scan(struct asfd *asfd,
	struct manio *p1manio, struct manio *cmanio,
	struct manio *unmanio, struct slist *slist, struct conf *conf)
{
	int ret=-1;
	static int ars;
	static int ec=0;
	struct sbuf *snew=NULL;

	while(1)
	{
		if(manio_closed(p1manio)) return 0;
		// Limit the amount loaded into memory at any one time.
		if(slist && slist->head)
		{
			if(slist->head->burp2->index
			  - slist->tail->burp2->index>4096)
				return 0;
		}
		if(!(snew=sbuf_alloc(conf))) goto end;

		if((ars=manio_sbuf_fill(p1manio,
			asfd, snew, NULL, NULL, conf))<0) goto end;
		else if(ars>0) return 0; // Finished.

		if(!(ec=entry_changed(asfd, snew, cmanio, unmanio, conf)))
		{
			// No change, no need to add to slist.
			continue;
		}
		else if(ec<0) goto end; // Error.

		if(data_needed(snew)) snew->flags|=SBUF_NEED_DATA;

		slist_add_sbuf(slist, snew);
	}
	return 0;
end:
	sbuf_free(&snew);
	return ret;
}