-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.h
45 lines (29 loc) · 898 Bytes
/
utils.h
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
#ifndef MUTTOR_UTILS_H
#define MUTTOR_UTILS_H
#include <vector>
#include <string>
#include <sstream>
#include <sys/stat.h>
#include <openssl/sha.h>
#include <fstream>
#include <cmath>
#include <iostream>
#include <cstring>
using namespace std;
#define PIECE_SIZE 524288 // 512*1024 Bytes (512KB)
#define CHUNK_SIZE 2048 // 2*1024 Bytes (2KB)
#define MAX_DATAGRAM_SIZE 2048 // 2*1024 Bytes (2KB)
#define MAX_PENDING_REQUESTS 10
#define LOCALHOST "127.0.0.1"
#define MSG_ADD "ADD"
#define MSG_REMOVE "REMOVE"
#define MSG_SEEDERLIST "SEEDERLIST"
#define FIELD_SEPARATOR '|'
vector<string> getTokens(const string& line, char DELIM);
int getFileSize(const string& filePath);
string getHash(const string& path);
string getFileNameFromPath(const string& path);
string getSHAofSHA(string sha);
string getNodeId(string str);
int getRandom(int min, int max);
#endif //MUTTOR_UTILS_H