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",
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 fwrite(pkt
->u
.msg
, pkt
->len
, 1, stderr
);
32 fprintf(stderr
, "%"PRIu16
"x%"PRIu16
, pkt
->u
.ws
.cols
, pkt
->u
.ws
.rows
);
35 fprintf(stderr
, "readonly: %d low-priority: %d",
36 pkt
->u
.i
& CLIENT_READONLY
,
37 pkt
->u
.i
& CLIENT_LOWPRIORITY
);
40 fprintf(stderr
, "status: %"PRIu32
, pkt
->u
.i
);
43 fprintf(stderr
, "pid: %"PRIu32
, pkt
->u
.i
);
46 fprintf(stderr
, "len: %"PRIu32
, pkt
->len
);
49 fprintf(stderr
, "\n");