summaryrefslogtreecommitdiff
path: root/source3/lib/util_file.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-07-14 19:21:44 +0000
committerLuke Leighton <lkcl@samba.org>1999-07-14 19:21:44 +0000
commit1f33d5a8aaa6b9a94dde21529fe2aa407fb5ffa1 (patch)
tree9dabf92f0bc5923d3d4f48c7a2eb4fcd1322f4a5 /source3/lib/util_file.c
parentc553c01c86bca04583277f65d45d0e097fa38603 (diff)
downloadsamba-1f33d5a8aaa6b9a94dde21529fe2aa407fb5ffa1.tar.gz
samba-1f33d5a8aaa6b9a94dde21529fe2aa407fb5ffa1.tar.bz2
samba-1f33d5a8aaa6b9a94dde21529fe2aa407fb5ffa1.zip
code from bertl to allow remap of default built-in names to anything.
parameter is "builtin rid file". Copyright 1999 Bertl <bp@vpnet.at> (This used to be commit 80d36778432d42eb265ed9428f27a27250ba5e08)
Diffstat (limited to 'source3/lib/util_file.c')
-rw-r--r--source3/lib/util_file.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 37489086d8..5861314c02 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -188,7 +188,6 @@ int getfileline(void *vp, char *linebuf, int linebuf_size)
/* Static buffers we will return. */
FILE *fp = (FILE *)vp;
unsigned char c;
- unsigned char *p;
size_t linebuf_len;
if (fp == NULL)
@@ -248,12 +247,6 @@ int getfileline(void *vp, char *linebuf, int linebuf_size)
continue;
}
- p = (unsigned char *) strchr(linebuf, ':');
- if (p == NULL)
- {
- DEBUG(0, ("getfileline: malformed line entry (no :)\n"));
- continue;
- }
return linebuf_len;
}
return -1;
@@ -326,3 +319,49 @@ char *fgets_slash(char *s2,int maxlen,FILE *f)
return(s);
}
+/****************************************************************************
+checks if a file has changed since last read
+****************************************************************************/
+BOOL file_modified(const char *filename, time_t *lastmodified)
+{
+ SMB_STRUCT_STAT st;
+
+ if (sys_stat(filename, &st) != 0)
+ {
+ DEBUG(0, ("file_changed: Unable to stat file %s. Error was %s\n",
+ filename, strerror(errno) ));
+ return False;
+ }
+
+ if(st.st_mtime <= *lastmodified)
+ {
+ DEBUG(20, ("file_modified: %s not modified\n", filename));
+ return False;
+ }
+
+ DEBUG(20, ("file_modified: %s modified\n", filename));
+ *lastmodified = st.st_mtime;
+ return True;
+}
+
+/***************************************************************************
+opens a file if modified otherwise returns NULL
+***************************************************************************/
+void *open_file_if_modified(const char *filename, char *mode, time_t *lastmodified)
+{
+ FILE *f;
+
+ if (file_modified(filename, lastmodified))
+ {
+ return NULL;
+ }
+
+ if( (f = fopen(filename, mode)) == NULL)
+ {
+ DEBUG(0, ("open_file_if_modified: can't open file %s. Error was %s\n",
+ filename, strerror(errno)));
+ return NULL;
+ }
+
+ return (void *)f;
+}