--- sa.c 2002/01/02 13:44:48 1.49
+++ sa.c 2002/01/02 13:52:38 1.50
@@ -1209,25 +1209,26 @@
/* override system call */
sa_rc_t sa_syscall(sa_t *sa, sa_syscall_t id, void (*fptr)(), void *fctx)
{
+ sa_rc_t rv;
+
+ /* argument sanity check(s) */
if (sa == NULL || fptr == NULL)
return SA_ERR_ARG;
- if (id == SA_SYSCALL_CONNECT)
- SA_SC_ASSIGN(sa, connect, fptr, fctx);
- else if (id == SA_SYSCALL_ACCEPT)
- SA_SC_ASSIGN(sa, accept, fptr, fctx);
- else if (id == SA_SYSCALL_SELECT)
- SA_SC_ASSIGN(sa, select, fptr, fctx);
- else if (id == SA_SYSCALL_READ)
- SA_SC_ASSIGN(sa, read, fptr, fctx);
- else if (id == SA_SYSCALL_WRITE)
- SA_SC_ASSIGN(sa, write, fptr, fctx);
- else if (id == SA_SYSCALL_RECVFROM)
- SA_SC_ASSIGN(sa, recvfrom, fptr, fctx);
- else if (id == SA_SYSCALL_SENDTO)
- SA_SC_ASSIGN(sa, sendto, fptr, fctx);
- else
- return SA_ERR_ARG;
- return SA_OK;
+
+ /* assign system call */
+ rv = SA_OK;
+ switch (id) {
+ case SA_SYSCALL_CONNECT: SA_SC_ASSIGN(sa, connect, fptr, fctx);
+ case SA_SYSCALL_ACCEPT: SA_SC_ASSIGN(sa, accept, fptr, fctx);
+ case SA_SYSCALL_SELECT: SA_SC_ASSIGN(sa, select, fptr, fctx);
+ case SA_SYSCALL_READ: SA_SC_ASSIGN(sa, read, fptr, fctx);
+ case SA_SYSCALL_WRITE: SA_SC_ASSIGN(sa, write, fptr, fctx);
+ case SA_SYSCALL_RECVFROM: SA_SC_ASSIGN(sa, recvfrom, fptr, fctx);
+ case SA_SYSCALL_SENDTO: SA_SC_ASSIGN(sa, sendto, fptr, fctx);
+ case: rv = SA_ERR_ARG;
+ }
+
+ return rv;
}
/* bind socket to a local address */
|