~ubuntu-branches/ubuntu/lucid/gpgme1.0/lucid-security

« back to all changes in this revision

Viewing changes to gpgme/gpgme.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2005-10-08 14:26:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051008142601-jajb789561w8nwhu
Tags: 1.1.0-1
New upstream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
  ctx = calloc (1, sizeof *ctx);
52
52
  if (!ctx)
53
53
    return gpg_error_from_errno (errno);
 
54
 
 
55
  _gpgme_engine_info_copy (&ctx->engine_info);
 
56
  if (!ctx->engine_info)
 
57
    {
 
58
      free (ctx);
 
59
      return gpg_error_from_errno (errno);
 
60
    }
 
61
 
54
62
  ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
55
 
  ctx->include_certs = 1;
 
63
  ctx->include_certs = GPGME_INCLUDE_CERTS_DEFAULT;
56
64
  ctx->protocol = GPGME_PROTOCOL_OpenPGP;
57
65
  _gpgme_fd_table_init (&ctx->fdt);
58
66
 
63
71
      if (!ctx->lc_ctype)
64
72
        {
65
73
          UNLOCK (def_lc_lock);
 
74
          _gpgme_engine_info_release (ctx->engine_info);
66
75
          free (ctx);
67
76
          return gpg_error_from_errno (errno);
68
77
        }
78
87
          UNLOCK (def_lc_lock);
79
88
          if (ctx->lc_ctype)
80
89
            free (ctx->lc_ctype);
 
90
          _gpgme_engine_info_release (ctx->engine_info);
81
91
          free (ctx);
82
92
          return gpg_error_from_errno (errno);
83
93
        }
121
131
    free (ctx->lc_ctype);
122
132
  if (ctx->lc_messages)
123
133
    free (ctx->lc_messages);
 
134
  _gpgme_engine_info_release (ctx->engine_info);
124
135
  free (ctx);
125
136
}
126
137
 
211
222
 
212
223
 
213
224
/* Set the number of certifications to include in an S/MIME message.
214
 
   The default is 1 (only the cert of the sender).  -1 means all
215
 
   certs, and -2 means all certs except the root cert.  */
 
225
   The default is GPGME_INCLUDE_CERTS_DEFAULT.  -1 means all certs,
 
226
   and -2 means all certs except the root cert.  */
216
227
void
217
228
gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
218
229
{
219
 
  if (nr_of_certs < -2)
 
230
  if (nr_of_certs == GPGME_INCLUDE_CERTS_DEFAULT)
 
231
    ctx->include_certs = GPGME_INCLUDE_CERTS_DEFAULT;
 
232
  else if (nr_of_certs < -2)
220
233
    ctx->include_certs = -2;
221
234
  else
222
235
    ctx->include_certs = nr_of_certs;
333
346
gpgme_error_t
334
347
gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
335
348
{
 
349
#ifndef HAVE_W32_SYSTEM
336
350
  int failed = 0;
337
351
  char *new_lc_ctype;
338
352
  char *new_lc_messages;
387
401
  if (!ctx)
388
402
    UNLOCK (def_lc_lock);
389
403
 
390
 
  return 0;
391
 
}
392
 
 
 
404
#endif /*!HAVE_W32_SYSTEM*/
 
405
  
 
406
  return 0;
 
407
}
 
408
 
 
409
 
 
410
/* Get the information about the configured engines.  A pointer to the
 
411
   first engine in the statically allocated linked list is returned.
 
412
   The returned data is valid until the next gpgme_ctx_set_engine_info.  */
 
413
gpgme_engine_info_t
 
414
gpgme_ctx_get_engine_info (gpgme_ctx_t ctx)
 
415
{
 
416
  return ctx->engine_info;
 
417
}
 
418
 
 
419
 
 
420
/* Set the engine info for the context CTX, protocol PROTO, to the
 
421
   file name FILE_NAME and the home directory HOME_DIR.  */
 
422
gpgme_error_t
 
423
gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, gpgme_protocol_t proto,
 
424
                           const char *file_name, const char *home_dir)
 
425
{
 
426
  /* FIXME: Make sure to reset the context if we are running in daemon
 
427
     mode.  */
 
428
  return _gpgme_set_engine_info (ctx->engine_info, proto,
 
429
                                 file_name, home_dir);
 
430
}
 
431
 
 
432
 
 
433
/* Clear all notation data from the context.  */
 
434
void
 
435
gpgme_sig_notation_clear (gpgme_ctx_t ctx)
 
436
{
 
437
  gpgme_sig_notation_t notation;
 
438
 
 
439
  if (!ctx)
 
440
    return;
 
441
 
 
442
  notation = ctx->sig_notations;
 
443
  while (notation)
 
444
    {
 
445
      gpgme_sig_notation_t next_notation = notation->next;
 
446
      _gpgme_sig_notation_free (notation);
 
447
      notation = next_notation;
 
448
    }
 
449
}
 
450
 
 
451
 
 
452
/* Add the human-readable notation data with name NAME and value VALUE
 
453
   to the context CTX, using the flags FLAGS.  If NAME is NULL, then
 
454
   VALUE should be a policy URL.  The flag
 
455
   GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
 
456
   data, and false for policy URLs.  */
 
457
gpgme_error_t
 
458
gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
 
459
                        const char *value, gpgme_sig_notation_flags_t flags)
 
460
{
 
461
  gpgme_error_t err;
 
462
  gpgme_sig_notation_t notation;
 
463
  gpgme_sig_notation_t *lastp;
 
464
 
 
465
  if (!ctx)
 
466
     gpg_error (GPG_ERR_INV_VALUE);
 
467
 
 
468
  if (name)
 
469
    flags |= GPGME_SIG_NOTATION_HUMAN_READABLE;
 
470
  else
 
471
    flags &= ~GPGME_SIG_NOTATION_HUMAN_READABLE;
 
472
 
 
473
  err = _gpgme_sig_notation_create (&notation, name, name ? strlen (name) : 0,
 
474
                                    value, value ? strlen (value) : 0, flags);
 
475
  if (err)
 
476
    return err;
 
477
 
 
478
  lastp = &ctx->sig_notations;
 
479
  while (*lastp)
 
480
    lastp = &(*lastp)->next;
 
481
 
 
482
  *lastp = notation;
 
483
  return 0;
 
484
}
 
485
 
 
486
 
 
487
/* Get the sig notations for this context.  */
 
488
gpgme_sig_notation_t
 
489
gpgme_sig_notation_get (gpgme_ctx_t ctx)
 
490
{
 
491
  if (!ctx)
 
492
    return NULL;
 
493
 
 
494
  return ctx->sig_notations;
 
495
}
 
496
  
393
497
 
394
498
const char *
395
499
gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo)