2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "gnashconfig.h"
23 #include "GnashFileUtilities.h"
37 extern int optind
, getopt(int, char *const *, const char *);
48 using namespace gnash
;
51 gnash::LogFile
& dbglogfile
= gnash::LogFile::getDefaultInstance();
52 gnash::RcInitFile
& rcfile
= gnash::RcInitFile::getDefaultInstance();
55 #ifdef BOOST_NO_EXCEPTIONS
59 void throw_exception(std::exception
const & e
)
66 const char *SOLDUMPER_VERSION
= "0.5";
68 /// \brief Display the command line arguments
72 o
<< _("This program dumps the internal data of a .sol file")
74 o
<< _("Usage: soldumper [h] filename") << endl
;
75 o
<< _("-h\tHelp") << endl
;
76 o
<< _("-f\tForce local directory access") << endl
;
77 o
<< _("-l\tList all .sol files in default dir") << endl
;
81 main(int argc
, char *argv
[])
85 bool localdir
= false;
88 string filespec
, realname
, tmpname
;
90 vector
<const char *> dirlist
;
92 // Enable native language support, i.e. internationalization
94 std::setlocale (LC_ALL
, "");
95 bindtextdomain (PACKAGE
, LOCALEDIR
);
98 // scan for the two main standard GNU options
99 for (c
= 0; c
< argc
; c
++) {
100 if (strcmp("--help", argv
[c
]) == 0) {
104 if (strcmp("--version", argv
[c
]) == 0) {
105 printf (_("Gnash soldumper version: %s, Gnash version: %s\n"),
106 SOLDUMPER_VERSION
, VERSION
);
111 /* This initializes the DBG_MSG macros */
112 while ((c
= getopt (argc
, argv
, "hvfl")) != -1) {
120 dbglogfile
.setVerbosity();
121 cout
<< _("Verbose output turned on") << endl
;
125 cout
<< _("forcing local directory access only") << endl
;
130 cout
<< _("List .sol files in the default directory") << endl
;
141 // If no command line arguments have been supplied, do nothing but
142 // print the usage message.
148 // get the file name from the command line
150 filespec
= argv
[optind
];
151 cout
<< "Will use \"" << filespec
<< "\" for sol files location" << endl
;
154 // List the .sol files in the default directory
157 if ((localdir
) || (filespec
[0] == '/') || (filespec
[0] == '.')) {
158 if (filespec
.size() == 0) {
161 dirname
= filespec
.c_str();
164 dirname
= rcfile
.getSOLSafeDir().c_str();
166 DIR *library_dir
= NULL
;
167 library_dir
= opendir (dirname
);
168 if (library_dir
!= NULL
) {
169 // By convention, the first two entries in each directory are
170 // for . and .. (``dot'' and ``dot dot''), so we ignore those. The
171 // next directory read will get a real file, if any exists.
172 entry
= readdir(library_dir
);
173 entry
= readdir(library_dir
);
175 if (library_dir
!= NULL
) {
176 for (i
=0; entry
>0; i
++) {
177 entry
= readdir(library_dir
);
179 //string::size_type pos;
180 if (strstr(entry
->d_name
, ".sol")) {
181 cout
<< "Found SOL: " << entry
->d_name
<< endl
;
190 if ((localdir
) || (filespec
[0] == '/') || (filespec
[0] == '.')) {
193 newspec
= rcfile
.getSOLSafeDir();
200 if (sol
.readFile(newspec
)) {
201 cout
<< "SOL file \"" << newspec
<< "\" read in" << endl
;
203 cerr
<< "SOL file \"" << newspec
<< "\" does not exist!" << endl
;
211 // indent-tabs-mode: t