"Fossies" - the Fresh Open Source Software Archive

Member "ettercap-0.8.3.1/include/ec_os_mingw.h" (1 Aug 2020, 6530 Bytes) of package /linux/privat/ettercap-0.8.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ec_os_mingw.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.8.3_vs_0.8.3.1.

    1 #ifndef ETTERCAP_OS_MINGW_H
    2 #define ETTERCAP_OS_MINGW_H
    3 
    4 /* This file is *not* MingW specific, but Ettercap requires gcc.
    5  * So that leaves other Win32 compilers out.
    6  */
    7 #include <malloc.h>     /* for alloca() */
    8 #include <winsock2.h>   /* u_char etc. */
    9 
   10 #if !defined(HAVE_GETUID)
   11    #define getuid()      (0)
   12 #endif
   13 
   14 #if !defined(HAVE_GETGID)
   15    #define getgid()      (0)
   16 #endif
   17 
   18 #if !defined(HAVE_GETEUID)
   19    #define geteuid()     (0)
   20 #endif
   21 
   22 #if !defined(HAVE_GETEUID)
   23    #define getegid()     (0)
   24 #endif
   25 
   26 #if !defined(HAVE_SETUID)
   27    #define setuid(x)     (0)
   28 #endif
   29 
   30 #if !defined(HAVE_SETGID)
   31    #define setgid(x)     (0)
   32 #endif
   33 
   34 #if !defined(HAVE_RANDOM)
   35    #define random()      rand()
   36 #endif
   37 
   38 #if !defined(HAVE_SRANDOM)
   39    #define srandom(s)    srand(s)
   40 #endif
   41 
   42 #if !defined(_TIMEVAL_DEFINED) && !defined(HAVE_STRUCT_TIMEVAL)
   43    #define _TIMEVAL_DEFINED
   44    struct timeval {
   45           long    tv_sec;
   46           long    tv_usec;
   47         };
   48 #endif
   49 
   50 #if !defined(HAVE_STRUCT_TIMEZONE)
   51    #define HAVE_STRUCT_TIMEZONE
   52    struct timezone {
   53           int tz_minuteswest;     /* minutes west of Greenwich */
   54           int tz_dsttime;         /* type of dst correction */
   55         };
   56 #endif
   57 
   58 #undef  _U_
   59 #if defined(__GNUC__)
   60    #define _U_  __attribute__((unused))
   61 #else
   62    #define _U_
   63 #endif
   64 
   65 #ifndef EINPROGRESS
   66 #define EINPROGRESS  WSAEINPROGRESS
   67 #endif
   68 
   69 #ifndef EALREADY
   70 #define EALREADY     WSAEALREADY
   71 #endif
   72 
   73 #ifndef EWOULDBLOCK
   74 #define EWOULDBLOCK  WSAEWOULDBLOCK
   75 #endif
   76 
   77 #ifndef EISCONN
   78 #define EISCONN WSAEISCONN
   79 #endif
   80 
   81 /* Only used in socket code */
   82 #undef  EINTR
   83 #define EINTR        WSAEINTR
   84 
   85 #undef  EAGAIN
   86 #define EAGAIN       WSAEWOULDBLOCK
   87 
   88 #define gettimeofday(tv,tz)    ec_win_gettimeofday (tv, tz)
   89 #define strsignal(signo)       ec_win_strsignal (signo)
   90 #define poll(p,n,t)            ec_win_poll (p,n,t)
   91 #define dn_expand(m,e,c,ex,l)  ec_win_dn_expand (m, e, c, ex, l)
   92 #define dn_comp(e,c,l,d,ld)    ec_win_dn_comp(e,c,l,d,ld)
   93 
   94 EC_API_EXTERN int         ec_win_dn_expand (const u_char *msg, const u_char *eom_orig,
   95                                      const u_char *comp_dn, char *exp_dn, int length);
   96 EC_API_EXTERN int         ec_win_dn_comp   (const char *exp_dn, u_char *comp_dn, int length,
   97                                      u_char **dnptrs, u_char **lastdnptr);
   98 
   99 EC_API_EXTERN int         ec_win_gettimeofday (struct timeval *tv, struct timezone *tz);
  100 EC_API_EXTERN const char *ec_win_strsignal (int signo);
  101 
  102 /* poll() emulation
  103  */
  104 #define POLLIN   0x0001
  105 #define POLLPRI  0x0002   /* not used */
  106 #define POLLOUT  0x0004
  107 #define POLLERR  0x0008
  108 #define POLLHUP  0x0010   /* not used */
  109 #define POLLNVAL 0x0020   /* not used */
  110 
  111 struct pollfd {
  112        int fd;
  113        int events;     /* in param: what to poll for */
  114        int revents;    /* out param: what events occurred */
  115      };
  116 
  117 #undef  HAVE_POLL
  118 #define HAVE_POLL 1
  119 
  120 EC_API_EXTERN int ec_win_poll (struct pollfd *p, int num, int timeout);
  121 
  122 /*  User/program dir
  123  */
  124 EC_API_EXTERN const char *ec_win_get_user_dir (void);
  125 EC_API_EXTERN const char *ec_win_get_ec_dir (void);
  126 
  127 /* This is a stupid hack. How can we on compile time know the install location on a
  128  * non-Unix system?
  129  */
  130 #ifndef INSTALL_PREFIX
  131    #define INSTALL_PREFIX  ec_win_get_ec_dir()
  132 #endif
  133 
  134 #ifndef INSTALL_EXECPREFIX
  135    #define INSTALL_EXECPREFIX ec_win_get_ec_dir()
  136 #endif
  137    
  138 #ifndef INSTALL_SYSCONFDIR
  139    #define INSTALL_SYSCONFDIR ec_win_get_ec_dir()
  140 #endif
  141 
  142 #ifndef INSTALL_BINDIR
  143    #define INSTALL_BINDIR     ec_win_get_ec_dir()
  144 #endif
  145 
  146 #ifndef INSTALL_LIBDIR
  147    #define INSTALL_LIBDIR    "/lib"    /* this cannot be a function (sigh) */
  148 #endif
  149 
  150 #ifndef INSTALL_DATADIR
  151    #define INSTALL_DATADIR   "/share"  /* this cannot be a function (sigh) */
  152 #endif
  153    
  154 /* dlopen() emulation (not exported)
  155  */
  156 #if !defined(HAVE_DLOPEN)
  157    #define RTLD_NOW  0         /* No importance */
  158    #define RTLD_LOCAL 0        /* No importance */
  159    #define RTLD_NOW 0
  160    #define PLUGIN_EXT           "*.dll"
  161 
  162    #define dlopen(dll,flg)      ec_win_dlopen (dll, flg)
  163    #define lt_dlopen(dll)       ec_win_dlopen (dll, 0)
  164    #define lt_dlopenext(dll)    ec_win_dlopen (dll, 0)
  165    #define dlsym(hnd,func)      ec_win_dlsym (hnd, func)
  166    #define lt_dlsym(hnd,func)   ec_win_dlsym (hnd, func)
  167    #define dlclose(hnd)         ec_win_dlclose (hnd)
  168    #define lt_dlclose(hnd)      ec_win_dlclose (hnd)
  169    #define dlerror()            ec_win_dlerror()
  170    #define lt_dlerror()         ec_win_dlerror()
  171    #define lt_dlinit()          (0)
  172    #define lt_dlexit()          (0)
  173 
  174    EC_API_EXTERN void       *ec_win_dlopen  (const char *dll_name, int flags _U_);
  175    EC_API_EXTERN void       *ec_win_dlsym   (const void *dll_handle, const char *func_name);
  176    EC_API_EXTERN void        ec_win_dlclose (const void *dll_handle);
  177    EC_API_EXTERN const char *ec_win_dlerror (void);
  178 #endif
  179 
  180 /*
  181  * Unix process emulation
  182  */
  183 #if !defined(HAVE_FORK)
  184   #define fork()  ec_win_fork()
  185 
  186   EC_API_EXTERN int ec_win_fork(void);
  187 #endif
  188 
  189 #if !defined(HAVE_WAIT)
  190   #define wait(st)  ec_win_wait(st)
  191   #define WEXITSTATUS(w) 1
  192   #define WIFEXITED(w)  1
  193 
  194   EC_API_EXTERN int ec_win_wait (int *status);
  195 #endif
  196    
  197   
  198 /* Missing stuff for ec_resolv.h / ec_win_dnexpand()
  199  */
  200 #ifndef INT16SZ
  201 #define INT16SZ 2
  202 #endif
  203 
  204 #ifndef INT32SZ
  205 #define INT32SZ 4
  206 #endif
  207 
  208 #undef  GETSHORT
  209 #define GETSHORT(s, cp) do { \
  210         register u_char *t_cp = (u_char *)(cp); \
  211         (s) = ((u_short)t_cp[0] << 8) \
  212             | ((u_short)t_cp[1]); \
  213         (cp) += INT16SZ; \
  214       } while (0)
  215 
  216 #undef  GETLONG
  217 #define GETLONG(l, cp) do { \
  218         register u_char *t_cp = (u_char *)(cp); \
  219         (l) = ((u_long)t_cp[0] << 24) \
  220             | ((u_long)t_cp[1] << 16) \
  221             | ((u_long)t_cp[2] << 8) \
  222             | ((u_long)t_cp[3]); \
  223         (cp) += INT32SZ; \
  224       } while (0)
  225 
  226 #undef  PUTSHORT
  227 #define PUTSHORT(s, cp) do { \
  228         register u_short t_s = (u_short)(s); \
  229         register u_char *t_cp = (u_char *)(cp); \
  230         *t_cp++ = t_s >> 8; \
  231         *t_cp   = t_s; \
  232         (cp) += INT16SZ; \
  233       } while (0)
  234 
  235 #undef  PUTLONG
  236 #define PUTLONG(l, cp) do { \
  237         register u_long t_l = (u_long)(l); \
  238         register u_char *t_cp = (u_char *)(cp); \
  239         *t_cp++ = t_l >> 24; \
  240         *t_cp++ = t_l >> 16; \
  241         *t_cp++ = t_l >> 8; \
  242         *t_cp   = t_l; \
  243         (cp) += INT32SZ; \
  244       } while (0)
  245 
  246 /*
  247  * Misc. stuff
  248  */
  249 #define strerror ec_win_strerror
  250 EC_API_EXTERN char *ec_win_strerror(int err);
  251 EC_API_EXTERN int  ec_win_pcap_stop(const void *pcap_handle);
  252   
  253 #endif /* EC_WIN_MISC_H */