int main (int argc, char *const* argv) { writeline ("Hello World", stdout); fprintf (stderr, "Zdravei Sviat\n"); newline(stdout); decout (123, stdout); newline(stdout); decout (0, stdout); newline(stdout); hexout (0xFEEDDAD, stdout); newline(stdout); return 0; }
int print_batches_cigar (const BATCH *b_ptr, int b_cnt, char* dest, unsigned destlen) { unsigned dpos = 0, pl; int curb = 0; const BATCH *pb = NULL; myassert (destlen > 1); while (curb <= b_cnt) { if (pb) { pl = decout (pb->len, dest + dpos, destlen - dpos); if (!pl) break; dpos += pl; if (dpos == destlen - 1) break; dest [dpos++] = 'M'; if (curb < b_cnt) { if (pb->xpos + pb->len < b_ptr->xpos) // skip on x (subject) == gap on y (query) { pl = decout (b_ptr->xpos - (pb->xpos + pb->len), dest + dpos, destlen - dpos); if (!pl) break; dpos += pl; if (dpos == destlen - 1) break; dest [dpos++] = 'I'; } if (pb->ypos + pb->len < b_ptr->ypos) // skip on y (query) == gap on x (subject) { pl = decout (b_ptr->ypos - (pb->ypos + pb->len), dest + dpos, destlen - dpos); if (!pl) break; dpos += pl; if (dpos == destlen - 1) break; dest [dpos++] = 'D'; } } } pb = b_ptr; b_ptr ++; curb ++; } dest [dpos] = 0; return dpos; }
signed GetProperty (struct plc * plc, struct plcproperty * plcproperty) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_get_property_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint32_t COOKIE; uint8_t DATA_FORMAT; uint8_t PROP_FORMAT; uint8_t RESERVED [2]; uint32_t PROP_VERSION; uint32_t PROP_LENGTH; uint8_t PROP_NUMBER; } * request = (struct vs_get_property_request *) (message); struct __packed vs_get_property_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint32_t MSTATUS; uint32_t COOKIE; uint8_t DATA_FORMAT; uint8_t RESERVED [3]; uint32_t DATA_LENGTH; uint32_t DATA_BUFFER [1]; } * confirm = (struct vs_get_property_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Get Property"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, HOMEPLUG_MTYPE); QualcommHeader (&request->qualcomm, 0, (VS_GET_PROPERTY | MMTYPE_REQ)); request->COOKIE = HTOLE32 (plc->cookie); request->DATA_FORMAT = plcproperty->DATA_FORMAT; request->PROP_FORMAT = plcproperty->PROP_FORMAT; request->PROP_VERSION = HTOLE32 (plcproperty->PROP_VERSION); request->PROP_LENGTH = HTOLE32 (plcproperty->PROP_LENGTH); request->PROP_NUMBER = HTOLE32 (plcproperty->PROP_NUMBER); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_GET_PROPERTY | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_BIN) { binout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_HEX) { hexout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_DEC) { decout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, ' ', '\n', stdout); continue; } if (plcproperty->DATA_FORMAT == PLC_FORMAT_ASC) { chrout (confirm->DATA_BUFFER, confirm->DATA_LENGTH, '.', '\n', stdout); continue; } } return (0); }