From 365b0c6330ea607706b708d92da7a46b1ed1fb15 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 2 Feb 2008 11:09:04 +0000 Subject: introduced libsys implemented signal handling --- src/sys/Makefile.am | 6 ++++++ src/sys/sys.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ src/sys/sys.h | 19 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/sys/Makefile.am create mode 100644 src/sys/sys.cc create mode 100644 src/sys/sys.h (limited to 'src/sys') diff --git a/src/sys/Makefile.am b/src/sys/Makefile.am new file mode 100644 index 0000000..44f69c4 --- /dev/null +++ b/src/sys/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES = -I$(top_srcdir)/src +METASOURCES = AUTO +libsys_la_LDFLAGS = -avoid-version -no-undefined +noinst_LTLIBRARIES = libsys.la +libsys_la_SOURCES = sys.cc +noinst_HEADERS = sys.h diff --git a/src/sys/sys.cc b/src/sys/sys.cc new file mode 100644 index 0000000..97da23e --- /dev/null +++ b/src/sys/sys.cc @@ -0,0 +1,42 @@ +/* + sys/sys.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +// project headers +#include "sys/sys.h" + +// system headers +#include + +#include +#include + + +namespace sys { + +bool mkdir(const char *path) +{ +#ifdef _WIN32 + ::mkdir(path); + // FIXME check return value + return true; +#else + return (::mkdir(path, 0777) == 0); +#endif +} + +void signal(int signum, signalfunc handler) +{ +#ifndef _WIN32 + struct sigaction sa; + + sa.sa_handler = handler; + sa.sa_flags = 0; + + sigaction(signum, &sa, 0); +#endif +} + +} diff --git a/src/sys/sys.h b/src/sys/sys.h new file mode 100644 index 0000000..0d05b67 --- /dev/null +++ b/src/sys/sys.h @@ -0,0 +1,19 @@ +/* + sys/sys.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_SYS_H__ +#define __INCLUDED_SYS_H__ + +/// contains operating system dependent functions +namespace sys { + typedef void (* signalfunc)(int signum); + + bool mkdir(const char *path); + void signal(int signum, signalfunc handler); +} + +#endif // __INCLUDED_SYS_H__ + -- cgit v1.2.3