--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CSc/Data.c Thu Nov 21 14:55:10 2019 +0100
@@ -0,0 +1,47 @@
+#include "CS.h"
+
+void Data(DataP thisP, DebugP callerDeP) {
+ DebugP deP = &(thisP->debug);
+ DEBID("%s DATA", callerDeP->id);
+ thisP->dataLen = sizeof(HeaderT) + sizeof(PayloadT) + strlen(csP->text);
+ thisP->contP = (ContainerP)malloc(thisP->dataLen);
+ thisP->contP->hdr.ttl = 0;
+ thisP->contP->hdr.ts = 0;
+ strcpy(&(thisP->contP->payl.text), "EMPTY");
+ LOG(5, "Data instance established");
+}
+int dttlData(DataP thisP) {
+ thisP->contP->hdr.ttl--;
+ return thisP->contP->hdr.ttl;
+}
+int ttlData(DataP thisP) {
+ return thisP->contP->hdr.ttl;
+}
+int remPortData(DataP thisP) {
+ return thisP->contP->hdr.listPort;
+}
+DataP loadData(DataP thisP, int ttl, char *loadP) {
+ DebugP deP = &(thisP->debug);
+ thisP->contP->hdr.ttl = ttl;
+ thisP->contP->payl.ts = time(NULL);
+ strcpy(&(thisP->contP->payl.text), csP->text);
+ LOG(5, "payload loaded to container");
+ return thisP;
+}
+char *unldData(DataP thisP) {
+ return &(thisP->contP->payl.text);
+}
+char *digest24Data(DataP thisP, char *digest) {
+ char *text = &(thisP->contP->payl.text);
+ if(strlen(text) < 24) strcpy(digest, text);
+ else { strncpy(digest, text, 8); strcpy(digest+8, "-------"); strcpy(digest+15, text+strlen(text)-8); }
+ return digest;
+}
+void sabotageData(DataP thisP) {
+ thisP->contP->payl.text = '?'; }
+int chkData(DataP thisP) {
+ return (int)(strcmp(csP->text, &(thisP->contP->payl.text)) == 0);
+}
+int tsData(DataP thisP) {
+ return thisP->contP->hdr.ts;
+}