ntHeaders.h

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 
00032 // $Id: ntHeaders.h,v 1.27 2008/05/09 00:25:37 jaw Exp $
00033 
00034 #if !defined(pd_nt_headers_h)
00035 #define pd_nt_headers_h
00036 
00037 #pragma warning( disable : 4996 )
00038 
00039 #define WIN32_LEAN_AND_MEAN
00040 #include <windows.h>
00041 #include <winsock2.h>
00042 
00043 #if !defined(__out_ecount_opt)
00044 #define __out_ecount_opt(x) //Working around dbhelp.h bugs
00045 #endif
00046 
00047 #include <dbghelp.h>
00048 
00049 #include <assert.h>
00050 #include <stdio.h>
00051 
00052 #include <string.h>
00053 #include <stdlib.h>
00054 #include <errno.h>
00055 #include <fcntl.h>
00056 #include <io.h>
00057 #include <direct.h>
00058 #include <malloc.h>
00059 
00060 #ifdef BPATCH_LIBRARY
00061 
00062 #include <wtypes.h>
00063 typedef void *caddr_t; 
00064 
00065 #else
00066 #if defined(PARADYND)
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif /* __cplusplus */
00070 
00071 #include <rpc/rpc.h>
00072 #include <rpc/types.h>
00073 #include <rpc/xdr.h>
00074 
00075 #ifdef __cplusplus
00076 }
00077 #endif /* __cplusplus */
00078 #endif
00079 #endif /* BPATCH_LIBRARY */
00080 
00081 
00082 #include <process.h>
00083 #include <sys/types.h>
00084 
00085 #include <signal.h>
00086 #include <stdarg.h>
00087 #include <time.h>
00088 #include <sys/stat.h>
00089 #include <float.h>
00090 
00091 #define isnan _isnan
00092 #ifndef alloca
00093 #define alloca _alloca
00094 #endif
00095 
00096 #define PDSOCKET_ERROR SOCKET_ERROR
00097 typedef SOCKET PDSOCKET;
00098 
00099 /* compatiblity typedefs */
00100 typedef int pid_t;
00101 typedef int key_t;
00102 typedef unsigned int socklen_t;
00103 
00104 // Apparently this doesn't exist on NT? Weird.
00105 int P_getopt(int argc, char *argv[], const char *optstring);
00106 
00107 /* POSIX */
00108 inline void P_abort (void) { abort();}
00109 inline int P_close (int FILEDES) { return (_close(FILEDES));}
00110 inline int P__dup2(int OLD, int NEW) { return (_dup2(OLD, NEW)); }
00111 inline void P__exit (int STATUS) { _exit(STATUS);}
00112 inline FILE * P_fdopen (int FILEDES, const char *OPENTYPE) {
00113   return (_fdopen(FILEDES, OPENTYPE));}
00114 inline FILE * P_fopen (const char *FILENAME, const char *OPENTYPE) {
00115   return fopen(FILENAME, OPENTYPE);
00116 }
00117 inline int P_fstat (int FILEDES, struct stat *BUF) { return (fstat(FILEDES, BUF));}
00118 inline int P_getpid () { return (_getpid());}
00119 inline off_t P_lseek (int FILEDES, off_t OFFSET, int WHENCE) {
00120   return (_lseek(FILEDES, OFFSET, WHENCE));}
00121 inline int P__open(const char *FILENAME, int FLAGS, int MODE) {
00122   return (_open(FILENAME, FLAGS, MODE));}
00123 inline int P__pclose (FILE *STREAM) { return (_pclose(STREAM));}
00124 inline FILE *P__popen (const char *COMMAND, const char *MODE) {
00125   return (_popen(COMMAND, MODE));}
00126 inline size_t P_write (int FILEDES, const void *BUFFER, size_t SIZE) {
00127   return (_write(FILEDES, BUFFER, SIZE));}
00128 inline int P_chdir(const char *path) { return (_chdir(path)); }
00129 inline int P_putenv(char *str) { return _putenv(str); }
00130 
00131 /* ANSI */
00132 inline void P_exit (int STATUS) { exit(STATUS);}
00133 inline int P_fflush(FILE *stream) { return (fflush(stream));}
00134 inline char * P_fgets (char *S, int COUNT, FILE *STREAM) {
00135   return (fgets(S, COUNT, STREAM));}
00136 inline void * P_malloc (size_t SIZE) { return (malloc(SIZE));}
00137 inline void * P_memcpy (void *A1, const void *A2, size_t SIZE) { return memcpy(A1, A2, SIZE); }
00138 inline void * P_memset (void *BLOCK, int C, size_t SIZE) {
00139   return (memset(BLOCK, C, SIZE));}
00140 inline void P_perror (const char *MESSAGE) { perror(MESSAGE);}
00141 typedef void (*P_sig_handler)(int);
00142 inline P_sig_handler P_signal (int SIGNUM, P_sig_handler ACTION) {
00143   return (signal(SIGNUM, ACTION));}
00144 inline char * P_strcat (char *TO, const char *FROM) {
00145   return (strcat(TO, FROM));}
00146 
00147 inline const char * P_strchr (const char *STRING, int C) {return (strchr(STRING, C));}
00148 inline char * P_strchr (char *STRING, int C) {return (strchr(STRING, C));}
00149 inline int P_getpagesize() { 
00150     SYSTEM_INFO info;
00151     static int page_size = 0;
00152     if (page_size)
00153         return page_size;
00154     GetSystemInfo(&info);
00155     page_size = info.dwPageSize;
00156     return page_size;
00157 }
00158 
00159 inline int P_strcmp (const char *S1, const char *S2) {
00160   return (strcmp(S1, S2));}
00161 inline char * P_strcpy (char *TO, const char *FROM) {
00162   return (strcpy(TO, FROM));}
00163 inline char *P_strdup(const char *S) { return (_strdup(S));}
00164 inline size_t P_strlen (const char *S) { return (strlen(S));}
00165 inline char * P_strncat (char *TO, const char *FROM, size_t SIZE) {
00166   return (strncat(TO, FROM, SIZE)); }
00167 inline int P_strncmp (const char *S1, const char *S2, size_t SIZE) {
00168   return (strncmp(S1, S2, SIZE));}
00169 inline char * P_strncpy (char *TO, const char *FROM, size_t SIZE) {
00170   return (strncpy(TO, FROM, SIZE));}
00171 
00172 inline const char * P_strrchr (const char *STRING, int C) {return (strrchr(STRING, C));}
00173 inline char * P_strrchr (char *STRING, int C) {return (strrchr(STRING, C));}
00174 
00175 inline const char * P_strstr (const char *HAYSTACK, const char *NEEDLE) {return (strstr(HAYSTACK, NEEDLE));}
00176 inline char * P_strstr (char *HAYSTACK, const char *NEEDLE) {return (strstr(HAYSTACK, NEEDLE));}
00177 
00178 inline double P_strtod (const char *STRING, char **TAILPTR) {
00179   return (strtod(STRING, TAILPTR));}
00180 inline char * P_strtok (char *NEWSTRING, const char *DELIMITERS) {
00181   return (strtok(NEWSTRING, DELIMITERS));}
00182 inline long int P_strtol (const char *STRING, char **TAILPTR, int BASE) {
00183   return (strtol(STRING, TAILPTR, BASE));}
00184 inline unsigned long int P_strtoul(const char *STRING, char **TAILPTR, int BASE) { 
00185   return (strtoul(STRING, TAILPTR, BASE));}
00186 
00187 /* BSD */
00188 inline int P_accept (int SOCK, struct sockaddr *ADDR, size_t *LENGTH_PTR) {
00189   return (accept(SOCK, ADDR, (int*) LENGTH_PTR));}
00190 inline int P_bind(int socket, struct sockaddr *addr, size_t len) {
00191   return (::bind(socket, addr, len));}
00192 inline int P_connect(int socket, struct sockaddr *addr, size_t len) {
00193   return (connect(socket, addr, len));}
00194 inline struct hostent * P_gethostbyname (const char *NAME) {
00195   return (gethostbyname(NAME));}
00196 inline struct servent * P_getservbyname (const char *NAME, const char *PROTO) {
00197   return (getservbyname(NAME, PROTO));}
00198 inline int P_getsockname (int SOCKET, struct sockaddr *ADDR, size_t *LENGTH_PTR) {
00199   return (getsockname(SOCKET, ADDR, (int*) LENGTH_PTR));}
00200 inline int P_listen (int socket, unsigned int n) { return (listen(socket, n));}
00201 inline int P_socket (int NAMESPACE, int STYLE, int PROTOCOL) {
00202   return (socket(NAMESPACE, STYLE, PROTOCOL));}
00203 
00204 inline int P_select(int wid, fd_set *rd, fd_set *wr, fd_set *ex,
00205             struct timeval *tm) {
00206   return (select(wid, rd, wr, ex, tm));}
00207 
00208 inline int P_recv(int s, void *buf, size_t len, int flags) {
00209    return (recv(s, (char*)buf, len, flags));
00210 }
00211 
00212 inline int P_mkdir(const char *pathname, int) {
00213     return _mkdir(pathname);
00214 }
00215 
00216 inline int P_unlink(const char *pathname) {
00217     return _unlink(pathname);
00218 }
00219 extern char *cplus_demangle(char *, int, bool );
00220 inline char * P_cplus_demangle( const char * symbol, bool /* nativeCompiler */, bool includeTypes = false ) {
00221    return cplus_demangle( (char *)symbol, 0, includeTypes );
00222    } /* end P_cplus_demangle() */
00223 
00224 #ifndef BPATCH_LIBRARY
00225 #if defined(PARADYND)
00226 typedef int (*P_xdrproc_t)(XDR*, ...);
00227 //extern const char *sys_errlist[];
00228 
00229 inline void   P_xdr_destroy(XDR *x) { xdr_destroy(x);}
00230 inline bool_t P_xdr_u_char(XDR *x, u_char *uc) { return (xdr_u_char(x, uc));}
00231 inline bool_t P_xdr_int(XDR *x, int *i) { return (xdr_int(x, i));}
00232 inline bool_t P_xdr_double(XDR *x, double *d) {
00233   return (xdr_double(x, d));}
00234 inline bool_t P_xdr_u_int(XDR *x, u_int *u){
00235   return (xdr_u_int(x, u));}
00236 inline bool_t P_xdr_float(XDR *x, float *f) {
00237   return (xdr_float(x, f));}
00238 inline bool_t P_xdr_char(XDR *x, char *c) {
00239   return (xdr_char(x, c));}
00240 inline bool_t P_xdr_string(XDR *x, char **h, const u_int maxsize) {
00241   return (xdr_string(x, h, maxsize));}
00242 
00243 inline void P_xdrrec_create(XDR *x, const u_int send_sz, const u_int rec_sz,
00244                 const caddr_t handle, 
00245                 xdr_rd_func read_r, xdr_wr_func write_f) {
00246   xdrrec_create(x, send_sz, rec_sz, handle, read_r, write_f);}
00247 inline bool_t P_xdrrec_endofrecord(XDR *x, int now) { 
00248   return (xdrrec_endofrecord(x, now));}
00249 inline bool_t P_xdrrec_skiprecord(XDR *x) { return (xdrrec_skiprecord(x));}
00250 inline bool_t P_xdrrec_eof(XDR *x) { return (xdrrec_eof(x)); }
00251 extern "C" int snprintf(char *, size_t, const char *, ...);
00252 #endif
00253 #endif
00254 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1