if (!npp || !npp->ndata) return NPERR_INVALID_INSTANCE_ERROR;
_getvalue(NPP npp, NPNVariable variable, void *result){  NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetValue: npp=%p, var=%d\n", (void*)npp, (int)variable));  nsresult res;  if(!npp || !npp->ndata)    return NPERR_INVALID_INSTANCE_ERROR;  switch(variable) {#ifdef XP_UNIX  case NPNVxDisplay:     return NPERR_GENERIC_ERROR;  case NPNVxtAppContext:     return NPERR_GENERIC_ERROR;#endif#ifdef XP_PC  case NPNVnetscapeWindow: {    ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;    nsIPluginInstancePeer *peer;    if (NS_SUCCEEDED(inst->GetPeer(&peer)) && peer) {      res = peer->GetValue(nsPluginInstancePeerVariable_NetscapeWindow, result);      NS_RELEASE(peer);      return res;    }    return NPERR_GENERIC_ERROR;  }#endif  case NPNVjavascriptEnabledBool: {    *(NPBool*)result = PR_TRUE;     nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID, &res));    if(NS_SUCCEEDED(res) && (nsnull != prefs)) {      PRBool js;      res = prefs->GetBoolPref("javascript.enabled", &js);      if(NS_SUCCEEDED(res))        *(NPBool*)result = js;     }    return NPERR_NO_ERROR;  }  case NPNVasdEnabledBool:     *(NPBool*)result = FALSE;     return NPERR_NO_ERROR;  case NPNVisOfflineBool:     *(NPBool*)result = FALSE;     return NPERR_NO_ERROR;  case NPNVserviceManager: {    // GetGlobalServiceManager does not AddRef, so we do here.    nsIServiceManager* serviceManager;    res = nsServiceManager::GetGlobalServiceManager(&serviceManager);    if (NS_SUCCEEDED(res)) {      *(nsIServiceManager**)result = serviceManager;      NS_ADDREF(serviceManager);      return NPERR_NO_ERROR;    } else      return NPERR_GENERIC_ERROR;  }  default : return NPERR_GENERIC_ERROR;  }#if 0  nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;  NS_ASSERTION(inst != NULL, "null instance");  if (inst == NULL)    return NPERR_INVALID_INSTANCE_ERROR;  nsIPluginInstancePeer *peer;  if (NS_OK == inst->GetPeer(&peer)) {    nsresult rv;    // XXX Note that for backwards compatibility, the old NPNVariables    // map correctly to NPPluginManagerVariables.    rv = peer->GetValue((nsPluginInstancePeerVariable)variable, result);    NS_RELEASE(peer);    return rv;  }  else    return NPERR_GENERIC_ERROR;#endif}