forked from quietbamboo/PacketTraceExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
54 lines (42 loc) · 1.11 KB
/
util.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
54
//
// util.h
// PacketTraceExplorer
//
// Created by Junxian Huang on 11/18/12.
// Copyright (c) 2012 Junxian Huang. All rights reserved.
//
#ifndef __PacketTraceExplorer__util__
#define __PacketTraceExplorer__util__
#include <iostream>
#include <cmath>
#include <sstream>
#include <vector>
#include <string.h>
#include <stdio.h>
#include "def.h"
#define MAX_FILE_ID 2781
using namespace std;
void MyAssert(bool x, int aid);
bool isClient(in_addr addr);
const char * ConvertIPToString(unsigned int ip);
//Usage: NumberToString (Number);
template <typename T>
string NumberToString (T Number) {
ostringstream ss;
ss << Number;
return ss.str();
}
//Usage: StringToNumber<Type> (String);
template <typename T>
T StringToNumber (const string &Text) {
istringstream ss(Text);
T result;
return ss >> result ? result : 0;
}
u_short bswap16(u_short);
u_int bswap32(u_int);
//uint64 bswap64(uint64);
vector <string> split(const string& str, const string& delimiter = " ");
string compress_user_agent(string ua);
string process_content_type(string str);
#endif /* defined(__PacketTraceExplorer__util__) */