a lot of printf
parent
58aab88dbf
commit
c897edf9e7
|
@ -126,6 +126,12 @@ struct ipc_error ipc_connection_ (struct ipc_ctx *ctx, const char *sname, enum i
|
|||
|
||||
int ipc_ctx_fd_type (struct ipc_ctx *ctx, int fd, enum ipc_connection_type type)
|
||||
{
|
||||
printf ("starting ipc_ctx_fd_type\n");
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf ("starting ipc_ctx_fd_type after ctx test\n");
|
||||
for (size_t i = 0; i < ctx->size; i++) {
|
||||
if (ctx->pollfd[i].fd == fd) {
|
||||
ctx->cinfos[i].type = type;
|
||||
|
|
|
@ -388,10 +388,13 @@ struct ipc_error service_path (char *path, const char *sname);
|
|||
* ipcd enumerations, structures and functions
|
||||
**/
|
||||
|
||||
void ipc_ctx_switching_add (struct ipc_ctx *ctx, int orig, int dest);
|
||||
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest);
|
||||
int ipc_switching_del (struct ipc_switchings *is, int fd);
|
||||
int ipc_switching_get (struct ipc_switchings *is, int fd);
|
||||
void ipc_switching_free (struct ipc_switchings *is);
|
||||
void ipc_switching_callbacks_ (struct ipc_ctx *ctx, int fd
|
||||
, enum ipccb (*cb_in )(int fd, struct ipc_message *m));
|
||||
void ipc_switching_callbacks (
|
||||
struct ipc_ctx *ctx
|
||||
, int fd
|
||||
|
|
|
@ -81,12 +81,21 @@ struct ipc_error ipc_provide_fd (int sock, int fd)
|
|||
IPC_RETURN_NO_ERROR;
|
||||
}
|
||||
|
||||
void ipc_ctx_switching_add (struct ipc_ctx *ctx, int orig, int dest)
|
||||
{
|
||||
ipc_switching_add (&ctx->switchdb, orig, dest);
|
||||
}
|
||||
|
||||
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest)
|
||||
{
|
||||
printf ("ipc_switching_add START: switchdb has %ld entries\n", is->size);
|
||||
|
||||
if (is->collection == NULL) {
|
||||
printf ("switchdb collection is null\n");
|
||||
is->collection = malloc (sizeof (struct ipc_switching) * (is->size + 1));
|
||||
}
|
||||
else {
|
||||
printf ("switchdb collection isn't null\n");
|
||||
is->collection = realloc (is->collection, sizeof (struct ipc_switching) * (is->size + 1));
|
||||
}
|
||||
|
||||
|
@ -105,6 +114,8 @@ void ipc_switching_add (struct ipc_switchings *is, int orig, int dest)
|
|||
is->collection[is->size - 1].dest_in = NULL;
|
||||
is->collection[is->size - 1].orig_out = NULL;
|
||||
is->collection[is->size - 1].dest_out = NULL;
|
||||
|
||||
printf ("ipc_switching_add END: switchdb has %ld entries\n", is->size);
|
||||
}
|
||||
|
||||
int ipc_switching_del (struct ipc_switchings *is, int fd)
|
||||
|
@ -239,18 +250,37 @@ default_cb_out(int fd, struct ipc_message *m)
|
|||
return IPC_CB_NO_ERROR;
|
||||
}
|
||||
|
||||
void ipc_switching_callbacks_ (struct ipc_ctx *ctx, int fd
|
||||
, enum ipccb (*cb_in )(int fd, struct ipc_message *m))
|
||||
{
|
||||
ipc_switching_callbacks (ctx, fd, cb_in, NULL);
|
||||
}
|
||||
|
||||
void ipc_switching_callbacks (
|
||||
struct ipc_ctx *ctx
|
||||
, int fd
|
||||
, enum ipccb (*cb_in )(int fd, struct ipc_message *m)
|
||||
, enum ipccb (*cb_out)(int fd, struct ipc_message *m))
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
printf ("context is null\n");
|
||||
}
|
||||
else {
|
||||
printf ("context has a switchdb with %ld entries\n", ctx->switchdb.size);
|
||||
}
|
||||
|
||||
printf ("\nBEFORE BREACKING THINGS\n");
|
||||
ipc_ctx_print (ctx);
|
||||
printf ("\nLET'S BREAK THINGS\n");
|
||||
|
||||
struct ipc_switching *sw = NULL;
|
||||
int is_valid = ipc_switching_get_ (&ctx->switchdb, fd, &sw);
|
||||
if (is_valid == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf ("valid sw in ipc_switching_callbacks\n");
|
||||
|
||||
if (sw->orig == fd) {
|
||||
sw->orig_in = cb_in;
|
||||
sw->orig_out = cb_out;
|
||||
|
@ -259,6 +289,7 @@ void ipc_switching_callbacks (
|
|||
sw->dest_in = cb_in;
|
||||
sw->dest_out = cb_out;
|
||||
}
|
||||
printf ("ipc_switching_callbacks done\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,6 +307,7 @@ struct ipc_error fd_switching_read (struct ipc_event *event, struct ipc_ctx *ctx
|
|||
int dest_fd = -1;
|
||||
struct ipc_switching *sw = NULL;
|
||||
struct ipc_message m;
|
||||
memset(&m, 0, sizeof (struct ipc_message));
|
||||
|
||||
enum ipccb r;
|
||||
int is_valid = 0;
|
||||
|
|
10
src/print.c
10
src/print.c
|
@ -37,6 +37,16 @@ void ipc_ctx_print (struct ipc_ctx *ctx)
|
|||
else {
|
||||
printf ("Context.switchdb is empty\n");
|
||||
}
|
||||
|
||||
if (ctx->tx.size > 0) {
|
||||
printf ("Context.tx contains:\n");
|
||||
for (size_t i = 0; i < ctx->tx.size; i++) {
|
||||
printf ("- message to %d\n", ctx->tx.messages[i].fd);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf ("Context.tx is empty\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ipc_message_print (const struct ipc_message *m)
|
||||
|
|
Reference in New Issue