1
/* dynload.c - load cipher extensions
2
* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
4
* This file is part of GnuPG.
6
* GnuPG is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* GnuPG is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
28
#include "algorithms.h"
31
typedef struct ext_list {
32
struct ext_list *next;
36
static EXTLIST extensions;
38
/* This is actually not used anymore but we keep a list of already
39
* set extensions modules here.
41
* Here is the ancient comment:
42
* Register an extension module. The last registered module will
43
* be loaded first. A name may have a list of classes
45
* mymodule.so(1:17,3:20,3:109)
46
* means that this module provides digest algorithm 17 and public key
47
* algorithms 20 and 109. This is only a hint but if it is there the
48
* loader may decide to only load a module which claims to have a
49
* requested algorithm.
51
* mainpgm is the path to the program which wants to load a module
52
* it is only used in some environments.
55
register_cipher_extension( const char *mainpgm, const char *fname )
60
if( *fname != DIRSEP_C ) { /* do tilde expansion etc */
63
if( strchr(fname, DIRSEP_C) )
64
tmp = make_filename(fname, NULL);
66
tmp = make_filename(GNUPG_LIBDIR, fname, NULL);
67
el = m_alloc_clear( sizeof *el + strlen(tmp) );
68
strcpy(el->name, tmp );
72
el = m_alloc_clear( sizeof *el + strlen(fname) );
73
strcpy(el->name, fname );
75
/* check whether we have a class hint */
76
if( (p=strchr(el->name,'(')) && (pe=strchr(p+1,')')) && !pe[1] )
79
/* check that it is not already registered */
81
for(r = extensions; r; r = r->next ) {
82
if( !compare_filenames(r->name, el->name) ) {
83
log_info("extension `%s' already registered\n", el->name );
89
el->next = extensions;
93
/* Return the module name with index SEQ, return NULL as as indication
96
dynload_enum_module_names (int seq)
98
EXTLIST el = extensions;
100
for (; el && el->name && seq; el = el->next, seq--)
102
return el? el->name:NULL;