Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 : client string routines
4 : Copyright (C) Andrew Tridgell 2001
5 : Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003
6 :
7 : This program is free software; you can redistribute it and/or modify
8 : it under the terms of the GNU General Public License as published by
9 : the Free Software Foundation; either version 3 of the License, or
10 : (at your option) any later version.
11 :
12 : This program is distributed in the hope that it will be useful,
13 : but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : GNU General Public License for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with this program. If not, see <http://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include "includes.h"
22 : #include "libsmb/proto.h"
23 :
24 11972 : bool clistr_is_previous_version_path(const char *path,
25 : const char **startp,
26 : const char **endp,
27 : time_t *ptime)
28 : {
29 : char *q;
30 : time_t timestamp;
31 : struct tm tm;
32 11972 : const char *p = strstr_m(path, "@GMT-");
33 :
34 11972 : if (p == NULL) {
35 11972 : return false;
36 : }
37 0 : if (p > path && (p[-1] != '\\')) {
38 0 : return false;
39 : }
40 0 : q = strptime(p, GMT_FORMAT, &tm);
41 0 : if (q == NULL) {
42 0 : return false;
43 : }
44 0 : tm.tm_isdst = -1;
45 0 : timestamp = timegm(&tm);
46 0 : if (timestamp == (time_t)-1) {
47 0 : return false;
48 : }
49 0 : if (q[0] != '\0' && q[0] != '\\') {
50 0 : return false;
51 : }
52 0 : if (startp) {
53 0 : *startp = p;
54 : }
55 0 : if (endp) {
56 0 : if (q[0] == '\\') {
57 0 : q++;
58 : }
59 0 : *endp = q;
60 : }
61 0 : if (ptime) {
62 0 : *ptime = timestamp;
63 : }
64 0 : return true;
65 : }
|