Debian Codegraph @

assuan/assuan-listen.c

raw symbols SCIP
1 /* assuan-listen.c - Wait for a connection (server)
2 * Copyright (C) 2001 Free Software Foundation, Inc.
3 *
4 * This file is part of GnuPG.
5 *
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <config.h>cxx . . $ `<file>/config.h`/
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <string.h>
25 #include <unistd.h>
26
27 #include "assuan-defs.h"cxx . . $ `<file>/assuan/assuan-defs.h`/
28
29 AssuanErrorcxx . . $ AssuanError#
30 assuan_set_hello_linecxx . . $ assuan_set_hello_line(ee7b1645795a12df). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx, const char *line)
31 {
32 if (!ctx)
33 return ASSUAN_Invalid_Valuecxx . . $ ASSUAN_Invalid_Value.;
34 if (!line)
35 {
36 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx->hello_line);
37 ctx->hello_linecxx . . $ assuan_context_s#hello_line. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
38 }
39 else
40 {
41 char *buf = xtrymalloccxx . . $ `assuan/assuan-defs.h:127:9`! (3+strlen(line)+1);
42 if (!buf)
43 return ASSUAN_Out_Of_Corecxx . . $ ASSUAN_Out_Of_Core.;
44 strcpycxx . . $ strcpy(b7b3a83273496486). (buf, "OK ");
45 strcpycxx . . $ strcpy(b7b3a83273496486). (buf+3, line);
46 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx->hello_line);
47 ctx->hello_linecxx . . $ assuan_context_s#hello_line. = buf;
48 }
49 return 0;
50 }
51
52
53 /**
54 * assuan_accept:
55 * @ctx: context
56 *
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.
60 *
61 * Return value: 0 on success or an error if the connection could for
62 * some reason not be established.
63 **/
64 AssuanErrorcxx . . $ AssuanError#
65 assuan_acceptcxx . . $ assuan_accept(5c60088356380db8). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
66 {
67 int rc;
68
69 if (!ctx)
70 return ASSUAN_Invalid_Valuecxx . . $ ASSUAN_Invalid_Value.;
71
72 if (ctx->pipe_modecxx . . $ assuan_context_s#pipe_mode. > 1)
73 return -1; /* second invocation for pipemode -> terminate */
74 ctx->finish_handlercxx . . $ assuan_context_s#finish_handler. (ctx);
75
76 rc = ctx->accept_handlercxx . . $ assuan_context_s#accept_handler. (ctx);
77 if (rc)
78 return rc;
79
80 /* send the hello */
81 rc = assuan_write_linecxx . . $ assuan_write_line(ee7b1645795a12df). (ctx, ctx->hello_linecxx . . $ assuan_context_s#hello_line.? ctx->hello_linecxx . . $ assuan_context_s#hello_line.
82 : "OK Your orders please");
83 if (rc)
84 return rc;
85
86 if (ctx->pipe_modecxx . . $ assuan_context_s#pipe_mode.)
87 ctx->pipe_modecxx . . $ assuan_context_s#pipe_mode. = 2;
88
89 return 0;
90 }
91
92
93
94 int
95 assuan_get_input_fdcxx . . $ assuan_get_input_fd(29493cd997091d1). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
96 {
97 return ctx? ctx->input_fdcxx . . $ assuan_context_s#input_fd. : -1;
98 }
99
100
101 int
102 assuan_get_output_fdcxx . . $ assuan_get_output_fd(29493cd997091d1). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
103 {
104 return ctx? ctx->output_fdcxx . . $ assuan_context_s#output_fd. : -1;
105 }
106
107
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 */
110 AssuanErrorcxx . . $ AssuanError#
111 assuan_close_input_fdcxx . . $ assuan_close_input_fd(5c60088356380db8). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
112 {
113 if (!ctx || ctx->input_fdcxx . . $ assuan_context_s#input_fd. == -1)
114 return ASSUAN_Invalid_Valuecxx . . $ ASSUAN_Invalid_Value.;
115 closecxx . . $ close(7864480464b09eea). (ctx->input_fdcxx . . $ assuan_context_s#input_fd.);
116 ctx->input_fdcxx . . $ assuan_context_s#input_fd. = -1;
117 return 0;
118 }
119
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 */
122 AssuanErrorcxx . . $ AssuanError#
123 assuan_close_output_fdcxx . . $ assuan_close_output_fd(5c60088356380db8). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
124 {
125 if (!ctx || ctx->output_fdcxx . . $ assuan_context_s#output_fd. == -1)
126 return ASSUAN_Invalid_Valuecxx . . $ ASSUAN_Invalid_Value.;
127
128 closecxx . . $ close(7864480464b09eea). (ctx->output_fdcxx . . $ assuan_context_s#output_fd.);
129 ctx->output_fdcxx . . $ assuan_context_s#output_fd. = -1;
130 return 0;
131 }
132