Mercurial > pidgin
annotate sounds/au2h.c @ 1712:560b3117aedf
[gaim-migrate @ 1722]
fix for segfault causer on solaris
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 13 Apr 2001 17:47:06 +0000 |
parents | 3deadbe50737 |
children | 6fa4f028d226 |
rev | line source |
---|---|
1 | 1 #include <stdio.h> |
2 #if !(__GLIBC__ < 2) | |
3 #include <error.h> | |
4 #endif | |
5 #include <fcntl.h> | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
10
diff
changeset
|
6 #include <unistd.h> |
469 | 7 #include <stdlib.h> |
8 #include <string.h> | |
1 | 9 |
10 #define BUF_SIZE 10 | |
11 | |
12 int main(int argc, char *argv[]) | |
13 { | |
14 int fd; | |
15 FILE *f; | |
16 int res,x; | |
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 | 20 |
21 fd = open(argv[1], O_RDONLY); | |
22 if (fd < 0) { | |
23 perror("open"); | |
24 exit(1); | |
25 } | |
26 f = fopen(argv[2], "w+"); | |
27 if (!f) { | |
28 perror("fopen"); | |
29 exit(1); | |
30 } | |
31 argv[1][strlen(argv[1])-3]='\0'; | |
1094
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
32 cnt = strlen(argv[1]); |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
33 while (offset != cnt) { |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
34 if (argv[1][cnt - offset] == '/') { |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
35 offset--; |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
36 break; |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
37 } |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
38 offset++; |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
39 } |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
40 sprintf(file, "%s", &argv[1][cnt - offset]); |
3deadbe50737
[gaim-migrate @ 1104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
469
diff
changeset
|
41 fprintf(f, "static unsigned char %s[] = {\n", file); |
1 | 42 read(fd, buf, 8); /* id & offset */ |
43 read(fd, buf, 8); /* len & encoding */ | |
44 read(fd, buf, 8); /* rate & count */ | |
45 /* no more click :) */ | |
46 | |
47 while((res = read(fd, buf, BUF_SIZE)) > 0) { | |
48 for (x=0;x<res;x++) | |
49 fprintf(f, "%#x, ", buf[x] & 0xff); | |
50 fprintf(f, "\n"); | |
51 } | |
52 fprintf(f,"};\n"); | |
10 | 53 fclose(f); |
1 | 54 return 0; |
55 } |