the code is this:
int DECL2 davePutProgramBlock(int blockType, int blknumber, char* buffer, int * length)
{
#define maxPBlockLen 0xDe;
int res = 0;
int cnt = 0;
int size = 0;
int blockNumber, rawLen, netLen, blockCont;
int number = 0;
uc pup[] = { 0x1A, 0, 1, 0, 0, 0, 0, 0, 9, 0x5F, 0x30, 0x42, 0x30, 0x30, 0x30, 0x30, 0x34, 0x50, 0x0D, 0x31, 0x30, 0x30, 0x30, 0x32, 0x30, 0x38, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0 };
PDU p, p2;
uc pablock[] = {0x1B, 0};
uc progBlock[maxPBlockLen + 4] = {0, maxPBlockLen, 0, 0xFB};
pup[11] = blockType;
paInsert[13] = blockType;
/*pup[12] = number / (10*10*10*10);
pup[13] = (number - (pup[12] * 10*10*10*10 )) / (10*10*10);
pup[14] = (number - (pup[13] * 10*10*10)) / (10*10);
pup[15] = (number - (pup[14] * 10*10)) / (10);
pup[16] = (number - (pup[15] * 10));
pup[12] = pup[12] + 0x30;
pup[13] = pup[13] + 0x30;
pup[14] = pup[14] + 0x30;
pup[15] = pup[15] + 0x30;
pup[16] = pup[16] + 0x30;*/
uc buffer[maxPBlockLen + 4] = { 0, maxPBlockLen, 0, 0xFB };
memcpy(progBlock , buffer, maxPBlockLen+4);
progBlock[9] = (blockType + 0x0A - 'A'); //Convert 'A' to 0x0A
if (blockType == '8') progBlock[9] = 0x08;
progBlock[10] = blknumber / 0x100;
progBlock[11] = blknumber - (progBlock[10] * 0x100);
rawLen = daveGetU16from(progBlock + 14);
netLen = daveGetU16from(progBlock + 38);
sprintf((char*)pup + 19, "1%06d%06d", rawLen, netLen);
sprintf((char*)pup + 12, "%05d", blknumber);
sprintf((char*)paInsert + 14, "%05d", blknumber);
pup[17] = 'P';
paInsert[19] = 'P';
p.header = dc->msgOut + dc->PDUstartO;
_daveInitPDUheader(&p, 1);
_daveAddParam(&p, pup, sizeof(pup)-1);
res = _daveExchange(dc, &p);
return res;
};