int GRecvInt() { int val; GDebug("Receiving int from %s ...\n", who); GRead(&val, sizeof(val)); GDebug(" -> %d (%#x)\n", val, val); return val; }
char *GRecvStr() { int len; char *buf; GDebug("Receiving string from %s ...\n", who); buf = iGRecvArr(&len); GDebug(" -> %'.*s\n", len, buf); return buf; }
char *GRecvArr(int *num) { char *arr; GDebug("Receiving array from %s ...\n", who); GRead(num, sizeof(*num)); GDebug(" -> %d bytes\n", *num); if(!*num) return (char *)0; if(!(arr = malloc(*num))) LogPanic("No memory for read buffer\n"); GRead(arr, *num); GDebug(" -> %02[*hhx\n", *num, arr); return arr; }
void GSendStr(const char *buf) { int len = buf ? strlen(buf) + 1 : 0; GDebug("Sending string %'s to %s\n", buf, who); GWrite(&len, sizeof(len)); GWrite(buf, len); }
void GSendArr( int len, const char *buf ) { GDebug( "Sending array %02[:*hhx to %s\n", len, buf, who ); GWrite( &len, sizeof(len) ); GWrite( buf, len ); }
static char *iGRecvArr(int *rlen) { int len; char *buf; GRead(&len, sizeof(len)); *rlen = len; GDebug(" -> %d bytes\n", len); if(!len) return (char *)0; if(!(buf = malloc(len))) LogPanic("No memory for read buffer\n"); GRead(buf, len); return buf; }
void GSendInt(int val) { GDebug("Sending int %d (%#x) to %s\n", val, val, who); GWrite(&val, sizeof(val)); }