#include "glprint.h"
#include "tmpalloc.h"
+#define UNUSED __attribute__((unused))
+
typedef struct sGlPrintData
{
char *buffer;
{
if(!data)
return "NULL";
+ else if((unsigned long)data<0x100000)
+ {
+ char *buffer = tmpalloc(20);
+ snprintf(buffer, 20, "%p", data);
+ return buffer;
+ }
else if(!size)
return "/* data */";
else
snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode"));
}
-static void print_unhandled(void *user_data, unsigned short func)
+static void print_unhandled(void *user_data, unsigned short func UNUSED)
{
GlPrintData *gpd = (GlPrintData *)user_data;
gpd->buffer[0] = 0;
void packet_write_data(GlPacket *pkt, const void *data, unsigned size)
{
- if(data)
+ if(!data)
+ packet_write_int(pkt, 0);
+ else if((unsigned long)data<0x100000)
+ {
+ packet_write_int(pkt, ~0);
+ packet_write_pointer(pkt, data);
+ }
+ else
{
GlOutPacket *out = &pkt->out;
++out->vec;
out->vec->iov_base = out->ptr;
}
- else
- packet_write_int(pkt, 0);
}
void packet_write_string(GlPacket *pkt, const char *s)
int vlen;
packet_read_int(pkt, &vlen);
- if(vlen)
+ if(vlen==~0)
+ packet_read_pointer(pkt, v);
+ else if(vlen)
+ {
*v = in->ptr;
+ in->ptr += vlen;
+ in->chunk -= vlen;
+ in->length -= vlen;
+ }
else
*v = NULL;
- in->ptr += vlen;
- in->chunk -= vlen;
- in->length -= vlen;
}
void packet_read_string(GlPacket *pkt, const char **v)