00001
00002
00003
00004
00005 #ifdef CURLDEBUG
00006 #ifndef _CURL_MEDEBUG_H
00007 #define _CURL_MEDEBUG_H
00008
00009 #include "setup.h"
00010
00011 #include <curl/curl.h>
00012
00013 #ifdef HAVE_SYS_TYPES_H
00014 #include <sys/types.h>
00015 #endif
00016
00017 #ifdef HAVE_SYS_SOCKET_H
00018 #include <sys/socket.h>
00019 #endif
00020 #include <stdio.h>
00021 #ifdef HAVE_MEMORY_H
00022 #include <memory.h>
00023 #endif
00024
00025 #define logfile curl_debuglogfile
00026
00027 extern FILE *logfile;
00028
00029 CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
00030 CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line, const char *source);
00031 CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
00032 CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
00033 CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
00034 CURL_EXTERN void curl_memdebug(const char *logname);
00035 CURL_EXTERN void curl_memlimit(long limit);
00036
00037 CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *);
00038 CURL_EXTERN int curl_sclose(int sockfd, int, const char *source);
00039 CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen,
00040 int line, const char *source);
00041
00042 CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
00043 const char *source);
00044 CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line,
00045 const char *source);
00046 CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
00047
00048 #ifndef MEMDEBUG_NODEFINES
00049
00050 #undef strdup
00051 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
00052 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
00053 #define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
00054 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
00055 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
00056
00057 #define socket(domain,type,protocol)\
00058 curl_socket(domain,type,protocol,__LINE__,__FILE__)
00059 #undef accept
00060 #define accept(sock,addr,len)\
00061 curl_accept(sock,addr,len,__LINE__,__FILE__)
00062
00063 #if defined(getaddrinfo) && defined(__osf__)
00064
00065 #define ogetaddrinfo(host,serv,hint,res) \
00066 curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
00067 #else
00068 #undef getaddrinfo
00069 #define getaddrinfo(host,serv,hint,res) \
00070 curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
00071 #endif
00072
00073 #ifdef HAVE_GETNAMEINFO
00074 #undef getnameinfo
00075 #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \
00076 curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \
00077 __FILE__)
00078 #endif
00079
00080 #undef freeaddrinfo
00081 #define freeaddrinfo(data) \
00082 curl_dofreeaddrinfo(data,__LINE__,__FILE__)
00083
00084 #undef sclose
00085 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
00086
00087 #undef closesocket
00088 #define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
00089
00090 #undef fopen
00091 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
00092 #undef fdopen
00093 #define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
00094 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
00095
00096 #endif
00097
00098 #endif
00099 #endif