Ejemplo n.º 1
0
void checkVol(void)
{
	int nl=0,nr=0;
	nl=convert_range(cure->element.data.volume1.pvoices[0],cure->info.data.volume1.prange[0].min,cure->info.data.volume1.prange[0].max,0,100);
	nr=convert_range(cure->element.data.volume1.pvoices[1],cure->info.data.volume1.prange[1].min,cure->info.data.volume1.prange[1].max,0,100);

	if(1)
	{
		curleft=nl;
		curright=nr;
	}
	else
	{
		if(nl!=curleft||nr!=curright)
		{
			if(nl!=curleft)
			{
				curleft=nl;
				drawLeft();
			}
			if(nr!=curright)
			{
				curright=nr;
				drawRight();
			}
		}
	}
	update();
	repaint();
}
Ejemplo n.º 2
0
void setVol(int left, int right)
{
	int err;
	callbacks();
	cure->element.data.volume1.pvoices[0]=convert_range(left,0,100,cure->info.data.volume1.prange[0].min,cure->info.data.volume1.prange[0].max);
	if(cure->element.data.volume1.pvoices[0]>cure->info.data.volume1.prange[0].max)
		cure->element.data.volume1.pvoices[0]=cure->info.data.volume1.prange[0].max;
	if(cure->element.data.volume1.pvoices[0]<cure->info.data.volume1.prange[0].min)
		cure->element.data.volume1.pvoices[0]=cure->info.data.volume1.prange[0].min;
	cure->element.data.volume1.pvoices[1]=convert_range(right,0,100,cure->info.data.volume1.prange[1].min,cure->info.data.volume1.prange[1].max);
	if(cure->element.data.volume1.pvoices[1]>cure->info.data.volume1.prange[1].max)
		cure->element.data.volume1.pvoices[1]=cure->info.data.volume1.prange[1].max;
	if((err=snd_mixer_element_write(mixer_handle,&cure->element))<0)
		fprintf(stderr,"Mixer element write error: %s\n",snd_strerror(err));
	return;
}
Ejemplo n.º 3
0
main(int argc, char **argv)
{
	char line[MAXLINE];
	int l, lnum;
	char *lb, *le, *hb, *he, *err;
	struct in_addr src_addr, dst_addr;
	unsigned int sa, da;

	if (argc > 1) {
		usage(argv[0]);
		exit(1);
	}

	lnum = 0;
	while (fgets(line, sizeof(line), stdin) != NULL) {
		l = strlen(line);
		if (l && line[l - 1] == '\n')
			line[--l] = '\0';

		lnum++;
		/* look for the first field which must be the low address of a range,
		 * in dotted IPv4 format or as an integer. spaces and commas are
		 * considered as delimiters, quotes are removed.
		 */
		for (lb = line; *lb == ' ' || *lb == '\t' || *lb == ',' || *lb == '"'; lb++);
		if (!*lb || *lb == '#')
			continue;
		for (le = lb + 1; *le != ' ' && *le != '\t' && *le != ',' && *le != '"' && *le; le++);
		if (!*le)
			continue;
		/* we have the low address between lb(included) and le(excluded) */
		*(le++) = 0;

		for (hb = le; *hb == ' ' || *hb == '\t' || *hb == ',' || *hb == '"'; hb++);
		if (!*hb || *hb == '#')
			continue;
		for (he = hb + 1; *he != ' ' && *he != '\t' && *he != ',' && *he != '"' && *he; he++);
		if (!*he)
			continue;
		/* we have the high address between hb(included) and he(excluded) */
		*(he++) = 0;

		/* we want to remove a possible ending quote and a possible comma,
		 * not more.
		 */
		while (*he == '"')
			*(he++) = ' ';
		while (*he == ',' || *he == ' ' || *he == '\t')
			*(he++) = ' ';

		/* if the trailing string is not empty, prefix it with a space */
		if (*(he-1) == ' ')
			he--;

		if (inet_pton(AF_INET, lb, &src_addr) <= 0) {
			/* parsing failed, retry with a plain numeric IP */
			src_addr.s_addr = ntohl(strtoul(lb, &err, 10));
			if (err && *err) {
				fprintf(stderr, "Failed to parse source address <%s> at line %d, skipping line\n", lb, lnum);
				continue;
			}
		}

		if (inet_pton(AF_INET, hb, &dst_addr) <= 0) {
			/* parsing failed, retry with a plain numeric IP */
			dst_addr.s_addr = ntohl(strtoul(hb, &err, 10));
			if (err && *err) {
				fprintf(stderr, "Failed to parse destination address <%s> at line %d, skipping line\n", hb, lnum);
				continue;
			}
		}

		sa = htonl(src_addr.s_addr);
		da = htonl(dst_addr.s_addr);
		convert_range(sa, da, he);
	}
}
Ejemplo n.º 4
0
main(int argc, char **argv)
{
	char line[MAXLINE];
	int l, lnum;
	char *lb, *le, *hb, *he, *err;
	struct in6_addr sa, da, ta;

	if (argc > 1 && *argv[1] == '-') {
		usage(argv[0]);
		exit(1);
	}

	lnum = 0;
	while (fgets(line, sizeof(line), stdin) != NULL) {
		l = strlen(line);
		if (l && line[l - 1] == '\n')
			line[--l] = '\0';

		lnum++;
		/* look for the first field which must be the low address of a range,
		 * in dotted IPv4 format or as an integer. spaces and commas are
		 * considered as delimiters, quotes are removed.
		 */
		for (lb = line; *lb == ' ' || *lb == '\t' || *lb == ',' || *lb == '"'; lb++);
		if (!*lb || *lb == '#')
			continue;
		for (le = lb + 1; *le != ' ' && *le != '\t' && *le != ',' && *le != '"' && *le; le++);
		if (!*le)
			continue;
		/* we have the low address between lb(included) and le(excluded) */
		*(le++) = 0;

		for (hb = le; *hb == ' ' || *hb == '\t' || *hb == ',' || *hb == '"'; hb++);
		if (!*hb || *hb == '#')
			continue;
		for (he = hb + 1; *he != ' ' && *he != '\t' && *he != ',' && *he != '"' && *he; he++);
		if (!*he)
			continue;
		/* we have the high address between hb(included) and he(excluded) */
		*(he++) = 0;

		/* we want to remove a possible ending quote and a possible comma,
		 * not more.
		 */
		while (*he == '"')
			*(he++) = ' ';
		while (*he == ',' || *he == ' ' || *he == '\t')
			*(he++) = ' ';

		/* if the trailing string is not empty, prefix it with a space */
		if (*(he-1) == ' ')
			he--;

		if (inet_pton(AF_INET6, lb, &sa) <= 0) {
			fprintf(stderr, "Failed to parse source address <%s> at line %d, skipping line\n", lb, lnum);
			continue;
		}

		if (inet_pton(AF_INET6, hb, &da) <= 0) {
			fprintf(stderr, "Failed to parse destination address <%s> at line %d, skipping line\n", hb, lnum);
			continue;
		}

		in6_bswap(&sa);
		in6_bswap(&da);

		if (argc > 1) {
			for (l = 1; l < argc; l++) {
				if (inet_pton(AF_INET6, argv[l], &da) <= 0)
					continue;
				in6_bswap(&ta);
				if ((a_le_b(&sa, &ta) && a_le_b(&ta, &da)) || (a_le_b(&da, &ta) && a_le_b(&ta, &sa)))
					convert_range(&sa, &da, he, argv[l]);
			}
		}
		else {
			convert_range(&sa, &da, he, NULL);
		}
	}
}