openbsd-ports/security/aircrack-ng/patches/patch-src_common_c
fgsch 8b11b60b1b Update to aircrack-ng 1.1.
input and ok sthen and benoit (maintainer)
2011-05-21 11:19:24 +00:00

33 lines
807 B
Plaintext

$OpenBSD: patch-src_common_c,v 1.1 2011/05/21 11:19:24 fgsch Exp $
--- src/common.c.orig Mon May 9 09:14:48 2011
+++ src/common.c Mon May 9 09:33:03 2011
@@ -31,6 +31,7 @@
#define isHex(c) (hexToInt(c) != -1)
#define HEX_BASE 16
+#if !defined(__OpenBSD__)
int get_ram_size(void) {
FILE *fp;
char str[256];
@@ -52,6 +53,20 @@ int get_ram_size(void) {
fclose(fp);
return ret;
}
+#else
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+int get_ram_size(void) {
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+ unsigned int physmem;
+ size_t len = sizeof(physmem);
+
+ if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0)
+ return -1;
+ return (physmem / 1024);
+}
+#endif
/* Return the version number */
char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc)