~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-updates

« back to all changes in this revision

Viewing changes to common/http.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* http.h  -  HTTP protocol handler
 
2
 * Copyright (C) 1999, 2000, 2001, 2003,
 
3
 *               2006 Free Software Foundation, Inc.
 
4
 *     
 
5
 * This file is part of GnuPG.
 
6
 *
 
7
 * GnuPG is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * GnuPG is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
#ifndef GNUPG_COMMON_HTTP_H
 
21
#define GNUPG_COMMON_HTTP_H 
 
22
 
 
23
#include <gpg-error.h>
 
24
#ifdef HTTP_USE_ESTREAM
 
25
#include "estream.h"
 
26
#endif
 
27
 
 
28
struct uri_tuple_s {
 
29
  struct uri_tuple_s *next;
 
30
  const char *name;     /* A pointer into name. */
 
31
  char  *value;         /* A pointer to value (a Nul is always appended). */
 
32
  size_t valuelen;      /* The real length of the value; we need it
 
33
                           because the value may contain embedded Nuls. */
 
34
  int no_value;         /* True if no value has been given in the URL. */
 
35
};
 
36
typedef struct uri_tuple_s *uri_tuple_t;
 
37
 
 
38
struct parsed_uri_s 
 
39
{
 
40
  /* All these pointers point into BUFFER; most stuff is not escaped. */
 
41
  char *scheme;         /* Pointer to the scheme string (lowercase). */
 
42
  int use_tls;          /* Whether TLS should be used. */
 
43
  char *auth;           /* username/password for basic auth */
 
44
  char *host;           /* Host (converted to lowercase). */
 
45
  unsigned short port;  /* Port (always set if the host is set). */
 
46
  char *path;           /* Path. */
 
47
  uri_tuple_t params;   /* ";xxxxx" */
 
48
  uri_tuple_t query;    /* "?xxx=yyy" */
 
49
  char buffer[1];       /* Buffer which holds a (modified) copy of the URI. */
 
50
};
 
51
typedef struct parsed_uri_s *parsed_uri_t;
 
52
 
 
53
typedef enum 
 
54
  {
 
55
    HTTP_REQ_GET  = 1,
 
56
    HTTP_REQ_HEAD = 2,
 
57
    HTTP_REQ_POST = 3
 
58
  } 
 
59
http_req_t;
 
60
 
 
61
/* We put the flag values into an enum, so that gdb can display them. */
 
62
enum
 
63
  { 
 
64
    HTTP_FLAG_TRY_PROXY = 1,
 
65
    HTTP_FLAG_NO_SHUTDOWN = 2,
 
66
    HTTP_FLAG_TRY_SRV = 4,
 
67
    HTTP_FLAG_LOG_RESP = 8,
 
68
    HTTP_FLAG_NEED_HEADER = 16
 
69
  };
 
70
 
 
71
struct http_context_s;
 
72
typedef struct http_context_s *http_t;
 
73
 
 
74
void http_register_tls_callback (gpg_error_t (*cb) (http_t, void *, int));
 
75
 
 
76
gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri);
 
77
 
 
78
void http_release_parsed_uri (parsed_uri_t uri);
 
79
 
 
80
gpg_error_t http_open (http_t *r_hd, http_req_t reqtype,
 
81
                       const char *url,
 
82
                       const char *auth,
 
83
                       unsigned int flags,
 
84
                       const char *proxy,
 
85
                       void *tls_context);
 
86
 
 
87
void http_start_data (http_t hd);
 
88
 
 
89
gpg_error_t http_wait_response (http_t hd);
 
90
 
 
91
void http_close (http_t hd, int keep_read_stream);
 
92
 
 
93
gpg_error_t http_open_document (http_t *r_hd,
 
94
                                const char *document,
 
95
                                const char *auth,
 
96
                                unsigned int flags,
 
97
                                const char *proxy,
 
98
                                void *tls_context);
 
99
 
 
100
#ifdef HTTP_USE_ESTREAM
 
101
estream_t http_get_read_ptr (http_t hd);
 
102
estream_t http_get_write_ptr (http_t hd);
 
103
#else /*!HTTP_USE_ESTREAM*/
 
104
FILE *http_get_read_ptr (http_t hd);
 
105
FILE *http_get_write_ptr (http_t hd);
 
106
#endif /*!HTTP_USE_ESTREAM*/
 
107
unsigned int http_get_status_code (http_t hd);
 
108
const char *http_get_header (http_t hd, const char *name);
 
109
 
 
110
char *http_escape_string (const char *string, const char *specials);
 
111
 
 
112
 
 
113
#endif /*GNUPG_COMMON_HTTP_H*/