Re: [PATCH v3 26/51] test: Add code to read input from a file (or stdin)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 21, 2015 at 05:45:56PM +0100, Frediano Ziglio wrote:
> This allow to emulate reading from network

'allows'

> @@ -540,10 +551,25 @@ int main(int argc, char **argv)
>  	hfs = g_ptr_array_new_with_free_func(free);
>  	spice_register_fields(1, NULL);
>  
> +	/* read message from standard input */
> +	buf = malloc(max_message_size);
> +	assert(buf);
> +	p = buf;
> +	pend = buf + max_message_size;
> +	while (p < pend && (size = fread(p, 1, pend - p, f)) > 0)
> +		p += size;
> +	assert(p < pend);
> +	assert(!ferror(f));
> +	size = p - buf;

This could probably use glib stream functions as well, which might make
the code a bit simpler (or more complicated given that this is very
short ;) I'd tend to move this bit to a small separate helper though for
readability.

Christophe

Attachment: pgpSTCKEHdKRo.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]