Beispiel #1
0
rs_filebuf_t *rs_filebuf_new(BFILE *bfd, FILE *fp, gzFile zp, int fd,
	size_t buf_len, size_t data_len, struct cntr *cntr)
{
    rs_filebuf_t *pf=NULL;
    if(!(pf=rs_alloc_struct(rs_filebuf_t))) return NULL;

    if(!(pf->buf=(char *)rs_alloc(buf_len, "file buffer")))
    {
	free(pf);
	return NULL;
    }
    pf->buf_len=buf_len;
    pf->fp=fp;
    pf->zp=zp;
    pf->fd=fd;
    pf->bfd=bfd;
    pf->bytes=0;
    pf->data_len=data_len;
    if(data_len>0)
    	pf->do_known_byte_count=1;
    else
    	pf->do_known_byte_count=0;
    pf->cntr=cntr;
    if(!MD5_Init(&(pf->md5)))
    {
	logp("MD5_Init() failed\n");
	rs_filebuf_free(pf);
	return NULL;
    }

    return pf;
}
Beispiel #2
0
rs_filebuf_t *rs_filebuf_new(FILE *f, size_t buf_len) 
{
    rs_filebuf_t *pf = rs_alloc_struct(rs_filebuf_t);

    pf->buf = rs_alloc(buf_len, "file buffer");
    pf->buf_len = buf_len;
    pf->f = f;

    return pf;
}
Beispiel #3
0
/**
 * \brief Read a signature from a file into an ::rs_signature_t structure
 * in memory.
 *
 * Once there, it can be used to generate a delta to a newer version of
 * the file.
 *
 * \note After loading the signatures, you must call
 * rs_build_hash_table() before you can use them.
 */
rs_job_t *rs_loadsig_begin(rs_signature_t **signature)
{
    rs_job_t *job;

    job = rs_job_new("loadsig", rs_loadsig_s_magic);
    *signature = job->signature = rs_alloc_struct(rs_signature_t);
    job->signature->count = 0;

    return job;
}
Beispiel #4
0
rs_job_t * rs_job_new(char const *job_name, rs_result (*statefn)(rs_job_t *))
{
    rs_job_t *job;

    job = rs_alloc_struct(rs_job_t);

    job->job_name = job_name;
    job->dogtag = rs_job_tag;
    job->statefn = statefn;

    job->stats.op = job_name;

    rs_trace("start %s job", job_name);

    return job;
}
Beispiel #5
0
/**
 * \brief Read a signature from a file into an ::rs_signature_t structure
 * in memory.
 *
 * Once there, it can be used to generate a delta to a newer version of
 * the file.
 *
 * \note After loading the signatures, you must call
 * rs_build_hash_table() before you can use them.
 */
rs_job_t *rs_loadsig_begin(rs_signature_t **signature, FILE *old_file)
{
    rs_job_t *job;

    job = rs_job_new("loadsig", rs_loadsig_s_magic);
    *signature = job->signature = rs_alloc_struct(rs_signature_t);
    job->signature->count = 0;
 
	(*signature)->old_file = old_file;
/*
	FILE *old_file = fopen(old_path, "rb");
	fread(buf, 10, 1, old_file);
	printf("buf =\n%s\n", buf);
	printf("OOOOO\n");
*/
    return job;
}