~noskcaj/ubuntu/trusty/gpgme1.0/1.4.3

« back to all changes in this revision

Viewing changes to assuan/assuan-socket-connect.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2009-09-08 14:30:11 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090908143011-dv8rzfraejhex6t5
Tags: 1.2.0-1
* New Upstream Version (Closes: #545671)
* As there are new symbols introduced in this version, bump shlibs info. 
* Bump Standards-Version to 3.8.3, no changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * Lesser General Public License for more details.
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public
17
 
 * License along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
 
 * USA. 
 
17
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20
18
 */
21
19
 
22
20
#include <config.h>
57
55
static int
58
56
do_finish (assuan_context_t ctx)
59
57
{
60
 
  if (ctx->inbound.fd != -1)
 
58
  if (ctx->inbound.fd != ASSUAN_INVALID_FD)
61
59
    {
62
60
      _assuan_close (ctx->inbound.fd);
63
61
    }
64
 
  ctx->inbound.fd = -1;
65
 
  ctx->outbound.fd = -1;
 
62
  ctx->inbound.fd = ASSUAN_INVALID_FD;
 
63
  ctx->outbound.fd = ASSUAN_INVALID_FD;
66
64
  return 0;
67
65
}
68
66
 
87
85
/* Make a connection to the Unix domain socket NAME and return a new
88
86
   Assuan context in CTX.  SERVER_PID is currently not used but may
89
87
   become handy in the future.  With flags set to 1 sendmsg and
90
 
   recvmesg are used. */
 
88
   recvmsg are used. */
91
89
assuan_error_t
92
90
assuan_socket_connect_ext (assuan_context_t *r_ctx,
93
91
                           const char *name, pid_t server_pid,
94
92
                           unsigned int flags)
95
93
{
96
 
  static struct assuan_io io = { _assuan_simple_read,
97
 
                                 _assuan_simple_write };
98
 
 
 
94
  static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write,
 
95
                                 NULL, NULL };
99
96
  assuan_error_t err;
100
97
  assuan_context_t ctx;
101
 
  int fd;
 
98
  assuan_fd_t fd;
102
99
  struct sockaddr_un srvr_addr;
103
100
  size_t len;
104
101
  const char *s;
109
106
 
110
107
  /* We require that the name starts with a slash, so that we
111
108
     eventually can reuse this function for other socket types.  To
112
 
     make things easier we allow an optional dirver prefix.  */
 
109
     make things easier we allow an optional driver prefix.  */
113
110
  s = name;
114
111
  if (*s && s[1] == ':')
115
112
    s += 2;
126
123
  ctx->finish_handler = do_finish;
127
124
 
128
125
  fd = _assuan_sock_new (PF_LOCAL, SOCK_STREAM, 0);
129
 
  if (fd == -1)
 
126
  if (fd == ASSUAN_INVALID_FD)
130
127
    {
131
128
      _assuan_log_printf ("can't create socket: %s\n", strerror (errno));
132
129
      _assuan_release_context (ctx);
139
136
  srvr_addr.sun_path[sizeof (srvr_addr.sun_path) - 1] = 0;
140
137
  len = SUN_LEN (&srvr_addr);
141
138
 
142
 
 
143
 
  if (_assuan_sock_connect (fd, (struct sockaddr *) &srvr_addr, len) == -1)
 
139
  if ( _assuan_sock_connect (fd, (struct sockaddr *) &srvr_addr, len) == -1 )
144
140
    {
145
141
      _assuan_log_printf ("can't connect to `%s': %s\n",
146
142
                          name, strerror (errno));