view sounds/au2h.c @ 305:77404a4692b1

[gaim-migrate @ 315] 12:10:45 EWarmenhoven: ok, the new method for chosing a font: it tries the requested font at the requested size. if it can't do that, it tries the requested font at any size. if it can't do that, it tries courier at any size, then helvetica at any size. if it can't do *that*, it tries the person's default outgoing font, if they have one. if it can't do that, it tries courier, helvetica, then times, all in their most boring form (no bold, italics, etc) at any size. if it *still* can't do that, then there's just no hope, and it segfaults. but at least there's a few more layers of protection and probability that you're going to get *something* right 12:11:43 EWarmenhoven: i don't even know that it'll segfault, but i'm pretty sure it will, since by the time you get down there, it returns NULL :-P committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 01 Jun 2000 19:13:00 +0000
parents bc117fbcf527
children 7ac742be351d
line wrap: on
line source

#include <stdio.h>
#if !(__GLIBC__ < 2)
#include <error.h>
#endif
#include <fcntl.h>
#include <unistd.h>

#define BUF_SIZE 10

int main(int argc, char *argv[])
{
	int fd;
	FILE *f;
	int res,x;
	char buf[BUF_SIZE];

	fd = open(argv[1], O_RDONLY);
	if (fd < 0) {
		perror("open");
		exit(1);
	}
	f = fopen(argv[2], "w+");
	if (!f) {
		perror("fopen");
		exit(1);
	}
	argv[1][strlen(argv[1])-3]='\0';
	fprintf(f, "static unsigned char %s[] = {\n", argv[1]);
	read(fd, buf, 8); /* id & offset */
	read(fd, buf, 8); /* len & encoding */
	read(fd, buf, 8); /* rate & count */
	/*  no more click :) */
	
	while((res = read(fd, buf, BUF_SIZE)) > 0) {
		for (x=0;x<res;x++)
			fprintf(f, "%#x, ", buf[x] & 0xff);
		fprintf(f, "\n");
	}
	fprintf(f,"};\n");
	fclose(f);
	return 0;
}