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
5 changed files with 24 additions and 18 deletions
6
Makefile
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
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);
|
||||
}
|
||||
|
3
common.h
Normal file
3
common.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define MSGBUFSZ 32
|
||||
|
||||
void die(char *, ...);
|
|
@ -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
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…
Reference in a new issue