summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2009-06-23 20:25:11 +0200
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-02 22:30:10 +0100
commit6000eef96493e8c1f755eced77b9c2eea65172f8 (patch)
tree5ecddfbeade30126339c175cad457f86633e97c2 /plugin
parent560fd659f00c6b584fdbd4805038da640bcbfd5b (diff)
downloadfribid-6000eef96493e8c1f755eced77b9c2eea65172f8.tar.gz
fribid-6000eef96493e8c1f755eced77b9c2eea65172f8.tar.bz2
fribid-6000eef96493e8c1f755eced77b9c2eea65172f8.zip
Code cleanup & fixed memory errors
Diffstat (limited to 'plugin')
-rw-r--r--plugin/np_entry.c6
-rw-r--r--plugin/npmain.c4
-rw-r--r--plugin/npn_gate.c176
-rw-r--r--plugin/npobject.c12
4 files changed, 100 insertions, 98 deletions
diff --git a/plugin/np_entry.c b/plugin/np_entry.c
index 7b15313..e42b4e6 100644
--- a/plugin/np_entry.c
+++ b/plugin/np_entry.c
@@ -76,7 +76,7 @@ EXPORT NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
//pFuncs->urlnotify = NPP_URLNotify;
pFuncs->getvalue = NPP_GetValue;
//pFuncs->setvalue = NPP_SetValue;
- pFuncs->javaClass = NULL;
+ //pFuncs->javaClass = NULL;
return NPERR_NO_ERROR;
}
@@ -176,9 +176,9 @@ NP_Initialize(NPNetscapeFuncs* pFuncs
//pluginFuncs->write = NPP_Write;
//pluginFuncs->print = NPP_Print;
//pluginFuncs->urlnotify = NPP_URLNotify;
- pluginFuncs->event = NULL;
+ //pluginFuncs->event = NULL;
pluginFuncs->getvalue = NPP_GetValue;
- pluginFuncs->javaClass = NULL;
+ //pluginFuncs->javaClass = NULL;
NPP_Initialize();
#endif
diff --git a/plugin/npmain.c b/plugin/npmain.c
index 3bcc048..c1e473c 100644
--- a/plugin/npmain.c
+++ b/plugin/npmain.c
@@ -51,10 +51,10 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save) {
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
switch (variable) {
case NPPVpluginNameString:
- *((char**)value) = "BankID e-legitimation";
+ *((const char**)value) = "BankID e-legitimation";
return NPERR_NO_ERROR;
case NPPVpluginDescriptionString:
- *((char**)value) = "Insticksmodul för BankID e-legitimation";
+ *((const char**)value) = "Insticksmodul för BankID e-legitimation";
return NPERR_NO_ERROR;
case NPPVpluginScriptableNPObject:
*((NPObject**)value) = (NPObject*)instance->pdata;
diff --git a/plugin/npn_gate.c b/plugin/npn_gate.c
index e3cd29e..bbef7be 100644
--- a/plugin/npn_gate.c
+++ b/plugin/npn_gate.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -55,263 +55,263 @@ extern NPNetscapeFuncs NPNFuncs;
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
- *plugin_major = NP_VERSION_MAJOR;
- *plugin_minor = NP_VERSION_MINOR;
- *netscape_major = HIBYTE(NPNFuncs.version);
- *netscape_minor = LOBYTE(NPNFuncs.version);
+ *plugin_major = NP_VERSION_MAJOR;
+ *plugin_minor = NP_VERSION_MINOR;
+ *netscape_major = HIBYTE(NPNFuncs.version);
+ *netscape_minor = LOBYTE(NPNFuncs.version);
}
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
+ int navMinorVers = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ if (navMinorVers >= NPVERS_HAS_NOTIFICATION)
+ rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
- return rv;
+ return rv;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
- NPError rv = NPNFuncs.geturl(instance, url, target);
- return rv;
+ NPError rv = NPNFuncs.geturl(instance, url, target);
+ return rv;
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
{
- int navMinorVers = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
+ int navMinorVers = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
- rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ if (navMinorVers >= NPVERS_HAS_NOTIFICATION)
+ rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
- return rv;
+ return rv;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
{
- NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
- return rv;
+ NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
+ return rv;
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
- NPError rv = NPNFuncs.requestread(stream, rangeList);
- return rv;
+ NPError rv = NPNFuncs.requestread(stream, rangeList);
+ return rv;
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
{
- int navMinorVersion = NPNFuncs.version & 0xFF;
+ int navMinorVersion = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
+ NPError rv = NPERR_NO_ERROR;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = NPNFuncs.newstream(instance, type, target, stream);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ if (navMinorVersion >= NPVERS_HAS_STREAMOUTPUT)
+ rv = NPNFuncs.newstream(instance, type, target, stream);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
- return rv;
+ return rv;
}
int32_t NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- int32_t rv = 0;
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+ int32_t rv = 0;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = NPNFuncs.write(instance, stream, len, buffer);
- else
- rv = -1;
+ if (navMinorVersion >= NPVERS_HAS_STREAMOUTPUT)
+ rv = NPNFuncs.write(instance, stream, len, buffer);
+ else
+ rv = -1;
- return rv;
+ return rv;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
- int navMinorVersion = NPNFuncs.version & 0xFF;
- NPError rv = NPERR_NO_ERROR;
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
- rv = NPNFuncs.destroystream(instance, stream, reason);
- else
- rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ if (navMinorVersion >= NPVERS_HAS_STREAMOUTPUT)
+ rv = NPNFuncs.destroystream(instance, stream, reason);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
- return rv;
+ return rv;
}
void NPN_Status(NPP instance, const char *message)
{
- NPNFuncs.status(instance, message);
+ NPNFuncs.status(instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
- const char * rv = NULL;
- rv = NPNFuncs.uagent(instance);
- return rv;
+ const char * rv = NULL;
+ rv = NPNFuncs.uagent(instance);
+ return rv;
}
void* NPN_MemAlloc(uint32_t size)
{
- void * rv = NULL;
- rv = NPNFuncs.memalloc(size);
- return rv;
+ void * rv = NULL;
+ rv = NPNFuncs.memalloc(size);
+ return rv;
}
void NPN_MemFree(void* ptr)
{
- NPNFuncs.memfree(ptr);
+ NPNFuncs.memfree(ptr);
}
uint32_t NPN_MemFlush(uint32_t size)
{
- uint32_t rv = NPNFuncs.memflush(size);
- return rv;
+ uint32_t rv = NPNFuncs.memflush(size);
+ return rv;
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
- NPNFuncs.reloadplugins(reloadPages);
+ NPNFuncs.reloadplugins(reloadPages);
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
- NPError rv = NPNFuncs.getvalue(instance, variable, value);
- return rv;
+ NPError rv = NPNFuncs.getvalue(instance, variable, value);
+ return rv;
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
- NPError rv = NPNFuncs.setvalue(instance, variable, value);
- return rv;
+ NPError rv = NPNFuncs.setvalue(instance, variable, value);
+ return rv;
}
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
- NPNFuncs.invalidaterect(instance, invalidRect);
+ NPNFuncs.invalidaterect(instance, invalidRect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
- NPNFuncs.invalidateregion(instance, invalidRegion);
+ NPNFuncs.invalidateregion(instance, invalidRegion);
}
void NPN_ForceRedraw(NPP instance)
{
- NPNFuncs.forceredraw(instance);
+ NPNFuncs.forceredraw(instance);
}
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
{
- return NPNFuncs.getstringidentifier(name);
+ return NPNFuncs.getstringidentifier(name);
}
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
NPIdentifier *identifiers)
{
- NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
+ NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
}
bool NPN_IdentifierIsString(NPIdentifier identifier)
{
- return NPNFuncs.identifierisstring(identifier);
+ return NPNFuncs.identifierisstring(identifier);
}
NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
{
- return NPNFuncs.utf8fromidentifier(identifier);
+ return NPNFuncs.utf8fromidentifier(identifier);
}
int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
{
- return NPNFuncs.intfromidentifier(identifier);
+ return NPNFuncs.intfromidentifier(identifier);
}
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
{
- return NPNFuncs.createobject(npp, aClass);
+ return NPNFuncs.createobject(npp, aClass);
}
NPObject *NPN_RetainObject(NPObject *obj)
{
- return NPNFuncs.retainobject(obj);
+ return NPNFuncs.retainobject(obj);
}
void NPN_ReleaseObject(NPObject *obj)
{
- NPNFuncs.releaseobject(obj);
+ NPNFuncs.releaseobject(obj);
}
bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
const NPVariant *args, uint32_t argCount, NPVariant *result)
{
- return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
+ return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
}
bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
+ return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
}
bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
- NPVariant *result)
+ NPVariant *result)
{
- return NPNFuncs.evaluate(npp, obj, script, result);
+ return NPNFuncs.evaluate(npp, obj, script, result);
}
bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
- NPVariant *result)
+ NPVariant *result)
{
- return NPNFuncs.getproperty(npp, obj, propertyName, result);
+ return NPNFuncs.getproperty(npp, obj, propertyName, result);
}
bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
const NPVariant *value)
{
- return NPNFuncs.setproperty(npp, obj, propertyName, value);
+ return NPNFuncs.setproperty(npp, obj, propertyName, value);
}
bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
{
- return NPNFuncs.removeproperty(npp, obj, propertyName);
+ return NPNFuncs.removeproperty(npp, obj, propertyName);
}
bool NPN_Enumerate(NPP npp, NPObject *obj, NPIdentifier **identifier,
- uint32_t *count)
+ uint32_t *count)
{
- return NPNFuncs.enumerate(npp, obj, identifier, count);
+ return NPNFuncs.enumerate(npp, obj, identifier, count);
}
bool NPN_Construct(NPP npp, NPObject *obj, const NPVariant *args,
- uint32_t argCount, NPVariant *result)
+ uint32_t argCount, NPVariant *result)
{
- return NPNFuncs.construct(npp, obj, args, argCount, result);
+ return NPNFuncs.construct(npp, obj, args, argCount, result);
}
bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
{
- return NPNFuncs.hasproperty(npp, obj, propertyName);
+ return NPNFuncs.hasproperty(npp, obj, propertyName);
}
bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
{
- return NPNFuncs.hasmethod(npp, obj, methodName);
+ return NPNFuncs.hasmethod(npp, obj, methodName);
}
void NPN_ReleaseVariantValue(NPVariant *variant)
{
- NPNFuncs.releasevariantvalue(variant);
+ NPNFuncs.releasevariantvalue(variant);
}
void NPN_SetException(NPObject* obj, const NPUTF8 *message)
{
- NPNFuncs.setexception(obj, message);
+ NPNFuncs.setexception(obj, message);
}
diff --git a/plugin/npobject.c b/plugin/npobject.c
index fc500f8..c45d5b7 100644
--- a/plugin/npobject.c
+++ b/plugin/npobject.c
@@ -73,8 +73,9 @@ static char *getWindowProperty(NPP instance, const char const *identifiers[]) {
while (1) {
NPVariant value;
- getProperty(instance, obj, *identifier, &value);
+ bool ok = getProperty(instance, obj, *identifier, &value);
NPN_ReleaseObject(obj);
+ if (!ok) return NULL;
identifier++;
if (*identifier) {
@@ -120,12 +121,13 @@ static char *getDocumentIP(NPP instance) {
// the plugin authenticates with the real IP.
char *hostname = getDocumentHostname(instance);
- struct addrinfo *ai;
- int ret = getaddrinfo(hostname, NULL, NULL, &ai);
+ struct addrinfo *firstAddrInfo;
+ int ret = getaddrinfo(hostname, NULL, NULL, &firstAddrInfo);
free(hostname);
if (ret != 0) return NULL;
// Find first INET address
+ const struct addrinfo *ai = firstAddrInfo;
while (ai && (ai->ai_family != AF_INET) && (ai->ai_family != AF_INET6))
ai = ai->ai_next;
@@ -134,10 +136,10 @@ static char *getDocumentIP(NPP instance) {
char ip[NI_MAXHOST];
if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ip, NI_MAXHOST,
NULL, 0, NI_NUMERICHOST) != 0) {
- freeaddrinfo(ai);
+ freeaddrinfo(firstAddrInfo);
return NULL;
}
- freeaddrinfo(ai);
+ freeaddrinfo(firstAddrInfo);
return strdup(ip);
}