-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkg.cpp
62 lines (47 loc) · 1.3 KB
/
pkg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "pkg.h"
Package::Package() {
strcpy_s(from, 32, "");
strcpy_s(fAddress, 256, "");
strcpy_s(to, 32, "");
strcpy_s(tAddress, 256,"");
strcpy_s(sendTime, 20, "");
strcpy_s(rcvTime, 20, "");
strcpy_s(description, 256, "NULL");
strcpy_s(UUID, 17, "0000000000000000");
type = -1;
status = -1;
}
Package::Package(User& fromUsr, User& toUsr, int t, std::string describe) {
status = 0;
type = t;
strcpy_s(from, 32, fromUsr.userName);
strcpy_s(fAddress, 256, fromUsr.address);
strcpy_s(to, 32, toUsr.userName);
strcpy_s(tAddress, 256, toUsr.address);
strcpy_s(sendTime, 20, getRT().c_str());
strcpy_s(rcvTime, 20, "");
strcpy_s(description, 256, describe.c_str());
strcpy_s(UUID, 17, create_uuid().c_str());
}
int Package::pack(User& fromUsr, User& toUsr, int t, std::string describe) {
status = 0;
type = t;
strcpy_s(from, 32, fromUsr.userName);
strcpy_s(fAddress, 256, fromUsr.address);
strcpy_s(to, 32, toUsr.userName);
strcpy_s(tAddress, 256, toUsr.address);
strcpy_s(sendTime, 20, getRT().c_str());
strcpy_s(rcvTime, 20, "");
strcpy_s(description, 256, describe.c_str());
strcpy_s(UUID, 17, create_uuid().c_str());
return 0;
}
int Package::receiption() {
if (status == 0) {
status = 1;
strcpy_s(rcvTime, 20, getRT().c_str());
return 0;
}
else { return -1; }
}