-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtracker_file.h
53 lines (47 loc) · 1.11 KB
/
tracker_file.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
46
47
48
49
50
51
52
53
#include<iostream>
#include<pthread.h>
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/fcntl.h>
#include<netdb.h>
#include<vector>
#include<boost/algorithm/string.hpp>
#include<map>
#include <openssl/sha.h>
using namespace std;
#define BUFFER_SIZE 512*1024
vector<string> getTrackerPort(string tracker_info){
FILE *fp = fopen(tracker_info.c_str(), "r+");
if(fp == NULL){
exit(1);
}
vector<string> portno;
char c[1000];
fscanf(fp, "%[^\n]", c);
string tracker(c);
boost::split(portno, tracker, boost::is_any_of(" "));
fclose(fp);
return portno;
}
vector<string> getTrackerIP(string tracker_info){
FILE *fp = fopen(tracker_info.c_str(), "r+");
if(fp == NULL){
exit(1);
}
vector<string> IP;
char c[1000];
char c1[1000];
fscanf(fp, "%[^\n]", c);
fscanf(fp, "%c", c);
fscanf(fp, "%[^\n]", c1);
string tracker(c1);
boost::split(IP, tracker, boost::is_any_of(" "));
fclose(fp);
return IP;
}