Documentation

Generated on Thu Aug 31 00:02:30 2006

 

Utilities.h

Go to the documentation of this file.
00001 
00002 // $Id: Utilities.h,v 1.33 2005/03/29 18:02:58 klas Exp $
00003 //
00004 // Usage: Various functions that doesn't belong anywhere else.
00005 //
00006 //  A part of babyftpd, licensed under the GNU GPL, see the file
00007 //    LICENSE for complete information.
00009 
00010 #ifndef UTILITIES_H
00011 #define UTILITIES_H
00012 
00013 #ifdef UTILITIES_CPP
00014 #include "generic.h"
00015 #endif
00016 
00017 class Utilities
00018 {
00019   private:
00020 
00021   public:
00022     void strip_line_breaks(string&);
00023     int clean_string(string&);
00024     string itos(long long int);
00025     string parse_perms_ls(mode_t);
00026     string parse_perms_num(mode_t);
00027     int time_string(string&, string, size_t len = 50, time_t timep = 0);
00028 
00029     // small inline functions, previously macros
00030     bool is_set(unsigned int flag, unsigned int bit)
00031     { return(flag & bit); }
00032     void set_bit(unsigned int &flag, unsigned int bit)
00033     { flag |= bit; }
00034     void remove_bit(unsigned int &flag, unsigned int bit)
00035     { flag &= ~bit; }
00036     void toggle_bit(unsigned int &flag, unsigned int bit)
00037     { flag ^= bit;  }
00038     struct eqstr
00039     {
00040       bool operator()(const char *s1, const char *s2)
00041       { return strcmp(s1, s2) == 0; }
00042     };
00043 };
00044 
00045 extern class Utilities util;
00046 
00047 #endif