Esempio n. 1
0
static int read_char(dearmour_arg_t *arg,ops_error_t **errors,
		     ops_reader_info_t *rinfo,
		     ops_parse_cb_info_t *cbinfo,
		     ops_boolean_t skip)
    {
    unsigned char c[1];

    do
	{
	if(arg->npushed_back)
	    {
	    c[0]=arg->pushed_back[--arg->npushed_back];
	    if(!arg->npushed_back)
		{
		free(arg->pushed_back);
		arg->pushed_back=NULL;
		}
	    }
	/* XXX: should ops_stacked_read exist? Shouldn't this be a limited_read? */
	else if(ops_stacked_read(c,1,errors,rinfo,cbinfo) != 1)
	    return -1;
	}
    while(skip && c[0] == '\r');

    arg->prev_nl=arg->seen_nl;
    arg->seen_nl=c[0] == '\n';

    return c[0];
    }
Esempio n. 2
0
static int hash_reader(void *dest,size_t length,ops_error_t **errors,
		       ops_reader_info_t *rinfo,ops_parse_cb_info_t *cbinfo)
    {
    ops_hash_t *hash=ops_reader_get_arg(rinfo);
    int r=ops_stacked_read(dest,length,errors,rinfo,cbinfo);

    if(r <= 0)
	return r;
	
    hash->add(hash,dest,r);

    return r;
    }
Esempio n. 3
0
static int sum16_reader(void *dest_,size_t length,ops_error_t **errors,
			ops_reader_info_t *rinfo,ops_parse_cb_info_t *cbinfo)
    {
    const unsigned char *dest=dest_;
    sum16_arg_t *arg=ops_reader_get_arg(rinfo);
    int r=ops_stacked_read(dest_,length,errors,rinfo,cbinfo);
    int n;

    if(r < 0)
	return r;

    for(n=0 ; n < r ; ++n)
	arg->sum=(arg->sum+dest[n])&0xffff;

    return r;
    }