summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-01-02 22:11:39 +0000
committerLennart Poettering <lennart@poettering.net>2004-01-02 22:11:39 +0000
commitb6b209d5433fb9f29acc468781edd267ce741cb5 (patch)
treea2b6406fb0050af5bcc184a2fa5644f2b4c799ed
parent263b632288c0662ae4ef08925291f8d1a55c1311 (diff)
Forgot much of the changes
git-svn-id: file:///home/lennart/svn/public/ivam2/trunk@11 dbf6933d-3bce-0310-9bcc-ed052ba35b35
-rw-r--r--doc/TODO5
-rw-r--r--src/msntab.c23
-rw-r--r--src/msntab.h17
-rw-r--r--src/timevalarith.c53
-rw-r--r--src/timevalarith.h11
5 files changed, 109 insertions, 0 deletions
diff --git a/doc/TODO b/doc/TODO
new file mode 100644
index 0000000..ce166e9
--- /dev/null
+++ b/doc/TODO
@@ -0,0 +1,5 @@
+* implement msntab.c
+* implement shbuf support
+* python part
+* dtmf fifo
+* uid switching support
diff --git a/src/msntab.c b/src/msntab.c
new file mode 100644
index 0000000..bcd3030
--- /dev/null
+++ b/src/msntab.c
@@ -0,0 +1,23 @@
+#include <stddef.h>
+#include <assert.h>
+#include "msntab.h"
+
+struct tabentry* msntab_check_call(const char *callee, const char *caller) {
+ static char *args[] = { "/bin/cat", NULL };
+ static struct tabentry ca = { CALL_ACTION_ACCEPT, 1, args };
+
+ return msntab_ref(&ca);
+}
+
+
+struct tabentry* msntab_ref(struct tabentry *t) {
+ assert(t && t->ref_counter >= 1);
+ t->ref_counter++;
+ return t;
+}
+
+void msntab_unref(struct tabentry *t) {
+ assert(t && t->ref_counter >= 1);
+ t->ref_counter--;
+}
+
diff --git a/src/msntab.h b/src/msntab.h
new file mode 100644
index 0000000..28de484
--- /dev/null
+++ b/src/msntab.h
@@ -0,0 +1,17 @@
+#ifndef foomsntabhfoo
+#define foomsntabhfoo
+
+enum call_action { CALL_ACTION_IGNORE, CALL_ACTION_ACCEPT, CALL_ACTION_HANGUP };
+
+struct tabentry {
+ enum call_action action;
+ int ref_counter;
+
+ char **args;
+};
+
+struct tabentry* msntab_check_call(const char *callee, const char *caller);
+struct tabentry* msntab_ref(struct tabentry *t);
+void msntab_unref(struct tabentry *t);
+
+#endif
diff --git a/src/timevalarith.c b/src/timevalarith.c
new file mode 100644
index 0000000..1091192
--- /dev/null
+++ b/src/timevalarith.c
@@ -0,0 +1,53 @@
+#include "timevalarith.h"
+
+struct timeval timeval_max(struct timeval a, struct timeval b) {
+
+ if (a.tv_sec > b.tv_sec)
+ return a;
+
+ if (a.tv_sec < b.tv_sec)
+ return b;
+
+ if (a.tv_usec > b.tv_usec)
+ return a;
+
+ return b;
+}
+
+struct timeval timeval_add(struct timeval a, uint32_t d) {
+ uint64_t sec, usec;
+ struct timeval r;
+
+ sec = (uint64_t) a.tv_sec + (d / 1000000L);
+ usec = (uint64_t) a.tv_usec + (d % 1000000L);
+
+ while (usec > 1000000L) {
+ usec -= 1000000L;
+ sec++;
+ }
+
+ r.tv_sec = (long) sec;
+ r.tv_usec = (long) usec;
+ return r;
+}
+
+struct timeval timeval_sub(struct timeval a, uint32_t d) {
+ uint64_t sec, usec;
+ struct timeval r;
+
+ sec = (uint64_t) a.tv_sec - (d / 1000000L);
+ usec = (uint64_t) a.tv_usec;
+
+ d = (d % 1000000L);
+
+ if (usec > d)
+ usec -= d;
+ else {
+ sec--;
+ usec = 1000000L + usec - d;
+ }
+
+ r.tv_sec = (long) sec;
+ r.tv_usec = (long) usec;
+ return r;
+}
diff --git a/src/timevalarith.h b/src/timevalarith.h
new file mode 100644
index 0000000..c0c015b
--- /dev/null
+++ b/src/timevalarith.h
@@ -0,0 +1,11 @@
+#ifndef footimevalarithhfoo
+#define footimevalarithhfoo
+
+#include <sys/types.h>
+#include <inttypes.h>
+
+struct timeval timeval_max(struct timeval a, struct timeval b);
+struct timeval timeval_add(struct timeval a, uint32_t d);
+struct timeval timeval_sub(struct timeval a, uint32_t s);
+
+#endif