/* Common declarations and definitions */ /* Copyright 2001 2002 Debajyoti Bera */ /* This file is part of mGet. * mGet is free Software; please refer to COPYING for terms and conditions */ //------------ Includes ----------------// #ifndef __COMMON_H #define __COMMON_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include //in the SunOS I tested, some of the strings functions were given in strings.h //a more rigourous and proper check is needed. will find out later #if defined(STRINGS_H) #include #endif /* herror() is a cool function: but not found in Sun */ #ifndef HAS_HERROR #define herror(A) printf("%s\n",A) #endif #ifndef NULL #define NULL 0 //some compilers complained #endif #ifdef DEBUG #define DEBUGPRINT(X) X; #else #define DEBUGPRINT(X) ; #endif #define VERBOSEPRINT(X) if(VERBOSE==TRUE) X; #define check_return_value(X,Y) if(X !=Y ){ \ fprintf(stderr, "Bad log file.\n"); \ exit(1); \ } //------------- Constants -----------------// #define VERSION "1.4.2" #define LENGTH 1024 #define MAX_SEGMENT 10 #define CLOSE_SOCK 1 #define NOCLOSE_SOCK 0 #define PORT 80 //default port #define PROXY_PORT 3128 #define min(a,b) ((a>=b)?b:a) #define max(a,b) ((a>=b)?a:b) #define strlen(x) ((x==NULL)?0:strlen(x)) //avoid segmentation fault #define PROXY_AUTH_STR \ "Proxy-Authorization:Basic " #define REFERRER_DECL \ "Referer: " typedef int SOCKET; #define closesocket(x) close(x) typedef enum bool {FALSE, TRUE} BOOL; #ifndef __MGET_H extern FILE *outfile; //default output to stdout extern int port; extern char *user_passwd, *host_name; extern BOOL VERBOSE; //how much to babble :) extern BOOL USE_HTTP_CONNECT; //use connect protocol in HTTP extern char error_buffer[1024]; //buffer to contain error message, as suitable #endif #endif