annotate sounds/au2h.c @ 3327:220c9f1fc75e

[gaim-migrate @ 3345] patch -r committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 18 Jun 2002 22:59:22 +0000
parents 5ed382006539
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 #if !(__GLIBC__ < 2)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 #include <error.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 #endif
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 #include <fcntl.h>
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 10
diff changeset
6 #include <unistd.h>
469
7ac742be351d [gaim-migrate @ 479]
Rob Flynn <gaim@robflynn.com>
parents: 200
diff changeset
7 #include <stdlib.h>
7ac742be351d [gaim-migrate @ 479]
Rob Flynn <gaim@robflynn.com>
parents: 200
diff changeset
8 #include <string.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 #define BUF_SIZE 10
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 int main(int argc, char *argv[])
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 int fd;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 FILE *f;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 int res,x;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 char buf[BUF_SIZE];
1094
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
18 char file[256];
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
19 int offset = 0, cnt;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20
1797
6fa4f028d226 [gaim-migrate @ 1807]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1094
diff changeset
21 if (argc != 3) {
1798
5ed382006539 [gaim-migrate @ 1808]
Rob Flynn <gaim@robflynn.com>
parents: 1797
diff changeset
22 fprintf(stderr, "Too few arguments! Are you using gmake? If you're not, then you really should. :-) \n");
1797
6fa4f028d226 [gaim-migrate @ 1807]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1094
diff changeset
23 exit(1);
6fa4f028d226 [gaim-migrate @ 1807]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1094
diff changeset
24 }
6fa4f028d226 [gaim-migrate @ 1807]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1094
diff changeset
25
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 fd = open(argv[1], O_RDONLY);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 if (fd < 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 perror("open");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 exit(1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 f = fopen(argv[2], "w+");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 if (!f) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 perror("fopen");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 exit(1);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 argv[1][strlen(argv[1])-3]='\0';
1094
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
37 cnt = strlen(argv[1]);
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
38 while (offset != cnt) {
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
39 if (argv[1][cnt - offset] == '/') {
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
40 offset--;
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
41 break;
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
42 }
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
43 offset++;
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
44 }
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
45 sprintf(file, "%s", &argv[1][cnt - offset]);
3deadbe50737 [gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 469
diff changeset
46 fprintf(f, "static unsigned char %s[] = {\n", file);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 read(fd, buf, 8); /* id & offset */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 read(fd, buf, 8); /* len & encoding */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 read(fd, buf, 8); /* rate & count */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 /* no more click :) */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52 while((res = read(fd, buf, BUF_SIZE)) > 0) {
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 for (x=0;x<res;x++)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 fprintf(f, "%#x, ", buf[x] & 0xff);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55 fprintf(f, "\n");
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 fprintf(f,"};\n");
10
34db9f242899 [gaim-migrate @ 19]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
58 fclose(f);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 return 0;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 }