Server 0.0.1
HTTP/REST server implementation

src/class/interface.c

Go to the documentation of this file.
00001 
00023 #include <sys/types.h>
00024 #include <stdlib.h>
00025 
00026 #include "class/interface.h"
00027 #include "commons.h"
00028 
00029 static
00030 inline
00031 int
00032 comp(const void * _a, const void * _b)
00033 {
00034         const struct interface * a = **(const struct interface ***)_a;
00035         const struct interface * b = **(const struct interface ***)_b;
00036     return ((a)<(b))? -1 : ((a)>(b))? 1 : 0;
00037 }
00038 
00043 iface_ptr
00044 interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface)
00045 {
00046         const iface_ptr * iface = &_iface;
00047         iface_ptr *       found;
00048 
00049     if (! iface_impl->simpl) {
00050         qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
00051         iface_impl->simpl=TRUE;
00052     }
00053 
00054     found = bsearch(
00055                         &iface,
00056                         iface_impl->impl,
00057                         iface_impl->nimpl,
00058                         sizeof(iface_ptr),
00059                         comp);
00060 
00061         return found? *found : (iface_ptr)NULL;
00062 }
00063 
00064 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines