NPError NPP_Initialize() { #if 1 log_function(); #endif return NPERR_NO_ERROR; }
NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value ) { #if 1 log_function(); #endif return NPERR_GENERIC_ERROR; }
void NPP_URLNotify( NPP instance, const char * url, NPReason reason, void * notifyData ) { // We can handle URL's here. #if 1 log_function(); #endif }
NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char * argn[], char * argv[], NPSavedData * saved ) { NPError status; #if 1 log_function(); #endif if (instance == 0) { log_debug("NPERR_INVALID_INSTANCE_ERROR"); return NPERR_INVALID_INSTANCE_ERROR; } g_instance = instance; little_shoot_plugin * plugin = new little_shoot_plugin(instance, mode); if (0 == plugin) { log_debug("NPERR_OUT_OF_MEMORY_ERROR"); return NPERR_OUT_OF_MEMORY_ERROR; } status = plugin->init( argc, const_cast<const char **> (argn), const_cast<const char **> (argv) ); if (NPERR_NO_ERROR == status) { log_debug("NPERR_NO_ERROR"); instance->pdata = reinterpret_cast<void *>(plugin); NPN_Status(instance, "LittleShoot P2P Plugin loaded."); #if 0 NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false); NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false); #endif } else { delete plugin; } return status; }
void NPP_StreamAsFile(NPP instance, NPStream * stream, const char * fname ) { #if 1 log_function(); #endif if (instance == 0 ) { return; } // We can stream data from the browser here. if (stream && fname) { log_debug("stream = " << stream << ", fname = " << fname); } if (fname) { } }
void NPP_Print(NPP instance, NPPrint * printInfo) { #if 1 log_function(); #endif if (printInfo == 0 ) { return; } if (instance != 0 ) { if (printInfo->mode == NP_FULL) { printInfo->print.fullPrint.pluginPrinted = false; } else { } } }
NPError NPP_Destroy(NPP instance, NPSavedData ** save ) { #if 1 log_function(); #endif if (0 == instance) { return NPERR_INVALID_INSTANCE_ERROR; } little_shoot_plugin * plugin = reinterpret_cast<little_shoot_plugin *>( instance->pdata ); if (0 == plugin) { return NPERR_NO_ERROR; } instance->pdata = 0; #if XP_WIN HWND win = (HWND)plugin->get_window().window; WNDPROC winproc = plugin->get_wndproc(); if (winproc) { SetWindowLong(win, GWL_WNDPROC, (LONG)winproc ); } #endif delete plugin; return NPERR_NO_ERROR; }
static VALUE do_log( void ( *log_function )( const char *format, ... ), int argc, VALUE *argv ) { VALUE message = rb_f_sprintf( argc, argv ); log_function( StringValuePtr( message ) ); return message; }
static void connect_client(const char *slave) { char *name, *port; struct client *c = ecalloc(1, sizeof(*c)); struct addrinfo hints, *res0, *res; int ret, fd; name = estrdup(slave); port = strchr(name, ':'); if (port == NULL) errx(1, "port missing from %s", name); *port++ = 0; c->name = estrdup(slave); memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; ret = getaddrinfo(name, port, &hints, &res0); if (ret) errx(1, "error resolving %s", name); for (res = res0, fd = -1; res; res = res->ai_next) { fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (fd < 0) continue; if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) { close(fd); fd = -1; continue; } c->sa = ecalloc(1, res->ai_addrlen); memcpy(c->sa, res->ai_addr, res->ai_addrlen); c->salen = res->ai_addrlen; break; /* okay we got one */ } if (fd < 0) err(1, "connect to host: %s", name); freeaddrinfo(res); c->sock = krb5_storage_from_fd(fd); close(fd); if (c->sock == NULL) errx(1, "krb5_storage_from_fd"); { int32_t version; char *str = NULL; get_version_capa(c, &version, &c->capabilities, &str); if (str) { free(str); } if (c->capabilities & HAS_MONIKER) get_moniker(c, &c->moniker); else c->moniker = c->name; if (c->capabilities & ISSERVER) get_targetname(c, &c->target_name); } if (logfile) { int fd; printf("starting log socket to client %s\n", c->moniker); fd = wait_log(c); c->logsock = krb5_storage_from_fd(fd); close(fd); if (c->logsock == NULL) errx(1, "failed to create log krb5_storage"); #ifdef ENABLE_PTHREAD_SUPPORT pthread_create(&c->thr, NULL, log_function, c); #else c->child = fork(); if (c->child == -1) errx(1, "failed to fork"); else if (c->child == 0) { log_function(c); fclose(logfile); exit(0); } #endif } clients = erealloc(clients, (num_clients + 1) * sizeof(*clients)); clients[num_clients] = c; num_clients++; free(name); }
NPError NPP_GetValue(NPP instance, NPPVariable variable, void * value ) { #if 1 log_function(); #endif static char psz_desc[1000]; /* plugin class variables */ switch (variable) { case NPPVpluginNameString: *((char **)value) = PLUGIN_NAME; return NPERR_NO_ERROR; case NPPVpluginDescriptionString: snprintf(psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, get_version()); //log_debug("NPP_GetValue: psz_desc = " << static_cast<char *> (psz_desc)); *((char **)value) = psz_desc; return NPERR_NO_ERROR; default: snprintf(psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, get_version()); /*log_debug( "NPP_GetValue: default = " << reinterpret_cast<char *> (variable) << ":" << reinterpret_cast<char *> (psz_desc) );*/ ; } if (instance == 0) { return NPERR_INVALID_INSTANCE_ERROR; } little_shoot_plugin * plugin = reinterpret_cast<little_shoot_plugin *>( instance->pdata ); if (0 == plugin) { return NPERR_INVALID_INSTANCE_ERROR; } switch (variable) { case NPPVpluginScriptableNPObject: { NPClass * scriptClass = plugin->getScriptClass(); if (scriptClass) { *(NPObject **)value = NPN_CreateObject(instance, scriptClass); return NPERR_NO_ERROR; } break; } default: ; } return NPERR_GENERIC_ERROR; }
NPError NPP_DestroyStream(NPP instance, NPStream * stream, NPError reason) { #if 1 log_function(); #endif if (!instance) { return NPERR_INVALID_INSTANCE_ERROR; } else { little_shoot_plugin * plugin = reinterpret_cast<little_shoot_plugin *>( instance->pdata ); if (!plugin) { return NPERR_INVALID_INSTANCE_ERROR; } else { plugin->destroy_stream(stream->url); if (!plugin->get_stream()) { const char * download_test_url = "http://www.littleshoot.org/downloadsWindow"; NPN_GetURL( instance, download_test_url, "_self" ); /* static bool did_open_download_window = false; if (!did_open_download_window) { did_open_download_window = true; NPN_GetURL( instance, download_test_url, "_blank" ); } NPN_GetURL( instance, "javascript:history.go(-1)", "_self" ); */ // // // NPStream * s = plugin->get_stream(); // // NPN_NewStream(instance, "text/html", 0, &s); // // // char html_buf[] = "<html>\n<body>\n\n<h2 align=center>LittleShoot is loading foo.bar...</h2>\n\n</body>\n</html>"; // // int32 written = NPN_Write(instance, s, strlen(html_buf), html_buf); // // log_debug("Wrote " << written << " bytes."); } // NPN_DestroyStream(instance, s, NPRES_DONE); } } return NPERR_NO_ERROR; }
void NPP_Shutdown() { #if 1 log_function(); #endif }