summaryrefslogtreecommitdiffstats
path: root/runtime/srutils.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-12 09:47:44 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-12 09:47:44 +0200
commit0917edf26da9055c6dc160aafca97896daea3e6c (patch)
treecaeee5f141e982597cd70070eb753ea1154d6720 /runtime/srutils.c
parent1c8fe77b78a64d69138b30ec28b430677b197601 (diff)
downloadrsyslog-0917edf26da9055c6dc160aafca97896daea3e6c.tar.gz
rsyslog-0917edf26da9055c6dc160aafca97896daea3e6c.tar.xz
rsyslog-0917edf26da9055c6dc160aafca97896daea3e6c.zip
re-enabled outchannel functionality
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r--runtime/srutils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/srutils.c b/runtime/srutils.c
index d01ca20d..5407531f 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -553,6 +553,33 @@ int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep)
}
+/* get the size of a file or return appropriate error code. If an error is returned,
+ * *pSize content is undefined.
+ * rgerhards, 2009-06-12
+ */
+rsRetVal
+getFileSize(uchar *pszName, off_t *pSize)
+{
+ int ret;
+ struct stat statBuf;
+ DEFiRet;
+
+ ret = stat((char*) pszName, &statBuf);
+ if(ret == -1) {
+ switch(errno) {
+ case EACCES: ABORT_FINALIZE(RS_RET_NO_FILE_ACCESS);
+ case ENOTDIR:
+ case ENOENT: ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
+ default: ABORT_FINALIZE(RS_RET_FILE_NO_STAT);
+ }
+ }
+
+ *pSize = statBuf.st_size;
+
+finalize_it:
+ RETiRet;
+}
+
/* vim:set ai:
*/