Main Menu

buffer.cpp

Started by sit0, January 09, 2011, 12:30:39 PM

Previous topic - Next topic

sit0

#include "bot.h"

void Bot::ABYTE(unsigned char data)
{
*(buff + buflen) = data;
buflen++;
}

void Bot::AWORD(unsigned short data)
{
*(unsigned short *)(buff + buflen) = data;
buflen += 2;
}

void Bot::ADWORD(unsigned long data)
{
*(unsigned long *)(buff + buflen) = data;
buflen += 4;
}

void Bot::ASTRING(char* data)
{
strcpy(buff + buflen, data);
buflen += strlen(data);
}

void Bot::ASTRING0(char* data)
{
ASTRING(data);
ABYTE(0);
}

void Bot::AVOID(void* data, unsigned int len)
{
memcpy(buff + buflen, data, (size_t)len);
buflen += len;
}

void Bot::APACKET(unsigned char PID)
{
buff[1] = PID;
*(unsigned short *)(buff + 2) = buflen;
send(sock, buff, buflen, 0);

if((PSB == SB) && (Dump==true))
hexdump(buff,buflen);

buflen = 4;
}

void Bot::APACKET0(char *Data, ...)
{
char buf[256];
va_list argptr;

va_start(argptr, Data);
vsprintf(buf, Data, argptr);
va_end(argptr);

if (send(sock, buf, strlen(buf), 0) < 0)
exit(1);
}