Main Page | Class List | File List | Class Members | File Members

incrontab.h

Go to the documentation of this file.
00001 
00003 
00017 #ifndef _INCRONTAB_H_
00018 #define _INCRONTAB_H_
00019 
00020 #include <string>
00021 #include <deque>
00022 
00023 #include "strtok.h"
00024 
00026 #define INCRON_TABLE_BASE "/var/spool/incron/"
00027 
00028 
00030 class InCronTabEntry
00031 {
00032 public:
00034 
00039   InCronTabEntry();
00040 
00042 
00049   InCronTabEntry(const std::string& rPath, uint32_t uMask, const std::string& rCmd);
00050   
00052   ~InCronTabEntry() {}
00053   
00055 
00060   std::string ToString() const;
00061   
00063 
00068   static bool Parse(const std::string& rStr, InCronTabEntry& rEntry);
00069   
00071 
00074   inline const std::string& GetPath() const
00075   {
00076     return m_path;
00077   }
00078   
00080 
00083   inline int32_t GetMask() const
00084   {
00085     return m_uMask;
00086   }
00087   
00089 
00092   inline const std::string& GetCmd() const
00093   {
00094     return m_cmd;
00095   }
00096   
00098 
00101   inline bool IsNoLoop() const
00102   {
00103     return m_fNoLoop;
00104   }
00105   
00107 
00119   static std::string GetSafePath(const std::string& rPath);
00120   
00121 protected:
00122   std::string m_path; 
00123   uint32_t m_uMask;   
00124   std::string m_cmd;  
00125   bool m_fNoLoop;     
00126 };
00127 
00128 
00130 class InCronTab
00131 {
00132 public:
00134   InCronTab() {}
00135   
00137   ~InCronTab() {}
00138   
00140 
00143   inline void Add(const InCronTabEntry& rEntry)
00144   {
00145     m_tab.push_back(rEntry);
00146   }
00147   
00149   inline void Clear()
00150   {
00151     m_tab.clear();
00152   }
00153   
00155 
00158   inline bool IsEmpty() const
00159   {
00160     return m_tab.empty();
00161   }
00162   
00164 
00167   inline int GetCount() const
00168   {
00169     return (int) m_tab.size();
00170   }
00171   
00173 
00180   inline InCronTabEntry& GetEntry(int index)
00181   {
00182     return m_tab[index];
00183   }
00184   
00186 
00190   bool Load(const std::string& rPath);
00191   
00193 
00197   bool Save(const std::string& rPath);
00198   
00200 
00204   static bool CheckUser(const std::string& rUser);
00205   
00207 
00213   static std::string GetUserTablePath(const std::string& rUser);
00214 
00215 protected:
00216   std::deque<InCronTabEntry> m_tab; 
00217 };
00218 
00219 
00220 #endif //_INCRONTAB_H_

Generated on Thu Nov 23 23:45:39 2006 for incron by  doxygen 1.4.4