s3/lib: add is_gmt_token()
authorRalph Boehme <slow@samba.org>
Mon, 27 Apr 2020 12:38:28 +0000 (14:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 May 2020 13:31:25 +0000 (13:31 +0000)
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 <slow@samba.org>
source3/include/proto.h
source3/lib/filename_util.c

index 43a4b8f8b4d5e3c03623c49d718f36ba59fab356..0c0ffc4f3ff714692b2c6333c5520560a40f9aa5 100644 (file)
@@ -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 */
 
index 66c07001eba273b0424ad03f31cc8312040b0ff6..58919256e0e83c3981c4c3289020f561e47259be 100644 (file)
@@ -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;
+}