summaryrefslogtreecommitdiff
path: root/src/assuan-listen.c
blob: f8ccb2708ed2883f78f1dbb40b9cefddee2c61c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* assuan-listen.c - Wait for a connection (server) 
 *	Copyright (C) 2001 Free Software Foundation, Inc.
 *
 * This file is part of GnuPG.
 *
 * GnuPG is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GnuPG is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 */

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "assuan-defs.h"



/**
 * assuan_accept:
 * @ctx: context
 * 
 * Cancel any existing connectiion and wait for a connection from a
 * client.  The initial handshake is performed which may include an
 * initial authentication or encryption negotiation.
 * 
 * Return value: 0 on success or an error if the connection could for
 * some reason not be established.
 **/
int
assuan_accept (ASSUAN_CONTEXT ctx)
{
  int rc;

  if (!ctx)
    return ASSUAN_Invalid_Value;

  /* fixme: cancel existing connection */
  if (ctx->pipe_mode > 1)
    return -1; /* second invocation for pipemode -> terminate */

  if (!ctx->pipe_mode)
    {

      /* fixme: wait for request */
    }

  /* send the hello */
  
  rc = _assuan_write_line (ctx,
                           "OK Hello dear client - what can I do for you?");
  if (rc)
    return rc;
  
  if (ctx->pipe_mode)
    ctx->pipe_mode = 2;
  
  return 0;
}


int
assuan_get_input_fd (ASSUAN_CONTEXT ctx)
{
  return ctx? ctx->input_fd : -1;
}


int
assuan_get_output_fd (ASSUAN_CONTEXT ctx)
{
  return ctx? ctx->output_fd : -1;
}