2 static void debug(const char *errstr
, ...) { }
3 static void print_packet(const char *prefix
, Packet
*pkt
) { }
6 static void debug(const char *errstr
, ...) {
9 vfprintf(stderr
, errstr
, ap
);
13 static void print_packet(const char *prefix
, Packet
*pkt
) {
14 static const char *msgtype
[] = {
15 [MSG_CONTENT
] = "CONTENT",
16 [MSG_ATTACH
] = "ATTACH",
17 [MSG_DETACH
] = "DETACH",
18 [MSG_RESIZE
] = "RESIZE",
19 [MSG_REDRAW
] = "REDRAW",
22 const char *type
= "UNKNOWN";
23 if (pkt
->type
< countof(msgtype
) && msgtype
[pkt
->type
])
24 type
= msgtype
[pkt
->type
];
26 fprintf(stderr
, "%s: %s ", prefix
, type
);
29 for (size_t i
= 0; i
< pkt
->len
&& i
< sizeof(pkt
->u
.msg
); i
++)
30 fprintf(stderr
, "%c", pkt
->u
.msg
[i
]);
33 fprintf(stderr
, "%dx%d", pkt
->u
.ws
.ws_col
, pkt
->u
.ws
.ws_row
);
36 fprintf(stderr
, "len: %d", pkt
->len
);
39 fprintf(stderr
, "\n");