// some packet commands require data
header.length[6] = 0; /* end of string */
- DMSG2(ctx, DDEBUG, "RECV: %c %s\n", header.status, header.length);
+ DMSG2(ctx, DDEBUG, "HEADERRECV: %c %s\n", header.status, header.length);
/* check for protocol status */
if (header.status == 'F'){
int32_t PTCOMM::handle_payload(bpContext *ctx, char *buf, int32_t nbytes)
{
// handle raw data read as payload
- if(!recvbackend_data(ctx, buf, nbytes))
- {
+ if(!recvbackend_data(ctx, buf, nbytes)){
// error
DMSG0(ctx, DERROR, "PTCOMM cannot get packet payload from backend.\n");
JMSG0(ctx, is_fatal() ? M_FATAL : M_ERROR, "PTCOMM cannot get packet payload from backend.\n");
f_eod = f_error = f_fatal = true;
return -1;
}
+ char bindata[17];
+ DMSG1(ctx, DDEBUG, "RECV> %s\n", asciidump(buf, nbytes, bindata, 17));
return nbytes;
}
{
int32_t length = remaininglen;
- if (!f_cont)
- {
+ if (!f_cont){
// handle header
length = handle_read_header(ctx, cmd);
if (length < 0)
}
// handle data payload
- if (length > 0)
- {
+ if (length > 0){
// we will need subsequent call to handle remaining data only when `buf` to short
f_cont = length > bufsize;
int32_t nbytes = f_cont * bufsize + (!f_cont) * length;
header = &myheader;
#endif
header->status = cmd;
- char bindata[17];
- transcript_bin_data_to_display(bindata, buf, len);
- DMSG2(ctx, DDEBUG, "SENT: %c %s\n", header->status, bindata);
- if (bsnprintf(header->length, sizeof(PTHEADER), "%06i", len) != 6){
+
+ if (bsnprintf(header->length, sizeof(header->length), "%06i\n", len) != 7){
/* problem rendering packet header */
DMSG0(ctx, DERROR, "Problem rendering packet header for command.\n");
JMSG0(ctx, M_FATAL, "Problem rendering packet header for command.\n");
return -1;
}
- header->length[6] = '\n';
+ // header->length[6] = '\n';
+
+ char bindata[17];
+ DMSG3(ctx, DDEBUG, "SENT: %c %s %s\n", header->status, header->length, asciidump(buf, len, bindata, sizeof(bindata)));
#ifdef NEED_REVIEW
status = sendbackend_data(ctx, (char*)header, len + sizeof(PTHEADER));
* -1 - when encountered any error
* <n> - the number of bytes sent, success
*/
- inline int32_t signal_eod(bpContext *ctx) { return sendbackend(ctx, 'F', NULL, 0); }
+ inline int32_t signal_eod(bpContext *ctx) { return sendbackend(ctx, 'F', "000000", 0); }
/**
* @brief Signal end of communication to the backend.
* -1 - when encountered any error
* <n> - the number of bytes sent, success
*/
- inline int32_t signal_term(bpContext *ctx) { return sendbackend(ctx, 'T', NULL, 0); }
+ inline int32_t signal_term(bpContext *ctx) { return sendbackend(ctx, 'T', "000000", 0); }
void terminate(bpContext *ctx);
write_plugin('A', "Some error...\n");
return;
}
-
+#if 0
+ snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/directory\n", PLUGINPREFIX, mypid);
+ write_plugin('C', buf);
+ write_plugin('C', "STAT:D 1024 100 100 040755 1\n");
+ write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n");
+ signal_eod();
+ write_plugin('I', "TEST15 - backup dir + xattrs");
+ write_plugin('C', "DATA\n");
+ write_plugin('D', "/* here comes a file data contents */");
+ write_plugin('D', "/* here comes another file line */");
+ signal_eod();
+ write_plugin('C', "XATTR\n");
+ write_plugin('D', "bacula.custom.data=Inteos\nsystem.custom.data=Bacula\n");
+ signal_eod();
+#endif
snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/\n", PLUGINPREFIX, mypid);
write_plugin('C', buf);
write_plugin('C', "STAT:D 1024 100 100 040755 1\n");
/* empty file to restore */
LOG("#> Empty file.");
continue;
+ } else {
+ LOG("#> file data saved.");
}
loopgo = true;
fsize = len;