aboutsummaryrefslogtreecommitdiffstats
path: root/kbx/keybox-init.c
blob: a4649d18c85d4319da6f9ea7076578216131a2ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* keybox-init.c - Initalization of the library 
 *	Copyright (C) 2001 Free Software Foundation, Inc.
 *
 * This file is part of GnuPG.
 *
 * GnuPG is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GnuPG is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 */

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "keybox-defs.h"

/* 
 * Register a filename for plain keybox files.  Returns a pointer to
 * be used to create a handles etc or NULL to indicate that it has
 * already been registered */
void *
keybox_register_file (const char *fname, int secret)
{
  return NULL;
#if 0
    KB_NAME kr;

    if (active_handles)
        BUG (); /* We don't allow that */

    for (kr=kb_names; kr; kr = kr->next) {
        if ( !compare_filenames (kr->fname, fname) )
            return NULL; /* already registered */
    }

    kr = m_alloc (sizeof *kr + strlen (fname));
    strcpy (kr->fname, fname);
    kr->secret = !!secret;
    kr->lockhd = NULL;
    kr->is_locked = 0;
    kr->did_full_scan = 0;
    /* keep a list of all issued pointers */
    kr->next = kb_names;
    kb_names = kr;

    /* create the offset table the first time a function here is used */
    if (!kb_offtbl)
      kb_offtbl = new_offset_hash_table ();

    return kr;
#endif
}

int
keybox_is_writable (void *token)
{
  KB_NAME r = token;

  return r? !access (r->fname, W_OK) : 0;
}