Debian Codegraph @

assuan/assuan-pipe-server.c

raw symbols SCIP
1 /* assuan-pipe-server.c - Assuan server working over a pipe
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
25 #include "assuan-defs.h"cxx . . $ `<file>/assuan/assuan-defs.h`/
26
27 static void
28 deinit_pipe_servercxx . . $ deinit_pipe_server(746ddb6f27ff0333). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
29 {
30 /* nothing to do for this simple server */
31 }
32
33 static int
34 accept_connectioncxx . . $ accept_connection(29493cd997091d1). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
35 {
36 /* This is a NOP for a pipe server */
37 return 0;
38 }
39
40 static int
41 finish_connectioncxx . . $ finish_connection(29493cd997091d1). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
42 {
43 /* This is a NOP for a pipe server */
44 return 0;
45 }
46
47
48 /* Create a new context. Note that the handlers are set up for a pipe
49 server/client - this wau we don't need extra dummy functions */
50 int
51 _assuan_new_contextcxx . . $ _assuan_new_context(644ebbdd931b9269). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# *r_ctx)
52 {
53 ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx;
54 int rc;
55
56 *r_ctx = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
57 ctx = xtrycalloccxx . . $ `assuan/assuan-defs.h:128:9`! (1, sizeof *ctx);
58 if (!ctx)
59 return ASSUAN_Out_Of_Corecxx . . $ ASSUAN_Out_Of_Core.;
60 ctx->input_fdcxx . . $ assuan_context_s#input_fd. = -1;
61 ctx->output_fdcxx . . $ assuan_context_s#output_fd. = -1;
62
63 ctx->inboundcxx . . $ assuan_context_s#inbound..fdcxx . . $ assuan_context_s#$anonymous_type_0#fd. = -1;
64 ctx->outboundcxx . . $ assuan_context_s#outbound..fdcxx . . $ assuan_context_s#$anonymous_type_2#fd. = -1;
65
66 ctx->listen_fdcxx . . $ assuan_context_s#listen_fd. = -1;
67 ctx->client_pidcxx . . $ assuan_context_s#client_pid. = (pid_tcxx . . $ pid_t#)-1;
68 /* use the pipe server handler as a default */
69 ctx->deinit_handlercxx . . $ assuan_context_s#deinit_handler. = deinit_pipe_servercxx . . $ deinit_pipe_server(746ddb6f27ff0333).;
70 ctx->accept_handlercxx . . $ assuan_context_s#accept_handler. = accept_connectioncxx . . $ accept_connection(29493cd997091d1).;
71 ctx->finish_handlercxx . . $ assuan_context_s#finish_handler. = finish_connectioncxx . . $ finish_connection(29493cd997091d1).;
72
73 rc = _assuan_register_std_commandscxx . . $ _assuan_register_std_commands(29493cd997091d1). (ctx);
74 if (rc)
75 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx);
76 else
77 *r_ctx = ctx;
78 return rc;
79 }
80
81
82
83 int
84 assuan_init_pipe_servercxx . . $ assuan_init_pipe_server(93ea0ddd021a766c). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# *r_ctx, int filedes[2])
85 {
86 int rc;
87
88 rc = _assuan_new_contextcxx . . $ _assuan_new_context(644ebbdd931b9269). (r_ctx);
89 if (!rc)
90 {
91 ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx = *r_ctx;
92
93 ctx->is_servercxx . . $ assuan_context_s#is_server. = 1;
94 ctx->inboundcxx . . $ assuan_context_s#inbound..fdcxx . . $ assuan_context_s#$anonymous_type_0#fd. = filedes[0];
95 ctx->outboundcxx . . $ assuan_context_s#outbound..fdcxx . . $ assuan_context_s#$anonymous_type_2#fd. = filedes[1];
96 ctx->pipe_modecxx . . $ assuan_context_s#pipe_mode. = 1;
97 }
98 return rc;
99 }
100
101
102 void
103 _assuan_release_contextcxx . . $ _assuan_release_context(746ddb6f27ff0333). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
104 {
105 if (ctx)
106 {
107 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx->hello_line);
108 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx->okay_line);
109 xfreecxx . . $ `assuan/assuan-defs.h:130:9`! (ctx);
110 }
111 }
112
113 void
114 assuan_deinit_servercxx . . $ assuan_deinit_server(746ddb6f27ff0333). (ASSUAN_CONTEXTcxx . . $ ASSUAN_CONTEXT# ctx)
115 {
116 if (ctx)
117 {
118 /* We use this function pointer to avoid linking other server
119 when not needed but still allow for a generic deinit function */
120 ctx->deinit_handlercxx . . $ assuan_context_s#deinit_handler. (ctx);
121 ctx->deinit_handlercxx . . $ assuan_context_s#deinit_handler. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
122 _assuan_release_contextcxx . . $ _assuan_release_context(746ddb6f27ff0333). (ctx);
123 }
124 }