commit 8de4119da73c58f265547f1b6f3e117859189a67
parent 35cd70737bb6bc77591b3ac66afd8c7ad12dd529
Author: Quentin Rameau <quinq@fifth.space>
Date: Mon, 4 Jan 2016 16:09:12 +0100
Add a file for shared functions
New common.[hc] files where shared functions between surf and
webkitextension will be put. First addition is die().
Diffstat:
5 files changed, 23 insertions(+), 16 deletions(-)
diff --git 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
@@ -39,8 +39,8 @@ config.h:
libsurf-webext.la: $(LIBOBJ)
@echo libtool link $@
- @$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \
- libsurf-webext.lo -rpath $(DESTDIR)$(LIBPREFIX)
+ @$(LIBTOOL) --mode link --tag CC $(CC) $(LIB) $(LIBLDFLAGS) -o $@ \
+ $(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX)
surf: $(OBJ)
@echo CC -o $@
diff --git a/common.c 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
@@ -0,0 +1 @@
+void die(char *, ...);
diff --git a/libsurf-webext.c b/libsurf-webext.c
@@ -8,6 +8,8 @@
#include <webkitdom/webkitdom.h>
#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
+#include "common.h"
+
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
typedef struct Page {
diff --git a/surf.c b/surf.c
@@ -30,6 +30,7 @@
#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))
@@ -140,7 +141,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);
@@ -304,17 +304,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;