コード例 #1
0
ファイル: backup_phase2.c プロジェクト: EmisFR/burp
// Return -1 for error, 0 for entry not changed, 1 for entry changed (or new).
static int entry_changed(struct sbuf *sb,
	struct manios *manios, struct asfd *chfd, struct sbuf **csb)
{
	static int finished=0;
	static struct blk *blk=NULL;

	if(finished) return 1;

	if((*csb)->path.buf)
	{
		// Already have an entry.
	}
	else
	{
		// Need to read another.
		if(!blk && !(blk=blk_alloc())) return -1;
		switch(manio_read_with_blk(manios->current,
			*csb, blk, NULL))
		{
			case 1: // Reached the end.
				sbuf_free(csb);
				blk_free(&blk);
				finished=1;
				return 1;
			case -1: return -1;
		}
		if(!(*csb)->path.buf)
		{
			logp("Should have a path at this point, but do not, in %s\n", __func__);
			return -1;
		}
		// Got an entry.
	}

	while(1)
	{
		switch(sbuf_pathcmp(*csb, sb))
		{
			case 0: return found_in_current_manifest(*csb, sb,
					manios, &blk, chfd);
			case 1: return 1;
			case -1:
				// Behind - need to read more data from the old
				// manifest.
				switch(manio_read_with_blk(manios->current,
					*csb, blk, NULL))
				{
					case 1: // Reached the end.
						sbuf_free(csb);
						blk_free(&blk);
						return 1;
					case -1: return -1;
				}
				// Got something, go back around the loop.
		}
	}

	return 0;
}
コード例 #2
0
ファイル: backup_phase2.c プロジェクト: Kalimeiro/burp
// Return -1 for error, 0 for entry not changed, 1 for entry changed (or new).
static int entry_changed(struct asfd *asfd, struct sbuf *sb,
	struct manio *cmanio, struct manio *unmanio, struct conf *conf)
{
	static int finished=0;
	static struct sbuf *csb=NULL;
	static struct blk *blk=NULL;

	if(finished) return 1;

	if(!csb && !(csb=sbuf_alloc(conf))) return -1;

	if(csb->path.buf)
	{
		// Already have an entry.
	}
	else
	{
		// Need to read another.
		if(!blk && !(blk=blk_alloc())) return -1;
		switch(manio_sbuf_fill(cmanio, asfd, csb, blk, NULL, conf))
		{
			case 1: // Reached the end.
				sbuf_free(&csb);
				blk_free(&blk);
				finished=1;
				return 1;
			case -1: return -1;
		}
		if(!csb->path.buf)
		{
			logp("Should have a path at this point, but do not, in %s\n", __func__);
			return -1;
		}
		// Got an entry.
	}

	while(1)
	{
		switch(sbuf_pathcmp(csb, sb))
		{
			case 0: return found_in_current_manifest(asfd, csb, sb,
					cmanio, unmanio, &blk, conf);
			case 1: return 1;
			case -1:
				// Behind - need to read more data from the old
				// manifest.
				switch(manio_sbuf_fill(cmanio, asfd,
					csb, blk, NULL, conf))
				{
					case -1: return -1;
					case 1:
					{
						// Reached the end.
						sbuf_free(&csb);
						blk_free(&blk);
						return 1;
					}
				}
				// Got something, go back around the loop.
		}
	}

	return 0;
}
コード例 #3
0
ファイル: backup_phase2.c プロジェクト: pablodav/burp
// Return -1 for error, 0 for entry not changed, 1 for entry changed (or new).
static int entry_changed(struct sbuf *sb,
	struct manios *manios, struct asfd *chfd, struct sbuf **csb,
	struct cntr *cntr)
{
	static int finished=0;
	int pcmp;

	if(finished)
	{
		cntr_add_new(cntr, sb->path.cmd);
		return 1;
	}

	if(*csb && (*csb)->path.buf)
	{
		// Already have an entry.
	}
	else
	{
		// Need to read another.
		switch(manio_read(manios->current, *csb))
		{
			case 1: // Reached the end.
				sbuf_free(csb);
				finished=1;
				cntr_add_new(cntr, sb->path.cmd);
				return 1;
			case -1: return -1;
		}
		if(!(*csb)->path.buf)
		{
			logp("Should have a path at this point, but do not, in %s\n", __func__);
			return -1;
		}
		// Got an entry.
	}

	while(1)
	{
		if(!(pcmp=sbuf_pathcmp(*csb, sb)))
			return found_in_current_manifest(*csb, sb,
					manios, chfd, cntr);
		else if(pcmp>0)
		{
			cntr_add_new(cntr, sb->path.cmd);
			return 1;
		}
//		cntr_add_deleted(cntr, (*csb)->path.cmd);
		// Behind - need to read more data from the old manifest.
		switch(manio_read(manios->current, *csb))
		{
			case 1: // Reached the end.
				sbuf_free(csb);
				cntr_add_new(cntr, sb->path.cmd);
				return 1;
			case -1: return -1;
		}
		// Got something, go back around the loop.
	}

	return 0;
}