1 /* assuan-connect.c - Establish a connection (client)
2 * Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4 * This file is part of Assuan.
6 * Assuan is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * Assuan is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
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,
22 /* Please note that this is a stripped down and modified version of
23 the orginal Assuan code from libassuan. */
35 #include <sys/types.h>
36 #ifndef HAVE_W32_SYSTEM
40 #include "assuan-defs.h"
42 /* Create a new context. */
44 _assuan_new_context (assuan_context_t
*r_ctx
)
49 ctx
= xcalloc (1, sizeof *ctx
);
55 ctx
->outbound
.fd
= -1;
65 _assuan_release_context (assuan_context_t ctx
)
69 xfree (ctx
->hello_line
);
70 xfree (ctx
->okay_line
);
76 /* Disconnect and release the context CTX. */
78 assuan_disconnect (assuan_context_t ctx
)
82 assuan_write_line (ctx
, "BYE");
83 ctx
->finish_handler (ctx
);
84 ctx
->deinit_handler (ctx
);
85 ctx
->deinit_handler
= NULL
;
86 _assuan_release_context (ctx
);
90 /* Return the PID of the peer or -1 if not known. */
92 assuan_get_pid (assuan_context_t ctx
)
94 return (ctx
&& ctx
->pid
)? ctx
->pid
: -1;