File: ecrontab.h

package info (click to toggle)
recoll 1.43.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 16,892 kB
  • sloc: cpp: 104,589; python: 9,603; xml: 7,272; ansic: 6,447; sh: 1,212; perl: 166; makefile: 72
file content (67 lines) | stat: -rw-r--r-- 2,919 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright (C) 2004 J.F.Dockes
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
#ifndef _ECRONTAB_H_INCLUDED_
#define _ECRONTAB_H_INCLUDED_

/** Utility function to manage lines inside a user crontab 
 * 
 * Lines managed by this routine are marked with a hopefully unique marker
 * and discriminated by a selector, both environment variable settings. 
 * Example:
 *  30 8 * * * RCLCRONTAB_RCLINDEX= RECOLL_CONFDIR=/path/to/dir recollindex ...
 * RCLCRONTAB_RCLINDEX is the line marker, and the RECOLL_CONFDIR value
 * allows selecting the affected line. 
 *
 * This approach allows leaving alone lines which do have a
 * RECOLL_CONFDIR value but not managed by us. The marker and selector
 * values are chosen by the caller, which should apply some thought to
 * choosing sane values.
 */

#include <string>
#include <vector>

/** Add, replace or delete a command inside a crontab file
 *
 * @param marker selects lines managed by this module and should take the form
 *  of a (possibly empty) environment variable assignment.
 * @param id selects the appropriate line to affect and will usually be an 
 *   actual variable assignment (see above)
 * @param sched is a standard cron schedule spec (ie: 30 8 * * *)
 * @param cmd is the command to execute (the last part of the line). 
 *    Set it to an empty string to delete the line from the crontab
 * @param reason error message
 *
 * "marker" and "id" should look like reasonable env variable assignments. 
 * Only ascii capital letters, numbers and _ before the '='
 */
bool editCrontab(const std::string& marker, const std::string& id, const std::string& sched,
                 const std::string& cmd, std::string& reason);

/**
 * check crontab for unmanaged lines
 * @param marker same as above, typically RCLCRONTAB_RCLINDEX=
 * @param data string to look for on lines NOT marked, typically "recollindex"
 * @return true if unmanaged lines exist, false else.
 */
bool checkCrontabUnmanaged(const std::string& marker, const std::string& data);

/** Retrieve the scheduling for a crontab entry */
bool getCrontabSched(const std::string& marker, const std::string& id, 
                     std::vector<std::string>& sched);

#endif /* _ECRONTAB_H_INCLUDED_ */