Add a file for shared functions
New common.[hc] files where shared functions between surf and webkitextension will be put. First addition is die().
This commit is contained in:
parent
7ea0c2f7f8
commit
1901359efa
6
Makefile
6
Makefile
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = surf.c
|
SRC = surf.c common.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
LIBSRC = libsurf-webext.c
|
LIBSRC = libsurf-webext.c common.c
|
||||||
LIBOBJ = $(LIBSRC:.c=.lo)
|
LIBOBJ = $(LIBSRC:.c=.lo)
|
||||||
|
|
||||||
all: options libsurf-webext.la surf
|
all: options libsurf-webext.la surf
|
||||||
|
@ -38,7 +38,7 @@ config.h:
|
||||||
libsurf-webext.la: $(LIBOBJ)
|
libsurf-webext.la: $(LIBOBJ)
|
||||||
@echo libtool link $@
|
@echo libtool link $@
|
||||||
@$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \
|
@$(LIBTOOL) --mode link --tag CC $(CC) $(LIBLDFLAGS) -o $@ \
|
||||||
$(LIBOBJ) -rpath $(DESTDIR)$(LIBPREFIX)
|
$(LIBOBJ) $(LIB) -rpath $(DESTDIR)$(LIBPREFIX)
|
||||||
|
|
||||||
surf: $(OBJ)
|
surf: $(OBJ)
|
||||||
@echo CC -o $@
|
@echo CC -o $@
|
||||||
|
|
15
common.c
Normal file
15
common.c
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include <webkitdom/webkitdom.h>
|
#include <webkitdom/webkitdom.h>
|
||||||
#include <webkitdom/WebKitDOMDOMWindowUnstable.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 {
|
typedef struct Page {
|
||||||
guint64 id;
|
guint64 id;
|
||||||
|
|
14
surf.c
14
surf.c
|
@ -30,10 +30,10 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
|
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
|
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
|
||||||
#define MSGBUFSZ 32
|
|
||||||
|
|
||||||
enum { AtomFind, AtomGo, AtomUri, AtomLast };
|
enum { AtomFind, AtomGo, AtomUri, AtomLast };
|
||||||
|
|
||||||
|
@ -142,7 +142,6 @@ typedef struct {
|
||||||
|
|
||||||
/* Surf */
|
/* Surf */
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
static void die(const char *errstr, ...);
|
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
static void sighup(int unused);
|
static void sighup(int unused);
|
||||||
|
@ -310,17 +309,6 @@ usage(void)
|
||||||
"[-r scriptfile] [-u useragent] [-z zoomlevel] [uri]\n");
|
"[-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
|
void
|
||||||
setup(void)
|
setup(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user