Subversion Repositories public

Rev

Rev 47 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
45 luk 1
 
2
/// inotify cron table manipulator classes header
3
/**
4
 * \file incrontab.h
5
 *
6
 * inotify cron system
7
 *
8
 * Copyright (C) 2006 Lukas Jelinek, <lukas@aiken.cz>
9
 *
10
 * This program is free software; you can use it, redistribute
11
 * it and/or modify it under the terms of the GNU General Public
12
 * License, version 2 (see LICENSE-GPL).
13
 *  
14
 */
15
 
16
 
17
#ifndef _INCRONTAB_H_
18
#define _INCRONTAB_H_
19
 
20
#include <string>
21
#include <deque>
22
 
23
#include "strtok.h"
24
 
25
 
26
#define INCRON_TABLE_BASE "/var/spool/incron/"
27
 
28
 
29
 
30
class InCronTabEntry
31
{
32
public:
33
  InCronTabEntry();
34
 
35
  InCronTabEntry(const std::string& rPath, uint32_t uMask, const std::string& rCmd);
36
 
37
  ~InCronTabEntry() {}
38
 
39
  std::string ToString() const;
40
 
41
  static bool Parse(const std::string& rStr, InCronTabEntry& rEntry);
42
 
43
  inline const std::string& GetPath() const
44
  {
45
    return m_path;
46
  }
47
 
48
  inline int32_t GetMask() const
49
  {
50
    return m_uMask;
51
  }
52
 
53
  inline const std::string& GetCmd() const
54
  {
55
    return m_cmd;
56
  }
57
 
58
protected:
59
  std::string m_path;
60
  uint32_t m_uMask;
61
  std::string m_cmd;
62
};
63
 
64
 
65
 
66
class InCronTab
67
{
68
public:
69
  InCronTab() {}
70
 
71
  ~InCronTab() {}
72
 
73
  inline void Add(const InCronTabEntry& rEntry)
74
  {
75
    m_tab.push_back(rEntry);
76
  }
77
 
78
  inline void Clear()
79
  {
80
    m_tab.clear();
81
  }
82
 
83
  inline bool IsEmpty() const
84
  {
85
    return m_tab.empty();
86
  }
87
 
88
  inline int GetCount() const
89
  {
90
    return (int) m_tab.size();
91
  }
92
 
93
  inline InCronTabEntry& GetEntry(int index)
94
  {
95
    return m_tab[index];
96
  }
97
 
98
  bool Load(const std::string& rPath);
99
 
100
  bool Save(const std::string& rPath);
101
 
102
  static bool CheckUser(const std::string& rUser);
103
 
104
  static std::string GetUserTablePath(const std::string& rUser);
105
 
106
protected:
107
  std::deque<InCronTabEntry> m_tab;
108
};
109
 
110
 
111
#endif //_INCRONTAB_H_