From: Ralph Boehme Date: Mon, 27 Apr 2020 12:38:28 +0000 (+0200) Subject: s3/lib: add is_gmt_token() X-Git-Tag: samba-4.11.10~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d60f8ac9fa2440fa559fd72f86adc53268254da;p=thirdparty%2Fsamba.git s3/lib: add is_gmt_token() This is not present in master as master has been converted to use struct smb_filename.twrp instead of @GMT string tokens as part of the path. Signed-off-by: Ralph Boehme --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 43a4b8f8b4d..0c0ffc4f3ff 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -992,6 +992,7 @@ bool split_stream_filename(TALLOC_CTX *ctx, const char *filename_in, char **filename_out, char **streamname_out); +bool is_gmt_token(const char *path); /* The following definitions come from lib/dummyroot.c */ diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 66c07001eba..58919256e0e 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -378,3 +378,22 @@ bool split_stream_filename(TALLOC_CTX *ctx, } return true; } + +/** + * Checks whether the first part of path is a valid GMT token + */ +bool is_gmt_token(const char *path) +{ + struct tm tm; + char *p = NULL; + + p = strptime(path, GMT_FORMAT, &tm); + if (p == NULL) { + /* Not a valid timestring. */ + return false; + } + if (p[0] != '\0' && p[0] != '/') { + return false; + } + return true; +}