~ubuntu-branches/ubuntu/raring/libgcrypt11/raring

« back to all changes in this revision

Viewing changes to src/module.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2008-07-02 18:32:45 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080702183245-b1p9zumbhmq9wk4g
Tags: 1.4.1-1ubuntu1
* Merge from Debian unstable.
* Remaining Ubuntu changes:
  - Add libgcrypt11-udeb package.
  - Add clean-la.mk, and add a symlink for the .la
* Ubuntu changes dropped:
  - Build-Depends changes.
  - Drop patch 20_socket_nsl_linkage.diff, basically applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
19
 */
20
20
 
21
 
#include <assert.h>
22
21
#include <config.h>
23
22
#include <errno.h>
24
23
#include "g10lib.h"
25
24
 
 
25
/* Please match these numbers with the allocated algorithm
 
26
   numbers.  */
26
27
#define MODULE_ID_MIN 600
 
28
#define MODULE_ID_LAST 65500
 
29
#define MODULE_ID_USER 1024
 
30
#define MODULE_ID_USER_LAST 4095
 
31
 
 
32
#if MODULE_ID_MIN >= MODULE_ID_USER
 
33
#error Need to implement a different search strategy
 
34
#endif
27
35
 
28
36
/* Internal function.  Generate a new, unique module ID for a module
29
37
   that should be inserted into the module chain starting at
31
39
static gcry_err_code_t
32
40
_gcry_module_id_new (gcry_module_t modules, unsigned int *id_new)
33
41
{
34
 
  /* FIXME, what should be the ID of the first module registered by
35
 
     the user?  */
36
 
  unsigned int id_min = MODULE_ID_MIN, id_max = (unsigned int) -1, mod_id;
 
42
  unsigned int mod_id;
37
43
  gcry_err_code_t err = GPG_ERR_NO_ERROR;
38
44
  gcry_module_t module;
39
45
 
40
46
  /* Search for unused ID.  */
41
 
  for (mod_id = id_min; mod_id < id_max; mod_id++)
 
47
  for (mod_id = MODULE_ID_MIN; mod_id < MODULE_ID_LAST; mod_id++)
42
48
    {
 
49
      if (mod_id == MODULE_ID_USER)
 
50
        {
 
51
          mod_id = MODULE_ID_USER_LAST;
 
52
          continue;
 
53
        }
 
54
 
43
55
      /* Search for a module with the current ID.  */
44
56
      for (module = modules; module; module = module->next)
45
57
        if (mod_id == module->mod_id)
50
62
        break;
51
63
    }
52
64
 
53
 
  if (mod_id < id_max)
 
65
  if (mod_id < MODULE_ID_LAST)
54
66
    /* Done.  */
55
67
    *id_new = mod_id;
56
68
  else