summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2009-12-30 23:51:45 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-02 22:30:15 +0100
commit570a5dd1ae37292a2f80acf6021ba4aa8ea35106 (patch)
tree3854509a02c476fca35a5bea60e6a822efdf9826 /plugin
parent3e7de18f943e10a93e31bde67a161c76db009699 (diff)
downloadfribid-570a5dd1ae37292a2f80acf6021ba4aa8ea35106.tar.gz
fribid-570a5dd1ae37292a2f80acf6021ba4aa8ea35106.tar.bz2
fribid-570a5dd1ae37292a2f80acf6021ba4aa8ea35106.zip
Increase use of const and static in the code
...and use char arrays instead of char pointers for string constants to avoid unnecessary indirection.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ipc.c8
-rw-r--r--plugin/npobject.c12
-rw-r--r--plugin/npobject.h1
3 files changed, 10 insertions, 11 deletions
diff --git a/plugin/ipc.c b/plugin/ipc.c
index 4032f8a..d76276d 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -36,10 +36,10 @@
#include "../common/pipe.h"
#include "plugin.h"
-static const char *mainBinary = SIGNING_EXECUTABLE;
-static const char *versionOption = "--internal--bankid-version-string";
-static const char *ipcOption = "--internal--ipc";
-static const char *windowIdOption = "--internal--window-id";
+static const char mainBinary[] = SIGNING_EXECUTABLE;
+static const char versionOption[] = "--internal--bankid-version-string";
+static const char ipcOption[] = "--internal--ipc";
+static const char windowIdOption[] = "--internal--window-id";
#define PIPE_READ_END 0
#define PIPE_WRITE_END 1
diff --git a/plugin/npobject.c b/plugin/npobject.c
index 5e41783..2de8eab 100644
--- a/plugin/npobject.c
+++ b/plugin/npobject.c
@@ -51,7 +51,7 @@ static char *strndup(const char *source, int maxLength) {
}
// Re-allocates a string with NPN_MemAlloc instead of malloc
-char *npstr(char *source) {
+static char *npstr(char *source) {
int size = strlen(source)+1;
char *dest = NPN_MemAlloc(size);
memcpy(dest, source, size);
@@ -64,12 +64,12 @@ static bool getProperty(NPP instance, NPObject *obj, const char *name, NPVariant
return NPN_GetProperty(instance, obj, ident, result);
}
-static char *getWindowProperty(NPP instance, const char const *identifiers[]) {
+static char *getWindowProperty(NPP instance, const char *const identifiers[]) {
NPObject *obj;
NPN_GetValue(instance, NPNVWindowNPObject, &obj);
- const char **identifier = &identifiers[0];
+ const char *const *identifier = &identifiers[0];
while (1) {
NPVariant value;
@@ -100,14 +100,14 @@ static char *getWindowProperty(NPP instance, const char const *identifiers[]) {
}
static char *getDocumentURL(NPP instance) {
- static const char const *identifiers[] = {
+ static const char *const identifiers[] = {
"document", "location", "href", NULL
};
return getWindowProperty(instance, identifiers);
}
static char *getDocumentHostname(NPP instance) {
- static const char const *identifiers[] = {
+ static const char *const identifiers[] = {
"document", "location", "hostname", NULL
};
return getWindowProperty(instance, identifiers);
@@ -147,7 +147,7 @@ static char *getDocumentIP(NPP instance) {
/**
* Returns the native ID of the browser window, or -1 on error.
*/
-int getWindowId(NPP instance) {
+static int getWindowId(NPP instance) {
int id;
if (NPN_GetValue(instance, NPNVnetscapeWindow, &id) == NPERR_NO_ERROR) {
return id;
diff --git a/plugin/npobject.h b/plugin/npobject.h
index 214ac63..69bde5b 100644
--- a/plugin/npobject.h
+++ b/plugin/npobject.h
@@ -36,7 +36,6 @@ typedef struct {
Plugin *plugin;
} PluginObject;
-char *npstr(char *source);
NPObject *npobject_fromMIME(NPP instance, NPMIMEType mimeType);
#endif