File: loadhttptest.c

package info (click to toggle)
aravis 0.8.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,028 kB
  • sloc: ansic: 38,758; xml: 1,384; python: 371; sh: 275; makefile: 60; javascript: 58; cpp: 6
file content (54 lines) | stat: -rw-r--r-- 1,175 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* SPDX-License-Identifier:Unlicense */

#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <stdio.h>
#include <arv.h>

#include <arvmiscprivate.h>

int
main (int argc, char **argv)
{
	GFile *file;
	GFileInputStream *stream;
	char *scheme = NULL;
	char *path = NULL;
	char *genicam = NULL;
	const char *filename;
	gsize len = 0;

	if (argc != 2) {
		printf ("Usage: load-http-test <URL>\n");
		return EXIT_FAILURE;
	}

	filename = argv[1];

	if (arv_parse_genicam_url (filename, -1, &scheme, NULL, &path, NULL, NULL, NULL, NULL)) {
		if (g_ascii_strcasecmp (scheme, "http:") == 0) {
			file = g_file_new_for_uri (filename);
			stream = g_file_read (file, NULL, NULL);
			if(stream) {
				GDataInputStream *data_stream;

				data_stream = g_data_input_stream_new (G_INPUT_STREAM (stream));
				genicam = g_data_input_stream_read_upto (data_stream, "", 0, &len, NULL, NULL);

				g_object_unref (data_stream);
				g_object_unref (stream);
			}
			g_object_unref (file);
		}
	}

	g_print ("size = %" G_GSIZE_FORMAT "\n", len);
	g_print ("%s\n", genicam != NULL ? genicam : "NULL");

	g_free (scheme);
	g_free (path);
	g_free (genicam);

	return EXIT_SUCCESS;
}