1
/* assuan-listen.c - Wait for a connection (server)
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
27
#include "assuan-defs.h"
30
assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line)
33
return ASSUAN_Invalid_Value;
36
xfree (ctx->hello_line);
37
ctx->hello_line = NULL;
41
char *buf = xtrymalloc (3+strlen(line)+1);
43
return ASSUAN_Out_Of_Core;
46
xfree (ctx->hello_line);
47
ctx->hello_line = buf;
57
* Cancel any existing connectiion and wait for a connection from a
58
* client. The initial handshake is performed which may include an
59
* initial authentication or encryption negotiation.
61
* Return value: 0 on success or an error if the connection could for
62
* some reason not be established.
65
assuan_accept (ASSUAN_CONTEXT ctx)
70
return ASSUAN_Invalid_Value;
72
if (ctx->pipe_mode > 1)
73
return -1; /* second invocation for pipemode -> terminate */
74
ctx->finish_handler (ctx);
76
rc = ctx->accept_handler (ctx);
81
rc = assuan_write_line (ctx, ctx->hello_line? ctx->hello_line
82
: "OK Your orders please");
95
assuan_get_input_fd (ASSUAN_CONTEXT ctx)
97
return ctx? ctx->input_fd : -1;
102
assuan_get_output_fd (ASSUAN_CONTEXT ctx)
104
return ctx? ctx->output_fd : -1;
108
/* Close the fd descriptor set by the command INPUT FD=n. We handle
109
this fd inside assuan so that we can do some initial checks */
111
assuan_close_input_fd (ASSUAN_CONTEXT ctx)
113
if (!ctx || ctx->input_fd == -1)
114
return ASSUAN_Invalid_Value;
115
close (ctx->input_fd);
120
/* Close the fd descriptor set by the command OUTPUT FD=n. We handle
121
this fd inside assuan so that we can do some initial checks */
123
assuan_close_output_fd (ASSUAN_CONTEXT ctx)
125
if (!ctx || ctx->output_fd == -1)
126
return ASSUAN_Invalid_Value;
128
close (ctx->output_fd);