Lines Matching defs:spctx
59 struct sp_ctx *spctx;
67 spctx = malloc(sizeof(*spctx));
68 if (spctx == NULL)
71 if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) == -1) {
73 free(spctx);
77 spctx->sp_side = SP_SIDE_UNDEF;
78 spctx->sp_magic = SP_CTX_MAGIC;
79 *ctxp = spctx;
87 struct sp_ctx *spctx = ctx;
90 PJDLOG_ASSERT(spctx != NULL);
91 PJDLOG_ASSERT(spctx->sp_magic == SP_CTX_MAGIC);
93 switch (spctx->sp_side) {
100 spctx->sp_side = SP_SIDE_CLIENT;
102 close(spctx->sp_fd[1]);
103 spctx->sp_fd[1] = -1;
105 PJDLOG_ASSERT(spctx->sp_fd[0] >= 0);
106 sock = spctx->sp_fd[0];
109 PJDLOG_ASSERT(spctx->sp_fd[1] >= 0);
110 sock = spctx->sp_fd[1];
113 PJDLOG_ABORT("Invalid socket side (%d).", spctx->sp_side);
126 struct sp_ctx *spctx = ctx;
129 PJDLOG_ASSERT(spctx != NULL);
130 PJDLOG_ASSERT(spctx->sp_magic == SP_CTX_MAGIC);
132 switch (spctx->sp_side) {
139 spctx->sp_side = SP_SIDE_SERVER;
141 close(spctx->sp_fd[0]);
142 spctx->sp_fd[0] = -1;
144 PJDLOG_ASSERT(spctx->sp_fd[1] >= 0);
145 fd = spctx->sp_fd[1];
148 PJDLOG_ASSERT(spctx->sp_fd[0] >= 0);
149 fd = spctx->sp_fd[0];
152 PJDLOG_ABORT("Invalid socket side (%d).", spctx->sp_side);
165 const struct sp_ctx *spctx = ctx;
167 PJDLOG_ASSERT(spctx != NULL);
168 PJDLOG_ASSERT(spctx->sp_magic == SP_CTX_MAGIC);
169 PJDLOG_ASSERT(spctx->sp_side == SP_SIDE_CLIENT ||
170 spctx->sp_side == SP_SIDE_SERVER);
172 switch (spctx->sp_side) {
174 PJDLOG_ASSERT(spctx->sp_fd[0] >= 0);
175 return (spctx->sp_fd[0]);
177 PJDLOG_ASSERT(spctx->sp_fd[1] >= 0);
178 return (spctx->sp_fd[1]);
181 PJDLOG_ABORT("Invalid socket side (%d).", spctx->sp_side);
187 struct sp_ctx *spctx = ctx;
189 PJDLOG_ASSERT(spctx != NULL);
190 PJDLOG_ASSERT(spctx->sp_magic == SP_CTX_MAGIC);
192 switch (spctx->sp_side) {
194 PJDLOG_ASSERT(spctx->sp_fd[0] >= 0);
195 close(spctx->sp_fd[0]);
196 spctx->sp_fd[0] = -1;
197 PJDLOG_ASSERT(spctx->sp_fd[1] >= 0);
198 close(spctx->sp_fd[1]);
199 spctx->sp_fd[1] = -1;
202 PJDLOG_ASSERT(spctx->sp_fd[0] >= 0);
203 close(spctx->sp_fd[0]);
204 spctx->sp_fd[0] = -1;
205 PJDLOG_ASSERT(spctx->sp_fd[1] == -1);
208 PJDLOG_ASSERT(spctx->sp_fd[1] >= 0);
209 close(spctx->sp_fd[1]);
210 spctx->sp_fd[1] = -1;
211 PJDLOG_ASSERT(spctx->sp_fd[0] == -1);
214 PJDLOG_ABORT("Invalid socket side (%d).", spctx->sp_side);
217 spctx->sp_magic = 0;
218 free(spctx);