From b6b209d5433fb9f29acc468781edd267ce741cb5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Jan 2004 22:11:39 +0000 Subject: Forgot much of the changes git-svn-id: file:///home/lennart/svn/public/ivam2/trunk@11 dbf6933d-3bce-0310-9bcc-ed052ba35b35 --- doc/TODO | 5 +++++ src/msntab.c | 23 +++++++++++++++++++++++ src/msntab.h | 17 +++++++++++++++++ src/timevalarith.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/timevalarith.h | 11 +++++++++++ 5 files changed, 109 insertions(+) create mode 100644 doc/TODO create mode 100644 src/msntab.c create mode 100644 src/msntab.h create mode 100644 src/timevalarith.c create mode 100644 src/timevalarith.h 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 +#include +#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 +#include + +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 -- cgit