Obsolete
/
libipc-old
Archived
3
0
Fork 0

print context

pollfd
Karchnu 2020-07-02 21:33:59 +02:00
parent b6f32819e5
commit 0f46858e78
2 changed files with 21 additions and 17 deletions

View File

@ -185,7 +185,7 @@ enum ipc_error_code {
, IPC_ERROR_CONNECTION__NO_CTX = 95
, IPC_ERROR_CTX_INIT__MALLOC_CTX = 96
, IPC_ERROR_CTX_INIT__MALLOC_POLLFD = 97
, IPC_ERROR_CONTACT_IPCD__NO_FD_PARAM = 98
, IPC_ERROR_CONTACT_IPCD__NO_FD_PARAM = 98
, IPC_ERROR_HANDLE_NEW_CONNECTION__INCONSISTENT_INDEX = 99
, IPC_ERROR_DEL_MESSAGE_TO_SEND__NO_PARAM_MESSAGES = 100
, IPC_ERROR_MESSAGE_DEL__INDEX_ERROR = 101
@ -356,8 +356,7 @@ struct ipc_error ipc_ctx_new_alloc (struct ipc_ctx *ctx);
struct ipc_error service_path (char *path, const char *sname);
struct ipc_error handle_writing_message (struct ipc_event *event, struct ipc_ctx *ctx, uint32_t index);
void ipc_connection_print (struct ipc_connection_info *cinfo);
void ipc_connections_print (struct ipc_ctx *cinfos);
void ipc_ctx_print (struct ipc_ctx *ctx);
// Last parameter is the index for the server fd in the context structure.
struct ipc_error ipc_accept_add (struct ipc_event *event, struct ipc_ctx *ctx, uint32_t index);
@ -376,7 +375,7 @@ struct ipcd {
};
struct ipc_error
ipc_wait_event_ipcd (struct ipc_ctx *cinfos
ipc_wait_event_ipcd (struct ipc_ctx *ctx
, struct ipc_connection_info *cinfo // cinfo is NULL for clients
, struct ipc_event *event, struct ipc_switchings *switchdb, int *timer);

View File

@ -1,20 +1,25 @@
#include "ipc.h"
void ipc_connection_print (struct ipc_connection_info *cinfo)
void ipc_ctx_print (struct ipc_ctx *ctx)
{
T_R_NOTHING ((cinfo == NULL));
printf ("Context contains:\n");
for (size_t i = 0; i < ctx->size; i++) {
printf ("- fd %d\t", ctx->pollfd[i].fd);
#if 0
LOG_DEBUG ("fd %d: index %d, version %d, type %c, path %s"
, cinfo->fd , cinfo->index, cinfo->version, cinfo->type
, (cinfo->spath == NULL) ? "-" : cinfo->spath);
#endif
}
void ipc_connections_print (struct ipc_ctx *cinfos)
{
for (size_t i = 0; i < cinfos->size; i++) {
ipc_connection_print (&cinfos->cinfos[i]);
switch (ctx->cinfos[i].type) {
case IPC_CONNECTION_TYPE_IPC: {
printf ("- ipc\n");
break;
}
case IPC_CONNECTION_TYPE_EXTERNAL: {
printf ("- external\n");
break;
}
case IPC_CONNECTION_TYPE_SERVER: {
printf ("- external\n");
break;
}
}
}
}