Browse Source

Add a file for shared functions

New common.[hc] files where shared functions between surf and
webkitextension will be put. First addition is die().
surf-webkit2
Quentin Rameau 6 years ago
parent
commit
1901359efa
  1. 6
      Makefile
  2. 15
      common.c
  3. 3
      common.h
  4. 4
      libsurf-webext.c
  5. 14
      surf.c

6
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 $@

15
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);
}

3
common.h

@ -0,0 +1,3 @@
#define MSGBUFSZ 32
void die(char *, ...);

4
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;

14
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);
@ -310,17 +309,6 @@ usage(void)
"[-r scriptfile] [-u useragent] [-z zoomlevel] [uri]\n");
}
void
die(const char *errstr, ...)
{
va_list ap;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(1);
}
void
setup(void)
{

Loading…
Cancel
Save