[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12148: Port a trimmed down version
From: |
Rob Savoye |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12148: Port a trimmed down version of the log_error() and log_debug() functions |
Date: |
Wed, 14 Apr 2010 13:28:49 -0600 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12148
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Wed 2010-04-14 13:28:49 -0600
message:
Port a trimmed down version of the log_error() and log_debug() functions
to the plugin so we don't have to link in libbase to use the same functions.
Cleanup logging, which was a mix of iostreams, GnashLog* and printf().
Move GNASH_PLUGIN_DEBUG to plugin.h so logging can be used in more than
one file conditionally.
modified:
plugin/npapi/plugin.cpp
plugin/npapi/plugin.h
plugin/npapi/pluginScriptObject.cpp
=== modified file 'plugin/npapi/plugin.cpp'
--- a/plugin/npapi/plugin.cpp 2010-04-14 03:24:40 +0000
+++ b/plugin/npapi/plugin.cpp 2010-04-14 19:28:49 +0000
@@ -33,6 +33,8 @@
# include <netdb.h>
#endif
+#include <boost/format.hpp>
+
#define MIME_TYPES_HANDLED "application/x-shockwave-flash"
// The name must be this value to get flash movies that check the
// plugin version to load.
@@ -60,13 +62,6 @@
<br>\
Compatible Shockwave Flash "FLASH_VERSION
-// Define the following to make the plugin verbose
-// WARNING: will write to .xsession_errors !
-// Values:
-// 1: fatal errors (errors preventing the plugin from working as it should)
-// 2: informational messages
-//
-#define GNASH_PLUGIN_DEBUG 1
//#define WRITE_FILE
// Defining this flag disables the pipe to the standalone player, as well
@@ -115,8 +110,8 @@
static bool createSaLauncher = false;
static const char* getPluginDescription();
-void GnashLogDebug(const std::string& msg);
-void GnashLogError(const std::string& msg);
+// void GnashLogDebug(const std::string& msg);
+// void GnashLogError(const std::string& msg);
/// \brief Return the MIME Type description for this plugin.
char*
@@ -139,31 +134,29 @@
NS_PluginInitialize()
{
if ( plugInitialized ) {
- GnashLogDebug("NS_PluginInitialize called, but ignored (we already
initialized)");
+ log_debug("NS_PluginInitialize called, but ignored (we already
initialized)");
return NPERR_NO_ERROR;
}
- GnashLogDebug("NS_PluginInitialize call ---------------------------");
+ log_debug("NS_PluginInitialize call ---------------------------");
- /* Browser Functionality Checks */
+ // Browser Functionality Checks
NPError err = NPERR_NO_ERROR;
NPBool supportsXEmbed = TRUE;
- /*
- First, check for XEmbed support. The NPAPI Gnash plugin
- only works with XEmbed, so tell the plugin API to fail if
- XEmbed is not found.
- */
+ // First, check for XEmbed support. The NPAPI Gnash plugin
+ // only works with XEmbed, so tell the plugin API to fail if
+ // XEmbed is not found.
err = NPN_GetValue(NULL,NPNVSupportsXEmbedBool,
(void *)&supportsXEmbed);
if (err != NPERR_NO_ERROR || !supportsXEmbed) {
- GnashLogError("NPAPI ERROR: No xEmbed support in this browser!");
+ log_error("NPAPI ERROR: No xEmbed support in this browser!");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
} else {
- GnashLogDebug("xEmbed supported in this browser");
+ log_debug("xEmbed supported in this browser");
}
// GTK is not strictly required, but we do use the Glib main event loop,
@@ -173,11 +166,10 @@
if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) {
#ifdef GNASH_PLUGIN_DEBUG
- std::cout << "NPAPI ERROR: No GTK2 support in this browser!"
- " Have version " << (int)toolkit << std::endl;
+ log_error("NPAPI ERROR: No GTK2 support in this browser! Have version
%d", (int)toolkit);
#endif
} else {
- GnashLogDebug("GTK2 supported in this browser");
+ log_debug("GTK2 supported in this browser");
}
/*
@@ -185,7 +177,7 @@
*/
char* opts = std::getenv("GNASH_OPTIONS");
if (opts != NULL) {
- GnashLogDebug(std::string("GNASH_OPTIONS : ") + std::string(opts));
+ log_debug(std::string("GNASH_OPTIONS : ") + std::string(opts));
// Should the plugin wait for gdb to be attached?
if ( strstr(opts, "waitforgdb") ) {
@@ -213,7 +205,7 @@
newGnashRc.append(home);
newGnashRc.append("/.gnashpluginrc");
} else {
- std::cout << "WARNING: NPAPI plugin could not find user home dir" <<
std::endl;
+ log_error("WARNING: NPAPI plugin could not find user home dir");
}
char *gnashrc = std::getenv("GNASHRC");
@@ -228,9 +220,10 @@
gnashrc[PATH_MAX-1] = '\0';
if ( putenv(gnashrc) ) {
- std::cout << "WARNING: NPAPI plugin could not append to the GNASHRC
env variable" << std::endl;
+ log_debug("WARNING: NPAPI plugin could not append to the GNASHRC env
variable");
+ } else {
+ log_debug("NOTE: NPAPI plugin set GNASHRC to %d", newGnashRc);
}
- else GnashLogDebug(std::string("NOTE: NPAPI plugin set GNASHRC to ") +
newGnashRc);
/* Success */
@@ -250,9 +243,7 @@
{
#if 0
if (!plugInitialized) {
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Plugin already shut down" << std::endl;
-#endif
+ log_debug("Plugin already shut down");
return;
}
@@ -347,7 +338,7 @@
_filefd(-1),
_name()
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
for (size_t i=0, n=data->argc; i<n; ++i) {
std::string name, val;
@@ -390,12 +381,12 @@
reinterpret_cast<struct sockaddr *>(&sock_in),
sizeof(sock_in));
if (ret == 0) {
- printf("Connected to debug server on fd #%d\n", sockfd);
+ log_debug("Connected to debug server on fd #%d", sockfd);
_controlfd = sockfd;
GnashPluginScriptObject *gpso = (GnashPluginScriptObject
*)_scriptObject;
gpso->setControlFD(_controlfd);
} else {
- printf("Couldn't connect to debug server: %s\n", strerror(errno));
+ log_debug("Couldn't connect to debug server: %s", strerror(errno));
}
}
#endif
@@ -413,15 +404,13 @@
if (rv <= 0) {
// The child process has not exited; it may be deadlocked. Kill it.
- GnashLogError("BUG: Child process is stuck. Killing it.");
+ log_error("BUG: Child process is stuck. Killing it.");
kill(*pid, SIGKILL);
waitpid(*pid, &status, 0);
}
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Child process exited with status " << status <<
std::endl;
-#endif
+ log_debug("Child process exited with status %s", status);
delete pid;
@@ -431,7 +420,7 @@
/// \brief Destructor
nsPluginInstance::~nsPluginInstance()
{
- GnashLogDebug("plugin instance destruction");
+ log_debug("plugin instance destruction");
if ( _ichanWatchId ) {
g_source_remove(_ichanWatchId);
@@ -452,9 +441,7 @@
cleanup_childpid(pid);
} else {
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Child process exited with status " << status <<
std::endl;
-#endif
+ log_debug("Child process exited with status %d", status);
}
}
_childpid = 0;
@@ -469,7 +456,7 @@
nsPluginInstance::init(NPWindow* aWindow)
{
if(!aWindow) {
- GnashLogError(std::string(__PRETTY_FUNCTION__) + " ERROR: Window
handle was bogus!");
+ log_error("%s: ERROR: Window handle was bogus!", __PRETTY_FUNCTION__);
return FALSE;
} else {
#if GNASH_PLUGIN_DEBUG > 1
@@ -493,7 +480,7 @@
void
nsPluginInstance::shut()
{
- GnashLogDebug("Gnash plugin shutting down");
+ log_debug("Gnash plugin shutting down");
if (_streamfd != -1) {
if (close(_streamfd) == -1) {
@@ -505,7 +492,7 @@
if (_controlfd != -1) {
if (close(_controlfd) != 0) {
- GnashLogError("Gnash plugin failed to close the control socket!");
+ log_error("Gnash plugin failed to close the control socket!");
}
}
}
@@ -520,7 +507,7 @@
nsPluginInstance::SetWindow(NPWindow* aWindow)
{
if(!aWindow) {
- GnashLogError(std::string(__FUNCTION__) + ": ERROR: Window handle was
bogus!");
+ log_error(std::string(__FUNCTION__) + ": ERROR: Window handle was
bogus!");
return NPERR_INVALID_PARAM;
#if 0
} else {
@@ -560,7 +547,7 @@
NPNFuncs.retainobject(_scriptObject);
*v = _scriptObject;
} else {
- GnashLogDebug("_scriptObject is not assigned");
+ log_debug("_scriptObject is not assigned");
}
}
#endif
@@ -572,7 +559,7 @@
// FIXME: debugging stuff, will be gone soon after I figure how this works
void myfunc(void */* param */)
{
- GnashLogDebug("Here I am!!!\n");
+ log_debug("Here I am!!!\n");
}
void
@@ -609,12 +596,10 @@
#if 0
// FIXME: debugging crap for now call javascript
NPN_PluginThreadAsyncCall(_instance, myfunc, NULL);
- // printf("FIXME: %s", getEmbedURL());
+ // log_debug("FIXME: %s", getEmbedURL());
#endif
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << __FUNCTION__ << ": The full URL is " << _swf_url << std::endl;
-#endif
+ log_debug("The full URL is %s", _swf_url);
#ifdef WRITE_FILE
size_t start, end;
@@ -624,7 +609,7 @@
fname = "/tmp/";
fname += _swf_url.substr(start, end - start);
- GnashLogDebug("The Flash movie name is: " + fname);
+ log_debug("The Flash movie name is: %s", fname);
_filefd = open(fname.c_str(),
O_CREAT | O_WRONLY,
@@ -674,9 +659,7 @@
int32_t
nsPluginInstance::WriteReady(NPStream* /* stream */ )
{
-#if GNASH_PLUGIN_DEBUG > 1
- //std::cout << "Stream for " << stream->url << " is ready" << std::endl;
-#endif
+ //log_debug("Stream for %s is ready", stream->url);
if ( _streamfd != -1 ) {
return 1024;
} else {
@@ -709,7 +692,7 @@
nsPluginInstance::handlePlayerRequests(GIOChannel* iochan, GIOCondition cond)
{
if ( cond & G_IO_HUP ) {
- GnashLogDebug("Player request channel hang up");
+ log_debug("Player request channel hang up");
// Returning false here will cause the "watch" to be removed. This
watch
// is the only reference held to the GIOChannel, so it will be
// destroyed. We must make sure we don't attempt to destroy it again.
@@ -719,10 +702,7 @@
assert(cond & G_IO_IN);
-#if GNASH_PLUGIN_DEBUG > 1
- int inputfd = g_io_channel_unix_get_fd(iochan);
- std::cout << "Checking player requests on fd " << inputfd << std::endl;
-#endif
+ log_debug("Checking player requests on fd #%d",
g_io_channel_unix_get_fd(iochan));
do {
GError* error=NULL;
@@ -733,22 +713,22 @@
switch ( status ) {
case G_IO_STATUS_ERROR:
- GnashLogError(std::string("Error reading request line: ") +
error->message);
+ log_error(std::string("Error reading request line: ") +
error->message);
g_error_free(error);
return false;
case G_IO_STATUS_EOF:
- GnashLogError(std::string("EOF (error: ") + error->message);
+ log_error(std::string("EOF (error: ") + error->message);
return false;
case G_IO_STATUS_AGAIN:
- GnashLogError(std::string("Read again(error: ") +
error->message);
+ log_error(std::string("Read again(error: ") + error->message);
break;
case G_IO_STATUS_NORMAL:
// process request
- GnashLogDebug("Normal read: " + std::string(request));
+ log_debug("Normal read: " + std::string(request));
break;
default:
- GnashLogError("Abnormal status!");
+ log_error("Abnormal status!");
return false;
}
@@ -767,7 +747,7 @@
nsPluginInstance::processPlayerRequest(gchar* buf, gsize linelen)
{
if ( linelen < 4 ) {
- GnashLogError(std::string("Invalid player request (too short): ") +
buf);
+ log_error(std::string("Invalid player request (too short): ") + buf);
return false;
}
@@ -775,7 +755,7 @@
char* target = buf + 4;
if ( ! *target )
{
- GnashLogError("No target found after GET request");
+ log_error("No target found after GET request");
return false;
}
char* url = target;
@@ -784,21 +764,19 @@
*url='\0';
++url;
} else {
- GnashLogError("No colon found after GETURL target string");
+ log_error("No colon found after GETURL target string");
return false;
}
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Asked to get URL '" << url << "' in target '"
- << target << "'" << std::endl;
-#endif
+ log_debug("Asked to get URL '%s''", url);
+ log_debug("In target '%s'", target);
NPN_GetURL(_instance, url, target);
return true;
} else if ( ! std::strncmp(buf, "INVOKE ", 7) ) {
char* command = buf + 7;
if ( ! *command ) {
- GnashLogError("No command found after INVOKE request");
+ log_error("No command found after INVOKE request");
return false;
}
char* arg = command;
@@ -807,7 +785,7 @@
*arg='\0';
++arg;
} else {
- GnashLogError("No colon found after INVOKE command string");
+ log_error("No colon found after INVOKE command string");
return false;
}
@@ -819,7 +797,7 @@
// TODO: check if _self is a good target for this
static const char* tgt = "_self";
- GnashLogDebug("Calling NPN_GetURL(" + jsurl.str() + ", '" +
std::string(tgt) + "');");
+ log_debug("Calling NPN_GetURL(" + jsurl.str() + ", '" +
std::string(tgt) + "');");
NPN_GetURL(_instance, jsurl.str().c_str(), tgt);
return true;
@@ -835,7 +813,7 @@
}
else
{
- GnashLogError("No colon found after getURL postdata string");
+ log_error("No colon found after getURL postdata string");
return false;
}
@@ -845,7 +823,7 @@
*url='\0';
++url;
} else {
- GnashLogError("No $ character found after getURL target string");
+ log_error("No $ character found after getURL target string");
return false;
}
@@ -855,29 +833,11 @@
return true;
} else {
- GnashLogError("Unknown player request: " + std::string(buf));
+ log_error("Unknown player request: " + std::string(buf));
return false;
}
}
-void
-GnashLogDebug(const std::string& msg)
-{
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << msg << std::endl;
-#else
- (void) msg; // suppress warning
-#endif
-}
-
-void
-GnashLogError(const std::string& msg)
-{
-#ifdef GNASH_PLUGIN_DEBUG
- std::cout << msg << std::endl;
-#endif
-}
-
std::string
getGnashExecutable()
{
@@ -891,7 +851,7 @@
procname = gnash_env;
process_found = (0 == stat(procname.c_str(), &procstats));
if (!process_found) {
- GnashLogError("Invalid path to gnash executable: ");
+ log_error("Invalid path to gnash executable: ");
return "";
}
}
@@ -906,7 +866,7 @@
}
if (!process_found) {
- GnashLogError(std::string("Unable to find Gnash in ") + GNASHBINDIR);
+ log_error(std::string("Unable to find Gnash in ") + GNASHBINDIR);
return "";
}
@@ -932,7 +892,7 @@
saLauncher.open(ss.str().c_str(), std::ios::out | std::ios::trunc);
if (!saLauncher) {
- GnashLogError("Failed to open new file for standalone launcher: " +
ss.str());
+ log_error("Failed to open new file for standalone launcher: " +
ss.str());
return;
}
@@ -965,7 +925,7 @@
std::string cmd = getGnashExecutable();
if (cmd.empty()) {
- GnashLogError("Failed to locate the Gnash executable!");
+ log_error("Failed to locate the Gnash executable!");
return arg_vec;
}
arg_vec.push_back(cmd);
@@ -975,7 +935,7 @@
const char* pageurl = getCurrentPageURL();
if (!pageurl) {
- GnashLogError("Could not get current page URL!");
+ log_error("Could not get current page URL!");
} else {
arg_vec.push_back("-U");
arg_vec.push_back(pageurl);
@@ -1028,9 +988,7 @@
closed++;
}
}
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Closed " << closed << " files." << std::endl;
-#endif
+ log_debug("Closed %d files.", closed);
}
void
@@ -1066,20 +1024,20 @@
int ret = pipe(p2c_pipe);
if (ret == -1) {
- GnashLogError("ERROR: parent to child pipe() failed: " +
+ log_error("ERROR: parent to child pipe() failed: " +
std::string(std::strerror(errno)));
}
_streamfd = p2c_pipe[1];
ret = pipe(c2p_pipe);
if (ret == -1) {
- GnashLogError("ERROR: child to parent pipe() failed: " +
+ log_error("ERROR: child to parent pipe() failed: " +
std::string(std::strerror(errno)));
}
ret = pipe(p2c_controlpipe);
if (ret == -1) {
- GnashLogError("ERROR: parent to child pipe() failed: " +
+ log_error("ERROR: parent to child pipe() failed: " +
std::string(std::strerror(errno)));
}
@@ -1087,8 +1045,10 @@
#ifdef ENABLE_SCRIPTABLE
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)_scriptObject;
+#ifdef NETTEST
gpso->setControlFD(_controlfd);
#endif
+#endif
/*
Setup the command line for starting Gnash
@@ -1097,7 +1057,7 @@
std::vector<std::string> arg_vec = getCmdLine(c2p_pipe[1],
p2c_controlpipe[0]);
if (arg_vec.empty()) {
- GnashLogError("Failed to obtain command line parameters.");
+ log_error("Failed to obtain command line parameters.");
return;
}
@@ -1115,7 +1075,7 @@
// If the fork failed, childpid is -1. So print out an error message.
if (_childpid == -1) {
- GnashLogError("ERROR: dup2() failed: " + std::string(strerror(errno)));
+ log_error("ERROR: dup2() failed: " + std::string(strerror(errno)));
return;
}
@@ -1125,24 +1085,20 @@
// we want to write to p2c pipe, so close read-fd0
ret = close (p2c_pipe[0]);
if (ret == -1) {
- GnashLogError("ERROR: p2c_pipe[0] close() failed: " +
+ log_error("ERROR: p2c_pipe[0] close() failed: " +
std::string(strerror(errno)));
}
// we want to read from c2p pipe, so close write-fd1
ret = close (c2p_pipe[1]);
if (ret == -1) {
- GnashLogError("ERROR: c2p_pipe[1] close() failed: " +
+ log_error("ERROR: c2p_pipe[1] close() failed: " +
std::string(strerror(errno)));
}
ret = close (p2c_controlpipe[0]); // close read descriptor
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Forked successfully, child process PID is "
- << _childpid
- << std::endl;
-#endif
+ log_debug("Forked successfully, child process PID is %d" , _childpid);
GIOChannel* ichan = g_io_channel_unix_new(c2p_pipe[0]);
g_io_channel_set_close_on_unref(ichan, true);
@@ -1163,7 +1119,7 @@
ret = dup2 (p2c_pipe[0], fileno(stdin));
if (ret == -1) {
- GnashLogError("ERROR: dup2() failed: " + std::string(strerror(errno)));
+ log_error("ERROR: dup2() failed: " + std::string(strerror(errno)));
}
// Close all of the browser's file descriptors that we just inherited
@@ -1172,12 +1128,9 @@
int dontclose[] = {c2p_pipe[1], p2c_controlpipe[0]};
close_fds(dontclose);
- /* Start the desired executable and go away. */
+ // Start the desired executable and go away.
-#if GNASH_PLUGIN_DEBUG > 1
- std::cout << "Starting process: " << boost::algorithm::join(arg_vec, " ")
- << std::endl;
-#endif
+ log_debug("Starting process: %s", boost::algorithm::join(arg_vec, " "));
wait_for_gdb();
@@ -1204,7 +1157,7 @@
NPN_ReleaseObject(window);
if (!NPVARIANT_IS_OBJECT(vDoc)) {
- GnashLogError("Can't get window object");
+ log_error("Can't get window object");
return NULL;
}
@@ -1216,7 +1169,7 @@
NPN_ReleaseObject(npDoc);
if (!NPVARIANT_IS_OBJECT(vLoc)) {
- GnashLogError("Can't get window.location object");
+ log_error("Can't get window.location object");
return NULL;
}
@@ -1228,7 +1181,7 @@
NPN_ReleaseObject(npLoc);
if (!NPVARIANT_IS_STRING(vProp)) {
- GnashLogError("Can't get window.location.href object");
+ log_error("Can't get window.location.href object");
return NULL;
}
@@ -1248,6 +1201,20 @@
return desc;
}
+void
+processLog_error(const boost::format& fmt)
+{
+ std::cerr << "ERROR: " << fmt.str() << std::endl;
+}
+
+void
+processLog_debug(const boost::format& fmt)
+{
+#if GNASH_PLUGIN_DEBUG > 1
+ std::cout << "DEBUG: " << fmt.str() << std::endl;
+#endif
+}
+
// Local Variables:
// mode: C++
// indent-tabs-mode: nil
=== modified file 'plugin/npapi/plugin.h'
--- a/plugin/npapi/plugin.h 2010-04-08 19:42:32 +0000
+++ b/plugin/npapi/plugin.h 2010-04-14 19:28:49 +0000
@@ -46,6 +46,12 @@
#include <string>
#include <map>
#include <vector>
+#include <boost/format.hpp>
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/seq/for_each.hpp>
#include "pluginbase.h"
@@ -124,6 +130,66 @@
const char* getCurrentPageURL() const;
};
+// Define the following to make the plugin verbose
+// WARNING: will write to .xsession_errors !
+// Values:
+// 0: no messages at all
+// 1: fatal errors (errors preventing the plugin from working as it should)
+// 2: informational messages
+//
+#define GNASH_PLUGIN_DEBUG 2
+
+// This following logging code is copied from libbase/log.h, but
+// duplicated here because the plugin only needs a more trimmed down
+// version that doesn't require any Gnash libraires to keep the
+// memory footprint down.
+DSOEXPORT void processLog_error(const boost::format& fmt);
+DSOEXPORT void processLog_debug(const boost::format& fmt);
+
+/// This heap of steaming preprocessor code magically converts
+/// printf-style statements into boost::format messages using templates.
+//
+/// Macro to feed boost::format strings to the boost::format object,
+/// producing code like this: "% t1 % t2 % t3 ..."
+#define TOKENIZE_FORMAT(z, n, t) % t##n
+
+/// Macro to add a number of arguments to the templated function
+/// corresponding to the number of template arguments. Produces code
+/// like this: "const T0& t0, const T1& t1, const T2& t2 ..."
+#define TOKENIZE_ARGS(z, n, t) BOOST_PP_COMMA_IF(n) const T##n& t##n
+
+/// This is a sequence of different log message types to be used in
+/// the code. Append the name to log_ to call the function, e.g.
+/// log_error, log_unimpl.
+#define LOG_TYPES (error) (debug)
+/// The preprocessor generates templates with 1..ARG_NUMBER
+/// arguments.
+#define ARG_NUMBER 2
+#define LOG_TEMPLATES(z, n, data)\
+template<BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename T)>\
+inline void log_##data(BOOST_PP_REPEAT(BOOST_PP_INC(n), TOKENIZE_ARGS, t)) \
+{\
+ if (GNASH_PLUGIN_DEBUG < 1) return; \
+ boost::format f(t0); \
+ using namespace boost::io; \
+ f.exceptions(all_error_bits ^ (too_many_args_bit | \
+ too_few_args_bit | \
+ bad_format_string_bit)); \
+ processLog_##data(f BOOST_PP_REPEAT_FROM_TO(1, \
+ BOOST_PP_INC(n), \
+ TOKENIZE_FORMAT, t));\
+}
+
+/// Calls the macro LOG_TEMPLATES an ARG_NUMBER number
+/// of times, each time adding an extra typename argument to the
+/// template.
+#define GENERATE_LOG_TYPES(r, _, t) \
+ BOOST_PP_REPEAT(ARG_NUMBER, LOG_TEMPLATES, t)
+
+/// Calls the template generator for each log type in the
+/// sequence LOG_TYPES.
+BOOST_PP_SEQ_FOR_EACH(GENERATE_LOG_TYPES, _, LOG_TYPES)
+
// end of __PLUGIN_H__
#endif
=== modified file 'plugin/npapi/pluginScriptObject.cpp'
--- a/plugin/npapi/pluginScriptObject.cpp 2010-04-14 03:24:40 +0000
+++ b/plugin/npapi/pluginScriptObject.cpp 2010-04-14 19:28:49 +0000
@@ -46,10 +46,6 @@
extern NPNetscapeFuncs NPNFuncs;
-// Debugging utilities
-extern void GnashLogDebug(const std::string& msg);
-extern void GnashLogError(const std::string& msg);
-
// NPClass of GnashPluginScriptObject
static NPClass GnashPluginScriptObjectClass = {
NP_CLASS_STRUCT_VERSION,
@@ -115,7 +111,7 @@
testfunc (NPObject */* npobj */, NPIdentifier /* name */, const NPVariant
*/*args */,
uint32_t /* argCount */, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
DOUBLE_TO_NPVARIANT(122333.4444, *result);
@@ -127,22 +123,22 @@
{
if (NPVARIANT_IS_DOUBLE(*value)) {
double num = NPVARIANT_TO_DOUBLE(*value);
- printf("is double, value %g\n", num);
+ log_debug("is double, value %g", num);
} else if (NPVARIANT_IS_STRING(*value)) {
std::string str(NPVARIANT_TO_STRING(*value).UTF8Characters);
- printf("is string, value %s\n", str.c_str());
+ log_debug("is string, value %s", str);
} else if (NPVARIANT_IS_BOOLEAN(*value)) {
bool flag = NPVARIANT_TO_BOOLEAN(*value);
- printf("is boolean, value %d\n", flag);
+ log_debug("is boolean, value %d", flag);
} else if (NPVARIANT_IS_INT32(*value)) {
int num = NPVARIANT_TO_INT32(*value);
- printf("is int, value %d\n", num);
+ log_debug("is int, value %d", num);
} else if (NPVARIANT_IS_NULL(*value)) {
- printf("value is null\n");
+ log_debug("value is null");
} else if (NPVARIANT_IS_VOID(*value)) {
- printf("value is void\n");
+ log_debug("value is void");
} else if (NPVARIANT_IS_OBJECT(*value)) {
- printf("value is object\n");
+ log_debug("value is object");
}
}
@@ -162,7 +158,7 @@
SetVariableCallback (NPObject *npobj, NPIdentifier /* name */, const NPVariant
*args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -170,7 +166,7 @@
if (argCount == 2) {
varname = NPVARIANT_TO_STRING(args[0]).UTF8Characters;
NPVariant *value = const_cast<NPVariant *>(&args[1]);
- // printf("Setting Variable \"%s\"\n", varname.c_str());
+ // log_debug("Setting Variable \"%s\"", varname);
gpso->SetVariable(varname, value);
BOOLEAN_TO_NPVARIANT(true, *result);
return true;
@@ -191,7 +187,7 @@
const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
NPVariant *value = 0;
@@ -241,7 +237,7 @@
GotoFrame (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -255,7 +251,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't goto the specified frame, network
problems.");
+ log_error("Couldn't goto the specified frame, network problems.");
return false;
}
// gpso->GotoFrame(value);
@@ -277,7 +273,7 @@
IsPlaying (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args
*/,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -289,7 +285,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't check if the movie is playing, network
problems.");
+ log_error("Couldn't check if the movie is playing, network
problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
@@ -302,12 +298,12 @@
}
ptr = const_cast<char *>(data);
if (strncmp(ptr, "IsPlaying ", 10) != 0) {
- printf("Illegal response! %s\n", ptr);
+ log_error("Illegal response! %s", ptr);
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
} else {
// A legit response has CR on the end already
- printf("Legit response: %s", ptr);
+ log_debug("Legit response: %s", ptr);
}
ptr += 10;
bool flag = false;
@@ -335,7 +331,7 @@
LoadMovie (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -349,7 +345,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't load the movie, network problems.");
+ log_error("Couldn't load the movie, network problems.");
return false;
}
// gpso->LoadMovie();
@@ -371,7 +367,7 @@
Pan (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -395,7 +391,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't pan the movie, network problems.");
+ log_error("Couldn't pan the movie, network problems.");
return false;
}
BOOLEAN_TO_NPVARIANT(true, *result);
@@ -416,7 +412,7 @@
PercentLoaded (NPObject *npobj, NPIdentifier /* name */, const NPVariant
*/*args */,
uint32_t argCount, NPVariant *result)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -439,7 +435,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't check percent loaded, network problems.");
+ log_error("Couldn't check percent loaded, network problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
@@ -452,12 +448,12 @@
}
ptr = const_cast<char *>(data);
if (strncmp(ptr, "PercentLoaded ", 15) != 0) {
- printf("Illegal response! %s\n", ptr);
+ log_error("Illegal response! %s\n", ptr);
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
} else {
// A legit response has CR on the end already
- printf("Legit response: %s", ptr);
+ log_debug("Legit response: %s", ptr);
}
ptr += 15;
int percent = strtol(ptr, NULL, 0);
@@ -484,7 +480,7 @@
Play (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -496,7 +492,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't play movie, network problems.");
+ log_error("Couldn't play movie, network problems.");
return false;
}
// gpso->IsPlaying(value);
@@ -518,7 +514,7 @@
Rewind (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -530,7 +526,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't rewind movie, network problems.");
+ log_error("Couldn't rewind movie, network problems.");
return false;
}
// gpso->Rewind(value);
@@ -552,7 +548,7 @@
SetZoomRect (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -573,7 +569,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't Set the Zoom Rect the movie, network
problems.");
+ log_error("Couldn't Set the Zoom Rect the movie, network
problems.");
return false;
}
BOOLEAN_TO_NPVARIANT(true, *result);
@@ -594,7 +590,7 @@
StopPlay (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -606,7 +602,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't stop-play movie, network problems.");
+ log_error("Couldn't stop-play movie, network problems.");
return false;
}
// gpso->IsPlaying(value);
@@ -628,7 +624,7 @@
Zoom (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -642,7 +638,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't zoom movie, network problems.");
+ log_error("Couldn't zoom movie, network problems.");
return false;
}
BOOLEAN_TO_NPVARIANT(true, *result);
@@ -663,7 +659,7 @@
TotalFrames (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args
*/,
uint32_t argCount, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -675,7 +671,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't check percent loaded, network problems.");
+ log_error("Couldn't check percent loaded, network problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
@@ -688,12 +684,12 @@
}
ptr = const_cast<char *>(data);
if (strncmp(ptr, "TotalFrames ", 13) != 0) {
- printf("Illegal response! %s\n", ptr);
+ log_error("Illegal response! %s\n", ptr);
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
} else {
// A legit response has CR on the end already
- printf("Legit response: %s", ptr);
+ log_debug("Legit response: %s", ptr);
}
ptr += 13;
int frames = strtol(ptr, NULL, 0);
@@ -749,7 +745,7 @@
void
GnashPluginScriptObject::initializeIdentifiers()
{
-// GnashLogDebug("initializeIdentifiers");
+// log_debug("initializeIdentifiers");
// NPN_Status(_nppinstance, __FUNCTION__);
@@ -883,7 +879,7 @@
GnashPluginScriptObject::GnashPluginScriptObject()
: _nppinstance (0)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
initializeIdentifiers();
}
@@ -891,14 +887,14 @@
GnashPluginScriptObject::GnashPluginScriptObject(NPP npp)
: _nppinstance (npp)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
initializeIdentifiers();
}
// Destructor
GnashPluginScriptObject::~GnashPluginScriptObject()
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
// do nothing
}
@@ -906,14 +902,14 @@
NPClass *
GnashPluginScriptObject::marshalGetNPClass()
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
return &GnashPluginScriptObjectClass;
}
NPObject *
GnashPluginScriptObject::marshalAllocate (NPP npp, NPClass */* aClass */)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
#if 0
GnashPluginScriptObject *npobj = reinterpret_cast<GnashPluginScriptObject
*>
(NPN_MemAlloc(sizeof(GnashPluginScriptObject)));
@@ -928,7 +924,7 @@
void
GnashPluginScriptObject::marshalDeallocate (NPObject *npobj)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
#if 0
NPN_MemFree(reinterpret_cast<void *>(npobj));
#else
@@ -939,7 +935,7 @@
void
GnashPluginScriptObject::marshalInvalidate (NPObject */* npobj */)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
// gpso->Invalidate();
}
@@ -947,16 +943,16 @@
bool
GnashPluginScriptObject::marshalHasMethod (NPObject *npobj, NPIdentifier name)
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
#if 0
- printf("Checking for Method: ");
+ log_debug("Checking for Method: ");
if (NPN_IdentifierIsString(name)) {
- printf("%s\n", NPN_UTF8FromIdentifier(name));
+ log_debug("%s", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\n", NPN_IntFromIdentifier(name));
+ log_debug("%d", NPN_IntFromIdentifier(name));
}
#endif
@@ -968,7 +964,7 @@
const NPVariant *args, uint32_t
argCount,
NPVariant *result)
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -981,7 +977,7 @@
uint32_t argCount,
NPVariant *result)
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -991,7 +987,7 @@
bool
GnashPluginScriptObject::marshalHasProperty (NPObject *npobj, NPIdentifier
name)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -1002,7 +998,7 @@
GnashPluginScriptObject::marshalGetProperty (NPObject *npobj, NPIdentifier
name,
NPVariant *result)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
@@ -1013,7 +1009,7 @@
GnashPluginScriptObject::marshalSetProperty (NPObject *npobj, NPIdentifier
name,
const NPVariant *value)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
return gpso->SetProperty(name, value);
@@ -1022,7 +1018,7 @@
bool
GnashPluginScriptObject::marshalRemoveProperty (NPObject *npobj, NPIdentifier
name)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
return gpso->RemoveProperty(name);
@@ -1032,7 +1028,7 @@
GnashPluginScriptObject::marshalEnumerate (NPObject *npobj, void***identifier,
uint32_t *count)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
return gpso->Enumerate(identifier, count);
@@ -1044,7 +1040,7 @@
GnashPluginScriptObject::marshalConstruct (NPObject *npobj, const NPVariant
*data,
uint32_t count, NPVariant *result)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
return gpso->Construct(data, count, result);
@@ -1055,21 +1051,21 @@
bool
GnashPluginScriptObject::HasProperty(NPIdentifier name)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
#if 0
- printf("Checking for Property \"");
+ log_debug("Checking for Property \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
#endif
std::map<NPIdentifier, NPVariant *>::iterator it;
it = _properties.find(name);
if (it != _properties.end()) {
- // printf(" FOUND\n");
+ // log_debug(" FOUND");
return true;
}
@@ -1079,60 +1075,58 @@
bool
GnashPluginScriptObject::GetProperty(NPIdentifier name, NPVariant *result)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
- printf("Getting Property \"");
+ log_debug("Getting Property \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
std::map<NPIdentifier, NPVariant *>::iterator it;
it = _properties.find(name);
if (it != _properties.end()) {
- printf(" FOUND = ");
+// log_debug(" FOUND = ");
// We have to copy the data we hold internally into the result
// data object, rather than just resetting the result point to
// our internal copy, which doesn't work.
NPVariant *value = it->second;
if (NPVARIANT_IS_DOUBLE(*value)) {
double num = NPVARIANT_TO_DOUBLE(*value);
- printf(" %g", num);
+ log_debug(" %g", num);
DOUBLE_TO_NPVARIANT(num, *result);
} else if (NPVARIANT_IS_STRING(*value)) {
- printf(" %s", NPVARIANT_TO_STRING(*value).UTF8Characters);
+ log_debug(" %s", NPVARIANT_TO_STRING(*value).UTF8Characters);
STRINGN_TO_NPVARIANT(NPVARIANT_TO_STRING(*value).UTF8Characters,
NPVARIANT_TO_STRING(*value).UTF8Length,
*result);
} else if (NPVARIANT_IS_BOOLEAN(*value)) {
- printf(" %d", NPVARIANT_TO_BOOLEAN(*value));
+ log_debug(" %d", NPVARIANT_TO_BOOLEAN(*value));
BOOLEAN_TO_NPVARIANT(NPVARIANT_TO_BOOLEAN(*value), *result);
} else if (NPVARIANT_IS_INT32(*value)) {
- printf(" %d", NPVARIANT_TO_INT32(*value));
+ log_debug(" %d", NPVARIANT_TO_INT32(*value));
INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(*value), *result);
} else if (NPVARIANT_IS_NULL(*value)) {
- printf(" null value");
+ log_debug(" null value");
NULL_TO_NPVARIANT(*result);
} else if (NPVARIANT_IS_VOID(*value)) {
- printf(" void value");
+ log_debug(" void value");
VOID_TO_NPVARIANT(*result);
} else if (NPVARIANT_IS_OBJECT(*value)) {
- printf(" object");
+ log_debug(" object");
OBJECT_TO_NPVARIANT(NPVARIANT_TO_OBJECT(*value), *result);
}
- printf("\n");
return true;
}
- printf("\n");
return false;
};
bool
GnashPluginScriptObject::SetProperty(NPIdentifier name, const NPVariant *value)
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
_properties[name] = const_cast<NPVariant *>(value);
@@ -1142,7 +1136,7 @@
bool
GnashPluginScriptObject::RemoveProperty(NPIdentifier name)
{
- // GnashLogDebug(__PRETTY_FUNCTION__);
+ // log_debug(__PRETTY_FUNCTION__);
std::map<NPIdentifier, NPVariant *>::iterator it;
it = _properties.find(name);
@@ -1157,7 +1151,7 @@
bool
GnashPluginScriptObject::Enumerate(NPIdentifier **/*identifier */, uint32_t
*/* count */)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
return false;
}
@@ -1166,7 +1160,7 @@
GnashPluginScriptObject::Construct(const NPVariant */* args */, uint32_t /*
argCount */,
NPVariant */* result */)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
return false;
}
@@ -1174,21 +1168,21 @@
bool
GnashPluginScriptObject::HasMethod(NPIdentifier name)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
#if 0
- printf("Checking for Method \"");
+ log_debug("Checking for Method \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
#endif
std::map<NPIdentifier, NPInvokeFunctionPtr>::iterator it;
it = _methods.find(name);
if (it != _methods.end()) {
- // printf(" FOUND\n");
+ // log_debug(" FOUND");
return true;
}
@@ -1198,20 +1192,20 @@
bool
GnashPluginScriptObject::Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
#if 0
- printf("Invoking Method \"");
+ log_debug("Invoking Method \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...\n", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...\n", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
#endif
std::map<NPIdentifier, NPInvokeFunctionPtr>::iterator it;
it = _methods.find(name);
if (it != _methods.end()) {
- // printf(" FOUND\n");
+ // log_debug(" FOUND");
NPInvokeFunctionPtr func = it->second;
return func(NULL, name, args, argCount, result);
}
@@ -1223,13 +1217,13 @@
GnashPluginScriptObject::InvokeDefault(const NPVariant */* args */,
uint32_t /* argCount */, NPVariant */* result */)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
#if 0
- printf("Invoking Default Method \"");
+ log_debug("Invoking Default Method \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...\n", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...\n", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
#endif
@@ -1239,14 +1233,14 @@
bool
GnashPluginScriptObject::AddMethod(NPIdentifier name, NPInvokeFunctionPtr func)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
#if 0
- printf("Adding Method \"");
+ log_debug("Adding Method \"");
if (NPN_IdentifierIsString(name)) {
- printf("%s\"...\n", NPN_UTF8FromIdentifier(name));
+ log_debug("%s\"...", NPN_UTF8FromIdentifier(name));
} else {
- printf("%d\"...\n", NPN_IntFromIdentifier(name));
+ log_debug("%d\"...", NPN_IntFromIdentifier(name));
}
#endif
@@ -1261,7 +1255,7 @@
GnashPluginScriptObject::SetVariable(const std::string &name,
NPVariant *value)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
// Build the command message
std::stringstream ss;
@@ -1291,7 +1285,7 @@
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
if (ret != ss.str().size()) {
- GnashLogError("Couldn't set the variable, network problems.");
+ log_error("Couldn't set the variable, network problems.");
return false;
}
@@ -1304,7 +1298,7 @@
NPVariant *
GnashPluginScriptObject::GetVariable(const std::string &name)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
NPVariant *value = (NPVariant *)NPN_MemAlloc(sizeof(NPVariant));
NULL_TO_NPVARIANT(*value);
@@ -1314,7 +1308,7 @@
ss << "GetVariable " << name << std::endl;
size_t ret = writePlayer(controlfd, ss.str());
if (ret != ss.str().size()) {
- GnashLogError("Couldn't send GetVariable request, network problems.");
+ log_error("Couldn't send GetVariable request, network problems.");
return false;
}
@@ -1332,20 +1326,20 @@
// Make sure this mesasge is our response, whnich it should be,
// but you never know...
if (strncmp(ptr, "GetVariable ", 12) != 0) {
- printf("Illegal response! %s\n", ptr);
+ log_debug("Illegal response! %s", ptr);
return value;
} else {
// A legit response has CR on the end already
- printf("Legit response: %s", ptr);
+ log_debug("Legit response: %s", ptr);
}
ptr += 12;
#if 0
if (strncmp(ptr, name.c_str(), name.size()) == 0) {
- printf("Mismatched variable name! %s\n", ptr);
+ log_debug("Mismatched variable name! %s", ptr);
return value;
} else {
- printf("Variable names matched: %s\n", ptr);
+ log_debug("Variable names matched: %s", ptr);
}
#endif
ptr += name.size() + 1; // don't forget to skip the space
@@ -1380,7 +1374,7 @@
VOID_TO_NPVARIANT(*value);
} else if (strncmp(ptr, "object ", 7) == 0) {
ptr += 7;
- printf("\tFIXME: %s = object\n", name.c_str());
+ log_debug("\tFIXME: %s = object", name);
// OBJECT_TO_NPVARIANT(num, *value);
}
@@ -1395,7 +1389,7 @@
void
GnashPluginScriptObject::setControlFD(int x)
{
-// printf("%s: %d\n", __FUNCTION__, x);
+// log_debug("%s: %d", __FUNCTION__, x);
controlfd = x;
}
@@ -1403,7 +1397,7 @@
int
GnashPluginScriptObject::getControlFD()
{
- printf("%s: %d\n", __FUNCTION__, controlfd);
+ log_debug("getControlFD: %d", controlfd);
return controlfd;
};
@@ -1413,9 +1407,9 @@
int
GnashPluginScriptObject::writePlayer(int fd, const std::string &data)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
+ log_debug(__PRETTY_FUNCTION__);
- printf("Writing to fd #%d: %s\n", fd, data.c_str());
+// log_debug("Writing data: %s", data);
if (fd > 2) {
return writePlayer(fd, data.c_str(), data.size());
@@ -1427,13 +1421,13 @@
int
GnashPluginScriptObject::writePlayer(int fd, const char *data, size_t length)
{
- GnashLogDebug(__PRETTY_FUNCTION__);
-
- printf("Writing to fd #%d: %s\n", fd, data);
+ log_debug(__PRETTY_FUNCTION__);
if (fd > 2) {
return ::write(fd, data, length);
}
+
+// log_debug("Writing data: %s", data);
return 0;
}
@@ -1442,7 +1436,7 @@
int
GnashPluginScriptObject::readPlayer(int /* fd */, const std::string &/* data
*/)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
// return readPlayer(fd, data.c_str(), data.size());
@@ -1452,7 +1446,7 @@
int
GnashPluginScriptObject::readPlayer(int fd, const char **data, size_t length)
{
-// GnashLogDebug(__PRETTY_FUNCTION__);
+// log_debug(__PRETTY_FUNCTION__);
if (fd > 0) {
// Wait for some data from the player
@@ -1463,20 +1457,20 @@
struct timeval tval;
tval.tv_sec = 10;
tval.tv_usec = 0;
- printf("Waiting for data... ");
+ log_debug("Waiting for data... ");
if (select(fd+1, &fdset, NULL, NULL, &tval)) {
- // printf("There is data in the network\n");
+ // log_debug("There is data in the network");
#ifndef _WIN32
ioctl(fd, FIONREAD, &bytes);
#else
ioctlSocket(fd, FIONREAD, &bytes);
#endif
// } else {
- // printf("There is no data in thhe network\n");
+ // log_debug("There is no data in thhe network");
}
- printf("There are %d bytes in the network buffer\n", bytes);
+ log_debug("There are %d bytes in the network buffer", bytes);
// No data yet
if (bytes == 0) {
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12148: Port a trimmed down version of the log_error() and log_debug() functions,
Rob Savoye <=