CPPFLAGS = -DVERSION=\"${VERSION}\"
CPPFLAGS += -DPROJECT=\"${PROJECT}\" -DPROJECT_UCFIRST=\"${PROJECT_UCFIRST}\"
-CPPFLAGS += -D_BSD_SOURCE -D_XOPEN_SOURCE=500
+CPPFLAGS += -D_XOPEN_SOURCE=500
ifeq ($(USEGTK3), 1)
CPPFLAGS += -DHAS_GTK3
endif
# normal compiler flags
CFLAGS += $(shell pkg-config --cflags $(LIBS))
-CFLAGS += -Wall -pipe -ansi -std=c99 -pedantic
+CFLAGS += -Wall -pipe -std=c99 -pedantic
CFLAGS += -Wmissing-declarations -Wmissing-parameter-type -Wno-overlength-strings
CFLAGS += ${CPPFLAGS}
LDFLAGS += ${LIBFLAGS}
*/
#include "config.h"
-#include <fcntl.h>
-#include <sys/file.h>
#include "main.h"
#include "history.h"
#include "util.h"
{
FILE *f;
if ((f = fopen(file, "w"))) {
- flock(fileno(f), LOCK_EX);
+ FLOCK(fileno(f), F_WRLCK);
/* overwrite the history file with new unique history items */
for (GList *link = list; link; link = link->next) {
}
}
- flock(fileno(f), LOCK_UN);
+ FLOCK(fileno(f), F_UNLCK);
fclose(f);
}
}
/* check if the char x is a char with CTRL like ^C */
#define IS_CTRL(x) (((guchar)x) <= 0x1f)
+#define FLOCK(fd, cmd) { \
+ struct flock lock = {.l_type=cmd,.l_start=0,.l_whence=SEEK_SET,.l_len=0}; \
+ fcntl(fd, F_SETLK, lock); \
+}
+
#ifdef DEBUG
#define PRINT_DEBUG(...) { \
fprintf(stderr, "\n\033[31;1mDEBUG:\033[0m %s:%d:%s()\t", __FILE__, __LINE__, __func__); \
*/
#include "config.h"
-#include <fcntl.h>
-#include <sys/file.h>
#include "main.h"
#include "session.h"
static void cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie, SoupCookie *new_cookie)
{
- flock(COOKIEJAR(self)->lock, LOCK_EX);
+ FLOCK(COOKIEJAR(self)->lock, F_WRLCK);
SoupDate *expire;
if (new_cookie && !new_cookie->expires && vb.config.cookie_timeout) {
expire = soup_date_new_from_now(vb.config.cookie_timeout);
soup_date_free(expire);
}
SOUP_COOKIE_JAR_CLASS(cookiejar_parent_class)->changed(self, old_cookie, new_cookie);
- flock(COOKIEJAR(self)->lock, LOCK_UN);
+ FLOCK(COOKIEJAR(self)->lock, F_UNLCK);
}
static void cookiejar_class_init(CookieJarClass *class)
static void cookiejar_set_property(GObject *self, guint prop_id, const
GValue *value, GParamSpec *pspec)
{
- flock(COOKIEJAR(self)->lock, LOCK_SH);
+ FLOCK(COOKIEJAR(self)->lock, F_RDLCK);
G_OBJECT_CLASS(cookiejar_parent_class)->set_property(self, prop_id, value, pspec);
- flock(COOKIEJAR(self)->lock, LOCK_UN);
+ FLOCK(COOKIEJAR(self)->lock, F_UNLCK);
}
#endif
*/
#include "config.h"
-#include <fcntl.h>
-#include <sys/file.h>
#include <stdio.h>
#include <pwd.h>
#include <ctype.h>
+#include "main.h"
#include "util.h"
#include "ascii.h"
FILE *f;
if ((f = fopen(file, "a+"))) {
- flock(fileno(f), LOCK_EX);
+ FLOCK(fileno(f), F_WRLCK);
va_start(args, format);
vfprintf(f, format, args);
va_end(args);
- flock(fileno(f), LOCK_UN);
+ FLOCK(fileno(f), F_UNLCK);
fclose(f);
return true;
content = util_get_file_contents(file, NULL);
if ((f = fopen(file, "w"))) {
- flock(fileno(f), LOCK_EX);
+ FLOCK(fileno(f), F_WRLCK);
va_start(args, format);
/* write new content to the file */
/* append previous file content */
fputs(content, f);
- flock(fileno(f), LOCK_UN);
+ FLOCK(fileno(f), F_UNLCK);
fclose(f);
res = true;