Subversion Repositories public

Rev

Rev 67 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 67 Rev 69
Line 20... Line 20...
20
#include <string>
20
#include <string>
21
#include <deque>
21
#include <deque>
22
22
23
#include "strtok.h"
23
#include "strtok.h"
24
24
-
 
25
/*
25
/// Incron user table base directory
26
/// Incron user table base directory
26
#define INCRON_USER_TABLE_BASE "/var/spool/incron/"
27
#define INCRON_USER_TABLE_BASE "/var/spool/incron/"
27
28

28
/// Incron system table base directory
29
/// Incron system table base directory
29
#define INCRON_SYS_TABLE_BASE "/etc/incron.d/"
30
#define INCRON_SYS_TABLE_BASE "/etc/incron.d/"
30
31
*/
31
32
32
/// Incron table entry class.
33
/// Incron table entry class.
33
class InCronTabEntry
34
class IncronTabEntry
34
{
35
{
35
public:
36
public:
36
  /// Constructor.
37
  /// Constructor.
37
  /**
38
  /**
38
   * Creates an empty entry for later use with Parse().
39
   * Creates an empty entry for later use with Parse().
39
   *
40
   *
40
   * \sa Parse()
41
   * \sa Parse()
41
   */
42
   */
42
  InCronTabEntry();
43
  IncronTabEntry();
43
44
44
  /// Constructor.
45
  /// Constructor.
45
  /**
46
  /**
46
   * Creates an entry based on defined parameters.
47
   * Creates an entry based on defined parameters.
47
   *
48
   *
48
   * \param[in] rPath watched filesystem path
49
   * \param[in] rPath watched filesystem path
49
   * \param[in] uMask event mask
50
   * \param[in] uMask event mask
50
   * \param[in] rCmd command string
51
   * \param[in] rCmd command string
51
   */
52
   */
52
  InCronTabEntry(const std::string& rPath, uint32_t uMask, const std::string& rCmd);
53
  IncronTabEntry(const std::string& rPath, uint32_t uMask, const std::string& rCmd);
53
 
54
 
54
  /// Destructor.
55
  /// Destructor.
55
  ~InCronTabEntry() {}
56
  ~IncronTabEntry() {}
56
 
57
 
57
  /// Converts the entry to string representation.
58
  /// Converts the entry to string representation.
58
  /**
59
  /**
59
   * This method creates a string for use in a table file.
60
   * This method creates a string for use in a table file.
60
   *
61
   *
Line 66... Line 67...
66
  /**
67
  /**
67
   * \param[in] rStr parsed string
68
   * \param[in] rStr parsed string
68
   * \param[out] rEntry parametrized entry
69
   * \param[out] rEntry parametrized entry
69
   * \return true = success, false = failure
70
   * \return true = success, false = failure
70
   */
71
   */
71
  static bool Parse(const std::string& rStr, InCronTabEntry& rEntry);
72
  static bool Parse(const std::string& rStr, IncronTabEntry& rEntry);
72
 
73
 
73
  /// Returns the watch filesystem path.
74
  /// Returns the watch filesystem path.
74
  /**
75
  /**
75
   * \return watch path
76
   * \return watch path
76
   */
77
   */
Line 128... Line 129...
128
  bool m_fNoLoop;     ///< no loop yes/no
129
  bool m_fNoLoop;     ///< no loop yes/no
129
};
130
};
130
131
131
132
132
/// Incron table class.
133
/// Incron table class.
133
class InCronTab
134
class IncronTab
134
{
135
{
135
public:
136
public:
136
  /// Constructor.
137
  /// Constructor.
137
  InCronTab() {}
138
  IncronTab() {}
138
 
139
 
139
  /// Destructor.
140
  /// Destructor.
140
  ~InCronTab() {}
141
  ~IncronTab() {}
141
 
142
 
142
  /// Add an entry to the table.
143
  /// Add an entry to the table.
143
  /**
144
  /**
144
   * \param[in] rEntry table entry
145
   * \param[in] rEntry table entry
145
   */
146
   */
146
  inline void Add(const InCronTabEntry& rEntry)
147
  inline void Add(const IncronTabEntry& rEntry)
147
  {
148
  {
148
    m_tab.push_back(rEntry);
149
    m_tab.push_back(rEntry);
149
  }
150
  }
150
 
151
 
151
  /// Removes all entries.
152
  /// Removes all entries.
Line 178... Line 179...
178
   *
179
   *
179
   * \attention This method doesn't test index bounds. If you
180
   * \attention This method doesn't test index bounds. If you
180
   *            pass an invalid value the program may crash
181
   *            pass an invalid value the program may crash
181
   *            and/or behave unpredictible way!
182
   *            and/or behave unpredictible way!
182
   */
183
   */
183
  inline InCronTabEntry& GetEntry(int index)
184
  inline IncronTabEntry& GetEntry(int index)
184
  {
185
  {
185
    return m_tab[index];
186
    return m_tab[index];
186
  }
187
  }
187
 
188
 
188
  /// Loads the table.
189
  /// Loads the table.
Line 223... Line 224...
223
   * \attention No tests (existence, permission etc.) are done.
224
   * \attention No tests (existence, permission etc.) are done.
224
   */
225
   */
225
  static std::string GetSystemTablePath(const std::string& rName);
226
  static std::string GetSystemTablePath(const std::string& rName);
226
227
227
protected:
228
protected:
228
  std::deque<InCronTabEntry> m_tab; ///< incron table
229
  std::deque<IncronTabEntry> m_tab; ///< incron table
229
};
230
};
230
231
231
232
232
#endif //_INCRONTAB_H_
233
#endif //_INCRONTAB_H_