upgrade to xpdf 3.00.
[swftools.git] / src / swfstrings.c
blob9e9261d29eca272461ffe5ab4fe14bfcd69d87f7
1 /* swfstrings.c
2 Scans a swf file for strings
4 Part of the swftools package.
6 Copyright (c) 2000,2001 Rainer Böhme <rfxswf@reflex-studio.de>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
22 #include <stdio.h>
23 #include <fcntl.h>
24 #include "../lib/rfxswf.h"
25 #include "../lib/args.h"
27 char * filename = 0;
29 struct options_t options[] =
31 {"v","verbose"},
32 {"V","version"},
33 {0,0}
36 int args_callback_option(char*name,char*val)
38 if(!strcmp(name, "V")) {
39 printf("swfstrings - part of %s %s\n", PACKAGE, VERSION);
40 exit(0);
42 return 0;
44 int args_callback_longoption(char*name,char*val)
46 return args_long2shortoption(options, name, val);
48 void args_callback_usage(char*name)
50 printf("\nreflex SWF Text Scan Utility\n(w) 2000 by Rainer Boehme <rb@reflex-studio.de>\n\nUsage: %s filename.swf\n", name);
51 exit(0);
53 int args_callback_command(char*name,char*val)
55 if(filename) {
56 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
57 filename, name);
59 filename = name;
60 return 0;
63 SWF swf;
65 void fontcallback(U16 id,U8 * name)
66 { LPSWFFONT font;
67 LPTAG t;
69 swf_FontExtract(&swf,id,&font);
70 printf("#< %s %s %s>\n",name,swf_FontIsBold(font)?"bold":"",swf_FontIsItalic(font)?"italic":"");
72 t = swf.firstTag;
74 while (t)
75 { swf_TextPrintDefineText(t,font);
76 t = swf_NextTag(t);
79 swf_FontFree(font);
82 int main (int argc,char ** argv)
83 { int f;
85 processargs(argc, argv);
86 if(!filename)
87 exit(0);
89 f = open(filename,O_RDONLY|O_BINARY);
90 if (f>=0)
91 { if FAILED(swf_ReadSWF(f,&swf))
92 { fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename);
93 close(f);
95 else
96 { close(f);
97 swf_FontEnumerate(&swf,&fontcallback);
98 swf_FreeTags(&swf);
100 } else {
101 fprintf(stderr,"File not found: %s\n",argv[1]);
104 return 0;