summaryrefslogtreecommitdiff
path: root/snmplib/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'snmplib/readdir.c')
-rw-r--r--snmplib/readdir.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/snmplib/readdir.c b/snmplib/readdir.c
new file mode 100644
index 0000000..33ff83d
--- /dev/null
+++ b/snmplib/readdir.c
@@ -0,0 +1,51 @@
+/*
+ * readdir() replacement for MSVC.
+ */
+
+#define WIN32IO_IS_STDIO
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/types.h>
+#include <net-snmp/library/system.h>
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#include <tchar.h>
+#include <windows.h>
+
+
+/*
+ * Readdir just returns the current string pointer and bumps the
+ * * string pointer to the nDllExport entry.
+ */
+struct direct *
+readdir(DIR * dirp)
+{
+ int len;
+ static int dummy = 0;
+
+ if (dirp->curr) {
+ /*
+ * first set up the structure to return
+ */
+ len = strlen(dirp->curr);
+ strcpy(dirp->dirstr.d_name, dirp->curr);
+ dirp->dirstr.d_namlen = len;
+
+ /*
+ * Fake an inode
+ */
+ dirp->dirstr.d_ino = dummy++;
+
+ /*
+ * Now set up for the nDllExport call to readdir
+ */
+ dirp->curr += len + 1;
+ if (dirp->curr >= (dirp->start + dirp->size)) {
+ dirp->curr = NULL;
+ }
+
+ return &(dirp->dirstr);
+ } else
+ return NULL;
+}