MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / main

Function main

tools/cws2fws.c:28–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#endif
27
28int main(int argc, char *argv[])
29{
30 int fd_in, fd_out, comp_len, uncomp_len, i, last_out;
31 char buf_in[1024], buf_out[65536];
32 z_stream zstream;
33 struct stat statbuf;
34 int ret = 1;
35
36 if (argc < 3) {
37 printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
38 return 1;
39 }
40
41 fd_in = open(argv[1], O_RDONLY);
42 if (fd_in < 0) {
43 perror("Error opening input file");
44 return 1;
45 }
46
47 fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
48 if (fd_out < 0) {
49 perror("Error opening output file");
50 close(fd_in);
51 return 1;
52 }
53
54 if (read(fd_in, &buf_in, 8) != 8) {
55 printf("Header error\n");
56 goto out;
57 }
58
59 if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') {
60 printf("Not a compressed flash file\n");
61 goto out;
62 }
63
64 if (fstat(fd_in, &statbuf) < 0) {
65 perror("fstat failed");
66 return 1;
67 }
68 comp_len = statbuf.st_size;
69 uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24);
70
71 printf("Compressed size: %d Uncompressed size: %d\n",
72 comp_len - 4, uncomp_len - 4);
73
74 // write out modified header
75 buf_in[0] = 'F';
76 if (write(fd_out, &buf_in, 8) < 8) {
77 perror("Error writing output file");
78 goto out;
79 }
80
81 zstream.zalloc = NULL;
82 zstream.zfree = NULL;
83 zstream.opaque = NULL;
84 if (inflateInit(&zstream) != Z_OK) {
85 fprintf(stderr, "inflateInit failed\n");

Callers

nothing calls this directly

Calls 2

closeFunction · 0.85
inflateFunction · 0.85

Tested by

no test coverage detected