From: Andre <maan@p133.(none)>
Date: Fri, 7 Apr 2006 11:23:57 +0000 (+0200)
Subject: New source files: fd.c/fd.h
X-Git-Tag: v0.2.12~110
X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=f2a7b00cf72104a38733b7bf3add9fb19dd71c93;p=paraslash.git

New source files: fd.c/fd.h

ATM, they only contain the file_exists() function which was pulled
out from exec.c. More to follow.
---

diff --git a/Makefile.in b/Makefile.in
index 834e4463..2c64d19d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -88,7 +88,8 @@ web_misc := $(patsubst %,web/sync/%,$(web_misc))
 misc := bash_completion
 headers := para.h server.h SFont.h crypt.h list.h http.h send.h ortp.h rc4.h \
 	close_on_fork.h afs.h db.h gcc-compat.h recv.h filter.h audiod.h \
-	grab_client.h error.h net.h ringbuffer.h daemon.h string.h ipc.h dccp.h
+	grab_client.h error.h net.h ringbuffer.h daemon.h string.h ipc.h dccp.h \
+	fd.h
 scripts := install-sh configure
 autocrap := Makefile.in config.h.in configure.ac autogen.sh
 tarball := web/sync/doc pics fonts $(c_sources) $(sample_conf) $(headers) \
@@ -100,10 +101,12 @@ all: $(BINARIES)
 www: $(gen_html) $(gruta_html) $(web_pics) $(web_misc) $(shots) tags doxygen
 
 client_objs = client.cmdline.o client.o net.o string.o crypt.o
-gui_objs = gui.cmdline.o gui.o gui_common.o exec.o close_on_fork.o signal.o string.o gui_theme.o stat.o ringbuffer.o
-sdl_gui_objs = sdl_gui.cmdline.o SFont.o sdl_gui.o gui_common.o exec.o close_on_fork.o string.o stat.o
+gui_objs = gui.cmdline.o gui.o gui_common.o exec.o close_on_fork.o signal.o \
+	string.o gui_theme.o stat.o ringbuffer.o fd.o
+sdl_gui_objs = sdl_gui.cmdline.o SFont.o sdl_gui.o gui_common.o exec.o \
+	close_on_fork.o string.o stat.o fd.o
 dbadm_objs = dbadm.o exec.o close_on_fork.o string.o
-fade_objs = fade.cmdline.o fade.o exec.o close_on_fork.o string.o
+fade_objs = fade.cmdline.o fade.o exec.o close_on_fork.o string.o fd.o
 krell_objs = krell.o string.o
 slider_objs = slider.o string.o
 audioc_objs = audioc.cmdline.o audioc.o string.o net.o
diff --git a/audiod.c b/audiod.c
index 695a6cfd..581cec15 100644
--- a/audiod.c
+++ b/audiod.c
@@ -34,6 +34,7 @@
 #include "net.h"
 #include "daemon.h"
 #include "string.h"
+#include "fd.h"
 
 /** define the array of error lists needed by para_audiod */
 INIT_AUDIOD_ERRLISTS;
diff --git a/configure.ac b/configure.ac
index f95a1682..19c2ae43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,7 @@ filter_ldflags=""
 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
 	http_recv.cmdline dccp_recv.cmdline"
 audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
-	time grab_client filter_chain wav compress http_recv dccp dccp_recv recv_common"
+	time grab_client filter_chain wav compress http_recv dccp dccp_recv recv_common fd"
 audiod_ldflags=""
 
 server_cmdline_objs="server.cmdline"
diff --git a/error.h b/error.h
index c72bdae4..ceaa6b38 100644
--- a/error.h
+++ b/error.h
@@ -56,6 +56,7 @@ enum para_subsystem {
 	SS_DCCP,
 	SS_DCCP_RECV,
 	SS_DCCP_SEND,
+	SS_FD,
 	SS_RINGBUFFER};
 
 #define NUM_SS (SS_RINGBUFFER + 1)
@@ -296,6 +297,7 @@ extern const char **para_errlist[];
 #define DAEMON_ERRORS
 #define ORTP_SEND_ERRORS
 #define RINGBUFFER_ERRORS
+#define FD_ERRORS
 
 
 /**
@@ -404,6 +406,7 @@ SS_ENUM(IPC);
 SS_ENUM(DCCP);
 SS_ENUM(DCCP_RECV);
 SS_ENUM(DCCP_SEND);
+SS_ENUM(FD);
 SS_ENUM(RINGBUFFER);
 /** \endcond */
 #undef PARA_ERROR
diff --git a/exec.c b/exec.c
index 1a302c16..b8f2df57 100644
--- a/exec.c
+++ b/exec.c
@@ -154,16 +154,3 @@ int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds)
 	return ret;
 }
 
-/**
- * check whether a file exists
- *
- * \param fn the file name
- *
- * \return Non-zero iff file exists.
- */
-int file_exists(const char *fn)
-{
-	struct stat statbuf;
-
-	return !stat(fn, &statbuf);
-}
diff --git a/fade.c b/fade.c
index b385cee7..33a6fa05 100644
--- a/fade.c
+++ b/fade.c
@@ -20,6 +20,7 @@
 
 #include "fade.cmdline.h"
 #include "para.h"
+#include "fd.h"
 
 #include <ctype.h>
 #include <curses.h>
diff --git a/fd.c b/fd.c
new file mode 100644
index 00000000..5db30b63
--- /dev/null
+++ b/fd.c
@@ -0,0 +1,14 @@
+#include "para.h"
+/**
+ * check whether a file exists
+ *
+ * \param fn the file name
+ *
+ * \return Non-zero iff file exists.
+ */
+int file_exists(const char *fn)
+{
+	struct stat statbuf;
+
+	return !stat(fn, &statbuf);
+}
diff --git a/fd.h b/fd.h
new file mode 100644
index 00000000..30ab0852
--- /dev/null
+++ b/fd.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */
+
+/** \file fd.h file handling functions */
+
+int file_exists(const char *);
diff --git a/gui.c b/gui.c
index 7b10992c..f63e99bd 100644
--- a/gui.c
+++ b/gui.c
@@ -23,6 +23,7 @@
 #include <curses.h>
 #include "ringbuffer.h"
 #include "string.h"
+#include "fd.h"
 
 extern const char *status_item_list[NUM_STAT_ITEMS];
 static char *stat_content[NUM_STAT_ITEMS];
diff --git a/para.h b/para.h
index 87c52d03..ef358c53 100644
--- a/para.h
+++ b/para.h
@@ -122,7 +122,6 @@ int para_open_audiod_pipe(char *);
 int read_audiod_pipe(int, void (*)(char *));
 
 /* exec */
-int file_exists(const char *);
 int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds);
 
 /* signal */
diff --git a/sdl_gui.c b/sdl_gui.c
index d0bf2fbf..d0b83f09 100644
--- a/sdl_gui.c
+++ b/sdl_gui.c
@@ -20,6 +20,7 @@
 
 #include "para.h"
 #include "string.h"
+#include "fd.h"
 
 
 #include <SDL/SDL.h>