Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (836 Bytes)

1
/*
2
 *        BIRD -- Password handling
3
 *
4
 *        (c) 1999 Pavel Machek <pavel@ucw.cz>
5
 *        (c) 2004 Ondrej Filip <feela@network.cz>
6
 *
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
#include "lib/string.h"
13

    
14
struct password_item *last_password_item = NULL;
15

    
16
struct password_item *
17
password_find(list *l, int first_fit)
18
{
19
  struct password_item *pi;
20
  struct password_item *pf = NULL;
21

    
22
  if (l)
23
  {
24
    WALK_LIST(pi, *l)
25
    {
26
      if ((pi->genfrom < now_real) && (pi->gento > now_real))
27
      {
28
        if (first_fit)
29
          return pi;
30

    
31
        if (!pf || pf->genfrom < pi->genfrom)
32
          pf = pi;
33
      }
34
    }
35
  }
36
  return pf;
37
}
38

    
39
void password_cpy(char *dst, char *src, int size)
40
{
41
  bzero(dst, size);
42
  memcpy(dst, src, (strlen(src) < (unsigned) size ? strlen(src) : (unsigned) size));
43
}
44