aboutsummaryrefslogtreecommitdiff
path: root/src/system33.c
diff options
context:
space:
mode:
authorpk33 <pk33@pk33.space>2024-11-11 18:06:18 +0100
committerpk33 <pk33@pk33.space>2024-11-11 18:06:18 +0100
commit5a54774474f43ae29716751d6415563a59b92c7d (patch)
tree151e865845b09b85992d8be20d8cc771d4110448 /src/system33.c
parent146a683b8d8315ef15dc1c9286f0983834f48d88 (diff)
downloadengine33-5a54774474f43ae29716751d6415563a59b92c7d.tar.gz
tidying up and basic input
Diffstat (limited to 'src/system33.c')
-rw-r--r--src/system33.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/system33.c b/src/system33.c
new file mode 100644
index 0000000..c533503
--- /dev/null
+++ b/src/system33.c
@@ -0,0 +1,50 @@
+#include "sys/ioctl.h"
+#include "errno.h"
+
+#include "stdarg.h"
+#include "stdio.h"
+#include "unistd.h"
+#include "signal.h"
+#include "string.h"
+
+#include "types33.h"
+
+
+Error e33_ioctl( Size fd, unsigned long req, void *arg )
+{
+ Size ret;
+
+ do {
+ ret = ioctl(fd, req, arg);
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+
+ return ret;
+}
+
+Boolean e33_strcmp( String s1, String s2 )
+{
+ while( (*s1 != '\0') && (*s2 != '\0') )
+ {
+ if( (*s1++) != (*s2++) ) {
+ return E33_FALSE;
+ }
+ }
+
+ return E33_TRUE;
+}
+
+Error e33_has_signal(Size signo)
+{
+ struct sigaction sact = {0};
+ sigaction(signo, 0, &sact);
+ return sact.sa_handler != 0;
+}
+
+Error e33_set_signal(Size signo, void(*sig_handler)(int))
+{
+ struct sigaction sact = {0};
+ sact.sa_handler = sig_handler;
+ sigemptyset(&sact.sa_mask);
+ sact.sa_flags = SA_RESTART;
+ return sigaction(signo, &sact, NULL);
+}