コード例 #1
0
ファイル: parse_release.c プロジェクト: credmon/libreport
void parse_release_for_bz(const char *release, char** product, char** version)
{
    /* Fedora/RH bugzilla uses "Red Hat Enterprise Linux N" product for RHEL */
    parse_release(release, product, version, 0
        | APPEND_MAJOR_VER_TO_RHEL_PRODUCT
    );
}
コード例 #2
0
ファイル: release.c プロジェクト: amanuel2/IMPORTED_OS_MIRROR
bool os_release_load(struct release* release,
                     const char* path,
                     const char* errpath)
{
	memset(release, 0, sizeof(*release));
	FILE* fp = fopen(path, "r");
	if ( !fp )
	{
		if ( errno != ENOENT )
			warn("%s", errpath);
		return false;
	}
	bool failure = false;
	bool success = false;
	bool found_id = false;
	bool found_pretty_name = false;
	bool found_sortix_abi = false;
	bool found_version_id = false;
	char* line = NULL;
	size_t line_size = 0;
	ssize_t line_length;
	while ( 0 < (line_length = getline(&line, &line_size, fp)) )
	{
		if ( line[line_length-1] == '\n' )
			line[--line_length] = '\0';
		if ( !strncmp(line, "ID=", strlen("ID=")) )
		{
			const char* param = line + strlen("ID=");
			found_id = true;
			char* value = os_release_eval(param);
			if ( value )
			{
				if ( strcmp(value, "sortix") != 0 )
				{
					warn("%s: ID does not specify a 'sortix' system", errpath);
					failure = true;
				}
				free(value);
			}
			else
			{
				warn("malloc");
				failure = true;
			}
		}
		else if ( !strncmp(line, "PRETTY_NAME=", strlen("PRETTY_NAME=")) )
		{
			const char* param = line + strlen("PRETTY_NAME=");
			found_pretty_name = true;
			if ( !(release->pretty_name = os_release_eval(param)) )
			{
				warn("malloc");
				failure = true;
			}
		}
		else if ( !strncmp(line, "SORTIX_ABI=", strlen("SORTIX_ABI=")) )
		{
			const char* param = line + strlen("SORTIX_ABI=");
			found_sortix_abi = true;
			char* value = os_release_eval(param);
			if ( value )
			{
				parse_version(value, &release->abi_major, &release->abi_minor);
				free(value);
			}
			else
			{
				warn("malloc");
				failure = true;
			}
		}
		else if ( !strncmp(line, "VERSION_ID=", strlen("VERSION_ID=")) )
		{
			const char* param = line + strlen("VERSION_ID=");
			found_version_id = true;
			char* value = os_release_eval(param);
			if ( value )
			{
				parse_release(value, &release->version_major,
				              &release->version_minor, &release->version_dev);
				free(value);
			}
			else
			{
				warn("malloc");
				failure = true;
			}
		}
	}
	if ( ferror(fp) )
		warn("%s", errpath);
	else if ( failure )
		;
	else if ( !found_id )
		warnx("%s: No ID", errpath);
	else if ( !found_pretty_name )
		warnx("%s: No PRETTY_NAME", errpath);
	else if ( !found_sortix_abi )
		warnx("%s: No SORTIX_ABI", errpath);
	else if ( !found_version_id )
		warnx("%s: No VERSION_ID", errpath);
	else
		success = true;
	free(line);
	fclose(fp);
	if ( failure || !success )
	{
		release_free(release);
		return false;
	}
	return true;
}
コード例 #3
0
ファイル: parse_release.c プロジェクト: credmon/libreport
/*
 * Note to developers: you can use
 * curl --silent -u $USER:$PASS "https://api.access.redhat.com/rs/products/Red%20Hat%20Enterprise%20Linux/versions" | xmllint --format -
 * to query RHTS for valid set of versions. Currently (2013-01) I get:
 * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 * <versions xmlns="http://www.redhat.com/gss/strata">
 *   <version>3 - ELS</version>
 *   <version>4</version>
 *   <version>4 - ELS</version>
 *   <version>5.0</version>
 *   <version>5.1</version>
 *   <version>5.2</version>
 *   <version>5.3</version>
 *   <version>5.4</version>
 *   <version>5.5</version>
 *   <version>5.6</version>
 *   <version>5.7</version>
 *   <version>5.8</version>
 *   <version>5.9</version>
 *   <version>6.0</version>
 *   <version>6.1</version>
 *   <version>6.2</version>
 *   <version>6.3</version>
 *   <version>6.4 Beta</version>
 *   <version>7.0 Alpha-2</version>
 *   <version>Unknown</version>
 * </versions>
 */
void parse_release_for_rhts(const char *release, char** product, char** version)
{
    parse_release(release, product, version, 0
        | RETAIN_ALPHA_BETA_TAIL_IN_VER
    );
}
コード例 #4
0
ファイル: reszhq.c プロジェクト: HackLinux/device_driver_test
int main(int argc, char *argv[])
{
	/* user parameters */
	static struct isp_node upipe;
	/* command line argument index */
	int opt_idx;

	if (argc == 1 || (argc == 2 && (!strcmp(argv[1], "?") ||
	!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))) {
		fprintf(stderr, "\nUSAGE: command <options>");
		opt_idx = get_option_index("-ifile",
			cmd_line, COUNT_OF(cmd_line));
		fprintf(stderr, " %s<input file>",
			cmd_line[opt_idx].o_symb);
		opt_idx = get_option_index("-ofile",
			cmd_line, COUNT_OF(cmd_line));
		fprintf(stderr, " %s<output file>\n",
			cmd_line[opt_idx].o_symb);
		print_options(cmd_line, COUNT_OF(cmd_line));

		/* Print additional help */
		printf("\nExamples:\n");

		printf("\nResize image: \n ");
		printf("reszhq -iw [in width] -ih [in height] "\
			"-ifile [input file] "\
			"-ow [out width] -oh [out height] "\
			"-ofile [output file]\n");

		exit(EXIT_FAILURE);
	}

	if (parse_prepare(argc, argv, cmd_line, COUNT_OF(cmd_line)))
		exit(errno);

	if (setup_user_parameters(&upipe, cmd_line, COUNT_OF(cmd_line)))
		exit(errno);

	/* index of input file name argument */
	opt_idx = get_option_index("-ifile", cmd_line, COUNT_OF(cmd_line));
	if (!cmd_line[opt_idx].o_dflt.v_char) {
		error(-1, ECANCELED, "Input file parameter missing.");
		exit(errno);
	}

	/* index of output file name argument */

	opt_idx = get_option_index("-ofile", cmd_line, COUNT_OF(cmd_line));
	if (!cmd_line[opt_idx].o_dflt.v_char) {
		error(-1, ECANCELED, "Output file parameter missing.");
		exit(errno);
	}

	int rz_fd;
	/* index of device name */
	opt_idx = get_option_index("-dev", cmd_line, COUNT_OF(cmd_line));
	rz_fd = open(cmd_line[opt_idx].o_dflt.v_char, O_RDWR);

	if (rz_fd < 0) {
		error(-1, ECANCELED, "Can't open device.");
		exit(errno);
	}
	printf(" Before  RSZ_S_PARAM : ");
	printf("%dx%d->", upipe.in.image.width, upipe.in.image.height);
	printf("%dx%d \n ", upipe.out.image.width, upipe.out.image.height);

	if (ioctl(rz_fd, RSZ_S_PARAM, &upipe) == -1) {
		error(-1, ECANCELED, "Invalid config parameters.");
		exit(errno);
	}

	printf(" After  RSZ_S_PARAM : ");
	printf("%dx%d->", upipe.in.image.width, upipe.in.image.height);
	printf("%dx%d \n ", upipe.out.image.width, upipe.out.image.height);

	/* V4L2 Buffer */
	struct v4l2_requestbuffers v4l2_req;
	/* user buffer source pointer */
	struct v4l2_buffer src_ubuf;
	struct v4l2_buffer dst_ubuf;

	/* clear buffers */
	memset(&v4l2_req, 0, sizeof(v4l2_req));
	memset(&src_ubuf, 0, sizeof(src_ubuf));
	memset(&dst_ubuf, 0, sizeof(dst_ubuf));
	void * inBuf;
	void * outBuf;

	/* V4L2 Memory map type */
	v4l2_req.memory	= V4L2_MEMORY_USERPTR;
	/* V4L2 The number of buffers requested */
	v4l2_req.count	= 1;
	/* V4L2 Buffer type */
	v4l2_req.type	= V4L2_BUF_TYPE_VIDEO_OUTPUT;

	if (ioctl(rz_fd, RSZ_REQBUF, &v4l2_req)) {
		error(-1, ECANCELED, "input: REQBUF failed.");
		exit(errno);
	}

	/* setup input buffer parameters */
	src_ubuf.index	= 0;
	src_ubuf.type	= V4L2_BUF_TYPE_VIDEO_OUTPUT;
	src_ubuf.memory	= v4l2_req.memory;
	/* calculate input buffer length */
	src_ubuf.length	= ALIGN(upipe.in.image.bytesperline *
					upipe.in.image.height, PAGE_SIZE);

	/* V4L2 - Query input buffer */
	if (ioctl(rz_fd, RSZ_QUERYBUF, &src_ubuf)) {
		error(-1, ECANCELED, "RSZ_QUERYBUF failed.");
		exit(errno);
	}

	/* allocate input data buffer */
	inBuf =  malloc(src_ubuf.length + PAGE_SIZE);
	if (inBuf == NULL ) {
		perror("input: Can't allocate memory");
		exit(errno);
	}

	src_ubuf.m.userptr = (unsigned long)(ALIGN(inBuf, PAGE_SIZE));

	if (!src_ubuf.m.userptr) {
		perror("input: Can't allocate memory");
		exit(errno);
	}


	/* V4L2 - Setup input buffer in queue */
	if (ioctl(rz_fd, RSZ_QUEUEBUF, &src_ubuf)) {
		error(-1, ECANCELED, "RSZ_QUEUEBUF failed.");
		exit(errno);
	}

	/* index of options for input file name */
	opt_idx = get_option_index("-ifile", cmd_line, COUNT_OF(cmd_line));
	/* load data buffer */
	if (Load_Image(cmd_line[opt_idx].o_dflt.v_char,
			(char *)src_ubuf.m.userptr, src_ubuf.length)) {
		error(-1, ECANCELED, "File load error.");
		exit(errno);
	}

	/* V4L2 Memory map type */
	v4l2_req.memory	= V4L2_MEMORY_USERPTR;
	/* V4L2 The number of buffers requested */
	v4l2_req.count	= 1;
	/* V4L2 Buffer type */
	v4l2_req.type	= V4L2_BUF_TYPE_VIDEO_CAPTURE;

	if (ioctl(rz_fd, RSZ_REQBUF, &v4l2_req)) {
		error(-1, ECANCELED, "RSZ_REQBUF failed.");
		exit(errno);
	}
	/* setup output buffer parameters */
	dst_ubuf.index	= 0;
	dst_ubuf.type	= V4L2_BUF_TYPE_VIDEO_CAPTURE;
	dst_ubuf.memory	= v4l2_req.memory;
	/* calculate buffer/buffers length */
	dst_ubuf.length	= ALIGN(upipe.out.image.bytesperline *
					upipe.out.image.height, PAGE_SIZE);

	/* V4L2 - Query output buffer */
	if (ioctl(rz_fd, RSZ_QUERYBUF, &dst_ubuf)) {
		error(-1, ECANCELED, "RSZ_QUERYBUF failed.");
		exit(errno);
	}
#if 0
	/* allocate output buffer */
	dst_ubuf.maddr = malloc(dst_ubuf.length);
	if (dst_ubuf.maddr == 0) {
		error(-1, ECANCELED, "Buffer allocation failed.");
		exit(errno);
	}
	/* align and setup ouput pointer */
	dst_ubuf.m.userptr = (unsigned long) (ALIGN(dst_ubuf.maddr, PAGE_SIZE));
#else
	/* allocate input data buffer */

	outBuf =  malloc(dst_ubuf.length + PAGE_SIZE);
	if (outBuf == NULL ) {
		perror("input: Can't allocate memory");
		exit(errno);
	}

	dst_ubuf.m.userptr = (unsigned long)(ALIGN(outBuf, PAGE_SIZE));

	if (!dst_ubuf.m.userptr) {
		perror("input: Can't allocate memory");
		exit(errno);
	}
#endif
	/* V4L2 - Setup output buffer in queue */
	if (ioctl(rz_fd, RSZ_QUEUEBUF, &dst_ubuf)) {
		error(-1, ECANCELED, "RSZ_QUEUEBUF failed.");
		exit(errno);
	}

#if !defined(NDEBUG)
	/* initialize start time */
	struct timeval beg_tv; gettimeofday(&beg_tv, NULL);
#endif

	/*
	 * Execute operation
	 */
	if (ioctl(rz_fd, RSZ_RESIZE, &upipe) == -1) {
		error(-1, ECANCELED, "RSZ_RESIZE error\n");
		exit(errno);
	}

#if !defined(NDEBUG)
	/* initialize end time */
	struct timeval end_tv; gettimeofday(&end_tv, NULL);
	fprintf(stderr, "\nOperation finished: %ld (usec)\n",
			(end_tv.tv_sec - beg_tv.tv_sec) * 1000000 +
			(end_tv.tv_usec - beg_tv.tv_usec)
	);
#endif

	/* index of options for output file name */
	opt_idx = get_option_index("-ofile", cmd_line, COUNT_OF(cmd_line));
	/* save image */
	if (Save_Image(cmd_line[opt_idx].o_dflt.v_char,
		(char *)dst_ubuf.m.userptr,
		upipe.out.image.bytesperline * upipe.out.image.height)) {
		error(-1, ECANCELED, "File save error");
		exit(errno);
	}

	/* release allocated buffers */
	if (src_ubuf.m.userptr)
		free(inBuf);

	if (dst_ubuf.m.userptr)
		free(outBuf);

	if (rz_fd)
		close(rz_fd);

	parse_release(cmd_line, COUNT_OF(cmd_line));

	return 0;
}