Ejemplo n.º 1
0
static int add_to_blks_list(struct asfd *asfd, struct conf *conf,
	struct slist *slist, struct blist *blist, struct win *win)
{
	struct sbuf *sb=slist->last_requested;
	if(!sb) return 0;
	if(blks_generate(asfd, conf, sb, blist, win)) return -1;

	// If it closed the file, move to the next one.
	if(sb->burp2->bfd.mode==BF_CLOSED) slist->last_requested=sb->next;

	return 0;
}
Ejemplo n.º 2
0
static int add_to_blks_list(struct asfd *asfd, struct conf **confs,
	struct slist *slist)
{
	int just_opened=0;
	struct sbuf *sb=slist->last_requested;
	if(!sb) return 0;

	if(sb->protocol2->bfd.mode==BF_CLOSED)
	{
		char buf[32];
		struct cntr *cntr=NULL;
		if(confs) cntr=get_cntr(confs);
		switch(rabin_open_file(sb, asfd, cntr, confs))
		{
			case 1: // All OK.
				break;
			case 0: // Could not open file. Tell the server.
				base64_from_uint64(sb->protocol2->index, buf);
				if(asfd->write_str(asfd, CMD_INTERRUPT, buf))
					return -1;
				if(slist_del_sbuf(slist, sb))
					return -1;
				sbuf_free(&sb);
				return 0;
			default:
				return -1;
		}
		just_opened=1;
	}

	switch(blks_generate(sb, slist->blist, just_opened))
	{
		case 0: // All OK.
			break;
		case 1: // File ended.
			if(rabin_close_file(sb, asfd))
			{
				logp("Failed to close file %s\n",
					iobuf_to_printable(&sb->path));
				return -1;
			}
			slist->last_requested=sb->next;
			break;
		default:
			return -1;
	}

	return 0;
}