summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2016-01-04 16:09:12 +0100
committerQuentin Rameau <quinq@fifth.space>2018-10-08 11:38:03 +0200
commit1901359efa10fe2e18794df34fc33b81da03a6f5 (patch)
tree5f0267eb93763156d9b4348db7b62056bb064c12
parent7ea0c2f7f8c5cc4616d8dc0676f7b4b59351667b (diff)
downloadsurf-1901359efa10fe2e18794df34fc33b81da03a6f5.tar.gz
surf-1901359efa10fe2e18794df34fc33b81da03a6f5.tar.bz2
surf-1901359efa10fe2e18794df34fc33b81da03a6f5.zip
Add a file for shared functions
New common.[hc] files where shared functions between surf and webkitextension will be put. First addition is die().
-rw-r--r--Makefile6
-rw-r--r--common.c15
-rw-r--r--common.h3
-rw-r--r--libsurf-webext.c4
-rw-r--r--surf.c14
5 files changed, 24 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 9aace4f..0385a50 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,9 @@
include config.mk
-SRC = surf.c
+SRC = surf.c common.c
OBJ = $(SRC:.c=.o)
-LIBSRC = libsurf-webext.c
+LIBSRC = libsurf-webext.c common.c
LIBOBJ = $(LIBSRC:.c=.lo)
all: options libsurf-webext.la surf
@@ -38,7 +38,7 @@ config.h:
libsurf-webext.la: $(LIBOBJ)
@echo libtool link $@
@$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \
- $(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX)
+ $(LIBOBJ) $(LIB) -rpath $(DESTDIR)$(LIBPREFIX)
surf: $(OBJ)
@echo CC -o $@
diff --git a/common.c b/common.c
new file mode 100644
index 0000000..42662ed
--- /dev/null
+++ b/common.c
@@ -0,0 +1,15 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+die(const char *errstr, ...)
+{
+ va_list ap;
+
+ va_start(ap, errstr);
+ vfprintf(stderr, errstr, ap);
+ va_end(ap);
+ exit(1);
+}
+
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..527c4f7
--- /dev/null
+++ b/common.h
@@ -0,0 +1,3 @@
+#define MSGBUFSZ 32
+
+void die(char *, ...);
diff --git a/libsurf-webext.c b/libsurf-webext.c
index 6c3deb7..4270b47 100644
--- a/libsurf-webext.c
+++ b/libsurf-webext.c
@@ -8,9 +8,9 @@
#include <webkitdom/webkitdom.h>
#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
-#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
+#include "common.h"
-#define MSGBUFSZ 32
+#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
typedef struct Page {
guint64 id;
diff --git a/surf.c b/surf.c
index 25940f9..d48fbc9 100644
--- a/surf.c
+++ b/surf.c
@@ -30,10 +30,10 @@
#include <glib.h>
#include "arg.h"
+#include "common.h"
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
-#define MSGBUFSZ 32
enum { AtomFind, AtomGo, AtomUri, AtomLast };
@@ -142,7 +142,6 @@ typedef struct {
/* Surf */
static void usage(void);
-static void die(const char *errstr, ...);
static void setup(void);
static void sigchld(int unused);
static void sighup(int unused);
@@ -311,17 +310,6 @@ usage(void)
}
void
-die(const char *errstr, ...)
-{
- va_list ap;
-
- va_start(ap, errstr);
- vfprintf(stderr, errstr, ap);
- va_end(ap);
- exit(1);
-}
-
-void
setup(void)
{
GIOChannel *gchanin;