summaryrefslogtreecommitdiff
path: root/nest/password.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>1999-05-31 17:12:00 +0000
committerPavel Machek <pavel@ucw.cz>1999-05-31 17:12:00 +0000
commit900d5470ae2cada4d37ed62f8bf2ce64c84349cd (patch)
treead3e392914612d72481a2d0ffb1e0821c5622d94 /nest/password.c
parent139ca21d05df71b59a72af126d063170421cf9f7 (diff)
Added PASSIVE option to paswwords.
Diffstat (limited to 'nest/password.c')
-rw-r--r--nest/password.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/nest/password.c b/nest/password.c
index ff084b41..ce7941ea 100644
--- a/nest/password.c
+++ b/nest/password.c
@@ -10,3 +10,31 @@
#include "nest/password.h"
struct password_item *last_password_item = NULL;
+
+static int
+password_goodness(struct password_item *i)
+{
+ if (i->from > now)
+ return 0;
+ if (i->to < now)
+ return 0;
+ if (i->passive < now)
+ return 1;
+ return 2;
+}
+
+struct password_item *
+get_best_password(struct password_item *head, int flags)
+{
+ int good = -1;
+ struct password_item *best = NULL;
+
+ while (head) {
+ int cur = password_goodness(head);
+ if (cur > good) {
+ good = cur;
+ best = head;
+ }
+ }
+ return best;
+}