Documentation

Generated on Thu Aug 31 00:02:29 2006

 

generic.h

Go to the documentation of this file.
00001 
00002 //  $Id: generic.h,v 1.98 2005/08/23 19:34:02 klas Exp $
00003 //
00004 // Usage: some defines that is important for correct inclusions of
00005 //        system headers, and all system header includes.
00006 //
00007 //  A part of babyftpd, licensed under the GNU GPL, see the file
00008 //    LICENSE for complete information.
00010 
00011 #ifndef GENERIC_H
00012 #define GENERIC_H
00013 
00014 #define __USE_GNU 1
00015 
00016 #include "config.h"
00017 #include <string>
00018 #include <vector>
00019 #include <semaphore.h>
00020 #include <assert.h>
00021 #include <errno.h>
00022 
00023 #ifdef NETINCLS
00024 #include <sys/socket.h>
00025 #include <arpa/inet.h>
00026 #endif // NETINCLS
00027 
00028 #ifdef BABY_IO
00029 #include <iostream>
00030 #include <fstream>
00031 using std::cout;
00032 using std::endl;
00033 using std::ifstream;
00034 using std::ofstream;
00035 #endif // BABY_IO
00036 
00037 #ifdef BABY_CORE
00038 #include <pthread.h>
00039 #include <bitset>
00040 #include <security/pam_appl.h>
00041 #include <ext/hash_map>
00042 #ifdef USE_TLS
00043 #include <gnutls/gnutls.h>
00044 #endif // USE_TLS
00045 using std::bitset;
00046 using __gnu_cxx::hash_map;
00047 using __gnu_cxx::hash;
00048 #endif // BABY_CORE
00049 
00050 #ifdef UTILITIES_H
00051 #include <sys/stat.h>
00052 #endif // UTILITIES_H
00053 
00054 #ifdef BABYFTPD_H
00055 #include <csignal>
00056 #include <sys/stat.h>
00057 #ifdef USE_TLS
00058 #ifndef OLD_GCRYPT
00059 #include <gcrypt.h>
00060 #endif // OLD_GCRYPT
00061 #endif // USE_TLS
00062 #endif // BABYFTPD_H
00063 
00064 #ifdef HANDLER_H
00065 #include <algorithm>
00066 #endif // HANDLER_H
00067 
00068 #ifdef CONFIGURATION_H
00069 #include <pwd.h>
00070 #include <grp.h>
00071 #include <getopt.h>
00072 #endif // CONFIGURATION_H
00073 
00074 #ifdef COMMANDS_H
00075 #include <pwd.h>
00076 #include <sys/stat.h>
00077 #endif // COMMANDS_H
00078 
00079 #ifdef COMMANDS2_CPP
00080 #include <grp.h>
00081 #include <dirent.h>
00082 #include <fcntl.h>
00083 #include <algorithm>
00084 #endif // COMMANDS2_CPP
00085 
00086 #ifdef LOG_H
00087 #include <syslog.h>
00088 #endif // LOG_H
00089 
00090 #ifdef CONNECTION_H
00091 #ifdef USE_TLS
00092 #include <gnutls/x509.h>
00093 #endif // USE_TLS
00094 #endif // CONNECTION_H
00095 
00096 #ifdef USER_H
00097 #include <pwd.h>
00098 #endif // USER_H
00099 
00100 #ifdef DATA_H
00101 #include <fcntl.h>
00102 #include <unistd.h>
00103 #endif // DATA_H
00104 
00105 using std::string;
00106 using std::vector;
00107 
00108 class Configuration;
00109 class User;
00110 class Data;
00111 class Handler;
00112 class Commands;
00113 class Utilities;
00114 class StringTokenizer;
00115 class Log;
00116 class Connection;
00117 
00118 const int PWBUF_SIZE = 100;
00119 
00120 // for exit_baby()
00121 enum exits { EXIT_EARLY, EXIT_FULL };
00122 
00123 #ifndef FTP_LOG
00124 #define FTP_LOG DAEMON_LOG
00125 #endif // FTP_LOG
00126 
00127 // various macros follow here
00128 
00129 // these three wrapper macros around pthread_rwlock_* should be used
00130 //  in all places where there is any risk one thread locks a lock twice without
00131 //  unlocking. note that the unlock must occur before the int declared in the
00132 //  lock has gone out of scope.
00133 #ifdef BABY_CORE
00134 #define BABY_WRLOCK(lock_var)   \
00135   int baby_lock_err = pthread_rwlock_wrlock(&lock_var); \
00136   assert(baby_lock_err == 0 || baby_lock_err == EDEADLK);
00137 #define BABY_RDLOCK(lock_var)   \
00138   int baby_lock_err = pthread_rwlock_rdlock(&lock_var); \
00139   assert(baby_lock_err == 0 || baby_lock_err == EDEADLK);
00140 #define BABY_UNLOCK(lock_var)   \
00141   if(baby_lock_err == 0)  \
00142     pthread_rwlock_unlock(&lock_var);
00143 #endif // BABY_CORE
00144 #endif // GENERIC_H