Statistics
| Branch: | Revision:

iof-bird-daemon / nest / password.c @ fbde6c39

History | View | Annotate | Download (836 Bytes)

1 1a2ded45 Pavel Machek
/*
2
 *        BIRD -- Password handling
3
 *
4 5236fb03 Ondrej Filip
 *        (c) 1999 Pavel Machek <pavel@ucw.cz>
5
 *        (c) 2004 Ondrej Filip <feela@network.cz>
6 1a2ded45 Pavel Machek
 *
7
 *        Can be freely distributed and used under the terms of the GNU GPL.
8
 */
9
10
#include "nest/bird.h"
11
#include "nest/password.h"
12 7d875e09 Martin Mares
#include "lib/string.h"
13 1a2ded45 Pavel Machek
14
struct password_item *last_password_item = NULL;
15 900d5470 Pavel Machek
16
struct password_item *
17 b21f68b4 Ondrej Zajicek
password_find(list *l, int first_fit)
18 900d5470 Pavel Machek
{
19 5236fb03 Ondrej Filip
  struct password_item *pi;
20 b21f68b4 Ondrej Zajicek
  struct password_item *pf = NULL;
21 900d5470 Pavel Machek
22 02ad2737 Ondrej Filip
  if (l)
23 5236fb03 Ondrej Filip
  {
24 02ad2737 Ondrej Filip
    WALK_LIST(pi, *l)
25
    {
26 fd91ae33 Ondrej Zajicek
      if ((pi->genfrom < now_real) && (pi->gento > now_real))
27 b21f68b4 Ondrej Zajicek
      {
28
        if (first_fit)
29
          return pi;
30
31
        if (!pf || pf->genfrom < pi->genfrom)
32
          pf = pi;
33
      }
34 02ad2737 Ondrej Filip
    }
35 900d5470 Pavel Machek
  }
36 b21f68b4 Ondrej Zajicek
  return pf;
37 900d5470 Pavel Machek
}
38 2e6197d6 Pavel Machek
39 5236fb03 Ondrej Filip
void password_cpy(char *dst, char *src, int size)
40 2e6197d6 Pavel Machek
{
41 5236fb03 Ondrej Filip
  bzero(dst, size);
42 32d3228d Ondrej Filip
  memcpy(dst, src, (strlen(src) < (unsigned) size ? strlen(src) : (unsigned) size));
43 2e6197d6 Pavel Machek
}